copilot-operator 0.1.17 → 0.1.18

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 (48) hide show
  1. package/dist/src/api/operator.service.js +23 -2
  2. package/dist/src/orchestrator/derivedChecks.js +19 -1
  3. package/dist/src/orchestrator/review.js +2 -2
  4. package/dist/src/orchestrator/taskRunner.js +81 -8
  5. package/dist/src/plan/brief.js +26 -0
  6. package/dist/src/plan/importPlan.js +28 -1
  7. package/dist/src/plan/schema.js +38 -0
  8. package/dist/src/plan/systemGuide.js +40 -0
  9. package/dist/src/protocol/replySchema.js +1 -1
  10. package/dist/src/protocol/reviewSchema.js +10 -5
  11. package/dist/src/session/exports.js +44 -13
  12. package/dist/src/session/model.js +20 -0
  13. package/dist/src/session/store.js +78 -0
  14. package/dist/src/vcs/artifacts.js +138 -0
  15. package/dist/src/vcs/inputs.js +332 -0
  16. package/dist/src/vcs/snapshot.js +59 -18
  17. package/dist/src/vcs/taskVcs.js +136 -25
  18. package/dist/web/404.html +2 -2
  19. package/dist/web/_next/static/chunks/549-5d7c845fb0a27dbe.js +1 -0
  20. package/dist/web/_next/static/chunks/867-c078b5b504bf4289.js +1 -0
  21. package/dist/web/_next/static/chunks/app/history/page-a0bd59986f7c8beb.js +1 -0
  22. package/dist/web/_next/static/chunks/app/sessions/view/page-27cb2d544b498d92.js +1 -0
  23. package/dist/web/appearance.html +2 -2
  24. package/dist/web/appearance.txt +11 -11
  25. package/dist/web/defaults.html +2 -2
  26. package/dist/web/defaults.txt +11 -11
  27. package/dist/web/history.html +2 -2
  28. package/dist/web/history.txt +11 -11
  29. package/dist/web/import.html +2 -2
  30. package/dist/web/import.txt +11 -11
  31. package/dist/web/index.html +2 -2
  32. package/dist/web/index.txt +11 -11
  33. package/dist/web/level1.html +2 -2
  34. package/dist/web/level1.txt +11 -11
  35. package/dist/web/presets.html +2 -2
  36. package/dist/web/presets.txt +11 -11
  37. package/dist/web/sessions/view.html +2 -2
  38. package/dist/web/sessions/view.txt +11 -11
  39. package/dist/web/system.html +2 -2
  40. package/dist/web/system.txt +11 -11
  41. package/package.json +7 -3
  42. package/prompts/level1.md +547 -546
  43. package/dist/web/_next/static/chunks/549-a13ae394c5e6a837.js +0 -1
  44. package/dist/web/_next/static/chunks/867-7f27ef819d251cc5.js +0 -1
  45. package/dist/web/_next/static/chunks/app/history/page-d7314ac22d47a3ab.js +0 -1
  46. package/dist/web/_next/static/chunks/app/sessions/view/page-d28825430ca280de.js +0 -1
  47. /package/dist/web/_next/static/{kkxFcGzA9Uo1uRAgcoDti → JPmlfAEvbNkbghoyvY9uC}/_buildManifest.js +0 -0
  48. /package/dist/web/_next/static/{kkxFcGzA9Uo1uRAgcoDti → JPmlfAEvbNkbghoyvY9uC}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
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),d=t(7527),c=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),[c,o]=(0,a.useState)(!1),[u,h]=(0,a.useState)(""),g=(0,a.useCallback)(async()=>{try{i(await r.FH.batch())}catch(e){}},[]);(0,d.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:c,onClick:()=>void p("resume"),title:t("batch.resumeWhy"),children:t("batch.resume")}):(0,n.jsx)("button",{disabled:c||l.stopping,onClick:()=>void p("pause"),title:t("batch.pauseWhy"),children:t("batch.pause")}),(0,n.jsx)("button",{className:"danger",disabled:c||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,c]=(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()),c("")}catch(e){c(e.message)}},[]);(0,d.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]),H=(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]),P=(0,a.useMemo)(()=>S(C),[C]),E=C.filter(e=>"running"===e.status||"waiting-approval"===e.status),O=C.filter(e=>"queued"===e.status),_=[...C.filter(e=>y.includes(e.status)&&"stop"===e.sessionOnFailure&&!e.sessionRunning&&O.some(s=>s.sessionId===e.sessionId)),...O].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}),B=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)}),z=""!==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)(G,{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")})]})]}),z&&(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)(M,{entries:[...E,...O,...B]}),"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")})]}),P.runs.map(e=>(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)(W,{run:e}),(0,n.jsx)(R,{entries:e.entries,sizes:H,onChange:()=>void b()})]},e.id)),P.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)(R,{entries:P.loose,sizes:H,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)(R,{entries:E,sizes:H,onChange:()=>void b()})]}),C.length>0&&(0,n.jsxs)("div",{style:{marginBottom:12},children:[(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)(D,{entries:C,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===B.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noPast")}):(0,n.jsx)(q,{entries:B,sizes:H,onChange:()=>void b()})]}),C.length>0&&(0,n.jsx)("section",{className:"panel",children:(0,n.jsxs)(T,{count:_.length,children:[(0,n.jsx)("p",{className:"muted small",children:e("reg.upcomingHint")}),0===_.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noUpcoming")}):(0,n.jsx)(R,{entries:_,upcoming:!0,sizes:H,onChange:()=>void b()})]})}),t&&t.length>0&&(0,n.jsx)(A,{refreshKey:o})]})]})}let H="cop.register.upcomingOpen";function T(e){let{count:s,children:t}=e,{t:l}=(0,m.kj)(),[i,r]=(0,a.useState)(()=>{try{let e=window.localStorage.getItem(H);if("true"===e||"false"===e)return"true"===e}catch(e){}return s<=8});return(0,n.jsxs)("details",{open:i,children:[(0,n.jsx)("summary",{onClick:e=>{e.preventDefault();let s=!i;r(s);try{window.localStorage.setItem(H,String(s))}catch(e){}},children:(0,n.jsxs)("h2",{style:{display:"inline"},children:[l("reg.upcoming")," (",s,")"]})}),i&&t]})}function A(e){let{refreshKey:s}=e,{t}=(0,m.kj)(),[l,i]=(0,a.useState)(null),[d,c]=(0,a.useState)("");if((0,a.useEffect)(()=>{r.FH.metrics().then(e=>{i(e),c("")}).catch(e=>c(e.message))},[s]),!l)return d?(0,n.jsx)("div",{className:"panel err",children:d}):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 R(e){let{entries:s,upcoming:t=!1,sizes:l,onChange:d,picking:c}=e,{t:o}=(0,m.kj)(),j=(0,m.W3)(),N=(0,v.e)(null!=d?d:()=>void 0),f=(0,h.c)(s.some(u.DG)),[w,C]=(0,a.useState)(null),[S,F]=(0,a.useState)(new Set),[H,T]=(0,a.useState)(null);return(0,n.jsxs)(n.Fragment,{children:[w&&(0,n.jsx)(E,{entry:w,onClose:e=>{C(null),e&&(null==d||d())}}),(0,n.jsx)("ol",{className:"flow",children:s.map(e=>{var s,a,h,m,v,w,A,R,W,q,E,G,D,M,_,B,z,L,U,X,V,Z,K,Q,J,Y;let $=t&&1===e.queuePosition,ee=e.runGroup?null!=(R=null==l?void 0:l.get(e.runGroup.id))?R:1:0;return(0,n.jsxs)("li",{className:"".concat(e.status).concat($?" next":""),children:[(0,n.jsxs)("div",{className:"head",children:[c&&(0,n.jsx)("input",{type:"checkbox",className:"pick","aria-label":e.title,checked:c.picked.has("".concat(e.sessionId,":").concat(e.taskId)),onChange:()=>c.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!=(W=e.deviations)?W:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:o("reg.deviationsWhy"),children:o("reg.deviations",{n:null!=(q=e.deviations)?q:0})}),(null!=(E=e.disputes)?E:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:o("reg.disputesWhy"),children:o("reg.disputes",{n:null!=(G=e.disputes)?G: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!=(D=null==(s=e.scope)?void 0:s.length)?D:0)>0&&(0,n.jsx)("span",{className:"chip",title:o("task.scopeWhy"),children:o("task.scope",{paths:(null!=(M=e.scope)?M:[]).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==(A=e.attempts)?void 0:A.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)(P,{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:H===e.taskId?"":"primary","aria-expanded":H===e.taskId,onClick:()=>T(H===e.taskId?null:e.taskId),title:o("reg.continueHereWhy"),children:o("reg.continueHere")}),!I(e)&&("failed"===e.status||"blocked"===e.status)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:H===e.taskId?"":"primary","aria-expanded":H===e.taskId,onClick:()=>T(H===e.taskId?null:e.taskId),title:o("reg.rerunHereWhy"),children:o("reg.rerunHere")}),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")})]})]}),H===e.taskId&&(I(e)||"failed"===e.status||"blocked"===e.status)&&!e.sessionRunning&&(0,n.jsx)(O,{entry:e,onClose:e=>{T(null),e&&(null==d||d())}}),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 P(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 W(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,d=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(d>0?"failed":r===t.entries.length?"done":""),children:a("reg.runCounts",{done:r,failed:d})}),(0,n.jsx)(P,{where:{run:t.id}})]})]})}function q(e){let{entries:s,sizes:t,onChange:l}=e,{t:i}=(0,m.kj)(),d=(0,a.useMemo)(()=>S(s),[s]),[c,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=c?{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:[c?(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})]}),d.runs.map((e,s)=>(0,n.jsxs)("details",{className:"run-fold",open:0===s||c,children:[(0,n.jsx)("summary",{children:(0,n.jsx)(W,{run:e})}),(0,n.jsx)(R,{entries:e.entries,sizes:t,onChange:l,picking:y})]},e.id)),d.loose.length>0&&(0,n.jsxs)("details",{className:"run-fold",open:0===d.runs.length||c,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)(R,{entries:d.loose,sizes:t,onChange:l,picking:y})]})]})}function E(e){let{entry:s,onClose:t}=e,{t:l}=(0,m.kj)(),[i,d]=(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,c.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;d(null!=(n=null==r?void 0:r.prompt)?n:""),I(null!=(a=null==r?void 0:r.prompt)?a:"");let c=null!=(l=null==r?void 0:r.checks)?l:[];j(c),N(new Set("done"===s.status?[]:c.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=>d(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 G(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 O(e){let{entry:s,onClose:t}=e,{t:l}=(0,m.kj)(),i=(0,f.p)(),[d,c]=(0,a.useState)(!1),[o,u]=(0,a.useState)(""),h=I(s),g=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"):l("reg.rerunHereBranch"),p=async e=>{if("unattended"!==e||i||await (0,N.Z)(l("batch.unattendedConfirm",{n:1}))){c(!0),u("");try{h?await r.FH.continueTask(s.sessionId,s.taskId):await r.FH.rerunTask(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{c(!1)}}};return(0,n.jsxs)("div",{className:"notice",role:"group","aria-label":l(h?"reg.continueHereTitle":"reg.rerunHereTitle",{title:s.title}),style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l(h?"reg.continueHereTitle":"reg.rerunHereTitle",{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(h?"reg.continueHereChat":"reg.rerunHereChat")}),(0,n.jsx)("li",{children:g}),(0,n.jsx)("li",{children:l(h?"reg.continueHereCount":"reg.rerunHereKept")}),(0,n.jsx)("li",{children:l("reg.continueHereAlone")})]}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:d,onClick:()=>void p("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{disabled:d,onClick:()=>void p("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{className:"quiet",disabled:d,onClick:()=>t(!1),children:l("dialog.cancel")}),o&&(0,n.jsx)("span",{className:"small",children:o})]})]})}function D(e){let{entries:s,onChange:t}=e,{t:l}=(0,m.kj)(),[i,d]=(0,a.useState)(!1),[c,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)),H=k.filter(e=>g.has(e.taskId)),T=v.filter(e=>g.has(e.taskId)),A=[...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))],R=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)(""),q=w.length>0?l("reg.continueWithFailed",{f:w.length,n:v.length,s:A.length}):l("reg.continue",{n:v.length,s:A.length}),G=(0,f.p)(),O=async e=>{if("unattended"!==e||G||await (0,N.Z)(l("batch.unattendedConfirm",{n:A.length}))){d(!0),o("");try{var s;for(let e of H)I(e)?await r.FH.continueTask(e.sessionId,e.taskId):await r.FH.rerunTask(e.sessionId,e.taskId);let n=await r.FH.startBatch(A,e,"stop",void 0,void 0,P.trim()||void 0,F.map(e=>e.taskId));o(n.started?l("reg.continueStarted",{n:A.length}):l("batch.notStarted",{reason:null!=(s=n.reason)?s:""})),h(!1),t()}catch(e){o(e.message)}finally{d(!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:q}),b&&(0,n.jsx)("span",{className:"muted small",children:l("reg.continueRunning")}),c&&(0,n.jsx)("span",{className:"small",children:c})]}),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",style:{marginTop:6},children:[(0,n.jsx)("span",{className:"small",children:l("reg.pickedCount",{n:F.length,of:S.length})}),(0,n.jsx)("button",{className:"small",onClick:()=>p(new Set),disabled:0===F.length,children:l("reg.pickNone")}),(0,n.jsx)("button",{className:"small",onClick:()=>p(new Set(S.map(e=>e.taskId))),disabled:F.length===S.length,children:l("reg.pickAll")})]}),[{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)),R.length>0&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:R.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:H.length,s:A.length})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",disabled:i||0===A.length,onClick:()=>void O("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{disabled:i||0===A.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)(E,{entry:x,onClose:e=>{j(null),e&&t()}})]})}function M(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()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[66],{1205:(e,s,n)=>{"use strict";n.d(s,{AppearanceProvider:()=>h,KP:()=>m,themeScript:()=>c});var a=n(3365),t=n(1521);let l=["small","normal","large","huge","giant"],i={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1},r="cop.appearance",c="\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(r,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(l),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n } catch (e) {}\n})();\n");function d(e){let s=document.documentElement;s.dataset.theme=e.theme,s.dataset.textsize=e.textSize,s.dataset.contrast=e.highContrast?"high":"normal",s.dataset.motion=e.reduceMotion?"reduced":"normal",s.dataset.links=e.underlineLinks?"underline":"plain",s.dataset.focus=e.strongFocus?"strong":"normal"}let o=(0,t.createContext)({appearance:i,set:()=>void 0,reset:()=>void 0,loaded:!1});function h(e){let{children:s}=e,[n,c]=(0,t.useState)(i),[h,m]=(0,t.useState)(!1);(0,t.useEffect)(()=>{let e=i;try{let s=window.localStorage.getItem(r);s?e=function(e){let s=e&&"object"==typeof e?e:{},n=(e,s)=>"boolean"==typeof e?e:s;return{theme:"dark"===s.theme?"dark":"light"===s.theme?"light":i.theme,textSize:l.includes(s.textSize)?s.textSize:i.textSize,highContrast:n(s.highContrast,i.highContrast),reduceMotion:n(s.reduceMotion,i.reduceMotion),underlineLinks:n(s.underlineLinks,i.underlineLinks),strongFocus:n(s.strongFocus,i.strongFocus)}}(JSON.parse(s)):window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!s&&(e={...e,reduceMotion:!0})}catch(e){}c(e),d(e),m(!0)},[]);let u=(0,t.useCallback)(e=>{c(s=>{let n={...s,...e};d(n);try{window.localStorage.setItem(r,JSON.stringify(n))}catch(e){}return n})},[]),p=(0,t.useCallback)(()=>{c(i),d(i);try{window.localStorage.removeItem(r)}catch(e){}},[]);return(0,a.jsx)(o.Provider,{value:{appearance:n,set:u,reset:p,loaded:h},children:s})}function m(){return(0,t.useContext)(o)}},1702:(e,s,n)=>{"use strict";var a=n(9962);n.o(a,"usePathname")&&n.d(s,{usePathname:function(){return a.usePathname}}),n.o(a,"useSearchParams")&&n.d(s,{useSearchParams:function(){return a.useSearchParams}})},1772:(e,s,n)=>{Promise.resolve().then(n.bind(n,2438))},2285:(e,s,n)=>{"use strict";n.d(s,{b:()=>r});var a=n(3365),t=n(1521),l=n(5549),i=n(867);function r(e){var s,n;let{dir:r}=e,{t:c}=(0,i.kj)(),d=(0,i.W3)(),[o,h]=(0,t.useState)(null),[m,u]=(0,t.useState)(""),[p,v]=(0,t.useState)(""),x=async()=>{u("");try{h(await l.FH.syncPlan(r))}catch(e){u(e.message)}},j=async(e,s)=>{try{await navigator.clipboard.writeText(s),v(e),window.setTimeout(()=>v(""),2500)}catch(e){u(c("plan.copyFailed"))}},g=e=>(0,a.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e)),e.length>30&&(0,a.jsx)("li",{className:"muted",children:c("sync.more",{n:e.length-30})})]});return(0,a.jsxs)("div",{className:"sync-command small",style:{marginTop:8},children:[(0,a.jsx)("button",{type:"button",onClick:()=>void x(),children:c("sync.show")}),m&&(0,a.jsx)("p",{className:"err",children:m}),o&&!o.ok&&(0,a.jsx)("p",{className:"err",children:o.problem}),(null==o?void 0:o.ok)&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsxs)("p",{children:[c("sync.what",{branch:null!=(s=o.branch)?s:"",target:null!=(n=o.target)?n:""})," ",(0,a.jsx)("span",{className:"muted",children:o.lastFetched?c("sync.fetchedAt",{when:d(o.lastFetched)}):c("sync.neverFetched")})]}),o.willLose.commits.length+o.willLose.changed.length+o.willLose.untracked.length===0?(0,a.jsx)("p",{children:c("sync.nothingLost")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("strong",{children:c("sync.loses")}),o.willLose.commits.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:c("sync.commits",{n:o.willLose.commits.length})}),g(o.willLose.commits)]}),o.willLose.changed.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:c("sync.changed",{n:o.willLose.changed.length})}),g(o.willLose.changed)]}),o.willLose.untracked.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:c("sync.untracked",{n:o.willLose.untracked.length})}),g(o.willLose.untracked)]})]}),(0,a.jsx)("p",{className:"muted",children:c("sync.keeps")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",onClick:()=>void j("preview",o.preview),children:c("sync.copyPreview")}),"preview"===p&&(0,a.jsx)("span",{className:"badge done",children:c("plan.copied")})]}),(0,a.jsx)("pre",{className:"sync-cmd",children:o.preview}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"danger",onClick:()=>void j("command",o.command),children:c("sync.copyCommand")}),"command"===p&&(0,a.jsx)("span",{className:"badge done",children:c("plan.copied")})]}),(0,a.jsx)("pre",{className:"sync-cmd",children:o.command}),(0,a.jsx)("p",{className:"muted",children:c("sync.howToRun")})]})]})}},2438:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>S});var a=n(3365),t=n(1521),l=n(1702),i=n(8197),r=n.n(i),c=n(5549),d=n(867),o=n(1910),h=n(3523),m=n(3374),u=n(1205),p=n(8848),v=n(4784),x=n(2876),j=n(5132),g=n(1035),y=n(8934),f=n(4811),b=n(3041),k=n(7527),N=n(1366),w=n(2285);function S(){return(0,a.jsx)(t.Suspense,{fallback:null,children:(0,a.jsx)(C,{})})}function C(){var e;let{t:s}=(0,d.kj)(),n=null!=(e=(0,l.useSearchParams)().get("id"))?e:"",[i,o]=(0,t.useState)(null),[h,m]=(0,t.useState)([]),[u,p]=(0,t.useState)([]),[v,x]=(0,t.useState)(null),[j,g]=(0,t.useState)(""),[y,f]=(0,t.useState)(!1),b=(0,t.useRef)(null),N=(0,t.useRef)(0),w=(0,t.useCallback)(async()=>{if(!n)return;let e=++N.current;try{let s=await c.FH.session(n);if(e!==N.current)return;o(s),g("")}catch(s){if(e!==N.current)return;g(s.message)}},[n]),S=(0,t.useCallback)(()=>{b.current||(b.current=window.setTimeout(()=>{b.current=null,w()},400))},[w]);if((0,t.useEffect)(()=>{if(!n)return;c.FH.presets().then(p).catch(()=>void 0),c.FH.level1().then(x).catch(()=>void 0);let e=new EventSource(c.FH.streamUrl(n));return e.onopen=()=>f(!1),e.onmessage=e=>{let s;try{s=JSON.parse(e.data)}catch(e){return}"ping"!==s.type&&(m(e=>[...e.slice(-400),s]),S())},e.onerror=()=>{e.readyState===EventSource.CLOSED&&f(!0)},()=>{e.close()}},[n,S]),(0,k.z)(w,8e3,!!n),!n)return(0,a.jsx)("div",{className:"panel err",children:s("session.noId")});if(j&&!i)return(0,a.jsx)("div",{className:"panel err",children:j});if(!i)return(0,a.jsx)("div",{className:"panel muted",children:s("home.loading")});let C=i.tasks.filter(e=>"queued"===e.status).length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"crumbs",children:[(0,a.jsx)(r(),{href:"/",children:s("session.crumb")})," / ",i.name]}),j&&(0,a.jsx)("div",{className:"panel err",role:"alert",children:s("session.stale",{err:j})}),y&&!j&&(0,a.jsx)("div",{className:"panel muted small",role:"status",children:s("session.streamClosed")}),(0,a.jsx)(F,{session:i,queued:C,onChange:w}),(0,a.jsx)(U,{tasks:i.tasks}),(0,a.jsx)(T,{session:i,onChange:w}),(0,a.jsx)(L,{level1:v,sent:i.contractSent}),(0,a.jsx)(M,{session:i,onChange:w}),(0,a.jsx)(I,{session:i,onChange:w}),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:s("tasks.title")}),(0,a.jsx)("p",{className:"muted small",children:s("tasks.hint")}),(0,a.jsx)(W,{session:i,onChange:w}),0===i.tasks.length&&(0,a.jsx)("div",{className:"muted",children:s("tasks.none")}),i.tasks.map((e,s)=>(0,a.jsx)(A,{session:i,task:e,index:s+1,presets:u,onChange:w},e.id))]}),(0,a.jsx)(R,{session:i}),(0,a.jsx)(B,{session:i,presets:u,onAdded:w,onPresetsChanged:()=>c.FH.presets().then(p)}),(0,a.jsx)(O,{events:h})]})}function F(e){var s;let{session:n,queued:l,onChange:i}=e,{t:r}=(0,d.kj)(),[o,h]=(0,t.useState)(""),[m,u]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;return u(null!=(s=e.defaultModel)?s:"")}).catch(()=>void 0)},[]);let[p,v]=(0,t.useState)(n.name),[x,j]=(0,t.useState)(null!=(s=n.conversationGroup)?s:"");(0,t.useEffect)(()=>v(n.name),[n.name]),(0,t.useEffect)(()=>{var e;return j(null!=(e=n.conversationGroup)?e:"")},[n.conversationGroup]);let y=(0,f.p)(),[b,k]=(0,t.useState)(!1),N=(0,t.useRef)(!1),w=async e=>{if(!N.current){N.current=!0,k(!0);try{await e()}catch(e){h(e.message)}finally{N.current=!1,k(!1),i()}}},S=async e=>{("unattended"!==e||y||await (0,g.Z)(r("session.unattendedConfirm")))&&await w(async()=>{var s;let a=await c.FH.start(n.id,e,n.planName);h(a.started?r("unattended"===e?"session.startedAuto":"session.startedStep"):r("session.notStarted",{reason:null!=(s=a.reason)?s:""}))})},C=async()=>{if(n.running)return void h(r("home.deleteRunning"));if(await (0,g.Z)(r("home.deleteConfirm",{name:n.name,n:n.tasks.length})))try{await c.FH.deleteSession(n.id),window.location.href="/"}catch(e){h(e.message)}},F=async()=>{var e;if(x.trim()!==(null!=(e=n.conversationGroup)?e:""))try{await c.FH.updateSession(n.id,{conversationGroup:x.trim()}),h(r("session.groupSaved")),i()}catch(e){h(e.message)}},L=n.running?r("state.running"):r("state.".concat(n.status));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow","aria-label":r("home.col.name"),value:p,onChange:e=>v(e.target.value),onBlur:()=>void w(async()=>{p.trim()&&p!==n.name&&await c.FH.updateSession(n.id,{name:p})})}),(0,a.jsx)("span",{className:"badge ".concat(n.running?"running":""),children:L})]}),!n.running&&(0,a.jsxs)("div",{className:"run-choice",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void S("unattended"),disabled:b||0===l,children:r("session.run",{n:l})}),(0,a.jsx)("p",{className:"why",children:r("session.runWhy")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{onClick:()=>void S("confirm"),disabled:b||0===l,children:r("session.runStep")}),(0,a.jsx)("p",{className:"why",children:r("session.runStepWhy")})]})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[n.running&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"danger",onClick:()=>void w(async()=>{await c.FH.stop(n.id),h(r("session.stopping"))}),disabled:b,children:r("session.stop")}),"unattended"===n.runMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge waiting-approval",children:r("session.modeUnattended")}),(0,a.jsx)("button",{onClick:()=>void w(async()=>{await c.FH.setRunMode(n.id,"confirm"),h(r("session.askingAgain"))}),disabled:b,children:r("session.askAgain")})]})]}),(0,a.jsx)("span",{className:"muted small",children:o}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void C(),disabled:n.running,children:r("home.delete")}),n.chat?(0,a.jsx)("a",{href:n.chat.url,target:"_blank",rel:"noreferrer",className:"small",children:r("session.openChat",{name:n.chat.name})}):(0,a.jsx)("span",{className:"muted small",children:r("session.noChat")})]}),(0,a.jsx)("label",{htmlFor:"session-group",children:r("session.group")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("input",{id:"session-group",type:"text",className:"grow",value:x,placeholder:r("session.groupPlaceholder"),onChange:e=>j(e.target.value),onBlur:()=>void F(),disabled:n.running})}),(0,a.jsxs)("p",{className:"why",children:[r("session.groupWhy"),n.chat&&" ".concat(r("session.groupHasChat"))]}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:10},children:r("session.willUseModel",{name:n.model||(m?r("model.followsDefault",{name:m}):r("model.default"))})})]})}function L(e){var s;let{level1:n,sent:t}=e,{t:l}=(0,d.kj)();return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:l("l1.title")}),(0,a.jsx)("span",{className:"badge",children:l(t?"l1.sent":"l1.notSent")}),(0,a.jsx)(r(),{href:"/level1",className:"small",children:l("l1.edit")})]}),(0,a.jsxs)("p",{className:"muted small",style:{marginBottom:6},children:[l("l1.hint"),(null==n?void 0:n.customised)?" ".concat(l("l1.customised")):""]}),(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:l("l1.show")}),(0,a.jsx)("pre",{className:"tall",children:null!=(s=null==n?void 0:n.content)?s:"…"})]})]})}function T(e){var s,n,l,i;let{session:r,onChange:o}=e,{t:h}=(0,d.kj)(),m=(0,d.W3)(),[u,v]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[y,f]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(v).catch(()=>void 0)},[]);let b=async e=>{try{await c.FH.updateSession(r.id,{model:e}),f(e?h("model.saved",{name:e}):h("model.savedDefault")),o()}catch(e){f(e.message)}},k=async()=>{try{let e=await c.FH.setDefaultModel(w);v(s=>s?{...s,defaultModel:e.defaultModel}:s),f(e.defaultModel?h("model.defaultSaved",{name:e.defaultModel}):h("model.defaultCleared"))}catch(e){f(e.message)}},N=async()=>{if(await (0,g.Z)(h("model.refreshConfirm"))){j(!0),f(h("model.refreshing"));try{var e;let s=await c.FH.refreshModels();v(s),f(0===s.options.length?null!=(e=s.note)?e:h("model.none"):h("model.refreshed",{n:s.options.length}))}catch(e){f(e.message)}finally{j(!1)}}},w=null!=(s=r.model)?s:"",S=null!=(n=null==u?void 0:u.options)?n:[],C=S.some(e=>e.name===w),F=S.filter(e=>!e.group),L=new Map;for(let e of S)e.group&&L.set(e.group,[...null!=(l=L.get(e.group))?l:[],e]);return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:h("model.title")}),r.modelInUse&&(0,a.jsx)("span",{className:"chip",children:h("model.lastUsed",{name:r.modelInUse})})]}),(0,a.jsx)("p",{className:"muted small",children:h("model.hint")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("select",{"aria-label":h("model.title"),value:w,disabled:r.running,onChange:e=>void b(e.target.value),style:{width:"auto",minWidth:260},children:[(0,a.jsx)("option",{value:"",children:(null==u?void 0:u.defaultModel)?h("model.followsDefault",{name:u.defaultModel}):h("model.default")}),w&&!C&&(0,a.jsx)("option",{value:w,children:h("model.notInList",{name:w})}),F.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(h("model.unavailable")):""]},e.name)),[...L.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(h("model.unavailable")):""]},e.name))},s)})]}),(0,a.jsx)("button",{onClick:()=>void N(),disabled:x||r.running,children:h("model.refresh")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:y})]}),(0,a.jsx)(p.L,{current:w,onUse:e=>void b(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("span",{className:"muted small",children:(null==u?void 0:u.defaultModel)?h("model.defaultIs",{name:u.defaultModel}):h("model.defaultIsNone")}),(0,a.jsx)("button",{onClick:()=>void k(),disabled:w===(null!=(i=null==u?void 0:u.defaultModel)?i:""),children:w?h("model.makeDefault",{name:w}):h("model.clearDefault")})]}),(null==u?void 0:u.readAt)?(0,a.jsxs)("p",{className:"muted small",style:{marginTop:8},children:[h("model.readAt",{t:m(u.readAt),n:u.options.length}),u.current?" ".concat(h("model.chatWasOn",{name:u.current})):"",u.note?" ".concat(u.note):""]}):(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:h("model.neverRead")}),S.length>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:h("model.showDetails")}),(0,a.jsx)("pre",{className:"tall",children:S.map(e=>"".concat(e.selected?"*":" "," ").concat(e.group?"".concat(e.group," > "):"").concat(e.name)+"".concat(e.disabled?" [unavailable]":"","\n ").concat(e.raw.replace(/\n/g," | "))).join("\n")})]})]})}function I(e){var s,n;let{session:l,onChange:i}=e,{t:r}=(0,d.kj)(),o=null!=(s=l.review)?s:{enabled:!0,model:""},[h,m]=(0,t.useState)(o.enabled),[u,x]=(0,t.useState)(null!=(n=o.model)?n:""),[j,g]=(0,t.useState)(""),[y,f]=(0,t.useState)(!1),[b,k]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;return k(null!=(s=e.defaultReviewModel)?s:"")}).catch(()=>void 0)},[]);let N=async()=>{f(!0),g("");try{await c.FH.updateSession(l.id,{review:{enabled:h,model:u}}),g(r("review.saved")),i()}catch(e){g(e.message)}finally{f(!1)}};return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:r("review.title")}),(0,a.jsx)("span",{className:"badge ".concat(h?"done":""),children:h?r("review.on"):r("review.off")})]}),(0,a.jsx)("p",{className:"muted small",children:r("review.hint")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:h,onChange:e=>m(e.target.checked),disabled:l.running}),(0,a.jsx)("span",{children:r("review.enable")})]}),(0,a.jsx)("p",{className:"why",children:r("review.enableWhy")})]}),(0,a.jsx)("label",{htmlFor:"review-model",children:r("review.modelField")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)(v.Y,{id:"review-model",chosen:u,onChange:x,none:b?r("model.followsDefault",{name:b}):r("review.modelSame"),disabled:l.running||!h})}),(0,a.jsx)("p",{className:"why",children:r("review.modelWhy")}),(0,a.jsx)(p.z4,{current:u,onUse:e=>x(e)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:y||l.running,children:r("review.save")}),j&&(0,a.jsx)("span",{className:"muted small",children:j})]})]})}function H(e){var s;let{session:n,plan:l,onDone:i}=e,{t:r}=(0,d.kj)(),o=()=>Object.fromEntries(l.entries.filter(e=>e.choice).map(e=>[e.path,e.choice])),h=JSON.stringify(l.entries.map(e=>[e.path,e.choice])),[m,u]=(0,t.useState)(o);(0,t.useEffect)(()=>u(o()),[h]);let[p,v]=(0,t.useState)(!1),[x,j]=(0,t.useState)(""),g=l.entries.filter(e=>"include"===m[e.path]).length,y=async()=>{v(!0),j("");try{var e,s,a;let t=await c.FH.vcsSnapshot(n.id,m);j(t.ok?r("vcs.snapshotTaken",{branch:null!=(e=t.branch)?e:"",commit:(null!=(s=t.commit)?s:"").slice(0,8)}):null!=(a=t.problem)?a:""),i()}catch(e){j(e.message)}finally{v(!1)}};return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("p",{className:"small",children:r("vcs.snapshotList",{n:l.entries.length,branch:null!=(s=l.baselineBranch)?s:"—"})}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:l.entries.map(e=>{var s;return(0,a.jsxs)("li",{style:{marginBottom:4,overflowWrap:"anywhere"},children:[(0,a.jsx)("code",{children:e.path})," ",(0,a.jsxs)("span",{className:"muted small",children:["(",r("vcs.snapshotKind.".concat(e.kind)),")"]})," ",0===e.allowed.length?(0,a.jsx)("span",{className:"err small",children:r("vcs.snapshotBlocked")}):(0,a.jsx)("select",{"aria-label":e.path,value:null!=(s=m[e.path])?s:"",onChange:s=>u({...m,[e.path]:s.target.value}),disabled:p||n.running||e.allowed.length<2,children:e.allowed.map(e=>(0,a.jsx)("option",{value:e,children:r("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,a.jsx)("div",{className:"muted small",children:e.reason})]},e.path)})}),(0,a.jsx)("button",{className:"primary",onClick:()=>void y(),disabled:p||n.running||!l.ok||0===g,children:r("vcs.snapshotTake")}),(0,a.jsx)("p",{className:"why",children:r("vcs.snapshotCancelWhy")}),x&&(0,a.jsx)("p",{className:"small",role:"status",children:x})]})}function M(e){var s,n,l,i,r,o,h,m,u,v,x,j,g,y,f,b,k,N,S,C,F,L,T,I,M,W,P,R;let{session:D,onChange:B}=e,{t:A}=(0,d.kj)(),O=null!=(m=D.vcs)?m:{enabled:!0,repoDir:"",branchMode:"per-task",commitOnFinish:!0,branchPrefix:"cop/"},[E,U]=(0,t.useState)(O.repoDir),[q,z]=(0,t.useState)(null),[G,J]=(0,t.useState)(""),[Z,_]=(0,t.useState)(!1),K=JSON.stringify(O),[Y,Q]=(0,t.useState)(null),[V,X]=(0,t.useState)(null!=(u=O.branchName)?u:"");(0,t.useEffect)(()=>{var e;return X(null!=(e=JSON.parse(K).branchName)?e:"")},[K]);let[$,ee]=(0,t.useState)(null!=(v=O.baseBranch)?v:"");(0,t.useEffect)(()=>{var e;return ee(null!=(e=JSON.parse(K).baseBranch)?e:"")},[K]);let[es,en]=(0,t.useState)(null!=(x=O.existingBranch)?x:"");(0,t.useEffect)(()=>{var e;return en(null!=(e=JSON.parse(K).existingBranch)?e:"")},[K]);let ea=null!=(j=O.startFrom)?j:"head";(0,t.useEffect)(()=>{U(JSON.parse(K).repoDir)},[K]);let et=JSON.parse(K).repoDir||D.projectDir||"";(0,t.useEffect)(()=>{let e=!1;return et.trim()?(c.FH.repoCheck(et).then(s=>{var n;e||Q(s.ok?null:null!=(n=s.problem)?n:null)}).catch(()=>{e||Q(null)}),()=>{e=!0}):void Q(null)},[et]);let el=(0,t.useCallback)(()=>{c.FH.vcsStatus(D.id).then(z).catch(()=>z(null))},[D.id]);(0,t.useEffect)(el,[el,K]);let ei=async e=>{try{await c.FH.updateSession(D.id,{vcs:e}),J(A("vcs.saved")),B(),el()}catch(e){J(e.message)}},er=async()=>{_(!0),J(A("mirror.browsing"));try{let s=await c.FH.browseFolder(E.trim()||D.projectDir||void 0);if(s.ok)U(s.path),await ei({repoDir:s.path});else{var e;J(s.cancelled?A("mirror.browseCancelled"):null!=(e=s.reason)?e:"")}}catch(e){J(e.message)}finally{_(!1)}},ec=O.repoDir||D.projectDir||"",ed=""!==ec.trim()&&null===Y;return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("h2",{className:"grow",style:{margin:0},children:A("vcs.title")}),(0,a.jsx)("span",{className:"badge ".concat(O.enabled?"done":""),children:O.enabled?A("vcs.on"):A("vcs.off")})]}),(0,a.jsx)("p",{className:"muted small",children:A("vcs.hint")}),(0,a.jsx)("label",{htmlFor:"vcs-root",children:A("vcs.repoField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"vcs-root",type:"text",className:"grow",value:E,onChange:e=>U(e.target.value),onBlur:()=>E.trim()!==O.repoDir&&void ei({repoDir:E.trim()}),placeholder:D.projectDir||"C:\\Projects\\my-app",disabled:D.running}),(0,a.jsx)("button",{onClick:()=>void er(),disabled:Z||D.running,children:A("mirror.browse")})]}),(0,a.jsx)(p.H4,{current:E,onUse:e=>{U(e),ei({repoDir:e})}}),Y&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("strong",{children:A("vcs.noRepo")}),(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:Y}),(0,a.jsx)("div",{className:"muted small",style:{marginTop:6},children:A("vcs.noRepoHow")})]}),!Y&&""!==ec.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:A("vcs.repoOk")}),""===ec.trim()&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:4},children:A("vcs.pickFirst")}),(0,a.jsxs)("div",{className:"option".concat(ed||O.enabled?"":" warned"),children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:O.enabled,onChange:e=>void ei({enabled:e.target.checked}),disabled:D.running||!ed&&!O.enabled}),(0,a.jsx)("span",{children:A("vcs.enable")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.enableWhy")})]}),O.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",style:{marginTop:4},children:ec?A("vcs.repoIs",{dir:ec}):A("vcs.repoNone")}),ec&&!Y&&(0,a.jsx)(w.b,{dir:ec}),(0,a.jsx)("h3",{children:A("vcs.branches")}),"existing-branch"===ea&&(0,a.jsx)("p",{className:"muted small",children:A("vcs.branchesExisting",{branch:O.existingBranch||"…"})}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-task"===O.branchMode,onChange:()=>void ei({branchMode:"per-task"}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.perTask")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.perTaskWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"branchMode",checked:"per-session"===O.branchMode,onChange:()=>void ei({branchMode:"per-session"}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.perSession")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.perSessionWhy")})]}),"per-session"===O.branchMode&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-branch-name",children:A("vcs.branchName")}),(0,a.jsx)("input",{id:"vcs-branch-name",type:"text",value:V,onChange:e=>X(e.target.value),onBlur:()=>{var e;return V.trim()!==(null!=(e=O.branchName)?e:"")&&void ei({branchName:V.trim()})},placeholder:D.name,disabled:D.running}),(0,a.jsx)("p",{className:"why",children:A("vcs.branchNameWhy")})]}),(0,a.jsx)("h3",{children:A("vcs.startFrom")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"branch"===ea,onChange:()=>void ei({startFrom:"branch"}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.startBranch")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.startBranchWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"previous-session"===ea,onChange:()=>void ei({startFrom:"previous-session"}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.startPrevious")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.startPreviousWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"head"===ea,onChange:()=>void ei({startFrom:"head"}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.startHead")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.startHeadWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"startFrom",checked:"existing-branch"===ea,onChange:()=>void ei({startFrom:"existing-branch"}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.startExisting")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.startExistingWhy")})]}),"existing-branch"===ea&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-existing-branch",children:A("vcs.existingBranch")}),(0,a.jsx)("input",{id:"vcs-existing-branch",type:"text",list:"vcs-local-branches",value:es,onChange:e=>en(e.target.value),onBlur:()=>{var e;return es.trim()!==(null!=(e=O.existingBranch)?e:"")&&void ei({existingBranch:es.trim()})},disabled:D.running}),(0,a.jsx)("datalist",{id:"vcs-local-branches",children:(null!=(g=null==q?void 0:q.branches)?g:[]).map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"why",children:A("vcs.existingBranchWhy")}),O.existingBranch&&(null==q?void 0:q.branches)&&!q.branches.includes(O.existingBranch)&&(0,a.jsx)("p",{className:"err small",children:A("vcs.existingBranchMissing",{branch:O.existingBranch})})]}),("branch"===ea||"previous-session"===ea)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"vcs-base-branch",children:A("vcs.baseBranch")}),(0,a.jsx)("input",{id:"vcs-base-branch",type:"text",value:$,onChange:e=>ee(e.target.value),onBlur:()=>{var e;return $.trim()!==(null!=(e=O.baseBranch)?e:"")&&void ei({baseBranch:$.trim()})},placeholder:"main",disabled:D.running}),(0,a.jsx)("p",{className:"why",children:A("vcs.baseBranchWhy")})]}),D.vcsStart&&(0,a.jsxs)("p",{className:"muted small",children:["existing-branch"===D.vcsStart.kind?A("vcs.startedExisting",{branch:null!=(y=D.vcsStart.branch)?y:"",commit:D.vcsStart.commit.slice(0,8)}):"previous-session"===D.vcsStart.kind?A("vcs.startedPrevious",{name:null!=(f=null==(s=D.vcsStart.fromSession)?void 0:s.name)?f:"",branch:null!=(b=D.vcsStart.branch)?b:"",commit:D.vcsStart.commit.slice(0,8)}):"branch"===D.vcsStart.kind?A("vcs.startedBranch",{branch:null!=(k=D.vcsStart.branch)?k:"",commit:D.vcsStart.commit.slice(0,8)}):"snapshot"===D.vcsStart.kind?A("vcs.startedSnapshot",{branch:null!=(N=D.vcsStart.branch)?N:"",commit:D.vcsStart.commit.slice(0,8),from:null!=(S=null==(n=D.vcsStart.snapshot)?void 0:n.fromBranch)?S:"HEAD",n:null!=(C=null==(l=D.vcsStart.snapshot)?void 0:l.included.length)?C:0,out:null!=(F=null==(i=D.vcsStart.snapshot)?void 0:i.leftOut.length)?F:0}):A("vcs.startedHead",{commit:D.vcsStart.commit.slice(0,8)}),D.vcsStart.note?" — ".concat(D.vcsStart.note):"",D.vcsStart.update&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("br",{}),"updated"===D.vcsStart.update.outcome?A("vcs.updated",{branch:D.vcsStart.update.branch,remote:null!=(L=D.vcsStart.update.remote)?L:"",from:(null!=(T=D.vcsStart.update.from)?T:"").slice(0,8),to:(null!=(I=D.vcsStart.update.to)?I:"").slice(0,8)}):"up-to-date"===D.vcsStart.update.outcome?A("vcs.upToDate",{branch:D.vcsStart.update.branch,remote:null!=(M=D.vcsStart.update.remote)?M:""}):A("vcs.notUpdated",{branch:D.vcsStart.update.branch,why:null!=(W=D.vcsStart.update.detail)?W:D.vcsStart.update.outcome})]})]}),"head"!==ea&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:!1!==O.updateFromRemote,onChange:e=>void ei({updateFromRemote:e.target.checked}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.updateFromRemote")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.updateFromRemoteWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:O.commitOnFinish,onChange:e=>void ei({commitOnFinish:e.target.checked}),disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.commit")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.commitWhy")})]}),"existing-branch"!==ea&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:A("vcs.dirty")}),["reject","snapshot","tracked-only-snapshot"].map(e=>{var s,n;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"vcs-dirty-".concat(D.id),checked:(null!=(n=null==(s=O.dirtyWorktree)?void 0:s.policy)?n:"reject")===e,onChange:()=>{var s;ei({dirtyWorktree:{policy:e,requireApproval:null==(s=O.dirtyWorktree)?void 0:s.requireApproval}})},disabled:D.running}),(0,a.jsx)("span",{children:A("reject"===e?"vcs.dirtyReject":"snapshot"===e?"vcs.dirtySnapshot":"vcs.dirtyTracked")})]}),(0,a.jsx)("p",{className:"why",children:A("reject"===e?"vcs.dirtyRejectWhy":"snapshot"===e?"vcs.dirtySnapshotWhy":"vcs.dirtyTrackedWhy")})]},e)}),(null!=(P=null==(r=O.dirtyWorktree)?void 0:r.policy)?P:"reject")!=="reject"&&(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:(null==(o=O.dirtyWorktree)?void 0:o.requireApproval)!==!1,onChange:e=>{var s,n;ei({dirtyWorktree:{policy:null!=(n=null==(s=O.dirtyWorktree)?void 0:s.policy)?n:"snapshot",requireApproval:e.target.checked}})},disabled:D.running}),(0,a.jsx)("span",{children:A("vcs.dirtyApproval")})]}),(0,a.jsx)("p",{className:"why",children:A("vcs.dirtyApprovalWhy")})]})]}),q&&!q.ok&&(0,a.jsxs)("div",{className:"notice caution",role:"status",children:[(0,a.jsx)("strong",{children:A("vcs.notReady")})," ",q.problem]}),(null==q||null==(h=q.snapshot)?void 0:h.needed)&&q.snapshot.entries.length>0&&(0,a.jsx)(H,{session:D,plan:q.snapshot,onDone:()=>{B(),el()}}),(null==q?void 0:q.ok)&&(0,a.jsx)("div",{className:"muted small",children:A("vcs.ready",{branch:null!=(R=q.branch)?R:"—",dir:q.repoDir})}),(null==q?void 0:q.ok)&&q.work&&q.work.branches.length>0&&(0,a.jsxs)("div",{className:"muted small",children:["per-session"===q.work.mode&&q.work.complete?A("vcs.completeOn",{branch:q.work.complete}):A("vcs.noSingleBranch",{n:q.work.branches.length}),"per-task"===q.work.mode&&(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:q.work.branches.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.branch})," — ",e.title,e.commit?"":" (".concat(A("vcs.taskNoFiles"),")")]},e.branch))})]}),(0,a.jsx)("p",{className:"muted small",children:A("vcs.pushIsYours")})]}),(0,a.jsx)("div",{className:"muted small",role:"status",children:G})]})}function W(e){var s;let{session:n,onChange:l}=e,{t:i}=(0,d.kj)(),[r,o]=(0,t.useState)(""),h=null!=(s=n.onFailure)?s:"stop",m=async e=>{if(e!==h)try{await c.FH.updateSession(n.id,{onFailure:e}),o(i("stop"===e?"chain.savedStop":"chain.savedContinue")),l()}catch(e){o(e.message)}};return(0,a.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,a.jsx)("legend",{className:"muted small",style:{padding:0},children:i("chain.title")}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"stop"===h,onChange:()=>void m("stop"),disabled:n.running}),(0,a.jsx)("span",{children:i("chain.stop")})]}),(0,a.jsx)("p",{className:"why",children:i("chain.stopWhy")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"chain",checked:"continue"===h,onChange:()=>void m("continue"),disabled:n.running}),(0,a.jsx)("span",{children:i("chain.continue")})]}),(0,a.jsx)("p",{className:"why",children:i("chain.continueWhy")})]}),r&&(0,a.jsx)("div",{className:"muted small",role:"status",children:r}),n.running&&(0,a.jsx)("div",{className:"muted small",children:i("chain.locked")})]})}function P(e){let{value:s,onChange:n,presets:l,onPresetsChanged:i}=e,{t:r}=(0,d.kj)(),o=(0,t.useId)(),[h,m]=(0,t.useState)(""),u=async()=>{let e=prompt(r("l2.saveAsPrompt"));if(e)try{await c.FH.savePreset(e,s),m(r("l2.savedAs",{name:e})),null==i||i()}catch(e){m(e.message)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("label",{className:"grow",style:{margin:0},htmlFor:"".concat(o,"-text"),children:r("l2.label")}),(0,a.jsxs)("select",{value:"","aria-label":r("l2.loadPreset"),onChange:e=>{let s=l.find(s=>s.name===e.target.value);s&&n(s.content)},children:[(0,a.jsx)("option",{value:"",children:r("l2.loadPreset")}),l.map(e=>(0,a.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,a.jsx)("button",{onClick:()=>void u(),disabled:!s.trim(),children:r("l2.saveAs")})]}),(0,a.jsx)("textarea",{id:"".concat(o,"-text"),className:"prose",value:s,onChange:e=>n(e.target.value),placeholder:r("l2.placeholder"),style:{minHeight:140,marginTop:10}}),h&&(0,a.jsx)("div",{className:"muted small",children:h})]})}function R(e){let{session:s}=e,{t:n}=(0,d.kj)(),l=(0,d.W3)(),i=s.tasks.filter(e=>"queued"!==e.status),[r,o]=(0,t.useState)([]),h=r.length>0?r:i.map(e=>e.id),m=e=>(0,c.ub)("".concat(c.nC,"/sessions/").concat(s.id,"/export?variant=").concat(e)+(r.length>0?"&tasks=".concat(encodeURIComponent(r.join(","))):""));return(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("export.title")}),(0,a.jsx)("p",{className:"muted small",children:n("export.hint")}),0===i.length?(0,a.jsx)("div",{className:"empty",children:n("export.nothing")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"row",style:{marginBottom:6},children:[(0,a.jsx)("button",{className:"quiet",onClick:()=>o(i.map(e=>e.id)),children:n("export.all")}),(0,a.jsx)("button",{className:"quiet",onClick:()=>o([]),children:n("export.none")}),(0,a.jsx)("span",{className:"muted small",children:r.length>0?n("export.selected",{n:r.length}):n("export.allOf",{n:i.length})})]}),i.map(e=>{var s,t,i,c,d;return(0,a.jsx)("div",{className:"option",style:{margin:"6px 0"},children:(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:r.includes(e.id),onChange:()=>{let s;return s=e.id,o(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])}}),(0,a.jsxs)("span",{children:[e.title," ",(0,a.jsx)("span",{className:"badge ".concat(e.status),children:n("status.".concat(e.status))})," ",e.readOnly&&(0,a.jsx)("span",{className:"chip",children:n("task.readOnly")})," ",(null!=(t=null==(s=e.scope)?void 0:s.length)?t:0)>0&&(0,a.jsx)("span",{className:"chip",children:n("task.scope",{paths:(null!=(i=e.scope)?i:[]).join(", ")})})," ",(0,a.jsx)("span",{className:"muted small",children:l(null!=(d=null!=(c=e.finishedAt)?c:e.startedAt)?d:e.createdAt)})]})]})},e.id)}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("a",{className:"button-link",href:m("outcome"),download:!0,children:n("export.outcome",{n:h.length})}),(0,a.jsx)("a",{className:"button-link",href:m("full"),download:!0,children:n("export.full",{n:h.length})})]}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:n("export.outcomeWhy")})]})]})}function D(e){let{handoff:s}=e,{t:n}=(0,d.kj)(),t=(e,s)=>(0,a.jsxs)("div",{className:"handoff-row",children:[(0,a.jsx)("strong",{children:n(e)})," ",s]}),l=e=>(0,a.jsx)("ul",{children:e.map((e,s)=>(0,a.jsx)("li",{children:e},s))}),i=s.validation.filter(e=>e.passed).length;return(0,a.jsxs)("div",{className:"summary handoff",children:[(0,a.jsx)("strong",{children:n("handoff.title")}),t("handoff.outcome",(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"badge ".concat(s.outcome.status),children:n("status.".concat(s.outcome.status))}),s.outcome.reason?" ".concat(s.outcome.reason):""]})),t("handoff.files",0===s.changedFiles.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noFiles")}):(0,a.jsx)("code",{children:s.changedFiles.map(e=>"".concat(e.path).concat(e.added>=0?" +".concat(e.added,"/-").concat(e.removed):"")).join(", ")})),s.validation.length>0&&t("handoff.validation",(0,a.jsxs)(a.Fragment,{children:[n("handoff.passed",{n:i,of:s.validation.length}),s.review?" \xb7 ".concat(n("handoff.review",{verdict:s.review.verdict,open:s.review.open})):""]})),t("handoff.issues",0===s.knownIssues.length?(0,a.jsx)("span",{className:"muted",children:n("handoff.noIssues")}):l(s.knownIssues)),s.evidence.runId&&t("handoff.evidence",(0,a.jsx)("code",{children:s.evidence.runId})),(s.vcs.branch||s.vcs.problem)&&t("handoff.vcs",(0,a.jsxs)(a.Fragment,{children:[s.vcs.branch&&(0,a.jsx)("code",{children:s.vcs.branch}),s.vcs.commit?" @ ".concat(s.vcs.commit.slice(0,8)," \xb7 ").concat(n("handoff.notPushed")):s.vcs.branch?" \xb7 ".concat(n("handoff.noCommit")):"",s.vcs.problem?" — ".concat(s.vcs.problem):""]})),s.manual.length>0&&t("handoff.manual",l(s.manual)),s.notExecuted.length>0&&t("handoff.notRun",l(s.notExecuted))]})}function B(e){var s;let{session:n,presets:l,onAdded:i,onPresetsChanged:r}=e,{t:o}=(0,d.kj)(),h=[...n.tasks].reverse()[0],[m,u]=(0,t.useState)(""),[p,v]=(0,t.useState)(null!=(s=null==h?void 0:h.level2)?s:""),[x,j]=(0,t.useState)(""),[g,y]=(0,t.useState)(""),[f,b]=(0,t.useState)(!1),k=(0,t.useRef)(!1),N=async()=>{if(!k.current){k.current=!0,b(!0);try{await c.FH.addTask(n.id,{title:m,level2:p,prompt:x}),u(""),j(""),y(o("form.queued")),i()}catch(e){y(e.message)}finally{k.current=!1,b(!1)}}};return(0,a.jsxs)("div",{className:"panel",id:"new-task",children:[(0,a.jsx)("h2",{children:o("form.title")}),(0,a.jsx)("p",{className:"muted small",children:o("form.hint")}),(0,a.jsx)("label",{htmlFor:"new-task-title",children:o("form.titleLabel")}),(0,a.jsx)("input",{id:"new-task-title",type:"text",value:m,onChange:e=>u(e.target.value),placeholder:o("form.titlePlaceholder")}),(0,a.jsx)("div",{style:{marginTop:10},children:(0,a.jsx)(P,{value:p,onChange:v,presets:l,onPresetsChanged:r})}),(0,a.jsx)("label",{htmlFor:"new-task-prompt",children:o("form.taskLabel")}),(0,a.jsx)("textarea",{id:"new-task-prompt",className:"prose",value:x,onChange:e=>j(e.target.value),placeholder:o("form.taskPlaceholder"),style:{minHeight:140}}),(0,a.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:f||!x.trim(),children:o("form.add")}),(0,a.jsx)("span",{className:"muted small",children:g})]})]})}function A(e){var s,n,l,i,r,u,p,v,f,k,w,S,C,F,L,T,I,H,M,W,R,B,A,O,U,J,Z,_,K,Y,Q,V,X,$,ee,es,en,ea,et,el,ei,er,ec,ed,eo,eh,em,eu,ep,ev,ex,ej,eg,ey,ef,eb,ek,eN,ew,eS,eC,eF,eL,eT,eI,eH,eM,eW,eP,eR,eD,eB,eA,eO;let{session:eE,task:eU,index:eq,presets:ez,onChange:eG}=e,{t:eJ}=(0,d.kj)(),eZ=(0,d.W3)(),[e_,eK]=(0,t.useState)(!1),[eY,eQ]=(0,t.useState)(!1),[eV,eX]=(0,t.useState)(eU.title),[e$,e0]=(0,t.useState)(eU.level2),[e1,e2]=(0,t.useState)(eU.prompt),[e8,e4]=(0,t.useState)(null!=(V=null==(s=eU.vcsPlan)?void 0:s.branch)?V:""),[e6,e3]=(0,t.useState)(null!=(X=null==(n=eU.vcsPlan)?void 0:n.commitMessage)?X:""),[e5,e7]=(0,t.useState)(null!=($=eU.checks)?$:[]),[e9,se]=(0,t.useState)(!!eU.readOnly),[ss,sn]=(0,t.useState)((null!=(ee=eU.scope)?ee:[]).join("\n")),sa={readOnly:e9,scope:e9?[]:(0,N.w)(ss)},st=(0,m.c)((0,h.DG)(eU)),[sl,si]=(0,t.useState)(null),[sr,sc]=(0,t.useState)(""),sd=async()=>{try{await c.FH.updateTask(eE.id,eU.id,{title:eV,level2:e$,prompt:e1,vcsPlan:{branch:e8,commitMessage:e6},checks:e5,...sa}),eK(!1),eG()}catch(e){sc(e.message)}},so="running"===eU.status||"waiting-approval"===eU.status,sh=!so&&"queued"!==eU.status,sm=!so&&"queued"!==eU.status,su=!so&&null!=(es=null==(l=eE.vcs)?void 0:l.enabled)&&es&&(!!(null==(i=eU.vcs)?void 0:i.baseCommit)||(null!=(en=eU.attempts)?en:[]).some(e=>{var s;return null==(s=e.vcs)?void 0:s.baseCommit})),sp=!so&&(0,c.Zm)(eU),sv=async()=>{if(await (0,g.Z)(eJ("task.continueConfirm",{title:eU.title})))try{await c.FH.continueTask(eE.id,eU.id),eG()}catch(e){sc(e.message)}},sx=async()=>{if(await (0,g.Z)(eJ("task.rerunConfirm",{title:eU.title})))try{await c.FH.rerunTask(eE.id,eU.id),eG()}catch(e){sc(e.message)}},sj=async()=>{if(await (0,g.Z)(eJ("task.editRanConfirm",{title:eU.title})))try{await c.FH.rerunTask(eE.id,eU.id,{title:eV,level2:e$,prompt:e1,vcsPlan:{branch:e8,commitMessage:e6},checks:e5,...sa},{buildOnFinished:"done"===eU.status}),eK(!1),eG()}catch(e){sc(e.message)}},sg=(0,b.e)(eG),sy=async()=>{let e="queued"===eU.status?"task.deleteConfirm":"task.deleteConfirmRan";if(await (0,g.Z)(eJ(e,{title:eU.title})))try{await c.FH.deleteTask(eE.id,eU.id),eG()}catch(e){sc(e.message)}},sf=async()=>{try{si(await c.FH.taskFiles(eE.id,eU.id))}catch(e){sc(e.message)}},sb=(e,s,n)=>n.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"muted",children:[eJ(e)," "]}),n.map(e=>(0,a.jsx)("span",{style:{marginRight:10},children:(0,a.jsx)(o.u,{label:e,save:()=>c.FH.saveTaskFile(eE.id,eU.id,s,e)})},e))]});return(0,a.jsxs)("div",{className:"task ".concat(eU.status),id:eU.id,children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("h4",{className:"grow",children:[eq,". ",eU.title]}),(0,a.jsx)("span",{className:"badge ".concat(eU.status),children:eJ("status.".concat(eU.status))}),eU.limit&&(0,a.jsx)("span",{className:"chip",title:eJ("reg.limitChipWhy"),children:eJ("reg.limitChip",{limit:eJ("limit.".concat(eU.limit.setting),{n:eU.limit.value})})}),(null!=(ea=eU.attempt)?ea:1)>1&&(0,a.jsx)("span",{className:"chip",children:eJ("task.attemptN",{n:null!=(et=eU.attempt)?et:1})}),eU.iterations>0&&(0,a.jsx)("span",{className:"muted small",children:eJ("task.iterations",{n:eU.iterations})}),eU.runId&&(0,a.jsxs)("button",{className:eY?"":"quiet","aria-expanded":eY,onClick:()=>eQ(e=>!e),title:(0,h.DG)(eU)?eJ("story.showLiveWhy"):eJ("story.why"),children:[(0,h.DG)(eU)&&!eY&&(0,a.jsx)("span",{className:"dot","aria-hidden":"true"}),eY?eJ("story.hide"):(0,h.DG)(eU)?eJ("story.showLive"):eJ("story.show")]}),!so&&(0,a.jsx)("button",{onClick:()=>{if(!e_){var e,s,n,a,t,l;eX(eU.title),e0(eU.level2),e2(eU.prompt),e4(null!=(n=null==(e=eU.vcsPlan)?void 0:e.branch)?n:""),e3(null!=(a=null==(s=eU.vcsPlan)?void 0:s.commitMessage)?a:""),e7(null!=(t=eU.checks)?t:[]),se(!!eU.readOnly),sn((null!=(l=eU.scope)?l:[]).join("\n"))}eK(!e_)},title:eJ("task.editAll"),children:e_?eJ("task.cancel"):eJ("task.edit")}),sp&&(0,a.jsx)("button",{className:"primary",onClick:()=>void sv(),title:eJ("task.continueWhy"),children:eJ("task.continue")}),sm&&(0,a.jsx)("button",{className:sp?"":"primary",onClick:()=>void sx(),title:eJ("task.rerunWhy"),children:eJ("task.rerun")}),su&&(0,a.jsx)("button",{onClick:()=>void sg.restore({sessionId:eE.id,taskId:eU.id,title:eU.title}),disabled:""!==sg.busy||eE.running,title:eJ("restore.why"),children:"restore"===sg.busy?eJ("restore.checking"):eJ("restore.button")}),sh&&(0,a.jsx)("button",{onClick:()=>void sg.restartFrom({sessionId:eE.id,taskId:eU.id,title:eU.title}),disabled:""!==sg.busy||eE.running,title:eJ("restart.why"),children:"restart"===sg.busy?eJ("restart.checking"):eJ("restart.button")}),!so&&(0,a.jsx)("button",{className:"danger",onClick:()=>void sy(),children:eJ("task.delete")}),!e_&&(sr||sg.message)&&(0,a.jsx)("span",{className:"err",role:"alert",children:sr||sg.message})]}),(0,a.jsxs)("div",{className:"muted small",children:[eU.startedAt?eJ("task.started",{t:eZ(eU.startedAt)}):eJ("task.added",{t:eZ(eU.createdAt)}),eU.finishedAt?" \xb7 ".concat(eJ("task.finished",{t:eZ(eU.finishedAt)})):"",eU.startedAt&&eU.finishedAt?" \xb7 ".concat(eJ("task.took",{d:(0,c.c5)((0,h.d5)(eU.startedAt,eU.finishedAt))})):"",(0,h.DG)(eU)?" \xb7 ".concat(eJ("task.runningFor",{d:(0,c.c5)((0,h.d5)(eU.startedAt,void 0,st))})):""]}),"queued"!==eU.status&&(null==(r=eE.vcs)?void 0:r.enabled)&&eU.vcs&&(0,a.jsx)("div",{className:"muted small",children:eU.vcs.problem&&!eU.vcs.branch?(0,a.jsx)("span",{className:"reason",children:eJ("vcs.taskProblem",{problem:eU.vcs.problem})}):(0,a.jsxs)(a.Fragment,{children:[eU.vcs.branch&&eJ("vcs.taskBranch",{branch:eU.vcs.branch}),eU.vcs.baseCommit&&" \xb7 ".concat(eJ("vcs.taskBase",{commit:eU.vcs.baseCommit.slice(0,8)})),eU.vcs.commit?" \xb7 ".concat(eJ("vcs.taskCommit",{commit:eU.vcs.commit.slice(0,8)})):" \xb7 ".concat(eJ("vcs.taskNoFiles")),(null!=(el=null==(u=eU.vcs.files)?void 0:u.length)?el:0)>0&&(0,a.jsxs)("details",{style:{display:"inline"},children:[(0,a.jsxs)("summary",{style:{display:"inline",cursor:"pointer"},children:[" \xb7 ",eJ("vcs.taskFiles",{n:null!=(ei=null==(p=eU.vcs.files)?void 0:p.length)?ei:0})]}),(0,a.jsx)("ul",{style:{margin:"4px 0 4px 0",paddingLeft:20},children:(null!=(er=eU.vcs.files)?er:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," ",e.added<0||e.removed<0?eJ("vcs.taskBinary"):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{style:{color:"var(--ok)"},children:["+",e.added]})," ",(0,a.jsxs)("span",{style:{color:"var(--bad)"},children:["-",e.removed]})]})]},e.path))})]}),eU.vcs.commit&&eU.vcs.baseCommit&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",(0,a.jsx)(y.C,{sessionId:eE.id,taskId:eU.id,title:eU.title,files:null!=(ec=null==(v=eU.vcs.files)?void 0:v.length)?ec:0})]}),(null!=(ed=null==(f=eU.vcs.suspicious)?void 0:f.length)?ed:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[eJ("vcs.suspicious",{n:null!=(eo=null==(k=eU.vcs.suspicious)?void 0:k.length)?eo:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eh=eU.vcs.suspicious)?eh:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.path})," — ",e.reason]},e.path))})]}),(null!=(em=null==(w=eU.scopeReverted)?void 0:w.length)?em:0)>0&&(0,a.jsx)("div",{className:"small",style:{marginTop:4},children:eJ("task.scopeReverted",{n:null!=(eu=null==(S=eU.scopeReverted)?void 0:S.length)?eu:0,paths:(null!=(ep=eU.scopeReverted)?ep:[]).join(", ")})}),(null!=(ev=null==(C=eU.vcs.foreignCommits)?void 0:C.length)?ev:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{marginTop:4},children:[eJ("vcs.foreignCommits",{n:null!=(ex=null==(F=eU.vcs.foreignCommits)?void 0:F.length)?ex:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(ej=eU.vcs.foreignCommits)?ej:[]).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]})]})}),"queued"===eU.status&&(null==(L=eE.vcs)?void 0:L.enabled)&&((null==(T=eU.vcsPlan)?void 0:T.branch)||(null==(I=eU.vcsPlan)?void 0:I.commitMessage))&&(0,a.jsx)("div",{className:"muted small",children:eU.vcsPlan.branch&&eU.vcsPlan.commitMessage?eJ("task.gitNames",{branch:eU.vcsPlan.branch,subject:eU.vcsPlan.commitMessage.split("\n")[0]}):eU.vcsPlan.branch?eJ("task.gitBranchOnly",{branch:eU.vcsPlan.branch}):eJ("task.gitCommitOnly",{subject:(null!=(eg=eU.vcsPlan.commitMessage)?eg:"").split("\n")[0]})}),eY&&eU.runId&&(0,a.jsx)(x.P,{sessionId:eE.id,taskId:eU.id,live:"running"===eU.status||"waiting-approval"===eU.status}),e_?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("label",{children:eJ("form.titleLabel")}),(0,a.jsx)("input",{type:"text",value:eV,onChange:e=>eX(e.target.value)}),(0,a.jsx)("div",{style:{marginTop:8},children:(0,a.jsx)(P,{value:e$,onChange:e0,presets:ez})}),(0,a.jsx)("label",{children:eJ("form.taskLabel")}),(0,a.jsx)("textarea",{className:"prose",value:e1,onChange:e=>e2(e.target.value)}),(null==(H=eE.vcs)?void 0:H.enabled)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{htmlFor:"branch-".concat(eU.id),children:eJ("task.branch")}),(0,a.jsx)("input",{id:"branch-".concat(eU.id),type:"text",value:e8,onChange:e=>e4(e.target.value),placeholder:eE.vcs.branchPrefix,disabled:"per-session"===eE.vcs.branchMode}),(0,a.jsx)("p",{className:"why",children:"per-session"===eE.vcs.branchMode?eJ("task.branchIgnored"):eJ("task.branchWhy")}),(0,a.jsx)("label",{htmlFor:"commit-".concat(eU.id),children:eJ("task.commitMessage")}),(0,a.jsx)("textarea",{id:"commit-".concat(eU.id),value:e6,onChange:e=>e3(e.target.value),style:{minHeight:70}}),(0,a.jsx)("p",{className:"why",children:eJ("task.commitWhy")})]}),(0,a.jsx)(E,{checks:e5,onChange:e7}),e1.trim()!==eU.prompt.trim()&&(0,a.jsx)("p",{className:"notice caution small",children:eJ("task.newIntentNote")}),(0,a.jsx)(N.y,{readOnly:e9,scope:ss,onReadOnly:se,onScope:sn}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("button",{className:"primary",onClick:()=>void(sh?sj():sd()),children:sh?eJ("task.saveAndRerun"):eJ("task.save")}),(0,a.jsx)("span",{className:"err",children:sr})]}),sh&&(0,a.jsx)("p",{className:"muted small",children:eJ("task.editRanWhy")})]}):(0,a.jsxs)(a.Fragment,{children:[(null!=(ey=null==(M=eU.checks)?void 0:M.length)?ey:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsxs)("summary",{children:[eJ("checks.title")," — ",eJ("checks.n",{n:null!=(ef=null==(W=eU.checks)?void 0:W.length)?ef:0}),(null!=(eb=null==(R=eU.checkResults)?void 0:R.length)?eb:0)>0&&" \xb7 ".concat((null!=(ek=eU.checkResults)?ek:[]).filter(e=>e.passed).length,"/").concat(null==(B=eU.checkResults)?void 0:B.length," ").concat(eJ("checks.passed"))]}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eN=eU.checks)?eN:[]).map((e,s)=>{var n;let t=(null!=(n=eU.checkResults)?n:[]).find(s=>s.name===e.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{children:e.name}),(0,a.jsxs)("span",{className:"muted",children:[" — ",eJ("checks.kind.".concat(e.expect)),e.value?' "'.concat(e.value,'"'):"",e.run?": ".concat(e.run):e.file?": ".concat(e.file):""]}),t&&(0,a.jsxs)("div",{className:t.passed?"muted":"reason",children:[t.passed?eJ("checks.passed"):eJ("checks.failed")," — ",t.detail]})]},"".concat(e.name,"-").concat(s))})})]}),(null!=(ew=null==(A=eU.reviewChecks)?void 0:A.length)?ew:0)>0&&(0,a.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,a.jsx)("summary",{children:eJ("checks.fromReview",{n:null!=(eS=null==(O=eU.reviewChecks)?void 0:O.length)?eS:0})}),(0,a.jsx)("p",{className:"why",children:eJ("checks.fromReviewWhy")}),(0,a.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eC=eU.reviewChecks)?eC:[]).map(e=>{var s;let n=(null!=(s=eU.checkResults)?s:[]).find(s=>s.name===e.check.name);return(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.findingId})," ",(0,a.jsx)("strong",{children:e.check.name}),"active"!==e.state&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:eJ("checks.state.".concat(e.state))}),(0,a.jsx)("div",{className:"muted",children:e.what}),n&&(0,a.jsxs)("div",{className:n.passed?"muted":"reason",children:[n.passed?eJ("checks.passed"):eJ("checks.failed")," — ",n.detail]})]},e.check.name)})})]}),(0,a.jsx)(G,{review:eU.review}),eU.stopCode&&!(0,h.DG)(eU)&&(0,a.jsx)("p",{className:"small",children:(0,a.jsx)("span",{className:"chip",title:eJ("stop.why"),children:eJ("stop.".concat(eU.stopCode))})}),eU.handoff&&!(0,h.DG)(eU)&&(0,a.jsx)(D,{handoff:eU.handoff}),eU.summary&&(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:eJ("task.whatWasDone")}),(0,a.jsx)(j.s,{text:eU.summary})]}),(null!=(eF=null==(U=eU.deviations)?void 0:U.length)?eF:0)>0&&(0,a.jsx)(q,{items:null!=(eL=eU.deviations)?eL:[]}),(null!=(eT=null==(J=eU.disputes)?void 0:J.length)?eT:0)>0&&(0,a.jsx)(z,{items:null!=(eI=eU.disputes)?eI:[]}),eU.environment&&(0,a.jsx)("div",{className:"muted small",style:{margin:"4px 0"},children:eJ("task.ranWith",{node:eU.environment.node,npm:null!=(eH=eU.environment.npm)?eH:"—",git:null!=(eM=eU.environment.git)?eM:"—",pwsh:null!=(eP=null!=(eW=eU.environment.pwsh)?eW:eU.environment.powershell)?eP:"—"})}),(null!=(eR=null==(Z=eU.leftovers)?void 0:Z.length)?eR:0)>0&&(0,a.jsxs)("div",{className:"err small",style:{margin:"6px 0"},children:[eJ("task.leftovers",{n:null!=(eD=null==(_=eU.leftovers)?void 0:_.length)?eD:0}),(0,a.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eB=eU.leftovers)?eB:[]).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.name})," pid ",e.pid,e.ports.length>0?" \xb7 ".concat(eJ("task.leftoverPorts",{ports:e.ports.join(", ")})):""," \xb7 ",e.by]},"".concat(e.by,"-").concat(e.pid)))})]}),eU.reason&&(0,a.jsx)("div",{className:"reason small",style:{margin:"6px 0"},children:eU.reason}),(null!=(eA=null==(K=eU.attempts)?void 0:K.length)?eA:0)>0&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.attempts",{n:null!=(eO=null==(Y=eU.attempts)?void 0:Y.length)?eO:0})}),null==(Q=eU.attempts)?void 0:Q.map((e,s)=>{var n,t,l,i;return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0 12px"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{children:eJ("task.attemptN",{n:s+1})}),(0,a.jsx)("span",{className:"badge ".concat(e.status),children:eJ("status.".concat(e.status))}),e.iterations>0&&(0,a.jsx)("span",{className:"muted",children:eJ("task.iterations",{n:e.iterations})}),e.runId&&(0,a.jsx)(o.u,{label:eJ("save.attemptLog"),save:()=>c.FH.saveTaskLog(eE.id,eU.id,e.runId)}),e.runId&&(0,a.jsx)(o.H,{sessionId:eE.id,taskId:eU.id,attempt:s+1}),e.runId&&(null==(n=e.vcs)?void 0:n.commit)&&e.vcs.baseCommit&&(0,a.jsx)(y.C,{sessionId:eE.id,taskId:eU.id,runId:e.runId,title:"".concat(eU.title," — ").concat(eJ("task.attemptN",{n:s+1})),files:null!=(l=null==(t=e.vcs.files)?void 0:t.length)?l:0})]}),(0,a.jsxs)("div",{className:"muted",children:[e.startedAt?eJ("task.started",{t:eZ(e.startedAt)}):"",e.finishedAt?" \xb7 ".concat(eJ("task.finished",{t:eZ(e.finishedAt)})):""]}),e.summary&&(0,a.jsx)("div",{children:e.summary}),e.reason&&(0,a.jsx)("div",{className:"err",children:e.reason}),e.prompt&&e.prompt!==eU.prompt&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.attemptText")}),(0,a.jsx)("pre",{children:e.prompt})]})]},"".concat(null!=(i=e.runId)?i:s))})]}),"queued"===eU.status?(0,a.jsxs)("div",{style:{marginTop:8},children:[(0,a.jsx)("div",{className:"muted small",children:eJ("task.prompt")}),(0,a.jsx)("pre",{children:eU.prompt}),eU.level2.trim()?(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.l2Show",{n:eU.level2.trim().split("\n").length})}),(0,a.jsx)("pre",{children:eU.level2})]}):(0,a.jsx)("div",{className:"muted small",children:eJ("task.noL2")})]}):(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.promptAndL2")}),eU.level2.trim()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"muted small",children:eJ("task.l2")}),(0,a.jsx)("pre",{children:eU.level2})]}),(0,a.jsx)("div",{className:"muted small",children:eJ("task.prompt")}),(0,a.jsx)("pre",{children:eU.prompt})]}),eU.firstMessage&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.firstMessage")}),(0,a.jsx)("pre",{className:"tall",children:eU.firstMessage})]}),eU.runId&&(0,a.jsxs)("details",{onToggle:e=>e.currentTarget.open&&void sf(),children:[(0,a.jsx)("summary",{children:eJ("task.files")}),(0,a.jsx)("div",{className:"row small",style:{margin:"6px 0"},children:(0,a.jsx)(o.u,{label:eJ("save.log"),save:()=>c.FH.saveTaskLog(eE.id,eU.id)})}),sl&&(0,a.jsxs)("div",{className:"small",children:[sb("task.reports","reports",sl.reports),sb("task.artifacts","artifacts",sl.artifacts),sb("task.replies","replies",sl.replies)]})]}),eU.finalReply&&(0,a.jsxs)("details",{children:[(0,a.jsx)("summary",{children:eJ("task.finalReply")}),(0,a.jsx)("pre",{className:"tall",children:eU.finalReply})]})]})]})}function O(e){let{events:s}=e,{t:n}=(0,d.kj)(),{appearance:l}=(0,u.KP)(),i=(0,t.useRef)(null);return(0,t.useEffect)(()=>{!l.reduceMotion&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[s.length,l.reduceMotion]),(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:n("live.title")}),(0,a.jsxs)("div",{className:"log",ref:i,children:[0===s.length&&(0,a.jsx)("div",{className:"muted",children:n("live.none")}),s.map((e,s)=>{var n;return(0,a.jsxs)("div",{className:e.level,children:[(0,a.jsx)("span",{className:"time",children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),null!=(n=e.message)?n:e.type]},s)})]})]})}function E(e){let{checks:s,onChange:n}=e,{t}=(0,d.kj)(),l=(e,a)=>n(s.map((s,n)=>e===n?{...s,...a}:s));return(0,a.jsxs)("div",{style:{marginTop:12},children:[(0,a.jsx)("label",{children:t("checks.title")}),(0,a.jsx)("p",{className:"why",style:{marginTop:0},children:t("checks.why")}),0===s.length&&(0,a.jsx)("p",{className:"muted small",children:t("checks.noneWhy")}),s.map((e,i)=>{var r,d,o,h;return(0,a.jsxs)("div",{className:"option",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{type:"text",className:"grow",value:e.name,placeholder:t("checks.namePlaceholder"),onChange:e=>l(i,{name:e.target.value}),"aria-label":t("checks.name")}),(0,a.jsx)("select",{value:e.expect,onChange:e=>l(i,{expect:e.target.value}),"aria-label":t("checks.kind"),style:{width:"auto"},children:c.FZ.map(e=>(0,a.jsx)("option",{value:e,children:t("checks.kind.".concat(e))},e))}),(0,a.jsx)("button",{className:"quiet",onClick:()=>n(s.filter((e,s)=>s!==i)),children:t("checks.remove")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,c.rt)(e.expect)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(r=e.run)?r:"",placeholder:t("checks.run"),onChange:e=>l(i,{run:e.target.value}),"aria-label":t("checks.run")}),(0,a.jsx)("input",{type:"text",value:null!=(d=e.cwd)?d:"",placeholder:t("checks.cwd"),onChange:e=>l(i,{cwd:e.target.value}),"aria-label":t("checks.cwd"),style:{width:220}})]}):(0,a.jsx)("input",{type:"text",className:"grow",value:null!=(o=e.file)?o:"",placeholder:t("checks.file"),onChange:e=>l(i,{file:e.target.value}),"aria-label":t("checks.file")}),(0,c.dK)(e.expect)&&(0,a.jsx)("input",{type:"text",value:null!=(h=e.value)?h:"",placeholder:"output-matches"===e.expect?t("checks.valueRegex"):t("checks.value"),onChange:e=>l(i,{value:e.target.value}),"aria-label":t("checks.value"),style:{width:240}})]})]},i)}),(0,a.jsx)("button",{onClick:()=>n([...s,{name:"",expect:"exit-zero",run:""}]),children:t("checks.add")})]})}function U(e){let{tasks:s}=e,{t:n}=(0,d.kj)(),t=(0,h.hH)(s),l=(0,m.c)(!!t&&t.tasks.some(h.DG));if(!t)return null;let i=(0,h.eZ)(t.run,t.tasks,l);return(0,a.jsx)("p",{className:"muted small",style:{margin:"4px 0 10px"},children:n(i.live?"session.runClockLive":"session.runClock",{n:i.tasks,d:(0,c.c5)(i.ms)})})}function q(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.deviations",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsx)("div",{children:e.instruction}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationDid"),": ",e.did]}),(0,a.jsxs)("div",{className:"muted",children:[n("task.deviationWhy"),": ",e.why]})]},s))})]})}function z(e){let{items:s}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"summary",children:[(0,a.jsx)("strong",{children:n("task.disputes",{n:s.length})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:6},children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("code",{children:e.finding})," — ",e.why]}),(0,a.jsxs)("div",{className:"muted",children:[n("review.evidence"),": ",e.evidence]})]},s))})]})}function G(e){var s,n,t,l,i;let{review:r}=e,{t:c}=(0,d.kj)();if(!r)return null;if("skipped"===r.verdict)return r.skippedBecause?(0,a.jsx)("p",{className:"muted small",children:c("review.skippedWhy",{why:r.skippedBecause})}):null;let o="pass"===r.verdict?"done":"fail"===r.verdict?"blocked":"waiting-approval";return(0,a.jsxs)("div",{className:"small",style:{margin:"8px 0"},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"badge ".concat(o),children:c("review.verdict.".concat(r.verdict))}),r.stepsRun>0&&(0,a.jsx)("span",{className:"muted",children:c("review.ran",{n:r.stepsRun})}),r.rounds>1&&(0,a.jsx)("span",{className:"muted",children:c("review.rounds",{n:r.rounds})}),r.model&&(0,a.jsx)("span",{className:"chip",children:c("review.onModel",{model:r.model})})]}),r.problem&&(0,a.jsx)("p",{className:"reason",children:c("review.problem",{problem:r.problem})}),r.summary&&(0,a.jsx)(j.s,{text:r.summary}),(null!=(t=null==(s=r.findings)?void 0:s.length)?t:0)>0&&(0,a.jsxs)("details",{style:{marginTop:4},children:[(0,a.jsx)("summary",{children:c("review.findings",{n:null!=(l=null==(n=r.findings)?void 0:n.length)?l:0})}),(0,a.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(i=r.findings)?i:[]).map((e,s)=>(0,a.jsxs)("li",{style:{marginBottom:8},children:[(0,a.jsxs)("div",{children:[e.id&&(0,a.jsx)("code",{style:{marginRight:6},children:e.id}),e.what,"task"===e.about&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.aboutTask")}),e.repeated&&(0,a.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.repeated")})]}),e.where&&(0,a.jsx)("div",{className:"muted",children:e.where}),(0,a.jsxs)("div",{className:"muted",children:[c("review.evidence"),": ",e.evidence]})]},s))})]})]})}},4784:(e,s,n)=>{"use strict";n.d(s,{Y:()=>r});var a=n(3365),t=n(1521),l=n(5549),i=n(867);function r(e){var s,n;let{id:r,chosen:c,onChange:d,none:o,catalogue:h,disabled:m=!1,style:u}=e,{t:p}=(0,i.kj)(),v=function(e){let[s,n]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(void 0!==e)return;let s=!0;return l.FH.models().then(e=>{s&&n(e)}).catch(()=>void 0),()=>{s=!1}},[e]),void 0!==e?e:s}(h),x=null!=(s=null==v?void 0:v.options)?s:[],j=x.some(e=>e.name===c),g=x.filter(e=>!e.group),y=new Map;for(let e of x)e.group&&y.set(e.group,[...null!=(n=y.get(e.group))?n:[],e]);return(0,a.jsxs)("select",{id:r,value:c,onChange:e=>d(e.target.value),disabled:m,style:{width:"auto",minWidth:280,...u},children:[(0,a.jsx)("option",{value:"",children:o}),c&&!j&&(0,a.jsx)("option",{value:c,children:p("model.notInList",{name:c})}),g.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name)),[...y.entries()].map(e=>{let[s,n]=e;return(0,a.jsx)("optgroup",{label:s,children:n.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name))},s)})]})}},8848:(e,s,n)=>{"use strict";n.d(s,{H4:()=>d,L:()=>o,z4:()=>h});var a=n(3365),t=n(8197),l=n.n(t),i=n(1521),r=n(5549),c=n(867);function d(e){let{current:s,onUse:n}=e,{t}=(0,c.kj)(),[l,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(s=>{e||d(s)}).catch(()=>void 0),()=>{e=!0}},[]),!l)return null;let o=l.rootDir.trim(),h=s.trim().toLowerCase(),m=n?l.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,a.jsx)(u,{label:o?t("proj.defaultIs",{dir:o}):t("proj.noneShort"),offer:o&&n&&h!==o.toLowerCase()?{text:t("proj.useIt"),onUse:()=>n(o)}:void 0,more:m.map(e=>({text:t("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==n?void 0:n(e.rootDir)})),link:o?t("proj.change"):t("proj.setIt"),anchor:"project"})}function o(e){let{current:s,onUse:n}=e,t=m(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultModel.trim();return(0,a.jsx)(u,{label:i?l("def.modelDefaultIs",{name:i}):l("def.modelNoneShort"),offer:i&&n&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:s,onUse:n}=e,t=m(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultReviewModel.trim();return(0,a.jsx)(u,{label:i?l("def.reviewDefaultIs",{name:i}):l("def.reviewNoneShort"),offer:i&&n&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>n(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"review"})}function m(){let[e,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(n=>{e||s(n)}).catch(()=>void 0),()=>{e=!0}},[]),e}function u(e){let{label:s,offer:n,more:t=[],link:i,anchor:r}=e;return(0,a.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[s," ",n&&(0,a.jsxs)(a.Fragment,{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:n.onUse,children:n.text})," "]}),t.map(e=>(0,a.jsxs)("span",{children:["\xb7"," ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,a.jsx)(l(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,36,347,131,358],()=>e(e.s=1772)),_N_E=e.O()}]);