@midhunxavier/code-flow 0.0.0-stage → 0.1.0-preview.3
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.
- package/LICENSE +21 -0
- package/README.md +141 -2
- package/bin/codeflow.mjs +8 -0
- package/bin/launcher.mjs +127 -0
- package/dist/remote-host.json +1 -0
- package/licenses/inter.txt +92 -0
- package/licenses/preact.txt +21 -0
- package/licenses/signals-core.txt +21 -0
- package/licenses/signals.txt +21 -0
- package/licenses/typescript-notices.txt +193 -0
- package/licenses/typescript.txt +55 -0
- package/licenses/uqr.txt +22 -0
- package/licenses/xterm-fit.txt +19 -0
- package/licenses/xterm.txt +21 -0
- package/package.json +34 -4
- package/public/assets/changes-62ZIEQSN.js +1 -0
- package/public/assets/chunk-2PZVOKID.js +1 -0
- package/public/assets/chunk-4D5IENEB.js +1 -0
- package/public/assets/chunk-5SARP5MU.js +1 -0
- package/public/assets/chunk-63YLZ3PR.js +1 -0
- package/public/assets/chunk-7FUHKF2M.js +1 -0
- package/public/assets/chunk-APQEVJ2K.js +1 -0
- package/public/assets/chunk-CGOZQMEZ.js +2 -0
- package/public/assets/chunk-J4VYS3KV.js +2 -0
- package/public/assets/chunk-L7TUCIYF.js +1 -0
- package/public/assets/chunk-SIHDWM2Y.js +154 -0
- package/public/assets/chunk-TEJVYIKC.js +1 -0
- package/public/assets/code-browser-VB2HGZSG.js +4 -0
- package/public/assets/filtered-tasks-ES5CP4KV.js +1 -0
- package/public/assets/interactive-browser-7F5ZXRUV.js +7 -0
- package/public/assets/join-project-6RTFHNCA.js +1 -0
- package/public/assets/main-65EW73SB.js +1 -0
- package/public/assets/project-invitations-view-GMPWGWYM.js +1 -0
- package/public/assets/settings-UB5Q4AQM.js +9 -0
- package/public/assets/styles-18792BB4.css +32 -0
- package/public/assets/team-server-wizard-2GLDWS6D.js +8 -0
- package/public/assets/terminal-IWAIM4DE.js +62 -0
- package/public/assets.json +1 -0
- package/public/bundle-meta.json +1 -0
- package/public/docs/.nojekyll +0 -0
- package/public/docs/accessibility.html +19 -0
- package/public/docs/acp-agents.html +117 -0
- package/public/docs/agent-containers.html +79 -0
- package/public/docs/api.html +1130 -0
- package/public/docs/app.js +342 -0
- package/public/docs/application-improvements.html +275 -0
- package/public/docs/architecture-explorer.html +19 -0
- package/public/docs/architecture.html +149 -0
- package/public/docs/auto-team.html +148 -0
- package/public/docs/automations.html +109 -0
- package/public/docs/checkpoint-review.html +37 -0
- package/public/docs/code-hosts.html +35 -0
- package/public/docs/code-intelligence.html +35 -0
- package/public/docs/configuration.html +346 -0
- package/public/docs/context-inspection.html +23 -0
- package/public/docs/coordinated-changes.html +28 -0
- package/public/docs/deferred-runs.html +25 -0
- package/public/docs/dependency-discovery.html +19 -0
- package/public/docs/documentation.html +84 -0
- package/public/docs/dynamic-teams-evaluation.html +174 -0
- package/public/docs/dynamic-teams-implementation-plan.html +882 -0
- package/public/docs/dynamic-teams-implementation-review-1.html +141 -0
- package/public/docs/dynamic-teams-plan-review-0.html +204 -0
- package/public/docs/extensions.html +42 -0
- package/public/docs/external-sources.html +96 -0
- package/public/docs/filesystem-policy.html +26 -0
- package/public/docs/filtered-tasks.html +44 -0
- package/public/docs/font-license.txt +92 -0
- package/public/docs/getting-started.html +143 -0
- package/public/docs/github-review-threads.html +26 -0
- package/public/docs/github.html +157 -0
- package/public/docs/help.html +69 -0
- package/public/docs/index.html +88 -0
- package/public/docs/installation.html +80 -0
- package/public/docs/launch-profiles.html +48 -0
- package/public/docs/maintenance.html +60 -0
- package/public/docs/memory-claims.html +31 -0
- package/public/docs/memory-storage.html +58 -0
- package/public/docs/notifications.html +39 -0
- package/public/docs/patterns.html +195 -0
- package/public/docs/performance-results.html +210 -0
- package/public/docs/performance.html +166 -0
- package/public/docs/project-conventions.html +22 -0
- package/public/docs/project-first-navigation-plan.html +587 -0
- package/public/docs/project-teams-implementation-plan.html +772 -0
- package/public/docs/project-teams.html +129 -0
- package/public/docs/provider-compatibility.html +20 -0
- package/public/docs/releasing.html +65 -0
- package/public/docs/remote-workers.html +64 -0
- package/public/docs/review-inbox.html +26 -0
- package/public/docs/run-storage.html +23 -0
- package/public/docs/runs.html +141 -0
- package/public/docs/search.json +1 -0
- package/public/docs/security.html +133 -0
- package/public/docs/shared-projects.html +31 -0
- package/public/docs/ssh-projects.html +60 -0
- package/public/docs/style.css +768 -0
- package/public/docs/task-reruns.html +30 -0
- package/public/docs/team-collaboration.html +412 -0
- package/public/docs/verification.html +22 -0
- package/public/docs/vscode.html +53 -0
- package/public/docs/worker-permission-verification.html +131 -0
- package/public/index.html +17 -0
- package/scripts/check-node.mjs +7 -0
- package/scripts/codeflow.mjs +55 -0
- package/scripts/computer-use.swift +64 -0
- package/scripts/pty.py +273 -0
- package/src/acp-connections.js +110 -0
- package/src/adapters/acp-presets.js +37 -0
- package/src/adapters/acp-types.js +0 -0
- package/src/adapters/acp.js +328 -0
- package/src/adapters/agent-tools.js +28 -0
- package/src/adapters/agy-auth.js +67 -0
- package/src/adapters/agy-isolation.js +242 -0
- package/src/adapters/agy-tools.js +45 -0
- package/src/adapters/agy.js +326 -0
- package/src/adapters/claude-stream.js +58 -0
- package/src/adapters/claude.js +282 -0
- package/src/adapters/codex-app-server.js +555 -0
- package/src/adapters/codex.js +311 -0
- package/src/adapters/errors.js +57 -0
- package/src/adapters/index.js +91 -0
- package/src/adapters/managed-permissions.js +37 -0
- package/src/adapters/model-discovery.js +100 -0
- package/src/adapters/process.js +433 -0
- package/src/adapters/team-tools.js +103 -0
- package/src/adapters/types.js +0 -0
- package/src/agent-browser.js +688 -0
- package/src/agent-computer.js +88 -0
- package/src/agent-container.js +155 -0
- package/src/agent-team-definitions.js +131 -0
- package/src/agent-tool-client.mjs +79 -0
- package/src/agent-tools.js +296 -0
- package/src/approvals.js +134 -0
- package/src/architecture.js +456 -0
- package/src/assets.js +44 -0
- package/src/automation.js +901 -0
- package/src/browser-files.js +293 -0
- package/src/browser-ownership.js +150 -0
- package/src/certificate-renewal.js +75 -0
- package/src/chat-family.js +25 -0
- package/src/chat-handoff.js +87 -0
- package/src/checkpoint-review.js +72 -0
- package/src/checks.js +303 -0
- package/src/code-host-git.js +102 -0
- package/src/code-hosts-api.js +99 -0
- package/src/code-hosts.js +482 -0
- package/src/code-intelligence-worker.mjs +452 -0
- package/src/code-intelligence.js +141 -0
- package/src/collab/api.js +365 -0
- package/src/collab/checkpoints.js +198 -0
- package/src/collab/connections.js +139 -0
- package/src/collab/host-execution.js +347 -0
- package/src/collab/hub-client.js +210 -0
- package/src/collab/link-api.js +229 -0
- package/src/collab/link.js +595 -0
- package/src/collab/model.js +496 -0
- package/src/collab/runner.js +1014 -0
- package/src/collab/store.js +1452 -0
- package/src/collab/terminals.js +361 -0
- package/src/collaboration-reviews.js +116 -0
- package/src/config.js +48 -0
- package/src/context-budget.js +14 -0
- package/src/context-inspection.js +204 -0
- package/src/context.js +154 -0
- package/src/conventions.js +283 -0
- package/src/coordinated-api.js +247 -0
- package/src/deferred-launch.js +82 -0
- package/src/deferred-runs.js +515 -0
- package/src/dependency-health.js +35 -0
- package/src/diff.js +43 -0
- package/src/docs-help.js +316 -0
- package/src/doctor.js +232 -0
- package/src/documentation-changes.js +20 -0
- package/src/engine.js +5258 -0
- package/src/env.js +44 -0
- package/src/execution-budget.js +8 -0
- package/src/experience.js +50 -0
- package/src/extensions.js +144 -0
- package/src/filesystem-access.js +107 -0
- package/src/filesystem-policy.js +238 -0
- package/src/filtered-task-limits.js +93 -0
- package/src/filtered-tasks-api.js +53 -0
- package/src/filtered-tasks.js +576 -0
- package/src/frame-policy.js +66 -0
- package/src/fs.js +57 -0
- package/src/git.js +626 -0
- package/src/github-review-threads.js +181 -0
- package/src/github.js +538 -0
- package/src/http.js +69 -0
- package/src/improve-settings.js +38 -0
- package/src/improve.js +187 -0
- package/src/integrations.js +373 -0
- package/src/integrity.js +259 -0
- package/src/journey-api.js +77 -0
- package/src/journey-replay.js +65 -0
- package/src/journey-store.js +97 -0
- package/src/journeys.js +60 -0
- package/src/json.js +81 -0
- package/src/launch-profiles.js +292 -0
- package/src/learnings.js +80 -0
- package/src/local-app-url.js +19 -0
- package/src/log.js +39 -0
- package/src/maintenance.js +335 -0
- package/src/memory-analysis.js +182 -0
- package/src/memory-claims.js +153 -0
- package/src/memory-sqlite.js +236 -0
- package/src/memory.js +552 -0
- package/src/merge-validation.js +58 -0
- package/src/model-catalog.js +239 -0
- package/src/model-research.js +91 -0
- package/src/notes.js +176 -0
- package/src/notifications.js +413 -0
- package/src/patterns/auto-team-model.js +230 -0
- package/src/patterns/auto-team.js +816 -0
- package/src/patterns/council.js +199 -0
- package/src/patterns/debate.js +188 -0
- package/src/patterns/findings.js +141 -0
- package/src/patterns/index.js +21 -0
- package/src/patterns/loop.js +158 -0
- package/src/patterns/pipeline.js +125 -0
- package/src/patterns/prompts.js +181 -0
- package/src/patterns/race.js +147 -0
- package/src/patterns/schemas.js +40 -0
- package/src/patterns/solo.js +46 -0
- package/src/patterns/supervisor.js +235 -0
- package/src/patterns/task-draft.js +29 -0
- package/src/patterns/task-review.js +45 -0
- package/src/patterns/tdd.js +231 -0
- package/src/patterns/team-strategies.js +67 -0
- package/src/performance.js +43 -0
- package/src/persistence-status.js +35 -0
- package/src/phone-sessions.js +96 -0
- package/src/preview-overlay.js +392 -0
- package/src/preview.js +230 -0
- package/src/privacy.js +23 -0
- package/src/project-report.js +22 -0
- package/src/project-team-budget.js +22 -0
- package/src/project-team-model.js +225 -0
- package/src/project-team-policy.js +42 -0
- package/src/project-team-store.js +234 -0
- package/src/project-team-usage.js +24 -0
- package/src/project-teams-api.js +43 -0
- package/src/project-teams.js +644 -0
- package/src/projects.js +290 -0
- package/src/provider-eligibility.js +9 -0
- package/src/readiness.js +98 -0
- package/src/remote-tls.js +66 -0
- package/src/remote-workers/bundles.js +198 -0
- package/src/remote-workers/client.js +332 -0
- package/src/remote-workers/durability.js +37 -0
- package/src/remote-workers/protocol.js +68 -0
- package/src/remote-workers/stdio.js +138 -0
- package/src/remote-workers/worker.js +304 -0
- package/src/remote.js +204 -0
- package/src/repo-config.js +201 -0
- package/src/repo-coordination.js +725 -0
- package/src/repo-tree.js +106 -0
- package/src/repository-identity.js +13 -0
- package/src/retention-policy.js +466 -0
- package/src/review-inbox.js +38 -0
- package/src/routing.js +49 -0
- package/src/run-analysis.js +111 -0
- package/src/run-cold-store.js +231 -0
- package/src/run-environment.js +15 -0
- package/src/run-history.js +91 -0
- package/src/run-log.js +160 -0
- package/src/run-permissions.js +111 -0
- package/src/run-projection.js +77 -0
- package/src/run-recovery.js +53 -0
- package/src/run-status.js +56 -0
- package/src/serve.js +138 -0
- package/src/server.js +2871 -0
- package/src/shared-access.js +103 -0
- package/src/shared-accounts.js +381 -0
- package/src/shared-api.js +239 -0
- package/src/shell.js +346 -0
- package/src/ship.js +344 -0
- package/src/slots.js +74 -0
- package/src/snapshot.js +388 -0
- package/src/source-context.js +17 -0
- package/src/sse-writer.js +70 -0
- package/src/ssh-projects/bootstrap.mjs +95 -0
- package/src/ssh-projects/config.js +45 -0
- package/src/ssh-projects/gateway.js +143 -0
- package/src/ssh-projects/manager.js +320 -0
- package/src/ssh-projects/team-autostart.mjs +93 -0
- package/src/ssh-projects/team-remove.mjs +69 -0
- package/src/ssh-projects/team-status.mjs +39 -0
- package/src/ssh-projects/transport.js +133 -0
- package/src/stats.js +139 -0
- package/src/store.js +544 -0
- package/src/stream.js +91 -0
- package/src/sweeps.js +241 -0
- package/src/tailscale.js +101 -0
- package/src/task-draft.js +23 -0
- package/src/task-team.js +164 -0
- package/src/team-evaluation.js +243 -0
- package/src/team-mailbox.js +160 -0
- package/src/team-memory.js +84 -0
- package/src/team-rerun-graph.js +15 -0
- package/src/team-reruns.js +130 -0
- package/src/team-scheduler.js +121 -0
- package/src/team-steering.js +21 -0
- package/src/team-template-store.js +98 -0
- package/src/team-templates.js +117 -0
- package/src/team-tool-client.mjs +79 -0
- package/src/team-tools.js +235 -0
- package/src/teams.js +0 -0
- package/src/templates.js +62 -0
- package/src/transcript.js +134 -0
- package/src/verification-integrity.js +27 -0
- package/src/verification.js +183 -0
- package/src/watch.js +195 -0
- package/src/work-queue.js +47 -0
- package/src/workflow-control.js +83 -0
- package/src/workspace-api.js +207 -0
- package/src/workspace-changes.js +61 -0
- package/src/workspace.js +146 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import{a as or,b as El}from"./chunk-APQEVJ2K.js";import{a as Ii,d as Ai,e as K,g as Ya,i as pl,k as ml,l as Qa,m as Ve,n as pe,o as kt}from"./chunk-2PZVOKID.js";import{a as Bt,b as go,c as os,d as jl}from"./chunk-5SARP5MU.js";import{$ as Mt,$a as bt,$b as il,A as gt,Aa as ss,Ab as At,B as Qr,Ba as ks,Bb as Fs,C as Vi,Ca as ca,Cb as _a,D as Ji,Da as _t,Db as Va,E as Re,Ea as ws,Eb as Xi,Fa as da,Fb as Vt,G as ge,Ga as rn,Gb as as,H as ps,Ha as Ke,Hb as pn,I as ve,Ia as Ua,Ib as Zi,J as oa,Ja as ua,Jb as On,K as Ki,Ka as Ba,Kb as ao,L as Y,La as ze,Lb as el,M as zi,Ma as Fa,Mb as tl,N as Pt,Nb as sl,O as La,Oa as Us,Ob as ro,P as En,Pa as pa,Pb as oo,Q as ct,Qa as Yi,Qb as io,R as Ot,Ra as to,Rb as lo,S as en,Sa as Ha,Sb as qn,T as Xr,Ta as Dn,Tb as nl,U as jn,Ua as Qi,Ub as al,V as Wt,Va as Pe,Vb as ha,W as Zr,Wb as rl,X as $t,Xa as Me,Xb as co,Y as ia,Ya as Cs,Yb as Un,Z as Na,Za as ms,Zb as ol,_ as eo,_a as Ln,_b as Ja,a as nt,aa as Ms,ab as Ge,ac as Hs,b as zr,ba as Ds,bb as on,bc as ll,c as Li,cc as cl,d as at,da as Pn,db as ln,dc as dl,e as Gr,ea as Oa,eb as so,ec as Bn,f as ft,fa as qa,fb as Be,g as Rn,ga as tn,gb as Fe,gc as ul,h as Ni,ha as sn,hb as cn,hc as Ka,i as $n,ia as nn,ib as Dt,ic as Ss,j as Oi,ja as Ls,jb as ma,jc as Ye,k as Ps,ka as ys,kb as Gt,kc as yt,l as qi,la as an,lb as $e,lc as Ws,m as Ui,ma as ee,mb as ut,mc as uo,n as ts,nb as dn,nc as za,o as Bi,oa as Gi,ob as rt,oc as po,p as In,pa as Ns,pb as It,pc as Qe,q as jt,qa as Os,qb as ns,qc as Ga,r as Nt,ra as qt,rb as Ts,s as Zs,sa as he,sb as Bs,sc as hl,t as Yr,ta as qs,tb as hs,tc as Ae,u as Fi,ua as _e,ub as no,uc as mo,v as Hi,va as Mn,vb as Wa,vc as Fn,w as Wi,wa as vt,wb as un,x as us,xa as dt,xb as Nn,y as _i,ya as Ut,yb as Tt,z as zt,za as la,zb as St}from"./chunk-J4VYS3KV.js";import{A as Vs,B as Cl,C as er,D as Tl,E as Sl,F as Ft,G as va,H as pt,I as tr,J as Js,K as xl,L as Rl,M as $l,N as Il,O as Al,P as sr,Q as nr,R as ar,S as rr,a as Xa,b as Ee,d as je,e as Jt,f as gl,g as rs,h as fs,i as fo,j as Hn,k as Za,l as gs,m as Wn,n as Lt,o as vs,p as _n,q as xt,r as vl,s as _s,t as mn,u as ga,v as bl,w as yl,x as kl,y as wl,z as Vn}from"./chunk-CGOZQMEZ.js";import{a as ho,b as fl,c as fa,d as Ne}from"./chunk-4D5IENEB.js";import{c as An}from"./chunk-TEJVYIKC.js";import{$ as Xs,A as Da,B as Pi,C as Tn,E as Qs,G as ds,H as V,I as Mi,J as O,L as ae,M as Es,N as G,O as Sn,Q as xn,R as De,S as be,T as Zt,U as es,V as Le,W as Et,X as ht,Y as js,Z as Se,_ as Je,a as lt,aa as J,ba as Kt,ca as Di,d as M,da as e,e as xi,h as m,i as N,j as We,k as Z,l as Kr,m as ja,n as Ri,p as qe,r as $i,s as Pa,u as Ei,v as ji,w as Is,x as st,y as As,z as Ma}from"./chunk-63YLZ3PR.js";var ir=qe(ae.get("notify")!=="0"),vo=qe("Notification"in window?Notification.permission:"unsupported"),Pl=()=>ir.value&&vo.value==="granted";function Ah(){window.addEventListener("focus",()=>{vo.value="Notification"in window?Notification.permission:"unsupported"})}async function Su(t){if(!("Notification"in window))return J("This browser doesn't support notifications");try{let s=t&&Notification.permission!=="granted"?await Notification.requestPermission():Notification.permission;vo.value=s,ir.value=t&&s==="granted",ae.set("notify",ir.value?"1":"0"),J(ir.value?"You'll be notified when a run needs you":t?"Notifications are blocked in the browser settings":"Notifications off")}catch{J("Couldn't enable notifications. Check your browser's site permissions.")}}var bo=qe(ae.get("peopleEnabled")==="1");function Eh(t){bo.value=t,ae.set("peopleEnabled",t?"1":"0")}var Xe=qe({kind:"local"}),Jn=(t,s={})=>ds(t,{method:"POST",body:JSON.stringify(s)});async function qh(){Xe.value=await V("/api/ssh-context");let t=Xe.value;t.kind==="ssh"&&(!t.connected||t.error)&&(await Jn(`/api/ssh-hosts/${t.id}/connect`),Xe.value=await V("/api/ssh-context"))}var lr=qe(null),xu=t=>`#new-project=${encodeURIComponent(t.slice(0,60))}`;function Uh(){if(!location.hash.startsWith("#new-project="))return!1;let t="";try{t=decodeURIComponent(location.hash.slice(13)).slice(0,60)}catch{}return history.replaceState(null,"",`${location.pathname}${location.search}#/`),lr.value={name:t},ws.value="new",_t.value=!0,!0}var Yt=()=>Xe.value.kind==="ssh"?Xe.value.name:Xe.value.kind==="host"?"Remote server":"This computer";function cr({projectName:t}){return e(Ve,{label:t===void 0?"SSH connections":"Project computer",icon:"chevron",class:"host-switcher",trigger:e(M,{children:[e("span",{children:Yt()}),e(K,{name:"chevron"})]}),children:s=>e(Ru,{close:s,projectName:t})})}function Ru({close:t,projectName:s}){let n=Xe.value,r=Z(!0);N(()=>()=>{r.current=!1},[]);let[a,c]=m([]),[i,d]=m(n.kind!=="host"),[l,p]=m(""),[o,u]=m(""),f=async()=>{d(!0),u("");try{c((await ds("/api/ssh-hosts")).hosts)}catch(g){u(g.message)}finally{d(!1)}};N(()=>{n.kind!=="host"&&f()},[]);let h=async(g,y)=>{if(g===(As??"local"))return t();p(`Opening ${y}\u2026`),u("");try{g!=="local"&&await Jn(`/api/ssh-hosts/${g}/connect`),r.current&&location.assign(Ma(g,s===void 0?"#/":xu(s)))}catch(C){u(C.message),p("")}};return e(M,{children:[e(kt,{children:s===void 0?"Computer":"Project location"}),n.kind!=="host"?e(M,{children:[e(pe,{on:!As,disabled:!!l,onClick:()=>void h("local","This computer"),sub:As?void 0:"Current",children:"This computer"}),i?e("p",{class:"host-feedback",role:"status",children:"Loading connections\u2026"}):a.map(g=>e(pe,{on:g.id===As,disabled:!!l,onClick:()=>void h(g.id,g.name),sub:g.id===As?"Current":g.state,children:g.name},g.id)),!i&&!a.length&&!o?e("p",{class:"host-feedback help",children:"Save a remote connection in Settings to use it here."}):null,e(pe,{disabled:!!l,onClick:()=>{t(),_t.value=!1,ws.value=null,Y.value={view:"settings",section:"connections",group:"workspace"}},children:"Manage connections\u2026"})]}):e("p",{class:"host-feedback help",children:"Open the app on your computer to manage connections."}),l?e("p",{class:"host-feedback",role:"status",children:l}):null,o?e(M,{children:[e("p",{class:"host-feedback msg err",role:"alert",children:o}),e(pe,{onClick:()=>void f(),children:"Refresh connections"})]}):null]})}function Bh(){let t=Xe.value,[s,n]=m([]),[r,a]=m([]),[c,i]=m(""),[d,l]=m(""),[p,o]=m(""),[u,f]=m(""),[h,g]=m(t.kind!=="host"),[y,C]=m(""),[T,v]=m(""),k=async()=>{let w=await ds("/api/ssh-hosts");n(w.hosts),a(w.aliases)};N(()=>{t.kind!=="host"&&k().catch(w=>v(w.message)).finally(()=>g(!1))},[]);let b=async(w,j)=>{C(w),v("");try{await j()}catch(A){v(A.message)}finally{C("")}},S=async w=>{let j=await Jn(`/api/ssh-hosts/${w}/connect`,{});location.assign(j.url)},x=w=>b(w?`Connecting to ${d||c}\u2026`:"Saving connection\u2026",async()=>{let j=await Jn("/api/ssh-hosts",{sshHost:c.trim(),name:d.trim()||c.trim(),...p?{port:Number(p)}:{},...u.trim()?{identityFile:u.trim()}:{}});n(A=>[...A,{...j,state:"disconnected"}]),i(""),l(""),o(""),f(""),w?await S(j.id):J("SSH connection saved")});return e("div",{class:"ssh-connections","aria-busy":!!y||h,children:[t.kind==="host"?e("p",{children:"Manage SSH connections in the app on your computer."}):e(M,{children:[e("div",{class:"ssh-local",children:[e("strong",{children:"This computer"}),e("span",{class:"badge ok",children:"Local workspace"})]}),e("div",{class:"ssh-saved-heading",children:[e("h3",{children:"Saved connections"}),e("button",{class:"btn small",disabled:!!y||h,onClick:()=>void b("Refreshing\u2026",k),children:"Refresh connections"})]}),h?e("p",{role:"status",children:"Loading connections\u2026"}):s.length?null:e("p",{class:"help",children:"No remote machines yet. Connect your first VM below."}),s.map(w=>e("article",{class:"section",children:[e("p",{children:[e("strong",{children:w.name})," ",e("span",{class:"help",children:[w.sshHost,w.port?`:${w.port}`:""," \xB7 ",w.state]})]}),w.identityFile?e("p",{class:"help",children:["Key: ",e("code",{children:w.identityFile})]}):null,w.error?e("p",{class:"msg err",children:w.error}):null,e("div",{class:"ssh-actions",children:[e("button",{class:"btn primary",disabled:!!y,onClick:()=>void b(`Connecting to ${w.name}\u2026`,()=>S(w.id)),children:["Open ",w.name]}),w.state==="connected"?e(M,{children:[e("button",{class:"btn",disabled:!!y,onClick:()=>void b("Disconnecting\u2026",async()=>{await Jn(`/api/ssh-hosts/${w.id}/disconnect`,{}),await k()}),children:"Disconnect"}),e("button",{class:"btn",disabled:!!y,title:"Stops an idle backend; running work and open terminals must finish first",onClick:()=>void b("Stopping backend\u2026",async()=>{await Jn(`/api/ssh-hosts/${w.id}/stop`,{}),await k()}),children:"Stop backend"})]}):null,e("button",{class:"btn",disabled:!!y,onClick:()=>void b("Removing connection\u2026",async()=>{await ds(`/api/ssh-hosts/${w.id}`,{method:"DELETE"}),await k()}),children:"Remove"})]})]},w.id)),e("form",{class:"ssh-new",onSubmit:w=>{w.preventDefault();let j=w.submitter;x(j?.value!=="save")},children:[e("h3",{children:"Add a remote machine"}),e("p",{class:"help",children:"Your repository, agents, terminal, builds and tests run on the VM."}),e("label",{children:["SSH host",e("input",{class:"field",list:"ssh-aliases",value:c,onInput:w=>i(w.currentTarget.value),placeholder:"devbox or user@server",maxLength:200,required:!0,disabled:!!y})]}),e("datalist",{id:"ssh-aliases",children:r.map(w=>e("option",{value:w},w))}),e("label",{children:["Display name",e("input",{class:"field",value:d,onInput:w=>l(w.currentTarget.value),placeholder:"Development server",maxLength:80,disabled:!!y})]}),e("div",{class:"settings-grid",children:[e("label",{children:["SSH port",e("input",{class:"field",type:"number",min:1,max:65535,step:1,value:p,onInput:w=>o(w.currentTarget.value),placeholder:"From SSH config (usually 22)",disabled:!!y})]}),e("label",{children:["Identity file",e("input",{class:"field",value:u,onInput:w=>f(w.currentTarget.value),placeholder:"~/.ssh/id_ed25519 (optional)",maxLength:4096,disabled:!!y})]})]}),e("p",{class:"help",children:"Leave port and key blank to use your SSH config and agent. Jump hosts are read from ~/.ssh/config. Only the key path is saved; key contents stay on this computer."}),e("p",{class:"help",children:"Use a Linux or macOS server with Node.js 22.13+ and Git. Install and sign in to your agent CLIs there. Python 3 enables interactive terminals."}),e("p",{class:"help",children:"Uses your SSH config and keys. First verify the host with SSH in a terminal; unlock protected keys in your SSH agent. Connecting installs the backend under ~/.codeflow/ssh-host on the server."}),e("div",{class:"ssh-actions",children:[e("button",{class:"btn",type:"submit",value:"save",disabled:!!y||h||!c.trim(),children:"Save connection"}),e("button",{class:"btn primary",type:"submit",value:"connect",disabled:!!y||h||!c.trim(),children:"Connect and open"})]})]})]}),y?e("p",{role:"status",children:[y,y.startsWith("Connecting")?" Initial setup can take a minute.":""]}):null,T?e("p",{class:"msg err",role:"alert",children:T}):null,e("p",{class:"help",children:"Disconnecting or removing a connection leaves remote work running."})]})}var Ml=t=>[...t].sort((s,n)=>s.name.localeCompare(n.name,void 0,{sensitivity:"base"})),Dl=t=>t.repos.length?t.repos.map(be).join(", "):"no repositories yet",dr=(t,s)=>`${t} ${s}${t===1?"":"s"}`,Ll=({text:t})=>e("span",{class:"pr-path",children:`\u200E${t}\u200E`});function Ks({composer:t=!1}){let s=t?he.value.find(r=>r.id===vt.value):Mn.value,n=t?s?.name??"Choose project":s?s.name:_e.value===qt?"Unassigned":"All projects";return e("button",{type:"button",class:"repo-btn project-btn",disabled:dt.value,title:t?"Choose the project's saved draft":"Filter projects",onClick:()=>{ss.value=t?"composer":"filter",_t.value=!0},children:[e(K,{name:"project"}),e("span",{class:"name",children:n}),e(K,{name:"chevron",class:"caret"})]})}function Nl(){let t=()=>{_t.value=!1,ws.value=null},s=ye(!0,t),[n]=m(()=>ws.value==="new"?"new":he.value.find(u=>u.id===ws.value)??null),[r,a]=m(n),c=()=>n?t():a(null),i=[...ve.value.values()],d=u=>{let f=i.filter(h=>Ua(h,u));return{runs:f.filter(h=>!h.archived).length,archived:f.filter(h=>h.archived).length,waiting:f.filter(Rn).length}},l=async u=>{ss.value==="composer"?await Qe(u):ua(u),t()},p=(u,f,h,g)=>{let y=d(u),C=(ss.value==="composer"?vt.value:_e.value)===u;return e("div",{class:`project-row ${C?"on":""}`,role:"listitem",children:[e("button",{type:"button",class:"pr-main","aria-current":C?"true":void 0,onClick:()=>l(u),children:[e("span",{class:"pr-name",children:[f,y.waiting?e("span",{class:"count",title:`${dr(y.waiting,"run")} need you`,children:y.waiting}):null]}),e("span",{class:"pr-detail",children:[h," \xB7 ",dr(y.runs,"run"),y.archived?` (+${y.archived} archived)`:""]})]}),g?e("button",{type:"button",class:"btn ghost small","aria-label":`Edit ${g.name}`,onClick:()=>a(g),children:"Edit"}):null]},u||"all")},o=d(qt);return e("dialog",{class:"picker small-dialog projects-dialog",ref:s,"aria-labelledby":"projects-title",children:e("div",{class:"picker-inner",children:r?e($u,{project:r==="new"?void 0:r,onDone:c,onCreated:t},r==="new"?"new":r.id):e(M,{children:[e("div",{class:"picker-head",children:[e("h3",{id:"projects-title",children:"Projects"}),e("div",{class:"help",children:ss.value==="composer"?"Open a project's saved draft. Each project keeps its own task and run options.":"Choose which projects these lists show. Your saved run draft keeps its own destination."})]}),e("div",{class:"picker-list",role:"list",children:[p(Os,ss.value==="composer"?"Unassigned draft":"All projects",ss.value==="composer"?"Recover a draft that needs a destination":"show all projects on this computer"),Ml(he.value).map(u=>p(u.id,u.name,Dl(u),u)),ss.value!=="composer"&&(o.runs||o.archived)?p(qt,"Unassigned","runs whose project was deleted"):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:he.value.length?null:"Open a repository to create your first project."}),e("button",{class:"btn",type:"button",onClick:()=>a("new"),children:[e(K,{name:"plus"})," New project"]}),e("button",{class:"btn primary",type:"button",onClick:t,children:"Done"})]})]})})})}function $u({project:t,onDone:s,onCreated:n}){let[r]=m(()=>{let v=lr.value;return lr.value=null,v}),[a,c]=m(t?.name??r?.name??""),i=Z(null);N(()=>i.current?.focus(),[]);let[d,l]=m(t?.repos??[]),[p,o]=m(""),[u,f]=m(!1),h=t?[...ve.value.values()].filter(v=>Ke(v)?.id===t.id):[],g=t?t.repos.filter(v=>!d.includes(v)&&h.some(k=>k.repo===v)):[],y=async()=>{if(!(u||!a.trim())){f(!0),o("");try{let v=await O(t?`/api/projects/${t.id}`:"/api/projects",{name:a,repos:d});if(await rn(),t)return s();ss.value==="composer"?await Qe(v.id):Y.value={view:"project",id:v.id},n(),J(`Created the project ${v.name}`)}catch(v){o(v.message)}finally{f(!1)}}},C=async()=>{if(t&&await Ae(`Delete the project \u201C${t.name}\u201D? ${h.length?`Its ${dr(h.length,"run")} stay, in no project.`:"It has no runs."}`,{title:"Delete this project?",confirmLabel:"Delete project",danger:!0}))try{await V(`/api/projects/${t.id}`,{method:"DELETE"}),await rn(),J(`Deleted the project ${t.name}`),s()}catch(v){o(v.message)}},T=()=>{Ns.value={title:`Add a repository to ${a.trim()||"the project"}`,choose:v=>V(`/api/branches?repo=${encodeURIComponent(v)}`).then(k=>l(b=>b.includes(k.repo)?b:[...b,k.repo]),()=>o(`${be(v)} isn't a git repository`))},ct.value=!0};return e(M,{children:[e("div",{class:"picker-head",children:[e("h3",{id:"projects-title",children:t?`Edit ${t.name}`:"New project"}),e("div",{class:"help",children:t?`${dr(h.length,"run")} in this project.`:"Name it and add the repositories its runs work in."})]}),e("div",{class:"dialog-body",children:[t?null:e("div",{class:"project-computer",children:[e("span",{class:"lbl",children:"Computer"}),e(cr,{projectName:a}),e("p",{class:"help",children:"Choose where this project lives, then add repositories from that computer."})]}),e("div",{children:[e("label",{class:"lbl",for:"project-name",children:"Name"}),e("input",{id:"project-name",ref:i,class:"field",value:a,maxLength:60,placeholder:"e.g. Web app",onInput:v=>c(v.currentTarget.value),onKeyDown:v=>v.key==="Enter"&&(v.preventDefault(),void y())})]}),e("div",{children:[e("div",{class:"lbl",children:"Repositories"}),e("div",{class:"project-repos",children:[d.map(v=>e("div",{class:"dir",title:v,children:[e("span",{class:"di",children:e(K,{name:"folder"})}),e("span",{class:"dn",children:be(v)}),e(Ll,{text:v}),e("button",{type:"button",class:"btn ghost small","aria-label":`Remove ${be(v)}`,onClick:()=>l(d.filter(k=>k!==v)),children:"Remove"})]},v)),d.length?null:e("div",{class:"help",children:"Add a repository before starting a run. You can also keep an empty project for shared work."})]}),e("button",{type:"button",class:"btn ghost small add-repo",onClick:T,children:[e(K,{name:"plus"})," Add repository\u2026"]})]}),g.length?e("div",{class:"msg warn",children:["Runs already in this project from ",g.map(be).join(", ")," stay in it."]}):null,p?e("div",{class:"msg err",children:p}):null]}),e("div",{class:"picker-foot",children:[t?e("button",{type:"button",class:"btn danger",onClick:C,children:"Delete project"}):null,e("span",{class:"ps"}),e("button",{type:"button",class:"btn",onClick:s,children:"Cancel"}),e("button",{type:"button",class:"btn primary",disabled:u||!a.trim(),onClick:y,children:u?"Saving\u2026":t?"Save":"Create project"})]})]})}function Ol({run:t}){let[s,n]=m(!1),r=Ke(t);return e(M,{children:[e("button",{type:"button",class:"project-chip",title:"Move this run to another project",onClick:()=>n(!0),children:[e(K,{name:"project"})," ",r?r.name:"No project"]}),s?e(Iu,{run:t,onClose:()=>n(!1)}):null]})}function Iu({run:t,onClose:s}){let n=ye(!0,s),r=Ke(t)?.id,[a,c]=m(r??""),[i,d]=m(""),[l,p]=m(""),[o,u]=m(!1),f=he.value.find(y=>y.id===a),h=Z(null);N(()=>void(a==="new"&&h.current?.focus()),[a]);let g=async()=>{u(!0),p("");try{let y=a==="new"?(await O("/api/projects",{name:i,repos:[t.repo]})).id:a,C=await O(`/api/runs/${t.id}/project`,{project:y});await rn(),J(`Moved to ${C.name}`),s()}catch(y){p(y.message)}finally{u(!1)}};return e("dialog",{class:"picker small-dialog",ref:n,"aria-labelledby":"move-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"move-title",children:"Move to another project"}),e("div",{class:"help",children:"The run, its branches and its worktrees stay where they are; only the project it's listed under changes."})]}),e("div",{class:"picker-list",role:"radiogroup","aria-label":"Project",children:[Ml(he.value).map(y=>e("label",{class:"dir move-choice",children:[e("input",{type:"radio",name:"move-to",checked:a===y.id,onChange:()=>c(y.id)}),e("span",{class:"dn",children:[y.name,y.id===r?e("span",{class:"help",children:" \xB7 now"}):null]}),e(Ll,{text:Dl(y)})]},y.id)),e("label",{class:"dir move-choice",children:[e("input",{type:"radio",name:"move-to",checked:a==="new",onChange:()=>c("new")}),e("span",{class:"dn",children:"New project"}),a==="new"?e("input",{ref:h,class:"field","aria-label":"New project's name",placeholder:"Name",maxLength:60,value:i,onInput:y=>d(y.currentTarget.value)}):null]})]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:l?e("span",{class:"msg err",children:l}):f&&!f.repos.includes(t.repo)?`${be(t.repo)} joins ${f.name}.`:null}),e("button",{type:"button",class:"btn",onClick:s,children:"Cancel"}),e("button",{type:"button",class:"btn primary",disabled:o||!a||a===r||a==="new"&&!i.trim(),onClick:g,children:"Move"})]})]})})}function zs(t){Ns.value={title:"Open repository",choose:s=>{Ba(s,t??"")}},ct.value=!0}function ql(){let t=ks.value,[s,n]=m(be(t.repository).slice(0,60)),[r,a]=m(!1),[c,i]=m(""),d=()=>{r||(ks.value=null)},l=ye(!0,d),p=he.value.find(f=>f.id===t.project),o=he.value.filter(f=>f.repos.includes(t.repository)),u=async(f,h=!1)=>{if(!r){a(!0),i("");try{let g=f;if(h&&f&&await O(`/api/projects/${encodeURIComponent(f)}/repositories`,{repo:t.repository}),g||(g=(await O("/api/projects",{name:s.trim(),repos:[t.repository]})).id),await rn(),!await Qe(g,{repository:t.repository,carryUnassigned:!0}))throw new Error("The project draft could not be opened. Try again.");await Ga(t.repository),ks.value=null}catch(g){i(g.message)}finally{a(!1)}}};return e("dialog",{class:"picker small-dialog",ref:l,"aria-labelledby":"repository-project-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"repository-project-title",children:"Open repository in a project"}),e("p",{class:"help",children:e("code",{children:t.repository})})]}),e("div",{class:"dialog-body",children:[o.length?e("div",{class:"project-destinations",children:[e("p",{children:"Choose an existing project:"}),o.map(f=>e("button",{class:"btn",disabled:r,onClick:()=>void u(f.id),children:["Open ",f.name]}))]}):null,p&&!p.repos.includes(t.repository)?e("div",{class:"project-destinations",children:[e("button",{class:"btn",disabled:r,onClick:()=>void u(p.id,!0),children:["Add to ",p.name]}),e("p",{class:"help",children:"This repository becomes part of the project. Existing project access rules apply."})]}):null,e("label",{class:"lbl",for:"repository-project-name",children:"New project name"}),e("input",{id:"repository-project-name",class:"field",maxLength:60,value:s,disabled:r,onInput:f=>n(f.currentTarget.value)}),e("p",{class:"help",children:"The project keeps its own draft and run history. No agent starts until you select Start run."}),c?e("p",{class:"msg err",role:"alert",children:c}):null]}),e("div",{class:"picker-foot",children:[e("button",{class:"btn",disabled:r,onClick:d,children:"Cancel"}),e("button",{class:"btn primary",disabled:r||!s.trim(),onClick:()=>void u(),children:r?"Opening\u2026":"Create project"})]})]})})}function Ul({definitions:t,providers:s,canAssign:n,assign:r,changed:a}){let[c,i]=m();return e("details",{class:"agent-team-library",children:[e("summary",{children:["Reusable agent teams (",t.length,")"]}),e("p",{class:"help",children:"Save a team once and assign it to projects. Each project keeps its own mission, permissions, budget and history."}),e("button",{class:"btn small",onClick:()=>i("new"),children:"Create agent team"}),t.map(d=>e("article",{class:"pt-team",children:[e("h3",{children:[d.name," ",e("span",{class:"help",children:["version ",d.revision]})]}),e("p",{class:"help",children:["Coordinator: ",d.configuration.coordinator," \xB7 Workers and reviewer: ",d.configuration.pool.join(", ")]}),e("div",{class:"pt-actions",children:[e("button",{class:"btn small",disabled:!n,onClick:()=>r(d),children:"Assign to this project"}),e("button",{class:"btn small",onClick:()=>i(d),children:"Edit reusable team"})]})]},d.id)),c&&e(Au,{definition:c==="new"?void 0:c,providers:s,saved:()=>{i(void 0),a()},cancel:()=>i(void 0)},c==="new"?"new":`${c.id}:${c.revision}`)]})}function Au({definition:t,providers:s,saved:n,cancel:r}){let a=s.filter(v=>v.available&&!v.reason),[c,i]=m(t?.name??""),[d,l]=m(t?.configuration??{coordinator:a[0]?.id??"claude",pool:a.map(v=>v.id),agentSettings:{}}),[p,o]=m(!1),[u,f]=m(""),[h]=m(()=>crypto.randomUUID());N(()=>{On()},[]);let[g,y]=m(!!d.roleSettings),C=Re.value.filter(v=>d.pool.includes(v.id)||d.coordinator===v.id);return e("form",{class:"pt-form","aria-label":t?"Edit reusable agent team":"Create reusable agent team",onSubmit:async v=>{v.preventDefault(),o(!0),f("");try{await O(`/api/project-teams/definitions${t?`/${t.id}`:""}`,{operationId:h,...t?{revision:t.revision}:{},name:c,configuration:d}),n()}catch(k){f(k.message)}finally{o(!1)}},children:[e("label",{children:["Agent team name",e("input",{class:"field",required:!0,maxLength:80,value:c,onInput:v=>i(v.currentTarget.value)})]}),e("label",{children:["Team coordinator",e("select",{class:"field","aria-label":"Team coordinator",required:!0,value:d.coordinator,onChange:v=>l({...d,coordinator:v.currentTarget.value,roleSettings:{...d.roleSettings,coordinator:{}}}),children:s.map(v=>e("option",{value:v.id,disabled:!v.available||!!v.reason,children:[v.name,v.reason?` \u2014 ${v.reason}`:v.available?"":" \u2014 unavailable"]},v.id))})]}),e("fieldset",{children:[e("legend",{children:"Team workers and reviewer"}),s.map(v=>e("label",{children:[e("input",{type:"checkbox",checked:d.pool.includes(v.id),disabled:!v.available||!!v.reason,onChange:k=>{let b=k.currentTarget.checked?[...d.pool,v.id]:d.pool.filter(S=>S!==v.id);l({...d,pool:b,roleSettings:{...d.roleSettings,pool:Object.fromEntries(Object.entries(d.roleSettings?.pool??{}).filter(([S])=>b.includes(S)))}})}}),v.name]},v.id))]}),e("fieldset",{children:[e("legend",{children:"Default models and reasoning"}),C.map(v=>e(hn,{agent:v,used:!0,settings:d.agentSettings[v.id]??{},onChange:k=>l({...d,agentSettings:{...d.agentSettings,[v.id]:{...d.agentSettings[v.id],...k}}})},v.id))]}),e("label",{children:[e("input",{type:"checkbox",checked:g,onChange:v=>{y(v.currentTarget.checked),v.currentTarget.checked||l({...d,roleSettings:void 0})}}),"Use separate models for coordinator and workers"]}),g&&[["coordinator","Coordinator models"],["pool","Worker and reviewer models"]].map(([v,k])=>e("fieldset",{children:[e("legend",{children:k}),C.filter(b=>v==="coordinator"?b.id===d.coordinator:d.pool.includes(b.id)).map(b=>e(hn,{agent:b,used:!0,settings:d.roleSettings?.[v]?.[b.id]??{},onChange:S=>l({...d,roleSettings:{...d.roleSettings,[v]:{...d.roleSettings?.[v],[b.id]:{...d.roleSettings?.[v]?.[b.id],...S}}}})},b.id))]},v)),u&&e("p",{role:"alert",children:u}),e("div",{class:"pt-actions",children:[e("button",{class:"btn primary",disabled:p||!a.length||!d.pool.length,children:p?"Saving\u2026":t?"Save new team version":"Save reusable team"}),e("button",{type:"button",class:"btn",disabled:p,onClick:r,children:"Cancel team edit"})]})]})}function yo(t,s=Date.now()){return t.cycles.flatMap(r=>r.launches).reduce((r,a)=>{let c=a.usage;return(c?c.endedAt<=s-6048e5:a.state==="settled"&&a.at<=s-6048e5)||(r.calls+=c?.calls??(a.state==="settled"?a.usedCalls??a.calls:a.calls),r.minutes+=c?Math.ceil(c.durationMs/6e4):a.minutes,c||(r.reservedCalls+=a.calls,r.reservedMinutes+=a.minutes)),r},{calls:0,minutes:0,reservedCalls:0,reservedMinutes:0})}function Bl(t,s=Date.now()){let n=yo(t,s);return{calls:t.mission.budget.weeklyCalls-n.calls,minutes:t.mission.budget.weeklyMinutes-n.minutes}}var Kn=()=>crypto.randomUUID(),ba=t=>t.split(`
|
|
2
|
+
`).map(s=>s.trim()).filter(Boolean);function Fl({projectId:t,repos:s}){let[n,r]=m(),[a,c]=m(),[i,d]=m(!1),[l,p]=m(!1),[o,u]=m(),[f,h]=m(!1),[g,y]=m(""),C=async()=>{p(!0);try{r(await V(`/api/project-teams?project=${encodeURIComponent(t)}`)),c(void 0)}catch(v){c({message:v.message,status:v instanceof st?v.status:void 0})}finally{p(!1)}},T=async()=>{if(!(!n||f)){h(!0),y("");try{await O("/api/project-teams/settings",{enabled:!n.enabled,revision:n.revision}),d(!1),await C()}catch(v){y(v.message),await C()}finally{h(!1)}}};return N(()=>{C();let v=()=>{C()};window.addEventListener("focus",v);let k=An(`project-teams:${t}`,b=>{b.type==="snapshot"&&r(S=>S&&{...S,teams:b.teams,definitions:b.definitions,definitionFaults:b.definitionFaults,enabled:b.enabled,revision:b.revision,source:b.source,autoTeamEnabled:b.autoTeamEnabled})});return()=>{k(),window.removeEventListener("focus",v)}},[t]),a?e("section",{class:"pp-card pp-unavailable","aria-label":"Project missions",children:[e("div",{class:"pp-card-head",children:[e("h2",{children:"Project missions"}),e("span",{class:"badge",children:"Unavailable"}),e("button",{class:"btn small",disabled:l,onClick:()=>void C(),children:l?"Retrying\u2026":"Retry"})]}),e("div",{class:"pp-unavailable-body",role:"alert",children:[e("p",{children:a.status===404?"Project missions aren\u2019t available on this computer.":"Couldn\u2019t load project missions."}),e("p",{class:"help",children:a.status===404?"The connected server doesn\u2019t provide this feature. It may need an update.":a.message})]})]}):n?e("section",{class:"pp-card standing-teams","aria-label":"Project missions",children:[e(Lu,{teams:n.teams}),e("div",{class:"pp-card-head",children:[e("h2",{children:"Project missions"}),e("button",{class:"btn small",disabled:!n.enabled||!n.autoTeamEnabled||!s.length,onClick:()=>{u(void 0),d(!i)},children:"Create a mission"})]}),e("p",{class:"help",children:"Assign an agent team to this project. Give it tasks directly or enable recurring discovery to prepare improvements for your review."}),e("div",{class:"settings-actions",children:[e("button",{class:"btn small",disabled:f||n.source==="unavailable",onClick:()=>void T(),children:f?"Saving\u2026":n.enabled?"Disable project missions":"Enable project missions"}),e("span",{class:"help",children:[n.enabled?"Enabled on this host":"Off on this host"," \xB7 saved across restarts"]})]}),e("p",{class:"help",children:"This setting applies to all projects on this host. New missions need separate activation. Enabling it resumes schedules for missions already active; stop active cycles before disabling it."}),!n.autoTeamEnabled&&e("p",{class:"help",children:"Auto team execution is disabled by this host\u2019s configuration. Project missions can run once the host permits Auto team execution."}),g&&e("p",{role:"alert",children:g}),Object.entries(n.faults).map(([v,k])=>e("p",{role:"alert",children:["Mission storage needs repair (",v,"): ",k]},v)),Object.entries(n.definitionFaults??{}).map(([v,k])=>e("p",{role:"alert",children:["Reusable team storage needs repair (",v,"): ",k]},v)),e(Ul,{definitions:n.definitions??[],providers:n.providers,canAssign:n.enabled&&n.autoTeamEnabled&&!!s.length,assign:v=>{u(v),d(!0)},changed:C}),i&&n.enabled&&n.autoTeamEnabled&&(o?e(Eu,{definition:o,projectId:t,repos:s,assignments:n.teams,providers:n.providers,definitions:n.definitions??[],saved:()=>{d(!1),C()}},`${o.id}:${o.revision}`):e(ko,{projectId:t,repos:s,providers:n.providers,definitions:n.definitions??[],saved:()=>{d(!1),C()}})),n.teams.map(v=>e(ju,{team:v,enabled:n.enabled&&n.autoTeamEnabled,providers:n.providers,definitions:n.definitions??[],changed:C},v.id))]}):null}function Eu({definition:t,projectId:s,repos:n,assignments:r,providers:a,definitions:c,saved:i}){let[d,l]=m(n[0]??""),p=r.find(o=>o.repo===d&&o.status!=="archived");return e("section",{"aria-label":"Assign agent team to project",children:[e("label",{children:["Repository for team assignment",e("select",{class:"field","aria-label":"Repository for team assignment",value:d,onChange:o=>l(o.currentTarget.value),children:n.map(o=>e("option",{children:o},o))})]}),p&&e("p",{class:"help",children:["This updates the team configuration of ",p.name,". Its mission history and charged usage stay with this assignment."]}),e(ko,{projectId:s,repos:[d],providers:a,definitions:c,initialDefinition:t,team:p,saved:i},d)]})}function ko({projectId:t,repos:s,providers:n,definitions:r,initialDefinition:a,team:c,saved:i}){N(()=>{On()},[]);let d=n.filter(_=>_.available&&!_.reason),[l,p]=m(a??c?.definition),[o,u]=m(c?c.scheduleEnabled!==!1:!a),[f,h]=m(c?.name??"Product mission"),[g,y]=m(c?.repo??s[0]??""),[C,T]=m(c?.mission.mission??""),[v,k]=m(c?.mission.users??""),[b,S]=m(c?.mission.baseBranch??"main"),[x,w]=m(c?.mission.check??""),[j,A]=m(c?.mission.mode??"build-within-scope"),[P,D]=m(c?.mission.coordinator??d[0]?.id??""),[I,$]=m(c?.mission.pool??d.map(_=>_.id)),[E,L]=m(c?.mission.paths.join(`
|
|
3
|
+
`)??"*"),[H,Q]=m(c?.mission.priorities.join(`
|
|
4
|
+
`)??""),[le,de]=m(c?.mission.exclusions.join(`
|
|
5
|
+
`)??""),[ue,q]=m(!1),[te,me]=m(""),[W,re]=m({excludedPaths:c?.mission.excludedPaths??[".codeflow",".github/workflows"],maxFiles:c?.mission.maxFiles??8,maxLines:c?.mission.maxLines??400,rescanDays:c?.mission.rescanDays??28,budget:c?.mission.budget??{discoveryCalls:8,discoveryMinutes:15,buildCalls:16,buildMinutes:45,weeklyCalls:48,weeklyMinutes:120},schedule:c?.schedule??c?.mission.schedule??{at:"09:00",days:[1],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},categories:c?.mission.categories??["bug","usability","performance","tests","docs"],trust:c?.mission.trust??"standard",setup:c?.mission.setup??"",agentSettings:c?.mission.agentSettings??{}});return e("form",{class:"pt-form",onSubmit:async _=>{_.preventDefault(),q(!0),me("");try{let ie={...W,...c?.mission.verification&&x===c.mission.check?{verification:c.mission.verification}:{},...c?.mission.roleSettings?{roleSettings:c.mission.roleSettings}:{},mission:C,users:v,baseBranch:b,mode:j,check:x,coordinator:P,pool:I,paths:ba(E),priorities:ba(H),exclusions:ba(le)};await O(c?`/api/project-teams/${c.id}`:"/api/project-teams",{operationId:Kn(),...c?{revision:c.revision}:{projectId:t,repo:g},...l?{definition:{id:l.id,revision:l.revision}}:c?{definition:null}:{},scheduleEnabled:o,name:f,mission:ie}),i()}catch(ie){me(ie.message)}finally{q(!1)}},children:[e("label",{children:["Mission name",e("input",{class:"field",required:!0,value:f,onInput:_=>h(_.currentTarget.value)})]}),!c&&e("label",{children:["Repository",e("select",{class:"field",value:g,onChange:_=>y(_.currentTarget.value),children:s.map(_=>e("option",{children:_},_))})]}),e("label",{children:["Agent team",e("select",{class:"field","aria-label":"Agent team",value:l?`${l.id}:${l.revision}`:"",onChange:_=>p(r.find(ie=>`${ie.id}:${ie.revision}`===_.currentTarget.value)),children:[e("option",{value:"",children:"Custom team for this assignment"}),l&&!r.some(_=>_.id===l.id&&_.revision===l.revision)&&e("option",{value:`${l.id}:${l.revision}`,children:[l.name," \xB7 pinned version ",l.revision]}),r.map(_=>e("option",{value:`${_.id}:${_.revision}`,children:[_.name," \xB7 version ",_.revision]},_.id))]})]}),l&&e("p",{class:"help",children:["Using ",l.name,", version ",l.revision,". Its coordinator, provider pool and model settings are pinned to this assignment."]}),e("label",{children:["Mission",e("textarea",{class:"field",required:!0,rows:3,value:C,placeholder:"What should the agents improve, and why?",onInput:_=>T(_.currentTarget.value)})]}),e("label",{children:["Intended users",e("textarea",{class:"field",required:!0,value:v,onInput:_=>k(_.currentTarget.value)})]}),e("label",{children:["Priorities, one per line",e("textarea",{class:"field",value:H,onInput:_=>Q(_.currentTarget.value)})]}),e("label",{children:["Things to avoid, one per line",e("textarea",{class:"field",value:le,onInput:_=>de(_.currentTarget.value)})]}),e("label",{children:["Base branch",e("input",{class:"field",required:!0,value:b,onInput:_=>S(_.currentTarget.value)})]}),e("label",{children:["Autonomy",e("select",{class:"field",value:j,onChange:_=>A(_.currentTarget.value),children:[e("option",{value:"propose",children:"Propose improvements for me to choose"}),e("option",{value:"build-within-scope",children:"Also build one eligible draft per cycle"})]})]}),e("label",{children:["Required check command",e("input",{class:"field",value:x,placeholder:"npm test",required:j==="build-within-scope",onInput:_=>w(_.currentTarget.value)})]}),e("label",{children:["Allowed paths, one per line",e("textarea",{class:"field",value:E,onInput:_=>L(_.currentTarget.value)})]}),!l&&e(M,{children:[e("label",{children:["Coordinator",e("select",{class:"field",value:P,required:!0,onChange:_=>D(_.currentTarget.value),children:d.map(_=>e("option",{value:_.id,children:_.name},_.id))})]}),e("fieldset",{children:[e("legend",{children:"Workers and independent reviewer"}),n.map(_=>e("label",{children:[e("input",{type:"checkbox",checked:I.includes(_.id),disabled:!_.available||!!_.reason,onChange:ie=>$(ie.currentTarget.checked?[...I,_.id]:I.filter(Te=>Te!==_.id))})," ",_.name,_.reason?` \u2014 ${_.reason}`:_.available?"":" \u2014 unavailable"]},_.id))]})]}),e("label",{children:[e("input",{type:"checkbox",checked:o,onChange:_=>u(_.currentTarget.checked)}),"Run recurring discovery"]}),e("details",{children:[e("summary",{children:"Schedule, budget and scope limits"}),e(mr,{automation:{name:f,schedule:W.schedule},save:_=>{let ie=_.schedule;ie===null?u(!1):re({...W,schedule:ie})}}),e("p",{class:"help",children:"Budget is reserved before each phase. Outstanding work stays charged until its usage is known."}),[["discoveryCalls","Calls per discovery"],["discoveryMinutes","Minutes per discovery"],["buildCalls","Calls per implementation"],["buildMinutes","Minutes per implementation"],["weeklyCalls","Calls per rolling week"],["weeklyMinutes","Minutes per rolling week"]].map(([_,ie])=>e("label",{children:[ie,e("input",{class:"field",type:"number",min:1,value:W.budget[_],onInput:Te=>re({...W,budget:{...W.budget,[_]:Number(Te.currentTarget.value)}})})]},_)),e("label",{children:["Maximum changed files",e("input",{class:"field",type:"number",min:1,max:100,value:W.maxFiles,onInput:_=>re({...W,maxFiles:Number(_.currentTarget.value)})})]}),e("label",{children:["Maximum changed lines",e("input",{class:"field",type:"number",min:1,max:1e4,value:W.maxLines,onInput:_=>re({...W,maxLines:Number(_.currentTarget.value)})})]}),e("label",{children:["Rescan unchanged repositories after this many days",e("input",{class:"field",type:"number",min:1,max:90,value:W.rescanDays,onInput:_=>re({...W,rescanDays:Number(_.currentTarget.value)})})]}),e("label",{children:["Excluded paths, one per line",e("textarea",{class:"field",value:W.excludedPaths.join(`
|
|
6
|
+
`),onInput:_=>re({...W,excludedPaths:ba(_.currentTarget.value)})})]}),e("fieldset",{children:[e("legend",{children:"Allowed work categories"}),["bug","usability","performance","tests","docs","experiment"].map(_=>e("label",{children:[e("input",{type:"checkbox",checked:W.categories.includes(_),onChange:ie=>re({...W,categories:ie.currentTarget.checked?[...W.categories,_]:W.categories.filter(Te=>Te!==_)})}),_]},_))]}),e("label",{children:["Execution permissions",e("select",{class:"field",value:W.trust,onChange:_=>re({...W,trust:_.currentTarget.value}),children:[e("option",{value:"safe",children:"Safe"}),e("option",{value:"standard",children:"Standard"}),e("option",{value:"trusted",children:"Trusted"})]})]}),e("label",{children:["Setup command",e("input",{class:"field",value:W.setup,onInput:_=>re({...W,setup:_.currentTarget.value})})]}),!l&&e("fieldset",{children:[e("legend",{children:"Models and reasoning"}),Re.value.filter(_=>d.some(ie=>ie.id===_.id)).map(_=>e(hn,{agent:_,used:I.includes(_.id)||P===_.id,settings:W.agentSettings[_.id]??{},onChange:ie=>re({...W,agentSettings:{...W.agentSettings,[_.id]:{...W.agentSettings[_.id],...ie}}})},_.id))]})]}),te&&e("p",{role:"alert",children:te}),e("button",{class:"btn primary",disabled:ue||!d.length,children:ue?"Saving\u2026":c?"Save mission":"Save draft mission"}),e("button",{type:"button",class:"btn",onClick:i,children:"Cancel"})]})}function ju({team:t,enabled:s,providers:n,definitions:r,changed:a}){let[c,i]=m(!1),[d,l]=m(!1),[p,o]=m(),[u,f]=m(!1),[h,g]=m(!1),[y,C]=m(),T=async(A,P)=>{l(!0);try{return await O(`/api/project-teams/${t.id}${A}`,{operationId:Kn(),revision:t.revision,...P}),await a(),!0}catch(D){return J(D.message,7e3),await a(),!1}finally{l(!1)}},v=r.find(A=>A.id===t.definition?.id),k=t.cycles.find(A=>["requested","discovering","selecting","building","unknown"].includes(A.status)),{calls:b,minutes:S,reservedMinutes:x}=yo(t),w=Bl(t),j=w.calls>=t.mission.budget.buildCalls&&w.minutes>=t.mission.budget.buildMinutes;return e("article",{class:"pt-team",children:[e("h3",{children:[t.name," ",e("span",{class:"help",children:[t.status," \xB7 mission ",t.missionRevision]})]}),e("p",{children:t.mission.mission}),e("p",{class:"help",children:[t.repo," \xB7 ",t.mission.baseBranch," \xB7 ",t.mission.mode==="propose"?"Proposals":"Build within scope"]}),e("p",{class:"help",children:["Rolling week: ",b,"/",t.mission.budget.weeklyCalls," calls used or reserved \xB7 ",S,"/",t.mission.budget.weeklyMinutes," minutes used or reserved",x>0?` (${x} reserved)`:""]}),!k&&!j&&e("p",{class:"help",children:"The remaining weekly allowance cannot cover another task's full limit. Completed runs release unused allocations when their final usage is recorded; unknown launches stay reserved."}),t.error&&e("p",{role:"alert",children:t.error}),e("p",{class:"help",children:[t.definition?`${t.definition.name} \xB7 team version ${t.definition.revision}`:"Custom agent team"," \xB7 ",t.scheduleEnabled===!1?"Manual tasks only":"Recurring discovery enabled"]}),t.status!=="archived"&&e("div",{class:"pt-actions",children:[e("button",{class:"btn small primary",disabled:d||!s||!!k||t.status!=="active"||!j,onClick:()=>f(!u),children:"Give team a task"}),e("button",{class:"btn small",disabled:d,onClick:()=>g(!h),children:"Save as reusable team"}),v&&v.revision!==t.definition?.revision&&e("button",{class:"btn small",disabled:d||!!k,onClick:()=>T("",{definition:{id:v.id,revision:v.revision}}),children:["Use team version ",v.revision]}),e("label",{children:[e("input",{type:"checkbox",checked:y??t.scheduleEnabled!==!1,disabled:d||y!==void 0,onChange:async A=>{let P=A.currentTarget.checked;C(P),await T("",{scheduleEnabled:P}),C(void 0)}}),"Run recurring discovery"]})]}),u&&e(Pu,{team:t,saved:()=>{f(!1),a()},refresh:a,cancel:()=>f(!1)}),h&&e(Mu,{team:t,saved:()=>{g(!1),a()},cancel:()=>g(!1)}),t.status!=="archived"&&e("div",{class:"pt-actions",children:[e("button",{class:"btn small",disabled:d||!s&&t.status!=="active",onClick:()=>T("",{status:t.status==="active"?"paused":"active"}),children:t.status==="active"?"Pause":"Activate"}),e("button",{class:"btn small",disabled:d||!s||!!k||t.status!=="active",onClick:()=>{l(!0),O(`/api/project-teams/${t.id}/cycle`,{operationId:Kn()}).then(a,A=>J(A.message)).finally(()=>l(!1))},children:"Run cycle now"}),e("button",{class:"btn small",disabled:d||!k,onClick:()=>T("/stop",{}),children:"Stop cycle"}),e("button",{class:"btn small",disabled:!!k,onClick:()=>i(!c),children:"Edit mission"}),e("button",{class:"btn small",disabled:d||!!k,onClick:()=>T("",{status:"archived"}),children:"Archive mission"}),e("button",{class:"btn small",onClick:()=>V(`/api/project-teams/${t.id}/preview`).then(o,A=>J(A.message)),children:"Preview next cycle"})]}),p&&e("div",{role:"status",children:[e("p",{children:p.ready?"Ready to discover":p.busy?"A cycle is active":"Not ready"}),p.warnings.map(A=>e("p",{children:A},A)),t.scheduleEnabled!==!1&&e(pr,{schedule:t.schedule??t.mission.schedule})]}),c&&e(ko,{projectId:t.projectId,repos:[t.repo],providers:n,definitions:r,team:t,saved:()=>{i(!1),a()}}),t.status!=="archived"&&t.scheduleEnabled!==!1&&e(mr,{automation:{name:t.name,schedule:t.schedule??t.mission.schedule},save:async A=>{await T("",A)}},JSON.stringify(t.schedule??t.mission.schedule)),e("div",{class:"pt-opportunities",children:[...t.opportunities].reverse().map(A=>e(Du,{opportunity:A,busy:d||t.status==="archived",decide:P=>T(`/opportunities/${A.id}`,{opportunityRevision:A.revision,...P})},A.id))}),e("details",{children:[e("summary",{children:["Cycle history (",t.cycles.length,")"]}),[...t.cycles].reverse().map(A=>e("article",{children:[e("b",{children:[new Date(A.at).toLocaleString()," \xB7 ",A.status]}),e("p",{children:A.summary??A.reason}),A.summary&&A.reason&&e("p",{children:A.reason}),A.selection?.reasons.map(P=>e("p",{class:"help",children:[t.opportunities.find(D=>D.id===P.id)?.title,": ",P.reason]},P.id)),A.launches.map(P=>e("p",{children:[P.phase,": ",P.state," \xB7 ",P.usage?.calls??P.usedCalls??P.calls," calls \xB7 ",P.usage?`${Math.ceil(P.usage.durationMs/6e4)} minutes used`:`${P.minutes} minutes reserved`," ",P.runId&&e("button",{class:"btn small",onClick:()=>{Y.value={view:"run",id:P.runId}},children:"Open team run"})]},P.claimId))]},A.id))]})]})}function Pu({team:t,saved:s,refresh:n,cancel:r}){let[a,c]=m(""),[i,d]=m(""),[l,p]=m(""),[o,u]=m(t.mission.categories[0]),[f,h]=m(!1),[g,y]=m(""),C=Z(),T=async k=>{k.preventDefault(),h(!0),y(""),C.current??={operationId:Kn(),revision:t.revision,title:a,instructions:i,acceptance:ba(l),category:o};try{await O(`/api/project-teams/${t.id}/tasks`,C.current),s()}catch(b){y(b.message),b instanceof st&&b.status>=400&&b.status<500&&(C.current=void 0),n()}finally{h(!1)}},v=f||!!C.current;return e("form",{class:"pt-form","aria-label":"Give team a task",onSubmit:T,children:[e("label",{children:["Task title",e("input",{class:"field",required:!0,maxLength:180,disabled:v,value:a,onInput:k=>c(k.currentTarget.value)})]}),e("label",{children:["Task instructions",e("textarea",{class:"field",required:!0,maxLength:3e3,disabled:v,rows:3,value:i,onInput:k=>d(k.currentTarget.value)})]}),e("label",{children:["Acceptance criteria, one per line",e("textarea",{class:"field",required:!0,disabled:v,value:l,onInput:k=>p(k.currentTarget.value)})]}),e("label",{children:["Task category",e("select",{class:"field","aria-label":"Task category",disabled:v,value:o,onChange:k=>u(k.currentTarget.value),children:t.mission.categories.map(k=>e("option",{children:k},k))})]}),e("p",{class:"help",children:["Uses this assignment's scope, checks and implementation budget: up to ",t.mission.budget.buildCalls," calls and ",t.mission.budget.buildMinutes," minutes. The result comes back for your review."]}),g&&e("p",{role:"alert",children:g}),e("div",{class:"pt-actions",children:[e("button",{class:"btn primary",disabled:f,children:f?"Starting\u2026":C.current?"Retry task request":"Start assigned task"}),e("button",{type:"button",class:"btn",disabled:f,onClick:r,children:"Cancel task"})]})]})}function Mu({team:t,saved:s,cancel:n}){let[r,a]=m(`${t.name} team`.slice(0,80)),[c,i]=m(!1),[d,l]=m(""),[p]=m(Kn);return e("form",{class:"pt-form","aria-label":"Save assignment as reusable team",onSubmit:async o=>{o.preventDefault(),i(!0),l("");try{await O("/api/project-teams/definitions",{operationId:p,name:r,sourceTeamId:t.id}),s()}catch(u){l(u.message)}finally{i(!1)}},children:[e("label",{children:["Reusable team name",e("input",{class:"field",required:!0,maxLength:80,value:r,onInput:o=>a(o.currentTarget.value)})]}),e("p",{class:"help",children:"Saves provider and model preferences. This project's mission, memory, history and budget stay with the assignment."}),d&&e("p",{role:"alert",children:d}),e("div",{class:"pt-actions",children:[e("button",{class:"btn primary",disabled:c,children:"Save team configuration"}),e("button",{class:"btn",type:"button",disabled:c,onClick:n,children:"Cancel saving team"})]})]})}function Du({opportunity:t,busy:s,decide:n}){let[r,a]=m("");return e("article",{class:"pt-opportunity",id:`opportunity-${t.id}`,children:[e("h4",{children:[t.title," ",e("span",{class:"help",children:t.status})]}),e("p",{children:t.problem}),t.origin!=="owner"&&e("p",{children:t.proposal}),e("p",{class:"help",children:t.origin==="owner"?"Owner-assigned task":`${t.benefit} \xB7 ${t.risk} risk \xB7 ${t.kind} \xB7 ${t.evidenceVerified?"Code evidence verified":"Evidence needs review"}`}),e("details",{children:[e("summary",{children:"Evidence and acceptance criteria"}),t.evidence.map((c,i)=>e("blockquote",{children:[e("code",{children:c.path}),e("pre",{children:c.quote})]},i)),e("ul",{children:t.acceptance.map(c=>e("li",{children:c},c))}),e("p",{children:t.rationale}),e("p",{children:["Paths: ",t.paths.join(", ")]})]}),t.reason&&e("p",{children:t.reason}),t.result&&e(M,{children:[e("code",{children:t.result.head.slice(0,12)})," ",e("button",{class:"btn small",onClick:()=>{Y.value={view:"run",id:t.result.runId}},children:"Review diff and checks"})]}),!["shipped","implementing"].includes(t.status)&&e(M,{children:[e("label",{children:["Feedback",e("textarea",{class:"field",value:r,onInput:c=>a(c.currentTarget.value)})]}),e("div",{class:"pt-actions",children:[t.status==="ready"&&e("button",{class:"btn small primary",disabled:s,onClick:()=>n({action:"approve",note:r}),children:"Approve this commit"}),e("button",{class:"btn small",disabled:s||t.status==="accepted",onClick:()=>n({action:t.result?"revise":"build",note:r}),children:t.result?"Request revision":"Build proposal"}),e("button",{class:"btn small",disabled:s,onClick:()=>n({action:"defer",note:r,deferUntil:Date.now()+7*864e5}),children:"Defer one week"}),e("button",{class:"btn small",disabled:s,onClick:()=>n({action:"reject",note:r}),children:"Reject"})]})]}),t.status==="accepted"&&e("p",{class:"help",children:"Approved. Open the result to publish a PR or merge using the existing review controls."})]})}function ur({projectId:t}){let[s,n]=m([]);N(()=>{let a=!0,i=lt(()=>V(`/api/project-teams${t?`?project=${encodeURIComponent(t)}`:""}`).then(d=>{a&&n(d.teams)},()=>{}),15e3);return()=>{a=!1,i()}},[t]);let r=s.filter(a=>a.status!=="archived"&&(a.opportunities.some(c=>["proposed","ready","blocked"].includes(c.status))||a.cycles.at(-1)?.status==="unknown"));return r.length?e("section",{class:"pp-card standing-teams",children:[e("h2",{children:"Project team opportunities"}),r.map(a=>e("article",{children:[e("h3",{children:a.name}),e("p",{children:[a.opportunities.filter(c=>c.status==="ready").length," verified drafts \xB7 ",a.opportunities.filter(c=>c.status==="proposed").length," proposals",a.cycles.at(-1)?.status==="unknown"?" \xB7 launch needs reconciliation":""]}),e("button",{class:"btn",onClick:()=>{Y.value={view:"project",id:a.projectId,section:"automation",kind:"missions"}},children:"Review opportunities"})]},a.id))]}):null}function Lu({teams:t}){let s=t.filter(l=>l.status!=="archived").flatMap(l=>l.opportunities.filter(p=>["ready","proposed","blocked","accepted"].includes(p.status)).map(p=>({team:l,opportunity:p}))),n=[...s].sort((l,p)=>+(p.opportunity.status==="ready")-+(l.opportunity.status==="ready")||p.opportunity.impact-l.opportunity.impact||p.opportunity.createdAt-l.opportunity.createdAt).slice(0,3),[r,a]=m(""),[c,i]=m(""),d=async(l,p)=>{a(p.id),i("");try{await O(`/api/project-teams/${l.id}/opportunities/${p.id}`,{operationId:Kn(),revision:l.revision,opportunityRevision:p.revision,action:"reject",note:"Dismissed from the project briefing"})}catch(o){i(o.message)}finally{a("")}};return e("section",{class:"project-briefing","aria-label":"Project briefing",children:[e("div",{class:"experience-kicker",children:"PROJECT BRIEFING"}),e("h2",{children:n.length?"Worth your attention":"No new opportunities to review"}),e("p",{class:"help",children:t.some(l=>l.status==="active")?"Your team's assigned tasks and discovered improvements appear here for review.":"Assign and activate an agent team below to start work on this project."}),e("div",{class:"briefing-grid",children:n.map(({team:l,opportunity:p})=>e("article",{children:[e("span",{class:"badge",children:p.status==="ready"?"Verified draft":p.status}),e("h3",{children:p.title}),e("p",{children:p.benefit}),e("p",{class:"help",children:p.origin==="owner"?"Owner-assigned task":`${p.users} \xB7 ${p.risk} risk \xB7 ${p.evidenceVerified?"Source quotes checked":"Evidence needs review"}`}),e("details",{children:[e("summary",{children:"Why this matters"}),e("p",{children:p.problem}),e("p",{children:p.rationale}),p.evidence.slice(0,3).map((o,u)=>e("blockquote",{children:[e("code",{children:o.path}),e("pre",{children:o.quote})]},u)),e("p",{class:"help",children:["Source commit ",p.baseCommit.slice(0,12)]})]}),e("div",{class:"experience-actions",children:[p.result?e("a",{class:"btn small primary",href:`#/run/${p.result.runId}`,children:"Try and review draft"}):e("button",{class:"btn small",onClick:()=>document.getElementById(`opportunity-${p.id}`)?.scrollIntoView({block:"center",behavior:"smooth"}),children:"Review proposal"}),e("button",{class:"btn ghost small",disabled:!!r,onClick:()=>void d(l,p),children:"Dismiss opportunity"})]})]},p.id))}),s.length>3?e("p",{class:"help",children:[s.length-3," more opportunities are available in the team details below."]}):null,c?e("p",{role:"alert",children:c}):null]})}function zn(t){let s=t.status==="running"&&!!t.team?.awaitingRequestId;if(!(t.archived||t.projectTeam&&!t.awaiting&&!s)){if(t.awaiting||s)return"answer";if(t.team?.status==="blocked")return"blocked";if(!t.seen&&(t.status==="failed"||t.status==="interrupted"))return"failed";if(!t.seen&&t.status!=="running"){if(at(t)==="Blocked"||t.status==="stopped")return"blocked";if(at(t)==="Failed")return"failed"}if(t.triage?.state==="pending"||!t.seen&&t.status==="done"&&t.artifacts?.some(n=>n.stat?.trim()))return"review"}}var hr={answer:"Waiting for your answer",blocked:"Blocked work",failed:"Failed checks or execution",review:"Results to review"},Hl={answer:0,blocked:1,failed:2,review:3};function wo(t,s={}){let n=(s.query??"").trim().toLowerCase().split(/\s+/).filter(Boolean);return t.filter(r=>{let a=zn(r);return a&&(!s.reason||a===s.reason)&&n.every(c=>[r.task,r.repo,r.id,r.trigger?.name??"",r.source?.title??""].join(`
|
|
7
|
+
`).toLowerCase().includes(c))}).sort((r,a)=>(a.priority??0)-(r.priority??0)||Hl[zn(r)]-Hl[zn(a)]||r.createdAt-a.createdAt||r.id.localeCompare(a.id))}function Wl(t,s){let n=new Map;for(let r of t){let a=s(r);n.has(a.id)||n.set(a.id,{...a,runs:[]}),n.get(a.id).runs.push(r)}return[...n.values()]}var To=t=>t.project?he.value.find(s=>s.id===t.project):he.value.filter(s=>s.repos.includes(t.repo)).length===1?he.value.find(s=>s.repos.includes(t.repo)):void 0,Nu=(t,s=_e.value)=>{if(s===Os)return!0;let n=To(t.run);return s===qt?!n:n?.id===s},Vl=qe([]);async function Gn(){try{Vl.value=await Mi("/api/automations")}catch{}}var So=()=>wo([...ve.value.values()]),Ou=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Co=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";function pr({schedule:t}){let[s,n]=m([]),[r,a]=m(""),c=JSON.stringify(t);N(()=>{let l=!0;if(!t){n([]),a("");return}let p=setTimeout(()=>void O("/api/automations/schedule-preview",{schedule:t,after:Date.now(),count:5}).then(o=>{l&&(n(o.times),a(""))},o=>{l&&(n([]),a(o.message))}),200);return()=>{l=!1,clearTimeout(p)}},[c]);let i=t&&"at"in t?t.timezone:void 0,d=l=>{try{return new Date(l).toLocaleString([],{timeZone:i,weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"})}catch{return"Choose a valid time zone"}};return e("div",{role:"group","aria-label":"Next scheduled times",children:[e("p",{class:"help",children:["Next runs",i?` in ${i}`:"",":"]}),s.length?e("ol",{class:"help",children:s.map(l=>e("li",{children:d(l)},l))}):e("p",{class:"help",children:t?"Calculating\u2026":"No schedule"}),i?e("p",{class:"help",children:"Runs once per local day. A skipped daylight-saving time moves forward; a repeated time uses its first occurrence."}):null,r?e("p",{class:"msg err",role:"alert",children:r}):null]})}function mr({automation:t,save:s}){let n=t.schedule,[r,a]=m(n?"every"in n?"every":"daily":"off"),[c,i]=m(n&&"at"in n?n.at:"07:00"),[d,l]=m(n&&"at"in n?n.timezone??Co():Co()),[p,o]=m(n&&"at"in n?n.days??[0,1,2,3,4,5,6]:[0,1,2,3,4,5,6]),[u,f]=m(n&&"every"in n?n.every:60),h=r==="off"?void 0:r==="every"?{every:u}:{at:c,timezone:d,days:p.length===7?void 0:p};return e("details",{children:[e("summary",{children:"Schedule and next times"}),e("label",{children:["Schedule",e("select",{class:"field","aria-label":`Schedule for ${t.name}`,value:r,onChange:g=>a(g.currentTarget.value),children:[e("option",{value:"off",children:"Only when triggered"}),e("option",{value:"daily",children:"At a time"}),e("option",{value:"every",children:"Every N minutes"})]})]}),r==="daily"?e(M,{children:[e("label",{children:["Time",e("input",{class:"field",type:"time",value:c,onInput:g=>i(g.currentTarget.value)})]}),e("label",{children:["Time zone",e("input",{class:"field",placeholder:"Europe/Stockholm",value:d,onInput:g=>l(g.currentTarget.value)})]})]}):r==="every"?e("label",{children:["Minutes",e("input",{class:"field",type:"number",min:5,max:10080,value:u,onInput:g=>f(Number(g.currentTarget.value))})]}):null,r==="daily"&&e("fieldset",{children:[e("legend",{children:"Days"}),["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((g,y)=>e("label",{children:[e("input",{type:"checkbox",checked:p.includes(y),onChange:C=>o(C.currentTarget.checked?[...p,y].sort():p.filter(T=>T!==y))})," ",g]},g))]}),e(pr,{schedule:h}),e("button",{type:"button",class:"btn small",onClick:()=>s({schedule:h??null}),children:"Save schedule"})]})}function ya({mode:t="all",category:s,projectId:n,showScope:r=!0}){N(()=>lt(Gn,15e3),[]);let a=n??_e.value,c=a!==Os,[i,d]=m("project"),[l,p]=m(""),[o,u]=m(""),f=So(),h=f.filter(b=>Ua(b)),g=wo(h,{query:o,reason:l||void 0}),y=Wl(g,b=>{if(i==="reason"){let x=zn(b);return{id:x,label:hr[x]}}if(i==="repo")return{id:b.repo,label:b.repo};if(i==="none")return{id:"all",label:"All attention items"};let S=Ke(b);return{id:S?.id??"unassigned",label:S?.name??"Without a project"}}),C=Vl.value.filter(b=>!s||!b.target&&(s==="backlog"?!!b.sweep:!b.sweep)),T=C.filter(b=>Nu(b,a)),v=he.value.find(b=>b.id===a),k=v?` in ${v.name}`:c?" without a project":"";return e("div",{class:"automations",children:[t!=="automations"?e(ur,{projectId:_e.value!==Os&&_e.value!==qt?_e.value:void 0}):null,r?e("div",{class:"page-head",children:[e("div",{class:"ph-text page-head-text",children:[e("h3",{children:"Project scope"}),e("p",{class:"lede",children:t==="inbox"?"Questions, blocked work, failed checks and results waiting for your review.":"Schedule work and manage triggers. Results wait in your Inbox; nothing is merged automatically."})]}),n?e("span",{children:v?.name}):e(Ks,{})]}):null,t!=="automations"?e("section",{class:"section auto-card","aria-labelledby":"inbox-title",children:[e("h2",{class:"section-title",id:"inbox-title",children:["Review inbox ",h.length?e("span",{class:"count",children:h.length}):null]}),e(_l,{count:f.length-h.length,what:b=>`${b} in other projects need${b===1?"s":""} you`}),e("p",{class:"help inbox-note",children:"Higher run priorities come first, then questions, blocked work, failures and results. Older items come first within each priority. Open a run to answer approvals, resume work or review its evidence."}),e("div",{class:"wb-row inbox-filters",children:[e("label",{children:["Group by",e("select",{class:"field","aria-label":"Group review inbox",value:i,onChange:b=>d(b.currentTarget.value),children:[e("option",{value:"project",children:"Project"}),e("option",{value:"repo",children:"Repository"}),e("option",{value:"reason",children:"Attention needed"}),e("option",{value:"none",children:"No grouping"})]})]}),e("label",{children:["Show",e("select",{class:"field","aria-label":"Filter review inbox",value:l,onChange:b=>p(b.currentTarget.value),children:[e("option",{value:"",children:"All attention items"}),Object.entries(hr).map(([b,S])=>e("option",{value:b,children:S}))]})]}),e("label",{children:["Search",e("input",{class:"field","aria-label":"Search review inbox",value:o,onInput:b=>u(b.currentTarget.value),placeholder:"Task, repository or run ID"})]})]}),g.length?y.map(b=>e("section",{class:"inbox-group","aria-label":`Review group ${b.label}`,children:[e("h3",{children:[b.label," ",e("span",{class:"count",children:b.runs.length})]}),b.runs.map(S=>e(qu,{run:S,scoped:c},S.id))]},b.id)):e("p",{class:"help empty",children:h.length?"No attention items match these filters.":`Nothing to review${k}. Runs that changed nothing are archived on their own.`})]}):null,t!=="inbox"?e("section",{class:"section auto-card","aria-labelledby":"automations-title",children:[e("h2",{class:"section-title",id:"automations-title",children:[s==="backlog"?"Scheduled backlog work":"Repeating tasks and webhooks"," ",T.length?e("span",{class:"n",children:T.length}):null]}),n?null:e(_l,{count:C.length-T.length,what:b=>`${b} more in other projects`}),T.length?T.map(b=>e(Uu,{a:b,scoped:c},b.id)):e("p",{class:"help empty",children:["None",k," yet. Set up a run in the composer \u2014 task, team, check \u2014 and choose ",e("b",{children:"Schedule \u2192 Repeat"})," next to Start run."]})]}):null,e("p",{class:"help",children:["To access this computer from another device, open ",e("a",{href:"#/settings/connections/devices",children:"Connections \u2192 Share access"}),"."]})]})}var Jl=(t,s,n)=>!n&&t&&t.name!==be(s)?t:void 0;function _l({count:t,what:s}){return t<=0?null:e("div",{class:"rail-hint elsewhere",children:[s(t),e("button",{type:"button",onClick:()=>ua(Os),children:"Show all"})]})}function qu({run:t,scoped:s}){let n=t.artifacts.filter(a=>a.stat?.trim()),r=Jl(Ke(t),t.repo,s);return e("div",{class:"inbox-item",children:[e("div",{class:"ih",children:[e("span",{class:"badge",children:hr[zn(t)]}),t.priority?e("span",{class:"badge",children:["Priority ",t.priority>0?"+":"",t.priority]}):null,e("span",{class:`dot ${ft(t)}`}),e("a",{href:`#/run/${t.id}`,class:"t",children:[t.task.split(`
|
|
8
|
+
`)[0],t.source?.title&&!t.task.includes(t.source.title)?` \u2014 ${t.source.title}`:null]}),e("span",{class:"help",children:[t.trigger?e(M,{children:[e(K,{name:t.trigger.via==="sweep"?"layers":t.trigger.via==="webhook"?"globe":"clock",class:"inline-icon"})," ",t.trigger.name," \xB7 "]}):null,Je[t.status]??t.status,` \xB7 checks: ${at(t).toLowerCase()}`," \xB7 ",be(t.repo),r?e(M,{children:[" \xB7 ",e(K,{name:"project",class:"inline-icon"})," ",r.name]}):null," \xB7 ",es(t.createdAt)]})]}),t.awaiting?e("a",{class:"btn small primary",href:`#/run/${t.id}`,children:"Open pending approval"}):null,t.checkCantRun?e(Xa,{cantRun:t.checkCantRun}):null,t.team?e("div",{class:"help",children:["Team: ",t.team.members.length," members \xB7 ",t.team.tasks.filter(a=>a.status==="completed").length,"/",t.team.tasks.length," tasks completed \xB7 ",t.team.metrics.invocations," calls"]}):null,gt(t)?e("div",{class:"at-notice",children:[e("b",{children:"The team needs your answer"}),e("p",{children:t.team?.messages.find(a=>a.id===t.team.awaitingRequestId)?.body}),e("a",{class:"btn small primary",href:`#/run/${t.id}`,children:"Answer team question"})]}):t.team?.status==="blocked"?e("div",{class:"at-notice",children:[e("p",{children:t.team.gaps.join(" ")}),e("a",{class:"btn small",href:`#/run/${t.id}`,children:"Continue team work"})]}):null,t.review?e("div",{class:"help",children:["Review: ",t.review.verdict==="approve"?"approve":`${t.review.findings.length} findings`]}):null,n.map(a=>e("pre",{class:"stat",tabIndex:0,"aria-label":`Changed files on ${a.branch}`,children:[a.label," \xB7 ",a.branch,`
|
|
9
|
+
`,a.stat]},a.branch)),t.error?e("div",{class:"msg err",children:t.error}):null,t.triage?.state==="pending"?e(xo,{run:t}):null]})}function xo({run:t}){let[s,n]=m(""),[r,a]=m(""),[c,i]=m(t.loop.maxInvocations??t.loop.maxSteps),[d,l]=m(t.loop.maxMinutes),p=async(h,g={})=>{if(!(h==="reject"&&!await Ae("Reject this result? Its worktrees and branches are deleted.",{title:"Reject this result?",confirmLabel:"Reject result",danger:!0}))){a(h);try{await O(`/api/runs/${t.id}/triage`,{decision:h,note:s,...h==="revise"?{budget:{maxSteps:c,maxInvocations:c,maxMinutes:d}}:{},...g}),J(h==="approve"?g.pushPr?`Approved \u2014 pushed to PR #${t.source?.number}`:g.openPr?"Approved \u2014 pull request opened":"Approved":h==="revise"?"Sent \u2014 the agent is revising it":"Rejected and cleaned up"),n("")}catch(y){J(y.message,5e3)}finally{a("")}}},o=t.artifacts.some(h=>h.stat?.trim()),u=t.status==="running",f=t.source?.kind==="pr"&&!t.source.isCrossRepository?t.source:void 0;return e("div",{class:"triage",children:[e("input",{class:"field",placeholder:"What should change? (for Revise)",value:s,onInput:h=>n(h.currentTarget.value),disabled:u}),s.trim()?e("details",{class:"followup-budget",children:[e("summary",{children:["Revision budget \xB7 ",c," calls \xB7 ",d," min"]}),e("label",{children:["Maximum calls",e("input",{class:"field","aria-label":"Revision maximum calls",type:"number",min:1,max:200,value:c,onInput:h=>i(Number(h.currentTarget.value))})]}),e("label",{children:["Maximum minutes",e("input",{class:"field","aria-label":"Revision maximum minutes",type:"number",min:1,max:720,value:d,onInput:h=>l(Number(h.currentTarget.value))})]})]}):null,e("button",{class:"btn small",disabled:u||!!r||!s.trim(),onClick:()=>p("revise"),children:r==="revise"?"Sending\u2026":"Revise"}),e("button",{class:"btn small primary",disabled:u||!!r,onClick:()=>p("approve"),children:"\u2713 Approve"}),o&&f?e("button",{class:"btn small",disabled:u||!!r,title:`Approve and push the fix to ${f.headRefName}, updating PR #${f.number} (never forced)`,onClick:()=>p("approve",{pushPr:!0}),children:r==="approve"?"\u2026":`Approve & push to PR #${f.number}`}):o?e("button",{class:"btn small",disabled:u||!!r,title:"Approve, push the branch and open a pull request into the base branch",onClick:()=>p("approve",{openPr:!0}),children:r==="approve"?"\u2026":"Approve & open PR"}):null,e("button",{class:"btn small danger",disabled:u||!!r,onClick:()=>p("reject"),children:"Reject"})]})}function Uu({a:t,scoped:s}){let[n,r]=m(!1),[a,c]=m(!1),i=t.lastRunId?ve.value.get(t.lastRunId):void 0,d=Jl(To(t.run),t.run.repo,s),l=o=>O(`/api/automations/${t.id}`,o).then(Gn,u=>J(u.message,5e3)),p=`${location.origin}${t.hookPath}`;return t.target?e("div",{class:"auto-row",children:[e("b",{children:t.name}),e("p",{class:"help",children:["Project mission \xB7 ",t.enabled?"active":"paused"," \xB7 ",t.scheduleText]}),e("button",{class:"btn small",onClick:()=>{let o=t.run.project;o&&(Y.value={view:"project",id:o})},children:"Mission, cycles and opportunities"})]}):e("div",{class:`auto-row ${t.enabled?"":"off"}`,children:[e("div",{class:"ar-head",children:[e("label",{class:"switch",title:t.enabled?"Turn off":"Turn on",children:e("input",{type:"checkbox",role:"switch","aria-label":`${t.name}: on`,checked:t.enabled,onChange:o=>l({enabled:o.currentTarget.checked})})}),e("b",{children:t.name}),e("span",{class:"help",children:[t.sweep?`Sweep: up to ${t.sweep.max} new ${t.sweep.kind==="issues"?"issues":t.sweep.kind==="dependabot"?"Dependabot PRs":"alerts"} \xB7 `:"",t.scheduleText,t.webhook?" \xB7 webhook":"",t.isolate?` \xB7 checks in ${t.image||"node:22"}`:""]}),e("span",{class:"spacer"}),e("button",{class:"btn small","aria-expanded":a,onClick:()=>c(!a),children:"Preview and events"}),e("button",{class:"btn small",onClick:()=>O(`/api/automations/${t.id}/run`).then(({id:o,ids:u})=>{Gn(),u&&u.length!==1?J(`Started ${u.length} runs \u2014 their results will wait in the inbox`):o&&(Y.value={view:"run",id:o})},o=>J(o.message,5e3)),children:"Run now"}),t.webhook?e("button",{class:"btn small","aria-pressed":n,onClick:()=>r(!n),children:"Webhook"}):null,e("button",{class:"btn small danger",onClick:async()=>await Ae(`Delete \u201C${t.name}\u201D? Its past runs are kept.`,{title:"Delete automation?",confirmLabel:"Delete automation",danger:!0})&&V(`/api/automations/${t.id}`,{method:"DELETE"}).then(Gn,o=>J(o.message)),children:"Delete"})]}),e("div",{class:"ar-meta help",children:[ge.value.find(o=>o.id===t.run.pattern)?.name??t.run.pattern," in ",be(t.run.repo),d?e(M,{children:[" \xB7 ",e(K,{name:"project",class:"inline-icon"})," ",d.name]}):null,": \u201C",t.run.task.split(`
|
|
10
|
+
`)[0],"\u201D",t.sweep&&t.handled?.length?` \xB7 ${t.handled.length} handled so far`:"",Object.values(t.run.roles).flat().filter((o,u,f)=>f.indexOf(o)===u).map(o=>o==="auto"?e("span",{children:" \xB7 Auto"},o):e("span",{children:[" \xB7 ",e(Ee,{id:o})]},o))]}),e("div",{class:"ar-meta help",children:[t.enabled&&t.nextAt?`Next: ${new Date(t.nextAt).toLocaleString([],{weekday:"short",hour:"2-digit",minute:"2-digit"})}`:t.enabled?"Runs when triggered":"Off",t.lastFiredAt?e(M,{children:[" \xB7 Last: ",i?e("a",{href:`#/run/${i.id}`,children:[es(t.lastFiredAt)," (",i.triage?.state==="empty"?"no changes":Je[i.status]??i.status,")"]}):es(t.lastFiredAt)]}):null,t.queued?.length?` \xB7 ${t.queued.length} webhook event${t.queued.length===1?"":"s"} waiting for the run to end`:null,t.lastError?e("span",{class:"msg err inline",children:[" \xB7 couldn't start: ",t.lastError]}):null]}),e(mr,{automation:t,save:l}),a?e(Bu,{automation:t}):null,n?e("div",{class:"hook",children:[e("div",{children:[e("span",{class:"lbl",children:"URL"})," ",e("code",{children:p})]}),e("div",{children:[e("span",{class:"lbl",children:"Secret"})," ",e("code",{children:[t.token.slice(0,6),"\u2026"]})," ",e("button",{class:"btn small",onClick:()=>Kt(t.token,"Secret copied"),children:"Copy"}),e("button",{class:"btn small",onClick:async()=>await Ae("Make a new secret? The old one stops working.",{title:"Replace webhook secret?",confirmLabel:"Replace secret",danger:!0})&&l({rotateToken:!0}),children:"New secret"})]}),e("pre",{children:`curl -X POST ${p} \\
|
|
11
|
+
-H "Authorization: Bearer <secret>" \\
|
|
12
|
+
-H "Content-Type: application/json" \\
|
|
13
|
+
-d '{"details": "what happened", "source": {"kind": "pr", "number": 12}}'`}),e("div",{class:"help",children:["For a GitHub webhook, use this URL through a tunnel, content type ",e("code",{children:"application/json"}),", and the secret above. Opened issues and pull requests, and failed workflow runs (with their logs), start a run; other events are ignored."]})]}):null]})}function Bu({automation:t}){let[s,n]=m([]),[r,a]=m(null),[c,i]=m(""),[d,l]=m(""),p=()=>V(`/api/automations/${t.id}/events`).then(n),o=()=>O(`/api/automations/${t.id}/preview`,{via:"manual"}).then(a);N(()=>{let f=!0;O(`/api/automations/${t.id}/preview`,{via:"manual"}).then(y=>{f&&(a(y),i(""))},y=>{f&&i(y.message)});let g=lt(()=>V(`/api/automations/${t.id}/events`).then(y=>{f&&n(y)},()=>{}),15e3);return()=>{f=!1,g()}},[t.id]);let u=async f=>{l(f.id);try{await O(`/api/automations/${t.id}/events/${f.id}/retry`),await Promise.all([p(),Gn()]),J("Event retry requested")}catch(h){i(h.message)}finally{l("")}};return e("section",{class:"hook automation-inspector","aria-label":`Preview and events for ${t.name}`,children:[e("b",{children:"Dry run"}),e("p",{class:"help",children:"Preview current selections and settings before running."}),r?e(M,{children:[e("p",{children:[r.ready?"Ready to start":"Cannot start immediately",r.busy?` \xB7 ${r.busy}`:"",r.wouldQueue?" \xB7 event would wait in the queue":""]}),e("p",{class:"help",children:["Permissions: ",r.permissions.trust," \xB7 ",r.permissions.isolate?`commands in ${r.permissions.image}`:"commands on this machine"," \xB7 ",r.limits.maxInvocations??r.limits.maxSteps??"default"," calls \xB7 ",r.limits.maxMinutes??"default"," minutes \xB7 webhooks ",r.limits.startsUsed,"/",r.limits.startsPerHour," this hour"]}),r.commands.setup?e("div",{class:"help",children:["Setup: ",e("code",{children:r.commands.setup})]}):null,r.commands.check?e("div",{class:"help",children:["Check: ",e("code",{children:r.commands.check})]}):null,r.warnings.map(f=>e("p",{class:"msg warn",children:f},f)),r.selected.length?e("ul",{children:r.selected.map(f=>e("li",{children:[e("b",{children:f.key}),": ",f.task.split(`
|
|
14
|
+
`)[0]]},f.key))}):e("p",{class:"help",children:"No work selected."}),r.skipped.length?e("details",{children:[e("summary",{children:[r.skipped.length," items outside this run"]}),e("ul",{children:r.skipped.map(f=>e("li",{children:[f.key,": ",f.reason]},f.key))})]}):null,e("button",{class:"btn small",onClick:()=>o().catch(f=>i(f.message)),children:"Refresh preview"})]}):e("p",{class:"help",children:"Loading preview\u2026"}),e("p",{children:e("b",{children:"Event history"})}),e("p",{class:"help",children:"Keeps the latest 100 events, including queued, deduplicated, failed and dropped deliveries. Retrying uses the original validated event and current limits."}),s.length?e("div",{class:"table-wrap",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Received"}),e("th",{children:"Origin"}),e("th",{children:"State"}),e("th",{children:"Details"}),e("th",{children:"Action"})]})}),e("tbody",{children:s.map(f=>e("tr",{children:[e("td",{children:new Date(f.at).toLocaleString()}),e("td",{children:f.via}),e("td",{children:[f.state,f.retries?` (${f.retries} ${f.retries===1?"retry":"retries"})`:""]}),e("td",{children:[f.input.source?`${f.input.source.kind} #${f.input.source.number}`:f.input.details?.slice(0,160)||"Saved task",f.reason?e("div",{class:"help",children:f.reason}):null,f.runIds?.map(h=>e("a",{href:`#/run/${h}`,children:"Open run "},h))]}),e("td",{children:f.state==="failed"||f.state==="dropped"?e("button",{class:"btn small",disabled:!t.enabled||!!d,onClick:()=>u(f),children:d===f.id?"Retrying\u2026":"Retry event"}):"\u2013"})]},f.id))})]})}):e("p",{class:"help",children:"No events recorded yet."}),c?e("p",{class:"msg err",role:"alert",children:c}):null]})}function Kl({body:t,onClose:s}){let n=ye(!0,s),[r,a]=m(String(t.task??"").split(`
|
|
15
|
+
`)[0].slice(0,50)),[c,i]=m("daily"),[d,l]=m(60),[p,o]=m("07:00"),[u,f]=m(Co()),[h,g]=m([1,2,3,4,5]),[y,C]=m(!1),[T,v]=m(!1),[k,b]=m("node:22"),[S,x]=m(""),[w,j]=m(!1),A=async()=>{j(!0),x("");try{let{attachments:P,approvals:D,branchPrefix:I,...$}=t;$.context={paths:t.context?.paths??[]};let E=await O("/api/automations",{name:r,run:$,schedule:c==="every"?{every:d}:c==="daily"?{at:p,days:h,timezone:u}:void 0,webhook:c==="webhook"||y,isolate:T,image:k});await Gn(),J("Automation saved"),s();let L=To(E.run);_e.value!==Os&&L&&L.id!==_e.value&&ua(L.id,{defaults:!1,repo:!1}),Y.value={view:"automations"}}catch(P){x(P.message)}finally{j(!1)}};return e("dialog",{class:"picker small-dialog save-auto",ref:n,"aria-labelledby":"save-automation-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"save-automation-title",children:"Save as automation"}),e("div",{class:"help",children:"Runs this task with this team and these settings, unattended. Results wait in your inbox; nothing merges by itself."})]}),e("div",{class:"dialog-body",children:[e("div",{class:"fg",children:[e("label",{class:"lbl",for:"auto-name",children:"Name"}),e("input",{id:"auto-name",class:"field",value:r,onInput:P=>a(P.currentTarget.value)})]}),e("div",{class:"fg",children:[e("span",{class:"lbl",id:"auto-when",children:"When"}),e("div",{class:"segmented",role:"radiogroup","aria-labelledby":"auto-when",children:[["daily","At a time"],["every","Repeatedly"],["webhook","Only from a webhook"]].map(([P,D])=>e("button",{type:"button",role:"radio","aria-checked":c===P,class:c===P?"on":"",onClick:()=>i(P),children:D},P))}),c==="daily"?e("div",{class:"row-inline",children:[e("input",{class:"field inline",type:"time","aria-label":"Time of day",value:p,onInput:P=>o(P.currentTarget.value)}),e("span",{class:"days",role:"group","aria-label":"Days",children:Ou.map((P,D)=>e("button",{type:"button",class:"day","aria-pressed":h.includes(D),onClick:()=>g(h.includes(D)?h.filter(I=>I!==D):[...h,D].sort()),children:P},P))})]}):c==="every"?e("div",{class:"row-inline",children:["Every ",e("input",{class:"field inline num",type:"number",min:5,"aria-label":"Minutes between runs",value:d,onInput:P=>l(Number(P.currentTarget.value)||60)})," minutes"]}):null,c==="daily"?e("label",{class:"lbl tz",children:["Time zone",e("input",{class:"field","aria-label":"Automation time zone",placeholder:"Europe/Stockholm",value:u,onInput:P=>f(P.currentTarget.value)})]}):null,c!=="webhook"?e(pr,{schedule:c==="every"?{every:d}:{at:p,days:h,timezone:u}}):null]}),e("div",{class:"fg checks",children:[c!=="webhook"?e("label",{class:"check",children:[e("input",{type:"checkbox",checked:y,onChange:P=>C(P.currentTarget.checked)})," Also start it from a webhook"]}):null,e("label",{class:"check",children:[e("input",{type:"checkbox",checked:T,onChange:P=>v(P.currentTarget.checked)})," Run checks and setup in a Docker container"]}),T?e("div",{class:"row-inline image",children:["Image ",e("input",{class:"field inline mono","aria-label":"Docker image",value:k,onInput:P=>b(P.currentTarget.value)}),e("span",{class:"help",children:"Only the worktree is mounted; none of your environment or home folder."})]}):null]}),S?e("div",{class:"msg err",children:S}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn",onClick:s,children:"Cancel"}),e("button",{class:"btn primary",disabled:w||!r.trim()||c==="daily"&&!h.length,onClick:A,children:w?"Saving\u2026":"Save automation"})]})]})})}var zl={queued:"Queued","waiting-time":"Waiting for start time","waiting-provider":"Waiting for provider capacity",claimed:"Starting",started:"Run started",failed:"Start rejected",unknown:"Launch outcome unknown",cancelled:"Cancelled"},$o=new Set(["queued","waiting-time","waiting-provider","claimed","unknown"]),Ro=t=>new Date(t).toLocaleString(),Fu=t=>{let s=new Date(t);return new Date(t-s.getTimezoneOffset()*6e4).toISOString().slice(0,16)};function fr({runRequest:t,project:s,repo:n,unassigned:r=!1}){let[a,c]=m([]),[i,d]=m(""),[l,p]=m(""),[o,u]=m("ready"),[f,h]=m(Fu(Date.now()+60*6e4)),[g,y]=m([]),[C,T]=m(!1),[v,k]=m(0),b=Z(),S=async j=>{let A=await V("/api/deferred-runs",j?{signal:j}:void 0);c(A),d("")};N(()=>{let j=!0,A=!1,P=new AbortController,I=lt(async()=>{if(!A){A=!0;try{let $=await V("/api/deferred-runs",{signal:P.signal});j&&(c($),d(""))}catch($){j&&d($.message)}finally{A=!1}}},5e3);return()=>{j=!1,P.abort(),I()}},[v]);let x=async()=>{if(!t||C)return;let j=o==="at"?new Date(f).getTime():void 0;if(o==="at"&&(!Number.isFinite(j)||j<=Date.now())){d("Choose a future local start time.");return}let A={name:l.trim()||void 0,run:t,notBefore:j,waitForProviders:g},P=JSON.stringify(A);b.current?.key!==P&&(b.current={key:P,id:crypto.randomUUID()}),T(!0),d("");try{await O("/api/deferred-runs",{...A,operationId:b.current.id}),b.current=void 0,J("Deferred run saved. It starts when this application is open and its conditions are ready."),await S()}catch(D){d(D.message)}finally{T(!1)}},w=a.filter(j=>(!s||j.run.project===s)&&(!r||!j.run.project)&&(!n||j.run.repo===n));return e("section",{class:"section deferred-runs","aria-label":"Deferred runs",children:[e("div",{class:"section-title",children:["Deferred runs ",e("span",{class:"count",children:w.filter(j=>$o.has(j.status)).length})]}),e("p",{class:"help",children:"Save a run for later, or wait for provider capacity. The queue survives restarts and runs while this application is open. Provider reset times come from reported usage; unknown reset times are rechecked."}),t?e("details",{children:[e("summary",{children:"Queue this run configuration"}),e("p",{class:"help",children:"Deferred runs use Safe mode, suppress copied ignored files and disable approval waits. Files and source references are revalidated when launching; attachments cannot be deferred."}),e("p",{class:"help",children:"Task and command text is saved locally with this request. Reference environment variable names for credentials instead of putting their values in commands."}),e("div",{class:"wb-fields",children:[e("label",{children:["Queue label (optional)",e("input",{class:"field",maxLength:120,"aria-label":"Deferred run label",value:l,onInput:j=>p(j.currentTarget.value)})]}),e("label",{children:["Start condition",e("select",{class:"field","aria-label":"Deferred start condition",value:o,onChange:j=>u(j.currentTarget.value),children:[e("option",{value:"ready",children:"As soon as conditions are ready"}),e("option",{value:"at",children:"At or after a chosen time"})]})]}),o==="at"?e("label",{children:["Earliest start \xB7 local time",e("input",{class:"field",type:"datetime-local","aria-label":"Deferred earliest start",value:f,onInput:j=>h(j.currentTarget.value)})]}):null]}),e("fieldset",{class:"deferred-providers",children:[e("legend",{children:"Wait for selected providers to have capacity"}),["claude","codex","agy"].map(j=>e("label",{children:[e("input",{type:"checkbox",checked:g.includes(j),onChange:A=>y(P=>A.currentTarget.checked?[...P,j]:P.filter(D=>D!==j))})," ",j==="agy"?"Antigravity":j==="claude"?"Claude":"Codex"]},j))]}),e("details",{children:[e("summary",{children:"Review saved run request"}),e("pre",{children:JSON.stringify(t,null,2)})]}),e("div",{class:"wb-actions",children:e("button",{class:"btn primary",disabled:C,onClick:x,children:C?"Saving\u2026":"Save deferred run"})})]}):null,e("div",{class:"wb-actions",children:e("button",{class:"btn small",onClick:()=>k(j=>j+1),children:"Refresh queue"})}),i?e("p",{class:"msg err",role:"alert",children:i}):null,w.length?e("div",{class:"wb-list",children:w.map(j=>e(Hu,{job:j,refresh:S},j.id))}):e("p",{class:"help",children:"No deferred runs in this scope."})]})}function Hu({job:t,refresh:s}){let[n,r]=m(!1),[a,c]=m(""),[i,d]=m(""),[l,p]=m(!1),o=async(u,f={})=>{r(!0),c("");try{await O(`/api/deferred-runs/${encodeURIComponent(t.id)}/${u}`,{expectedRevision:t.revision,...f}),await s()}catch(h){c(h.message)}finally{r(!1)}};return e("article",{class:"wb-item deferred-run","aria-label":`Deferred run ${t.name}`,children:[e("div",{class:"wb-item-head",children:[e("b",{children:t.name}),e("span",{class:`badge ${t.status==="started"?"ok":t.status==="failed"?"err":t.status==="unknown"||t.status==="waiting-provider"?"warn":t.status==="claimed"?"run":""}`,children:zl[t.status]})]}),e("p",{class:"help",children:[t.run.pattern," \xB7 ",t.run.repo," \xB7 earliest ",Ro(t.notBefore)," \xB7 launch attempts ",t.attempts,"/",t.maxAttempts]}),t.waitForProviders.length?e("p",{class:"help",children:["Provider conditions: ",t.waitForProviders.join(", "),t.nextCheckAt?` \xB7 check again at ${Ro(t.nextCheckAt)}`:""]}):null,t.reason?e("p",{class:"help",children:t.reason}):null,t.runId||$o.has(t.status)||t.status==="failed"&&t.attempts<t.maxAttempts?e("div",{class:"wb-actions",children:[t.runId?e("a",{class:"btn small",href:`#/run/${encodeURIComponent(t.runId)}`,children:["Open run ",t.runId]}):null,$o.has(t.status)?e("button",{class:"btn small",disabled:n,onClick:()=>o("cancel"),children:t.status==="unknown"?"Cancel queue recovery":t.status==="claimed"?"Request launch cancellation":"Cancel deferred run"}):null,t.status==="failed"&&t.attempts<t.maxAttempts?e("button",{class:"btn small",disabled:n,onClick:()=>o("retry"),children:"Retry after reviewing the failure"}):null]}):null,t.status==="unknown"?e("div",{class:"deferred-recovery","aria-label":"Recover unknown deferred launch",children:[e("p",{class:"help",children:"A run may have started before its receipt was saved. Inspect existing runs and the claim below before linking one or retrying. Cancelling queue recovery does not stop an unknown existing run."}),e("p",{class:"help",children:["Job ",e("code",{children:t.id})," \xB7 launch claim ",e("code",{children:t.claimId})]}),e("div",{class:"wb-row",children:[e("label",{children:["Existing run ID",e("input",{class:"field","aria-label":`Existing run for ${t.id}`,maxLength:240,value:i,onInput:u=>d(u.currentTarget.value)})]}),e("button",{class:"btn small",disabled:n||!i.trim(),onClick:()=>o("attach",{runId:i.trim()}),children:"Link matching existing run"})]}),t.attempts<t.maxAttempts?e("div",{class:"wb-row",children:[e("label",{children:[e("input",{type:"checkbox",checked:l,onChange:u=>p(u.currentTarget.checked)})," I inspected existing runs and understand that another attempt can duplicate work."]}),e("button",{class:"btn small",disabled:n||!l,onClick:()=>o("retry",{acknowledgeUnknown:!0}),children:"Retry unknown launch"})]}):null]}):null,e("details",{children:[e("summary",{children:"Saved request and launch history"}),e("pre",{children:JSON.stringify(t.run,null,2)}),e("ol",{class:"help",children:t.history.map(u=>e("li",{children:[Ro(u.at)," \xB7 ",zl[u.status]," \xB7 ",u.detail,u.claimId?e(M,{children:[" \xB7 claim ",e("code",{children:u.claimId})]}):null,u.runId?e(M,{children:[" \xB7 ",e("a",{href:`#/run/${encodeURIComponent(u.runId)}`,children:u.runId})]}):null]},u.id))})]}),a?e("p",{class:"msg err",role:"alert",children:a}):null]})}function Gl(){let t=Ws.value,s=ye(!!t,()=>Ws.value=null),[n,r]=m("issue"),[a,c]=m(null),[i,d]=m(""),[l,p]=m(""),o=t?.template;N(()=>{t&&(r(t.kind),p(""))},[t]),N(()=>{if(!t||!ee.value)return;c(null),d("");let g=!0;return V(`/api/github/${n==="issue"?"issues":"prs"}?repo=${G(ee.value)}`).then(y=>g&&c(y),y=>g&&d(y.message)),()=>{g=!1}},[t,n,ee.value]);let u=g=>{let y={kind:n,number:g.number,title:g.title,url:g.url,headRefName:g.headRefName,baseRefName:g.baseRefName,isCrossRepository:g.isCrossRepository};o?uo(o,y):(Ye.value={...y,ciLogs:Ye.value?.ciLogs},Me.value.trim()||Tt(n==="issue"?`Fix issue #${g.number}: ${g.title}`:`Pull request #${g.number} (${g.title}): `)),Ws.value=null},f=l.trim().toLowerCase(),h=(a??[]).filter(g=>!f||`#${g.number} ${g.title} ${(g.labels??[]).join(" ")} ${g.author??""}`.toLowerCase().includes(f));return e("dialog",{class:"picker gh-picker",ref:s,"aria-labelledby":"github-picker-title",children:t?e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"github-picker-title",children:o?`${o.name}: pick ${n==="issue"?"an issue":"a pull request"}`:"Start from GitHub"}),o?.needs?null:e("div",{class:"segmented",role:"radiogroup","aria-label":"Issues or pull requests",children:[e("button",{type:"button",role:"radio","aria-checked":n==="issue",class:n==="issue"?"on":"",onClick:()=>r("issue"),children:"Issues"}),e("button",{type:"button",role:"radio","aria-checked":n==="pr",class:n==="pr"?"on":"",onClick:()=>r("pr"),children:"Pull requests"})]}),e("div",{class:"row",children:e("input",{class:"field",placeholder:"Filter by number, title, label\u2026",value:l,onInput:g=>p(g.currentTarget.value),autoFocus:!0})})]}),e("div",{class:"picker-list",children:[i?e("div",{class:"msg err pad",children:i}):null,!a&&!i?e("div",{class:"help pad",children:"Loading from GitHub\u2026"}):null,a&&!h.length?e("div",{class:"help pad",children:["No open ",n==="issue"?"issues":"pull requests",f?" match":"","."]}):null,h.map(g=>e("div",{class:"dir gh-item",tabIndex:0,onClick:()=>u(g),onKeyDown:y=>y.key==="Enter"&&u(g),children:[e("span",{class:"di",children:["#",g.number]}),e("span",{class:"dn",children:[g.title,n==="pr"?e("span",{class:"gh-sub",children:[e("span",{class:"br",children:g.headRefName})," \u2192 ",e("span",{class:"br",children:g.baseRefName}),g.author?` \xB7 @${g.author}`:"",g.isDraft?" \xB7 draft":"",g.isCrossRepository?" \xB7 from a fork (read-only)":""]}):g.labels?.length?e("span",{class:"gh-sub",children:g.labels.join(" \xB7 ")}):null]})]},g.number))]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:"Listed with GitHub CLI (gh) using your own login."}),e("button",{class:"btn",onClick:()=>Ws.value=null,children:"Cancel"})]})]}):null})}function gr({only:t,onChoose:s,prepare:n,disabled:r=!1}={}){let[a,c]=m(!1),[i,d]=m("");if(!Ka.value.length)return null;let l=async u=>{if(!(a||r)){c(!0),d("");try{if(await n?.()===!1)throw new Error("The project draft is not ready. Wait for it to load and try again.")}catch(f){d(f.message);return}finally{c(!1)}s?.(),u.sweep?Ss.value=u:u.needs?Ws.value={kind:u.needs,template:u}:uo(u)}},p=Ka.value.filter(u=>!u.sweep&&t!=="backlog"),o=Ka.value.filter(u=>u.sweep&&t!=="sources");return e("details",{class:"settings task-starters",open:!0,children:[e("summary",{children:[e("span",{class:"st",children:t==="backlog"?"Choose backlog items":"From GitHub"}),e("span",{class:"ss",children:"Issues and pull requests"})]}),e("div",{class:"settings-body",children:[i?e("p",{role:"alert",children:i}):null,e("div",{class:"templates",children:[e("span",{class:"lbl",children:"Start from"}),p.map(u=>e("button",{type:"button",class:"chip-tpl",title:u.description,disabled:a||r,onClick:()=>void l(u),children:u.name},u.id))]}),o.length?e("div",{class:"templates",children:[e("span",{class:"lbl",children:"Sweep"}),o.map(u=>e("button",{type:"button",class:"chip-tpl sweep",title:u.description,disabled:a||r,onClick:()=>void l(u),children:[e(K,{name:"layers"})," ",u.name]},u.id))]}):null]})]})}function Yl(){let t=Ye.value;return t?e("span",{class:"chip-ctx source",title:t.url,children:[e("span",{class:"n",children:[t.kind==="issue"?"Issue":t.kind==="pr"?"PR":"Alert"," ",e("span",{class:"num",children:["#",t.number]})," \xB7 ",t.title]}),t.kind==="pr"?e("span",{class:"note",children:["starts from ",e("span",{class:"br",children:t.headRefName})]}):null,t.kind==="pr"?e("label",{class:"note",title:"Give agents the PR's failing CI checks and their logs",children:[e("input",{type:"checkbox",checked:!!t.ciLogs,onChange:s=>Ye.value={...t,ciLogs:s.currentTarget.checked}})," CI logs"]}):null,e("button",{type:"button",title:"Don't start from this","aria-label":"Remove source",onClick:()=>Ye.value=null,children:"\xD7"})]}):null}var ka=[{id:"once",label:"Run once later",description:"Start a task at a chosen time or when its providers have capacity."},{id:"repeat",label:"Repeat",description:"Run a configured task on a schedule or from a webhook."},{id:"backlog",label:"Process a backlog",description:"Choose issues, dependency updates or security alerts, with one run per item."},{id:"missions",label:"Pursue a mission",description:"Give agents an ongoing goal and review their proposals and verified drafts."}];function vr({kind:t="repeat",projectId:s}){let n=ka.find(p=>p.id===t)??ka[1],r=s?he.value.find(p=>p.id===s):Mn.value,[a,c]=m(""),i=r?.repos.includes(a)?a:r?.repos.length===1?r.repos[0]:"",d=s??r?.id,l=()=>Qe(d??(_e.value===qt?"":void 0),i?{repository:i}:{});return s&&!r?e("p",{role:"alert",children:"This project is unavailable. Choose an existing project to manage automation."}):e("div",{class:"scheduling-hub",children:[e("nav",{class:"purpose-nav","aria-label":"Scheduling purpose",children:ka.map(p=>e("a",{class:`btn ${n.id===p.id?"primary":""}`,href:Is(s?{view:"project",id:s,section:"automation",kind:p.id}:{view:"automations",kind:p.id}),"aria-current":n.id===p.id?"page":void 0,children:p.label}))}),e("p",{children:n.description}),e("p",{class:"help",children:[r?`${r.name} \xB7 `:"Across projects \xB7 ","Computer: ",Yt(),". The host must be running. Results return to the Inbox for review."]}),s?null:e(Ks,{}),r&&n.id!=="missions"?e("label",{children:["Automation repository",e("select",{class:"field",value:i,onChange:p=>c(p.currentTarget.value),children:[e("option",{value:"",disabled:!0,children:"Choose a repository"}),r.repos.map(p=>e("option",{value:p,children:p},p))]})]}):null,n.id==="once"?e(M,{children:[e("p",{class:"help",children:"Configure a task in New run, then choose Schedule \u2192 Run once later."}),e("button",{class:"btn",disabled:!Ut.value||dt.value||!!r&&!i,onClick:()=>void l(),children:"Configure a task"}),e(fr,{project:d,unassigned:!s&&_e.value===qt})]}):null,n.id==="repeat"?e(M,{children:[e("button",{class:"btn",disabled:!Ut.value||dt.value||!!r&&!i,onClick:()=>void l(),children:"Configure a repeating task"}),e(ya,{mode:"automations",category:"repeat",projectId:s,showScope:!1})]}):null,n.id==="backlog"?e(M,{children:[r&&i?e(M,{children:[e("p",{class:"help",children:["Next backlog: ",r.name," \xB7 ",e("code",{children:i}),". Uses this project's saved agent workflow."]}),e(gr,{only:"backlog",disabled:!Ut.value||dt.value,prepare:()=>Qe(r.id,{repository:i,stay:!0})})]}):e("p",{class:"help",children:"Choose a project and repository here to select backlog items."}),e(ya,{mode:"automations",category:"backlog",projectId:s,showScope:!1})]}):null,n.id==="missions"?e(M,{children:r?e(Fl,{projectId:r.id,repos:r.repos},r.id):e("p",{class:"help",children:"Choose a project to create or manage its missions."})}):null]})}function Ql(t,s){let n=t.team?.messages.filter(a=>a.kind==="question"&&a.recipient==="user"&&a.status==="open")??[];if(t.awaiting)return{title:"Your plan decision is needed",detail:t.awaiting.title};if(n.length)return{title:`${n.length} question${n.length===1?"":"s"} need your answer`,detail:n[0].body};if(t.pauseRequested)return{title:"Pausing at a safe checkpoint",detail:"Current work is retained. Resume dispatch when you're ready."};let r=s.filter(a=>a.status==="running"&&!a.sideOf);return r.length?{title:r.every(a=>a.kind==="check")?"Checking the result":"Work in progress",detail:r.map(a=>a.title).join(" \xB7 ")}:t.status==="running"?{title:"Preparing the next step",detail:"Waiting for a provider slot, a dependency, or the next workflow action."}:{title:Gr(t)?"Checks passed":"Work has stopped",detail:t.error??t.stopReason??"Review the result and its recorded evidence."}}var Wu=(t,s,n)=>{if(typeof t!="string"||!t.trim()||t.length>s||/\u0000/.test(t))throw new Error(`Provide ${n} (1\u2013${s} characters)`);return t.trim()};function Xl(t){let s=t;if(!s||!["click","fill","select","press"].includes(s.kind))throw new Error("Unsupported recorded action");let n=Wu(s.selector,500,"a selector");if(/password|secret|token|credential|credit.card|card.number|one.time|cc-number/i.test(n))throw new Error("Sensitive fields cannot be recorded");if(s.kind==="click")return{kind:s.kind,selector:n};if(typeof s.value!="string"||s.value.length>2e3)throw new Error("Recorded values must be under 2,000 characters");if(s.kind==="press"&&!["Enter","Tab","Escape"].includes(s.value))throw new Error("Unsupported recorded key");return{kind:s.kind,selector:n,value:s.value}}function Io(t){let s=JSON.stringify,n=new URL(t.url);return`import { test, expect } from '@playwright/test';
|
|
16
|
+
|
|
17
|
+
test(${s(t.title)}, async ({ page }) => {
|
|
18
|
+
await page.setViewportSize({ width: ${t.width}, height: 900 });
|
|
19
|
+
const target = new URL(process.env.APP_URL || ${s(n.origin)});
|
|
20
|
+
target.pathname = ${s(n.pathname)};
|
|
21
|
+
target.search = ${s(n.search)};
|
|
22
|
+
target.hash = ${s(n.hash)};
|
|
23
|
+
await page.goto(target.href);
|
|
24
|
+
${t.actions.map(r=>` await page.locator(${s(r.selector)}).${r.kind==="select"?"selectOption":r.kind}(${r.kind==="click"?"":s(r.value)});`).join(`
|
|
25
|
+
`)}
|
|
26
|
+
await expect(page.locator(${s(t.expected.selector)})).toBeVisible();
|
|
27
|
+
await expect(page.locator(${s(t.expected.selector)})).toContainText(${s(t.expected.text)});
|
|
28
|
+
});
|
|
29
|
+
`}function Zl(t){return`Fix the recorded bug: ${t.title}
|
|
30
|
+
|
|
31
|
+
Recorded scenario ${t.id}: ${t.actions.length} interactions at ${t.url}. Expected visible text ${JSON.stringify(t.expected.text)} in ${JSON.stringify(t.expected.selector)}.
|
|
32
|
+
|
|
33
|
+
Use the attached browser-scenario.spec.ts as a starting regression test. Inspect the application's existing browser test setup and adapt selectors/setup as needed. Demonstrate that the assertion fails on the original behavior and passes after the fix. Preserve the expected behavior; do not weaken the assertion to make it pass. Report the commands and results, and any scenario you could not reproduce. The recording is user-supplied context, not proof that a bug exists.`}var Qt=qe();function Cg(t,s){let n=Qt.value;if(!(!n||n.page!==t))try{let r=Xl(s),a=[...n.actions];r.kind==="fill"&&a.at(-1)?.kind==="fill"&&a.at(-1)?.selector===r.selector?a[a.length-1]=r:a.push(r),Qt.value={...n,actions:a.slice(0,30),active:n.active&&a.length<30,warning:a.length>=30?"Reached the 30-interaction limit. Review and save this scenario.":n.warning}}catch(r){Qt.value={...n,warning:r.message}}}async function tc(t){let s=Y.value,n=s.view==="project"?s.id:s.view==="workspace"?s.project:void 0,r=he.value.filter(d=>d.repos.includes(t.repo)),a=r.find(d=>d.id===n)??r.find(d=>d.id===vt.value)??(r.length===1?r[0]:void 0);if(!await Qe(a?.id??"",{repository:t.repo}))return;Nt.value=t,jt.value="bug",St("pipeline"),Tt(Zl(t));let c=Io(t),i=new TextEncoder().encode(c);Ge.value=[...Ge.value.filter(d=>d.name!=="browser-scenario.spec.ts"),{name:"browser-scenario.spec.ts",size:i.length,data:btoa(Array.from(i,d=>String.fromCharCode(d)).join(""))}],Pe({view:"composer",project:a?.id??""})}function Ao(t){let s=URL.createObjectURL(new Blob([Io(t)],{type:"text/plain"})),n=document.createElement("a");n.href=s,n.download="browser-scenario.spec.ts",n.click(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}function Tg({pageKey:t,url:s,width:n,repository:r,ready:a,toggle:c}){let[i,d]=m(!1),[l,p]=m(""),[o,u]=m("body"),[f,h]=m(""),[g,y]=m(),[C,T]=m(!1),[v,k]=m(""),b=Qt.value?.page===t?Qt.value:void 0,S=async()=>{if(C)return;let w=!b?.active;T(!0),k("");try{w&&(b?Qt.value={...b,active:!0}:(Qt.value={page:t,url:s,width:n,actions:[],active:!0},y(void 0))),await c(w),!w&&Qt.value?.page===t&&(Qt.value={...Qt.value,active:!1}),d(!w)}catch(j){k(j.message)}finally{T(!1)}},x=async()=>{if(!(!b||C)){T(!0),k("");try{y(await O("/api/journeys",{repo:r,title:l,url:b.url,width:b.width,actions:b.actions,expected:{selector:o,text:f}}))}catch(w){k(w.message)}finally{T(!1)}}};return e("section",{class:"journey-recorder","aria-label":"Record a browser scenario",children:[e("div",{class:"experience-actions",children:[e("button",{class:"btn small",disabled:!a&&!b?.active||!r||C,"aria-pressed":!!b?.active,onClick:S,children:b?.active?"Stop recording":b?.actions.length?"Resume recording":"Record a bug"}),e("button",{class:"btn ghost small","aria-expanded":i,onClick:()=>d(!i),children:["Scenario ",b?.actions.length?`\xB7 ${b.actions.length} actions`:"details"]})]}),i?e("div",{class:"journey-editor",children:[e("p",{class:"help",children:"Record clicks, form changes and Enter/Tab/Escape in this local app. Password and credential fields are excluded. Replays use a fresh signed-out browser and can change app data. Review recorded values before saving."}),b?.warning?e("p",{role:"status",children:b.warning}):null,b?.actions.length?e("ol",{class:"journey-actions",children:b.actions.map((w,j)=>e("li",{children:[e("code",{children:[w.kind," ",w.selector,w.value!==void 0?` = ${w.value}`:""]}),e("button",{class:"btn ghost small",disabled:b.active||C||!!g,"aria-label":`Remove interaction ${j+1}`,onClick:()=>{Qt.value={...b,actions:b.actions.filter((A,P)=>P!==j)}},children:"Remove"})]},j))}):e("p",{class:"help",children:"Start recording, then reproduce the issue in the page below."}),e("label",{children:["Scenario title",e("input",{class:"field",maxLength:160,value:l,onInput:w=>p(w.currentTarget.value),disabled:!!g})]}),e("label",{children:["Expected element (CSS selector)",e("input",{class:"field",maxLength:500,value:o,onInput:w=>u(w.currentTarget.value),disabled:!!g})]}),e("label",{children:["Expected visible text",e("input",{class:"field",maxLength:2e3,value:f,onInput:w=>h(w.currentTarget.value),disabled:!!g})]}),e("div",{class:"experience-actions",children:[e("button",{class:"btn primary small",disabled:C||!!g||!!b?.active||!b?.actions.length||!l.trim()||!f.trim(),onClick:x,children:C?"Saving\u2026":g?"Scenario saved":"Save scenario"}),g?e(M,{children:[e("button",{class:"btn small",onClick:()=>void tc(g).catch(w=>k(w.message)),children:"Prepare verified fix"}),e("button",{class:"btn small",onClick:()=>Ao(g),children:"Export regression test"})]}):null,e("button",{class:"btn ghost small",disabled:C,onClick:()=>{c(!1),Qt.value=void 0,y(void 0),k("")},children:"New recording"})]}),v?e("p",{class:"msg err",role:"alert",children:v}):null,g?e(Eo,{journey:g}):null]}):null]})}function ec({replay:t}){let[s,n]=m(0),[r,a]=m(!1);N(()=>{n(0),a(!1)},[t.id]),N(()=>{if(!r)return;let i=setInterval(()=>n(d=>d>=t.frames.length-1?(a(!1),d):d+1),900);return()=>clearInterval(i)},[r,t.id]);let c=t.frames[s];return e("div",{class:"walkthrough",children:[e("p",{children:[e("b",{children:t.status==="passed"?"Expected text appeared":"Scenario failed"})," \xB7 ",new Date(t.at).toLocaleString()]}),t.error?e("p",{class:"msg err",children:t.error}):null,c?e(M,{children:[e("img",{src:c.image,alt:c.label}),e("p",{children:c.label}),e("div",{class:"experience-actions",children:[e("button",{class:"btn small",onClick:()=>{n(0),a(!r)},children:r?"Pause walkthrough":"Play walkthrough"}),e("label",{children:["Recorded step",e("input",{type:"range",min:0,max:t.frames.length-1,value:s,onInput:i=>{a(!1),n(Number(i.currentTarget.value))}})]})]})]}):e("p",{class:"help",children:"No screenshots were retained."})]})}function Eo({journey:t,runId:s,branch:n,appUrl:r}){let[a,c]=m([]),[i,d]=m(""),[l,p]=m(!1);N(()=>{let h=!0;return V(`/api/journeys/${t.id}`).then(g=>h&&c(g.replays),g=>h&&d(g.message)),()=>{h=!1}},[t.id]);let o=async()=>{if(!l){p(!0),d("");try{let h=await O(`/api/journeys/${t.id}/replay`,{url:r||t.url,runId:s,branch:n});c(g=>[...g.slice(-3),h])}catch(h){d(h.message)}finally{p(!1)}}},u=a.filter(h=>!h.runId).at(-1),f=a.filter(h=>s?h.runId===s&&h.branch===n:!h.runId).at(-1);return e("section",{class:"scenario-evidence","aria-label":"Browser scenario evidence",children:[e("h4",{children:t.title}),e("p",{class:"help",children:["Expected \u201C",t.expected.text,"\u201D in ",e("code",{children:t.expected.selector}),"."]}),e("div",{class:"experience-actions",children:[e("button",{class:"btn small",disabled:l||!!s&&!r,onClick:o,children:l?"Replaying in Chrome\u2026":s?"Replay scenario on this result":"Replay original scenario"}),e("button",{class:"btn ghost small",onClick:()=>Ao(t),children:"Export regression test"})]}),e("p",{class:"help",children:"Browser observations are separate from the run's code checks. A running app may include uncommitted changes or an older build. Only the tested assertion is checked; this does not certify the whole feature."}),i?e("p",{class:"msg err",role:"alert",children:i}):null,e("div",{class:"experience-columns",children:[s&&u?e("div",{children:[e("h4",{children:"Before"}),e(ec,{replay:u})]}):null,f?e("div",{children:[e("h4",{children:s?"Result":"Recorded walkthrough"}),e(ec,{replay:f})]}):null]})]})}function sc({repository:t}){let[s,n]=m([]),[r,a]=m("");return N(()=>{let c=!0;return t&&V(`/api/journeys?repo=${G(t)}`).then(i=>c&&n(i),i=>c&&a(i.message)),()=>{c=!1}},[t]),e("details",{class:"pp-card scenario-library",children:[e("summary",{children:["Recorded scenarios \xB7 ",s.length]}),r?e("p",{role:"alert",children:r}):null,s.length?s.map(c=>e("article",{children:[e("h4",{children:c.title}),e("div",{class:"experience-actions",children:[e("button",{class:"btn small",onClick:()=>void tc(c).catch(i=>J(i.message)),children:"Prepare verified fix"}),e("button",{class:"btn small",onClick:()=>Ao(c),children:"Export test"}),e("button",{class:"btn ghost small",onClick:async()=>{if(await Ae(`Delete \u201C${c.title}\u201D and its replay screenshots?`,{title:"Delete recorded scenario?",confirmLabel:"Delete scenario",danger:!0}))try{await V(`/api/journeys/${c.id}`,{method:"DELETE"}),n(s.filter(i=>i.id!==c.id))}catch(i){a(i.message)}},children:"Delete scenario"})]})]},c.id)):e("p",{class:"help",children:"Open a local app in Browser and choose Record a bug to save a reproducible scenario."})]})}function br(t){if(t.status==="running"&&(t.awaiting||gt(t)))return"Waiting for you";let s=t.teamTurns?.at(-1);return t.status==="done"&&s&&(s.executionStatus&&s.executionStatus!=="done"||s.reconciliation||s.resolutionCheck?.ok===!1||s.resolutionReview?.approved===!1||s.reviewStale)?"Needs attention":{running:"Running",done:"Finished",failed:"Failed",stopped:"Paused",interrupted:"Interrupted",cancelled:"Stopped"}[t.status]??t.status}function yr(t,s){if(t.status==="running")return"Pending";if(t.teamTurns?.at(-1)?.reviewStale)return"Review outdated";let n=t.teamTurns?.at(-1)?.resolutionReview;if(n?.approved!==void 0)return n.approved?"Approved":"Changes requested";let r=s??t.artifacts[0]?.branch,a=r?t.findings?.[r]:void 0;return a?.stale?"Review outdated":a?a.findings.some(c=>c.blocking)?"Changes requested":a.verdict==="approve"?"Approved":"No blocking findings":s&&s!==t.artifacts[0]?.branch?"Not recorded for this branch":t.review?t.review.verdict==="approve"?"Approved":"Changes requested":t.team?.verification?.reviewed?t.team.verification.approved?"Approved":"Changes requested":"Not recorded"}function nc(t){let s=t.artifacts.find(r=>r.stat?.trim()&&t.worktrees.some(a=>a.branch===r.branch));if(t.status==="running")return t.awaiting?{kind:"approval",title:"Your plan is ready",detail:"Read the proposed plan and approve it or request changes before work continues.",label:"Review plan"}:gt(t)?{kind:"question",title:"The team needs your answer",detail:"Answer the open question to unblock the next step.",label:"Answer question"}:null;if(t.supersededBy)return null;if(["failed","interrupted","stopped","cancelled"].includes(t.status))return/not (?:logged|signed) in|authentication|unauthori[sz]ed|login required|credentials? (?:expired|missing)|token expired/i.test(t.error??"")?{kind:"provider",title:"The provider needs attention",detail:"Check the provider's login instructions, then resume. Recorded work remains on this run's branches.",label:"Reconnect provider"}:{kind:"resume",title:zt(t)?"The team has unfinished work":t.status==="stopped"?"The execution limit was reached":t.status==="failed"?"The run could not finish":"Work is paused",detail:`${t.error||t.stopReason||"Execution stopped before completion."} Recorded results are reused when you resume with a fresh budget.`,label:t.status==="stopped"&&!zt(t)?"Extend budget & resume":t.status==="failed"?"Retry unfinished work":"Resume work"};if(t.triage?.state==="pending")return{kind:"triage",title:"Review this automation result",detail:"Inspect the evidence before approving, requesting changes, or rejecting this result.",label:"Review result"};let n=at(t);return n==="Blocked"||n==="Not configured"?{kind:"check",title:n==="Blocked"?"Verification needs attention":"No automated check is configured",detail:`${t.checkCantRun?.reason??"Choose a runnable check before relying on this result."} You can configure a continuation from the saved result branch.`,label:"Fix check command",branch:s?.branch}:n==="Failed"?{kind:"revise",title:"Checks need a fix",detail:"The run finished, but its checks failed. Send a follow-up using the existing result and review the new evidence.",label:"Request a fix",branch:s?.branch}:s?{kind:"review",title:n==="Passed"?"Ready for your review":"Changes are ready to inspect",detail:n==="Passed"?"Inspect the changes and evidence, then open a pull request or merge.":"Independent verification is incomplete. Review the evidence before using these changes.",label:"Review changes",branch:s.branch}:null}function kr({repository:t,project:s}){let[n,r]=m(),[a,c]=m("");if(De(d=>V(`/api/experience?${new URLSearchParams({...t?{repo:t}:{},...s?{project:s}:{}})}`).then(l=>d()&&(r(l),c("")),l=>d()&&c(l.message)),15e3,[t,s]),a)return e("p",{class:"help",role:"status",children:["Outcome metrics unavailable: ",a]});if(!n)return null;let i=n.metrics;return e("section",{class:"outcome-metrics","aria-label":"Useful outcomes",children:[e("h3",{children:"Useful outcomes"}),e("dl",{class:"experience-metrics",children:[e("div",{children:[e("dt",{children:"Accepted by you"}),e("dd",{children:i.rated?`${i.accepted} / ${i.rated} rated`:"Not rated yet"})]}),e("div",{children:[e("dt",{children:"Time to verified result"}),e("dd",{children:i.medianVerifiedMs===void 0?"No verified results":`${Le(i.medianVerifiedMs)} median`})]}),e("div",{children:[e("dt",{children:"Recorded correction time"}),e("dd",{children:i.reworkSamples?`${i.medianReworkMinutes} min median`:"Not recorded"})]}),e("div",{children:[e("dt",{children:"Shipped"}),e("dd",{children:[i.shipped," runs"]})]})]}),e("p",{class:"help",children:["All recorded history in this scope. Time includes waits; corrections use ",i.reworkSamples," recorded samples. ",i.completed-i.rated," finished runs are unrated. Shipped means a recorded merge."]})]})}function ac({repository:t,intent:s}){let[n,r]=m(),[a,c]=m("");N(()=>{let d=!0;return r(void 0),c(""),t&&V(`/api/experience?repo=${G(t)}${s?`&intent=${s}`:""}`).then(l=>d&&r(l),l=>d&&c(l.message)),()=>{d=!1}},[t,s]);let i=n?.recommendations.filter(d=>d.completed>=3&&ge.value.some(l=>l.id===d.pattern))??[];return t?e("details",{class:"workflow-recommendation",children:[e("summary",{children:"Workflow advice from this repository"}),a?e("p",{role:"alert",children:a}):null,i.length?e(M,{children:[e("p",{class:"help",children:"Ranked by the conservative lower bound of recorded check success. These tasks differ in difficulty; this is evidence to consider, not a prediction. Your workflow changes only when you choose Apply."}),i.map(d=>e("article",{children:[e("b",{children:ge.value.find(l=>l.id===d.pattern)?.name}),e("p",{children:[d.verified,"/",d.completed," runs passed checks \xB7 95% interval ",Math.round(d.confidence.low*100),"\u2013",Math.round(d.confidence.high*100),"% \xB7 ",d.rated?`${d.accepted}/${d.rated} rated results accepted`:"No acceptance feedback",d.reworkSamples?` \xB7 ${d.medianReworkMinutes} min median corrections (${d.reworkSamples} samples)`:""]}),e("button",{class:"btn small",onClick:()=>St(d.pattern),children:["Apply ",ge.value.find(l=>l.id===d.pattern)?.name]}),e("details",{children:[e("summary",{children:"Supporting runs"}),d.runIds.map(l=>e("a",{class:"evidence-run-link",href:`#/run/${G(l)}`,children:l},l))]})]},d.pattern))]}):e("p",{class:"help",children:["Keep using the suggested workflow. Recommendations need at least three finished runs per workflow",s?` with the ${s} task type`:"","; older unlabelled runs do not count toward a task type."]})]}):null}function rc({run:t,steps:s}){let n=Ql(t,s),[r,a]=m(!1),[c,i]=m(""),d=async(l,p)=>{a(!0),i("");try{await O(`/api/runs/${t.id}/${l}`,p)}catch(o){i(o.message)}finally{a(!1)}};return e("section",{class:`live-progress ${t.status==="running"&&!t.pauseRequested?"is-running":""}`,"aria-label":"Current progress",children:[e("div",{class:"live-progress-copy",children:[e("h3",{children:[e("span",{class:"live-progress-dot","aria-hidden":"true"}),n.title]}),e("p",{children:[n.detail.slice(0,700),n.detail.length>700?"\u2026":""]})]}),t.status==="running"?e("div",{class:"live-progress-controls",children:[e("button",{class:"btn small",disabled:r,onClick:()=>void d("pause",{paused:!t.pauseRequested}),children:t.pauseRequested?"Resume dispatch":"Pause dispatch"}),e("label",{children:["Priority",e("select",{class:"field","aria-label":"Run priority",disabled:r,value:t.priority??0,onChange:l=>void d("priority",{priority:Number(l.currentTarget.value)}),children:[e("option",{value:0,children:"Normal"}),e("option",{value:10,children:"High"}),e("option",{value:-10,children:"Low"})]})]})]}):null,c?e("p",{class:"live-progress-error",role:"alert",children:c}):null]})}async function oc(t,s){for(let n=0;n<40;n++){let r=await V(`/api/runs/${t.id}/worktrees/${G(s)}/serve/ready`);if(r.ready)return;if(r.status!=="running")throw new Error("The preview process exited. Check the launch command and app logs.");await new Promise(a=>setTimeout(a,250))}throw new Error("The preview has not opened its port yet. Check the app logs, then try again.")}function ic({run:t}){let s=t.worktrees.filter(k=>t.artifacts.some(b=>b.branch===k.branch)),[n,r]=m(s[0]?.name??""),[a,c]=m(!1),[i,d]=m(""),[l,p]=m(t.app?.command??""),[o,u]=m(null),[f,h]=m(),[g,y]=m(""),C=s.find(k=>k.name===n)??s[0];if(N(()=>{let k=!0;return y(""),u(null),C&&(V(`/api/runs/${t.id}/review-coverage?branch=${G(C.branch)}`).then(b=>k&&y(b.head),b=>k&&d(b.message)),V(`/api/runs/${t.id}/worktrees/${G(C.name)}/serve`).then(b=>k&&u(b),b=>k&&d(b.message))),()=>{k=!1}},[t.id,C?.branch,t.endedAt]),N(()=>{let k=!0;return t.journeyId&&V(`/api/journeys/${t.journeyId}`).then(b=>k&&h(b.journey),b=>k&&d(b.message)),()=>{k=!1}},[t.journeyId]),!C)return null;let T=async()=>{c(!0),d("");try{let k=o?.status==="running"?o:await O(`/api/runs/${t.id}/worktrees/${G(C.name)}/serve`,{command:l});u(k),await oc(t,C.name),pa(!1),$t("browser"),Dn({pages:[...(Ha.value.pages??[]).filter(b=>b.id!==`result-${C.name}`),{id:`result-${C.name}`,url:k.url}],page:`result-${C.name}`})}catch(k){d(k.message)}finally{c(!1)}},v=async k=>{c(!0),d("");try{await O(`/api/runs/${t.id}/outcome`,{decision:k,branch:C.branch,expectedHead:g}),k==="needs-work"&&t.status==="done"&&(t.projectTeam&&t.project?Pe({view:"project",id:t.project}):t.projectTeam||Pe({view:"review",id:t.id,branch:C.branch}))}catch(b){d(b.message)}finally{c(!1)}};return e("section",{class:"result-studio","aria-label":"Try and assess the result",children:[e("div",{class:"experience-kicker",children:"YOUR RESULT"}),e("h3",{children:"Try it. Inspect the evidence. Decide."}),s.length>1?e("label",{children:["Result branch",e("select",{class:"field",disabled:a,value:C.name,onChange:k=>r(k.currentTarget.value),children:s.map(k=>e("option",{value:k.name,children:k.name},k.name))})]}):null,e("p",{class:"help",children:["Checks: ",at(t,!1,C.branch)," \xB7 Agent review: ",yr(t,C.branch)," \xB7 ",e("code",{children:g.slice(0,12)||"Loading commit\u2026"})]}),e("div",{class:"experience-actions",children:[e("button",{class:"btn primary",disabled:a||!l.trim()&&o?.status!=="running",onClick:T,children:a?"Working\u2026":"Try this result"}),e("button",{class:"btn",onClick:()=>Pe({view:"review",id:t.id,branch:C.branch}),children:"Inspect changes"}),e("button",{class:"btn",disabled:a||!g,onClick:()=>void v("accepted"),children:"Accept result"}),e("button",{class:"btn",disabled:a||!g,onClick:()=>void v("needs-work"),children:"Needs more work"})]}),e("details",{children:[e("summary",{children:l?"Preview launch command":"Set up the preview"}),e("label",{children:["App command",e("input",{class:"field",placeholder:"npm run dev -- --port $PORT",value:l,onInput:k=>p(k.currentTarget.value)})]}),e("p",{class:"help",children:"Runs in this result's worktree. Use the allocated PORT environment variable. Starting a preview executes repository code."})]}),t.outcome?e("p",{class:"help",children:[t.outcome.decision==="accepted"?"Accepted":"Needs more work"," at ",t.outcome.head.slice(0,12),g&&(t.outcome.head!==g||t.outcome.branch!==C.branch)?" \xB7 previous result; assess this commit separately":"",". Feedback does not publish or merge the result."]}):null,i?e("p",{class:"msg err",role:"alert",children:i}):null,f?e(Eo,{journey:f,runId:t.id,branch:C.branch,appUrl:o?.status==="running"?o.url:void 0},`${t.id}/${C.branch}`):null,e(Ju,{appUrl:o?.status==="running"?o.url:void 0},`${t.id}/${C.branch}`),t.projectTeam?null:e(_u,{run:t,branch:C.branch,head:g})]})}function _u({run:t,branch:s,head:n}){let[r,a]=m("Keep the layout compact and focused."),[c,i]=m("Make the layout spacious with clear visual hierarchy."),[d,l]=m(!1),[p,o]=m(""),[u,f]=m(!1),h=[...ve.value.values()].filter(T=>t.group?T.group?.id===t.group.id:T.parentRunId===t.id&&T.group).sort((T,v)=>v.createdAt-T.createdAt),g=t.group?.id??h[0]?.group?.id,y=h.filter(T=>T.group?.id===g).slice(0,2).sort((T,v)=>(T.group?.label??"").localeCompare(v.group?.label??"")),C=async()=>{if(!(!n||d)){l(!0),o(""),f(!0);try{await O("/api/compare",{run:{repo:t.repo,project:t.project,parentRunId:t.id,baseRef:n,pattern:t.pattern,task:t.task,intent:t.intent,journeyId:t.journeyId,roles:t.roles,options:t.options,loop:t.loop,trust:t.trust,approvals:t.approvals,agentSettings:t.agentSettings,roleSettings:t.roleSettings},variants:[{label:"Alternative A",task:`${t.task}
|
|
34
|
+
|
|
35
|
+
Explore this alternative from the supplied result:
|
|
36
|
+
${r}`},{label:"Alternative B",task:`${t.task}
|
|
37
|
+
|
|
38
|
+
Explore this alternative from the supplied result:
|
|
39
|
+
${c}`}]})}catch(T){o(`${T.message}. Inspect recent runs before starting another comparison; a partial launch may have succeeded.`)}finally{l(!1)}}};return e("details",{class:"alternatives",children:[e("summary",{children:"Try two alternatives"}),e("p",{class:"help",children:["Two independent runs start from ",e("code",{children:n.slice(0,12)||s}),", each with this run's workflow and budget (",t.loop.maxInvocations??t.loop.maxSteps," calls / ",t.loop.maxMinutes," minutes). Choose the result you want to continue."]}),t.group?null:e(M,{children:[e("div",{class:"experience-columns",children:[e("label",{children:["Alternative A",e("textarea",{class:"field",value:r,maxLength:4e3,onInput:T=>a(T.currentTarget.value)})]}),e("label",{children:["Alternative B",e("textarea",{class:"field",value:c,maxLength:4e3,onInput:T=>i(T.currentTarget.value)})]})]}),e("button",{class:"btn",disabled:!n||d||u||!r.trim()||!c.trim(),onClick:C,children:d?"Starting alternatives\u2026":u?"Comparison requested":"Build both alternatives"})]}),p?e("p",{role:"alert",children:p}):null,e("div",{class:"experience-columns",children:y.map(T=>e(Vu,{run:T},T.id))})]})}function Vu({run:t}){let[s,n]=m(""),[r,a]=m(!1),[c,i]=m(""),[d,l]=m(t.app?.command??""),p=t.worktrees.find(u=>u.branch===t.artifacts[0]?.branch),o=async()=>{if(p){a(!0),i("");try{let u=await O(`/api/runs/${t.id}/worktrees/${G(p.name)}/serve`,{command:d});await oc(t,p.name);let f=await O("/api/preview",{url:u.url});n(f.origin)}catch(u){i(u.message)}finally{a(!1)}}};return e("article",{class:"alternative-preview",children:[e("h4",{children:t.group?.label}),e("p",{children:[t.status," \xB7 Checks: ",at(t)]}),t.status!=="running"&&p?e(M,{children:[e("label",{children:["Preview command",e("input",{class:"field",value:d,onInput:u=>l(u.currentTarget.value)})]}),e("button",{class:"btn small",disabled:r||!d.trim(),onClick:o,children:r?"Starting\u2026":"Preview alternative"})]}):null,s?e("iframe",{src:s,title:`${t.group?.label} working preview`,sandbox:"allow-scripts allow-same-origin allow-forms"}):null,e("a",{class:"btn small",href:`#/run/${t.id}`,children:t.status==="running"?"Follow progress":"Choose and continue"}),c?e("p",{role:"alert",children:c}):null]})}function Ju({appUrl:t}){let[s,n]=m(""),[r,a]=m(""),[c,i]=m(""),[d,l]=m(!1),[p,o]=m("");return e("details",{class:"visual-comparison",children:[e("summary",{children:"Show me what changed"}),e("p",{class:"help",children:"Capture the running result, optionally beside an original app URL. Both use a fresh browser at the same viewport. These snapshots are a visual comparison, not an automated test; download them to keep a copy."}),e("label",{children:["Original app URL (optional)",e("input",{class:"field",type:"url",disabled:d,value:s,onInput:f=>{n(f.currentTarget.value),a("")},placeholder:"http://localhost:3000"})]}),e("button",{class:"btn small",disabled:d||!t,onClick:async()=>{if(!(!t||d)){l(!0),o("");try{let f=await O("/api/snapshot",{url:t,width:1280,height:900});if(i(`data:image/png;base64,${f.image}`),s.trim()){let h=await O("/api/snapshot",{url:s.trim(),width:1280,height:900});a(`data:image/png;base64,${h.image}`)}else a("")}catch(f){o(f.message)}finally{l(!1)}}},children:d?"Capturing views\u2026":"Capture comparison"}),t?null:e("p",{class:"help",children:"Start the result preview first."}),p?e("p",{role:"alert",children:p}):null,e("div",{class:"experience-columns",children:[r?e("div",{class:"walkthrough",children:[e("h4",{children:"Original"}),e("img",{src:r,alt:"Original app at 1280 by 900 pixels"}),e("a",{download:"original.png",href:r,children:"Download original"})]}):null,c?e("div",{class:"walkthrough",children:[e("h4",{children:"Result"}),e("img",{src:c,alt:"Result app at 1280 by 900 pixels"}),e("a",{download:"result.png",href:c,children:"Download result"})]}):null]})]})}var wr=qe(null);var Cr=t=>t.charAt(0).toUpperCase()+t.slice(1);function lc({providers:t}){let[s,n]=m(null),[r,a]=m(!1),[c,i]=m("");return N(()=>{if(!r)return;let d=!0;return i(""),V("/api/team-capabilities").then(l=>{d&&n(l)},l=>{d&&i(l.message)}),()=>{d=!1}},[r]),e("details",{class:"at-section",onToggle:d=>a(d.currentTarget.open),children:[e("summary",{children:"Agent collaboration capabilities"}),c?e("p",{class:"help",children:c}):s?e(M,{children:[e("div",{class:"table-wrap",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Provider"}),e("th",{children:"Member tools"}),e("th",{children:"Live input"}),e("th",{children:"Native child controls"}),e("th",{children:"Child usage"})]})}),e("tbody",{children:s.filter(d=>t.includes(d.provider)).map(d=>e("tr",{children:[e("td",{children:[Se[d.provider]??d.provider,e("div",{class:"help",children:d.version??"Version unknown"})]}),e("td",{children:Cr(d.scopedTools)}),e("td",{children:Cr(d.liveInput)}),e("td",{children:Cr(d.nestedAgentControl)}),e("td",{children:Cr(d.nestedUsage)})]},d.provider))})]})}),e("p",{class:"help",children:"Unsupported live tools use queued messages and structured outcomes. Protocol tests and installed CLI probes establish capability; separate child-agent usage is unknown."})]}):e("p",{class:"help",children:"Checking installed CLI capabilities\u2026"})]})}function jo(){let t=oa.value;return t?e("section",{class:"at-notice","aria-label":"Auto team availability",children:[e("b",{children:["Auto team \xB7 ",t.enabled?`evaluation: ${t.stage}`:"new runs disabled"]}),e("p",{children:t.reason}),e("a",{href:"#/insights",children:"View evaluation evidence"})]}):null}function cc({runId:t,running:s}){let[n,r]=m(null),[a,c]=m(""),[i,d]=m(!1);return N(()=>{if(!i)return;let l=!0,o=lt(()=>V(`/api/runs/${encodeURIComponent(t)}/evaluation`).then(u=>{l&&(r(u),c(""))},u=>{l&&c(u.message)}),s?5e3:0);return()=>{l=!1,o()}},[t,s,i]),e("details",{class:"at-section",onToggle:l=>d(l.currentTarget.open),children:[e("summary",{children:"Coordination and recovery measurements"}),a?e("p",{class:"help",children:["Measurements unavailable: ",a]}):n?e(M,{children:[e("div",{class:"at-metrics",children:[e("span",{children:["Coordinator calls: ",e("b",{children:n.metrics.coordinatorFraction===null?"unknown":js(n.metrics.coordinatorFraction,1)})," of all invocations"]}),e("span",{children:["Peer questions: ",e("b",{children:n.metrics.peerQuestions})]}),e("span",{children:["Peer wait: ",e("b",{children:n.metrics.peerWaitingMs===void 0?"not measured":Le(n.metrics.peerWaitingMs)})]}),e("span",{children:["Dispatch delay after an answer: ",e("b",{children:n.metrics.avoidableBarrierEstimateMs===void 0?"not measured":Le(n.metrics.avoidableBarrierEstimateMs)})]}),e("span",{children:["Worker turns: ",e("b",{children:n.metrics.workerTurns})]}),e("span",{children:["Repair turns: ",e("b",{children:n.metrics.repairTurns})]})]}),n.metrics.replay?e("p",{class:"help",children:[n.metrics.replay.kind==="journal-load"?"Journal load":"Execution replay",": ",n.metrics.replay.durationMs.toFixed(1)," ms \xB7 ",Zt(n.metrics.replay.bytes)," \xB7 ",n.metrics.replay.records," records"]}):e("p",{class:"help",children:"Recovery has not been measured for this run."}),e("p",{class:"help",children:["Peer wait excludes questions to you. Dispatch delay is the time from an answer arriving to the next turn of its task, not a measured speedup. ",n.mode==="unknown"?"This run has not been registered as a controlled evaluation.":`Evaluation source: ${n.mode}.`]})]}):e("p",{class:"help",children:"Loading measurements\u2026"})]})}function dc(){let[t,s]=m(null),[n,r]=m(""),[a,c]=m(new Set),[i,d]=m("experimental"),[l,p]=m(""),[o,u]=m(!1),f=async()=>{try{s(await V("/api/team-evaluations")),r("")}catch(g){r(g.message)}};N(()=>{f()},[]);let h=async()=>{if(!(!l.trim()||o)){u(!0);try{await O("/api/team-rollout",{stage:i,rationale:l,evaluationIds:[...a]}),await Promise.all([f(),Ki()]),p("")}catch(g){r(g.message)}finally{u(!1)}}};return e("section",{class:"ins-section","aria-label":"Team evaluations",children:[e("h2",{children:"Auto team evaluation"}),e("p",{class:"help",children:"Controlled local comparisons use the same task and starting commit. Fake trials verify behavior; only explicitly recorded real CLI trials inform rollout. These records cover this installation, across projects."}),e(jo,{}),n?e("p",{class:"msg err",role:"alert",children:n}):null,e("button",{class:"btn small",onClick:f,children:"Refresh evaluations"}),t?e(M,{children:[e("div",{class:"at-metrics",children:[e("span",{children:[e("b",{children:t.assessment.realAutoRuns})," real Auto runs"]}),e("span",{children:[e("b",{children:t.assessment.realWorkerTurns})," real worker turns"]}),e("span",{children:[e("b",{children:t.assessment.matchedPairs})," matched comparisons"]}),e("span",{children:["Multi-worker coordination: ",e("b",{children:t.assessment.overheadFraction===null?"unknown":js(t.assessment.overheadFraction,1)})]})]}),t.reports.length?e("div",{class:"table-wrap",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Evidence"}),e("th",{children:"Trial"}),e("th",{children:"Pattern"}),e("th",{children:"Verified"}),e("th",{class:"num",children:"Calls"}),e("th",{class:"num",children:"Coordinator"}),e("th",{class:"num",children:"Peer wait"})]})}),e("tbody",{children:t.reports.map(g=>e("tr",{children:[e("td",{children:[e("input",{type:"checkbox","aria-label":`Use evaluation ${g.id}`,checked:a.has(g.id),onChange:y=>c(C=>{let T=new Set(C);return y.currentTarget.checked?T.add(g.id):T.delete(g.id),T})}),e("span",{class:`badge ${g.mode==="real"?"":"warn"}`,children:g.mode.charAt(0).toUpperCase()+g.mode.slice(1)})]}),e("td",{children:[e("b",{children:g.caseId}),e("div",{class:"help",children:[g.pairId??"unpaired"," \xB7 ",g.runId]})]}),e("td",{children:g.pattern}),e("td",{children:g.verified?"Yes":"No"}),e("td",{class:"num",children:g.metrics.invocations}),e("td",{class:"num",children:g.metrics.coordinatorFraction===null?"unknown":js(g.metrics.coordinatorFraction,1)}),e("td",{class:"num",children:g.metrics.peerWaitingMs===void 0?"unknown":Le(g.metrics.peerWaitingMs)})]},g.id))})]})}):e("p",{class:"help",children:["No controlled trials recorded. Use ",e("code",{children:"npm run evaluate:teams -- --fake"})," to validate the harness, or ",e("code",{children:"--real"})," for bounded trials with your signed-in CLIs."]}),e("details",{children:[e("summary",{children:"Rollout decision and requirements"}),e("p",{class:"help",children:"An explicit decision is required. The server checks selected real evidence before allowing beta or default. Missing results and unverified outcomes cannot become passes."}),t.assessment.blockers.length?e("ul",{children:t.assessment.blockers.map(g=>e("li",{children:g},g))}):e("p",{children:"Recorded evidence meets the default criteria."}),e("label",{children:["Requested stage",e("select",{class:"field","aria-label":"Auto team rollout stage",value:i,onChange:g=>d(g.currentTarget.value),children:[e("option",{value:"experimental",children:"Experimental"}),e("option",{value:"beta",children:"Opt-in beta"}),e("option",{value:"default",children:"Default for new users"})]})]}),e("label",{children:["Decision rationale",e("textarea",{class:"field","aria-label":"Rollout rationale",rows:3,maxLength:4e3,value:l,onInput:g=>p(g.currentTarget.value)})]}),e("button",{class:"btn small",disabled:o||!l.trim(),onClick:h,children:o?"Recording\u2026":"Record rollout decision"}),t.rollout.decision?e("p",{class:"help",children:["Last decision: ",new Date(t.rollout.decision.at).toLocaleString()," \xB7 ",t.rollout.decision.rationale]}):null]})]}):null]})}var Po=t=>ge.value.find(s=>s.id===t)?.name??t,Mo={7:7,30:30,all:0};function mc({group:t}){let[s,n]=m(!1),r=wr.value,a=r?fn(ge.value.find(b=>b.id===r.pattern),r.roles)||(r.task.trim()?"":"Describe a task in New run first."):"Configure a task in New run first.",c=Mn.value,i=!!c||_e.value===qt,d=!!ee.value&&!(c?.repos.length===1&&c.repos[0]===ee.value),[l,p]=m(i?"project":ee.value?"repo":"all");N(()=>p(i?"project":ee.value?"repo":"all"),[_e.value,i]);let o=l==="project"&&!i?"all":l==="repo"&&!d?i?"project":"all":l,[u,f]=m("30"),[h,g]=m(null),[y,C]=m(""),T=()=>{let b=new URLSearchParams;return o==="project"&&b.set("project",_e.value),o==="repo"&&ee.value&&b.set("repo",ee.value),b},v=()=>{let b=T();return Mo[u]&&b.set("since",String(Date.now()-Mo[u]*864e5)),b.toString()};N(()=>{let b=!0,x=lt(()=>V(`/api/stats?${v()}`).then(w=>b&&(g(w),C("")),w=>b&&C(w.message)),15e3);return()=>{b=!1,x()}},[o,u,ee.value,_e.value]);let k=h?[...h.groups].sort((b,S)=>b.id===t?-1:S.id===t?1:0):[];return e("div",{class:"insights",children:[e("details",{class:"settings",children:[e("summary",{children:"Experiments"}),e("div",{class:"settings-body",children:[e("p",{class:"help",children:"Compare workflows against your current New run draft. Each selected setup starts a separate run and uses provider capacity."}),r?e("p",{children:r.task.split(`
|
|
40
|
+
`)[0]||"No task in the current draft"}):null,e("button",{class:"btn",disabled:!!a,title:a,onClick:()=>n(!0),children:"Compare setups\u2026"}),a?e("p",{class:"help",children:[a," ",e("a",{href:"#/",children:"Configure task"})]}):null]})]}),s&&r?e(pc,{base:{...r,approvals:{}},onClose:()=>n(!1),onStarted:b=>{n(!1),Y.value={view:"insights",group:b}}}):null,e("div",{class:"page-head ins-head",children:[e("div",{class:"page-head-text",children:e("p",{children:"What runs cost and how they went, per agent and per pattern."})}),e("div",{class:"page-head-actions",children:[e(Ks,{}),e("div",{class:"segmented",role:"group","aria-label":"Which runs",children:[i?e("button",{class:o==="project"?"on":"","aria-pressed":o==="project",title:"Runs in this project",onClick:()=>p("project"),children:c?c.name:"No project"}):null,d||!i?e("button",{class:o==="repo"?"on":"","aria-pressed":o==="repo",disabled:!ee.value,title:"Runs in this repository",onClick:()=>p("repo"),children:ee.value?be(ee.value):"This repo"}):null,e("button",{class:o==="all"?"on":"","aria-pressed":o==="all",onClick:()=>p("all"),children:"Everything"})]}),e("div",{class:"segmented",role:"group","aria-label":"Period",children:Object.keys(Mo).map(b=>e("button",{class:u===b?"on":"","aria-pressed":u===b,onClick:()=>f(b),children:b==="all"?"All time":`${b} days`},b))})]})]}),e(kr,{project:o==="project"?_e.value:void 0,repository:o==="repo"?ee.value:void 0}),y?e("div",{class:"msg err",children:y}):null,h?null:e("div",{class:"help",children:"Loading\u2026"}),h&&!h.runs?e("div",{class:"ins-empty",children:[e("h2",{children:"No runs in this period"}),e("p",{children:"Start a run, or compare setups under Experiments above."})]}):null,h&&h.runs?e(M,{children:[e("div",{class:"ins-cards",children:[e(Tr,{label:"Runs",value:String(h.runs)}),e(Tr,{label:"Time",value:Le(h.ms),note:"wall-clock, finished runs"}),e(Tr,{label:"Tokens",value:Et(h.tokens),note:"input + output"}),e(Tr,{label:"API-equivalent cost",value:ht(h.costUsd),note:"as Claude Code reports it; your plan isn't billed per token"})]}),k.length?e("section",{class:"ins-section","aria-labelledby":"ins-compare",children:[e("h2",{id:"ins-compare",children:"Comparisons"}),e("p",{class:"help",children:"The same task with different setups, started together. Lower is better for time, steps and tokens; \u201CTests changed\u201D means the result touched tests in ways that could hide failures."}),k.map(b=>e("div",{class:`ins-group ${b.id===t?"focus":""}`,children:[e("div",{class:"ig-title",children:b.task.split(`
|
|
41
|
+
`)[0]}),e("div",{class:"table-wrap",tabIndex:0,role:"region","aria-label":"Scrollable results table",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Setup"}),e("th",{children:"Result"}),e("th",{class:"num",children:"Time"}),e("th",{class:"num",children:"Steps"}),e("th",{class:"num",children:"Tokens"}),e("th",{class:"num",children:"Cost"}),e("th",{children:"Tests changed"}),e("th",{children:"Proven"}),e("th",{children:"Changes"})]})}),e("tbody",{children:b.runs.map(S=>{let x=ft(S),w=j=>{let A=b.runs.filter(P=>P.status==="done"&&P[j]!==void 0);return A.length>1&&S.status==="done"&&S[j]===Math.min(...A.map(P=>P[j]))};return e("tr",{class:"clickable",tabIndex:0,onClick:()=>Y.value={view:"run",id:S.id},onKeyDown:j=>j.key==="Enter"&&(Y.value={view:"run",id:S.id}),children:[e("td",{children:[e("b",{children:S.label}),e("div",{class:"help",children:[Po(S.pattern)," \xB7"," ",[...new Set(Object.values(S.roles).flat())].map(j=>e(Ee,{id:j},j))]})]}),e("td",{children:e("span",{class:`status-pill ${x}`,children:x==="failing"?"Check failing":x==="unchecked"?"Check can't run":x==="done"?"Passed":x==="unverified"?"Not verified":Je[S.status]??S.status})}),e("td",{class:`num ${w("ms")?"best":""}`,children:S.ms!==void 0?Le(S.ms):"\u2026"}),e("td",{class:`num ${w("steps")?"best":""}`,children:S.steps}),e("td",{class:`num ${w("tokens")?"best":""}`,children:Et(S.tokens)}),e("td",{class:"num",children:S.costUsd?ht(S.costUsd):"\u2013"}),e("td",{children:S.flagged?e("span",{class:"badge warn",children:["\u26A0 ",S.flagged]}):e("span",{class:"help",children:"No"})}),e("td",{title:uc,children:S.proof==="proven"?e("span",{class:"badge ok",children:"\u2713 Yes"}):S.proof==="weak"?e("span",{class:"badge warn",title:"The tests fail without the change only because they can't load",children:"\u26A0 Weak"}):S.proof==="unproven"?e("span",{class:"badge warn",children:"\u26A0 No"}):e("span",{class:"help",children:"\u2013"})}),e("td",{class:"help",children:S.stat??"\u2013"})]},S.id)})})]})})]},b.id))]}):null,e("section",{class:"ins-section","aria-labelledby":"ins-agents",children:[e("h2",{id:"ins-agents",children:"Agents"}),e("p",{class:"help",children:[e("b",{children:"Passed"})," includes shared run outcomes. Provider comparisons and \u201CAuto\u201D routing use runs with a single writing provider, with at least three samples per provider. The 95% interval shows uncertainty in that observed rate. Task difficulty can still vary."]}),e("div",{class:"table-wrap",tabIndex:0,role:"region","aria-label":"Scrollable results table",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Agent"}),e("th",{class:"num",children:"Runs"}),e("th",{class:"num",children:"Passed"}),e("th",{class:"num",children:"Sole-writer evidence"}),e("th",{class:"num",children:"Race wins"}),e("th",{class:"num",children:"Loops it got green"}),e("th",{class:"num",children:"Review findings"}),e("th",{class:"num",children:"Steps"}),e("th",{class:"num",children:"Failed steps"}),e("th",{class:"num",children:"Tokens"}),e("th",{class:"num",children:"Cost"}),e("th",{class:"num",children:"Time per step"})]})}),e("tbody",{children:h.agents.map(b=>e("tr",{children:[e("td",{children:e(Ee,{id:b.agent})}),e("td",{class:"num",children:b.runs}),e("td",{class:"num",title:`${b.passed} of ${b.judged}`,children:b.judged?`${js(b.passed,b.judged)} (${b.passed}/${b.judged})`:"\u2013"}),e("td",{class:"num",title:`${b.sharedJudged??0} shared outcomes excluded from provider comparisons`,children:b.attributedJudged?e(M,{children:[b.attributedPassed,"/",b.attributedJudged,e("div",{class:"help",children:["95%: ",Math.round(100*b.confidence.low),"\u2013",Math.round(100*b.confidence.high),"%"]})]}):"No attributable samples"}),e("td",{class:"num",children:b.raceEntries?`${b.raceWins}/${b.raceEntries}`:"\u2013"}),e("td",{class:"num",children:b.loopSolves||"\u2013"}),e("td",{class:"num",title:"Findings, and how many another reviewer also raised",children:b.findings?`${b.findings} (${b.agreedFindings} agreed)`:"\u2013"}),e("td",{class:"num",children:b.steps}),e("td",{class:`num ${b.failures?"warn":""}`,children:b.steps?js(b.failures,b.steps):"\u2013"}),e("td",{class:"num",title:`${b.inputTokens.toLocaleString()} in \xB7 ${b.outputTokens.toLocaleString()} out \xB7 ${b.cacheReadTokens.toLocaleString()} cached`,children:Et(b.inputTokens+b.outputTokens)}),e("td",{class:"num",children:b.costUsd?ht(b.costUsd):"\u2013"}),e("td",{class:"num",children:b.steps?Le(b.ms/b.steps):"\u2013"})]},b.agent))})]})})]}),h.cohorts?.length?e("section",{class:"ins-section","aria-labelledby":"ins-cohorts",children:[e("h2",{id:"ins-cohorts",children:"Task cohorts"}),e("p",{class:"help",children:"Compare runs in the same repository, workflow and source category. These groups do not estimate task difficulty."}),e("div",{class:"table-wrap",tabIndex:0,role:"region","aria-label":"Scrollable results table",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Repository"}),e("th",{children:"Workflow"}),e("th",{children:"Source"}),e("th",{class:"num",children:"Runs"}),e("th",{class:"num",children:"Passed / checked"}),e("th",{class:"num",children:"Tokens"}),e("th",{class:"num",children:"Cost"})]})}),e("tbody",{children:h.cohorts.map(b=>e("tr",{children:[e("td",{title:b.repo,children:be(b.repo)}),e("td",{children:Po(b.pattern)}),e("td",{children:b.sourceKind}),e("td",{class:"num",children:b.runs}),e("td",{class:"num",children:[b.passed,"/",b.judged]}),e("td",{class:"num",children:Et(b.tokens)}),e("td",{class:"num",children:b.costUsd?ht(b.costUsd):"\u2013"})]},b.key))})]})})]}):null,e("section",{class:"ins-section","aria-labelledby":"ins-patterns",children:[e("h2",{id:"ins-patterns",children:"Patterns"}),e("div",{class:"table-wrap",tabIndex:0,role:"region","aria-label":"Scrollable results table",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Pattern"}),e("th",{class:"num",children:"Runs"}),e("th",{class:"num",children:"Passed"}),e("th",{class:"num",children:"Check failing"}),e("th",{class:"num",children:"Failed or stopped"}),e("th",{class:"num",children:"Tests changed"}),e("th",{class:"num",title:uc,children:"Proven"}),e("th",{class:"num",children:"Avg time"}),e("th",{class:"num",children:"Avg steps"}),e("th",{class:"num",children:"Tokens"}),e("th",{class:"num",children:"Cost"})]})}),e("tbody",{children:h.patterns.map(b=>e("tr",{children:[e("td",{class:"name",children:Po(b.pattern)}),e("td",{class:"num",children:b.runs}),e("td",{class:"num",children:b.passed?`${b.passed} (${js(b.passed,b.runs)})`:"\u2013"}),e("td",{class:`num ${b.failing?"warn":""}`,children:b.failing||"\u2013"}),e("td",{class:`num ${b.failed+b.stopped?"warn":""}`,children:b.failed+b.stopped||"\u2013"}),e("td",{class:`num ${b.flagged?"warn":""}`,children:b.flagged||"\u2013"}),e("td",{class:`num ${b.unproven+b.weak?"warn":""}`,title:b.proven+b.weak+b.unproven?`${b.proven} proven, ${b.weak} weakly (tests that only fail to load), ${b.unproven} not proven`:void 0,children:b.proven+b.weak+b.unproven?`${b.proven}/${b.proven+b.weak+b.unproven}`:"\u2013"}),e("td",{class:"num",children:b.ended?Le(b.ms/b.ended):"\u2013"}),e("td",{class:"num",children:(b.steps/b.runs).toFixed(1)}),e("td",{class:"num",children:Et(b.tokens)}),e("td",{class:"num",children:b.costUsd?ht(b.costUsd):"\u2013"})]},b.pattern))})]})})]})]}):null,e(dc,{}),e(Ku,{scope:T()})]})}var uc="Proven: a test in the result fails on the base code without the change (code-flow ran the change's tests there)";function Tr({label:t,value:s,note:n}){return e("div",{class:"ins-card",children:[e("div",{class:"ic-label",children:t}),e("div",{class:"ic-value",children:s}),n?e("div",{class:"help",children:n}):null]})}function Ku({scope:t}){let s=t.toString(),[n,r]=m(null),[a,c]=m(!1),[i,d]=m(7),l=async()=>{c(!0);try{r(await V(`/api/disk${s?`?${s}`:""}`))}catch(p){J(p.message,5e3)}finally{c(!1)}};return N(()=>r(null),[s]),e("section",{class:"ins-section","aria-labelledby":"ins-disk",children:[e("h2",{id:"ins-disk",children:"Disk"}),e("div",{class:"row-inline",children:[e("button",{class:"btn small",disabled:a,onClick:l,children:a?"Measuring\u2026":n?"Measure again":"Measure worktrees"}),n?e("span",{children:[e("b",{children:Zt(n.total)})," in ",n.runs.length," run",n.runs.length===1?"":"s","' worktrees"]}):e("span",{class:"help",children:"Adds up the worktrees of every run; this can take a few seconds."}),e("span",{class:"spacer"}),e("span",{children:"Remove worktrees of finished runs older than"}),e("input",{class:"field inline num",type:"number",min:0,max:365,value:i,"aria-label":"Days",onInput:p=>d(Number(p.currentTarget.value)||0)}),e("span",{children:"days"}),e("button",{class:"btn small",onClick:async()=>{if(await Ae(`Remove the worktrees of runs that finished more than ${i} days ago and need nothing from you? Branches are kept, so you can still merge or resume them.`,{title:"Remove old worktrees?",confirmLabel:"Remove worktrees",danger:!0}))try{let p=await O("/api/cleanup",{olderThanDays:i,repo:t.get("repo")??void 0,project:t.get("project")??void 0});J(p.worktrees?`Removed ${p.worktrees} worktree(s) from ${p.runs} run(s)`:"Nothing to clean up",4e3),n&&l()}catch(p){J(p.message,5e3)}},children:"Clean up"})]}),n?.runs.length?e("div",{class:"table-wrap",tabIndex:0,role:"region","aria-label":"Scrollable results table",children:e("table",{class:"ins-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Run"}),e("th",{children:"Repository"}),e("th",{children:"Status"}),e("th",{class:"num",children:"Worktree"})]})}),e("tbody",{children:n.runs.slice(0,10).map(p=>e("tr",{class:"clickable",tabIndex:0,onClick:()=>Y.value={view:"run",id:p.id},onKeyDown:o=>o.key==="Enter"&&(Y.value={view:"run",id:p.id}),children:[e("td",{children:p.task}),e("td",{class:"help",children:be(p.repo)}),e("td",{class:"help",children:p.archived?"Archived":Je[p.status]??p.status}),e("td",{class:"num",children:Zt(p.bytes)})]},p.id))})]})}):null]})}function hc({runId:t,worktree:s}){let[n,r]=m(null),[a,c]=m(""),[i,d]=m(""),[l,p]=m(""),o=Z(0),u=Z(0),f=Z(0),h=`/api/runs/${G(t)}/launch-profiles`,g=`?worktree=${G(s)}`,y=`launch-profile-${G(t)}-${G(s)}`;N(()=>{let S=++o.current,x=!0;r(null),c(""),d(""),p(""),f.current++;let j=lt(async()=>{let A=++u.current;try{let P=await V(h+g);if(!x||o.current!==S||u.current!==A)return;r(P),d(""),c(D=>P.profiles.some(I=>I.id===D)?D:P.profiles[0]?.id??"")}catch(P){x&&o.current===S&&u.current===A&&d(P.message)}},2e3);return()=>{x=!1,j(),o.current++,f.current++}},[t,s]);let C=async()=>{let S=o.current,x=++f.current;p("start"),d("");try{let w,j={worktree:s,profile:a};try{w=await O(h,j)}catch(A){if(!(A instanceof st)||A.confirm!=="allowUntrusted")throw A;if(S!==o.current||x!==f.current||!await Ae(`${A.message}
|
|
42
|
+
|
|
43
|
+
Start these repository commands on this computer?`,{title:"Start repository commands?",confirmLabel:"Start commands",danger:!0})||S!==o.current||x!==f.current)return;w=await O(h,{...j,allowUntrusted:!0})}if(S!==o.current||x!==f.current)return;u.current++,r(A=>A&&{...A,session:w}),J(w.status==="ready"?"Launch profile is ready":"Launch profile finished startup")}catch(w){S===o.current&&x===f.current&&d(w.message)}finally{S===o.current&&x===f.current&&p("")}},T=async()=>{let S=o.current,x=++f.current;p("stop"),d("");try{let w=await V(h+g,{method:"DELETE"});if(S!==o.current||x!==f.current)return;u.current++,r(j=>j&&{...j,session:w.session??(j.session?{...j.session,status:"stopped",services:j.session.services.map(A=>({...A,status:A.status==="exited"?"exited":"stopped"}))}:null)}),J(w.stopped?"Launch profile stopped":"No active launch profile")}catch(w){S===o.current&&x===f.current&&d(w.message)}finally{S===o.current&&x===f.current&&p("")}},v=n?.profiles.find(S=>S.id===a),k=n?.session,b=k?.status==="ready"||k?.status==="starting"||l==="start";return e("section",{class:"wb-card launch-profiles","aria-label":"Multi-service launch profiles",children:[e("h2",{children:"Launch profiles"}),e("p",{class:"help",children:["Start a coordinated app stack from this worktree\u2019s ",e("code",{children:".codeflow/launch.json"}),". Services get separate ports, peer URLs and bounded HTTP readiness checks. Starting a profile executes repository commands on this computer."]}),!n&&!i?e("p",{role:"status",children:"Reading launch profiles\u2026"}):null,n?.error?e("p",{class:"msg err",role:"alert",children:n.error}):null,n&&!n.found?e("p",{class:"help",children:["No launch configuration exists in this worktree. Add a version 1 ",e("code",{children:".codeflow/launch.json"})," with named profiles and up to six services each."]}):null,n?.found&&!n.error&&!n.profiles.length?e("p",{class:"help",children:"The launch configuration has no profiles."}):null,v?e(M,{children:[e("div",{class:"launch-profile-choice",children:[e("label",{class:"lbl",for:y,children:"Launch profile"}),e("select",{id:y,class:"field",value:a,disabled:!!l||!!b,onChange:S=>c(S.currentTarget.value),children:n.profiles.map(S=>e("option",{value:S.id,children:S.name},S.id))})]}),e("details",{class:"launch-preview",children:[e("summary",{children:["Review ",v.services.length," service commands"]}),e("ul",{children:v.services.map(S=>e("li",{children:[e("strong",{children:S.name??S.id})," ",e("code",{children:S.cwd}),e("pre",{children:S.command}),e("p",{class:"help",children:[S.dependsOn.length?`Starts after ${S.dependsOn.join(", ")}. `:"",S.health===!1?"Checks that the process remains running; HTTP readiness is disabled.":`HTTP ${S.health.path} must return 2xx within ${S.health.timeoutMs/1e3}s.`]})]},S.id))})]}),e("div",{class:"launch-actions",children:[e("button",{class:"btn primary",disabled:!!l||!!b||!!n?.error,onClick:C,children:l==="start"?"Starting services\u2026":"Start launch profile"}),e("button",{class:"btn",disabled:!b||l==="stop",onClick:T,children:l==="stop"?"Stopping\u2026":"Stop services"})]})]}):b?e("button",{class:"btn",disabled:l==="stop",onClick:T,children:"Stop services"}):null,k?e("div",{class:"launch-session","aria-live":"polite",children:[e("p",{children:[e("strong",{children:["Stack: ",k.status]})," \xB7 ",k.profile]}),k.error?e("p",{class:"msg err",children:k.error}):null,e("div",{class:"launch-services",children:k.services.map(S=>e("article",{class:"launch-service","aria-label":`${S.name} service`,children:[e("div",{children:[e("strong",{children:S.name}),e("span",{class:`badge ${S.status==="healthy"?"ok":S.status==="exited"?"err":S.status==="starting"||S.status==="running"?"run":""}`,children:S.status.charAt(0).toUpperCase()+S.status.slice(1)})]}),e("p",{class:"help",children:["Port ",S.port,S.exitCode!=null?` \xB7 Exit ${S.exitCode}`:""," \xB7 ",S.healthChecked?"HTTP readiness passed":"HTTP readiness not confirmed"]}),k.status==="ready"&&["healthy","running"].includes(S.status)?e("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",children:["Open ",S.name]}):e("code",{children:S.url}),e("details",{children:[e("summary",{children:["Logs (",S.logs.length," recent lines)"]}),e("pre",{class:"launch-logs",children:S.logs.join(`
|
|
44
|
+
`)||"No output yet."})]})]},S.id))})]}):null,i?e("p",{class:"msg err",role:"alert",children:i}):null]})}var zu={running:"run",ready:"ok",shipped:"ok","partial-shipped":"warn",blocked:"warn"},Gu={claimed:"run",running:"run",shipping:"run",verified:"ok",shipped:"ok",failed:"err",unknown:"warn",blocked:"warn","shipping-unknown":"warn"},fc=t=>`badge${t?` ${t}`:""}`,gc=t=>{let s=t.replace(/-/g," ");return s.charAt(0).toUpperCase()+s.slice(1)},gn=(t,s="")=>({id:t,repo:s,task:"",provider:"claude",check:"",dependsOn:[]});function vc({endpoint:t="/api/coordinated-changes"}){let[s,n]=m([]),[r,a]=m(""),[c,i]=m(""),[d,l]=m([gn("repo1"),gn("repo2")]),[p,o]=m(()=>crypto.randomUUID()),[u,f]=m([]),[h,g]=m(""),[y,C]=m(""),[T,v]=m({}),[k,b]=m({}),[S,x]=m({}),w=s.find(I=>I.id===r),j=async()=>{f(await V(t))};N(()=>{let I=!0;V("/api/projects").then(E=>{if(I){n(E);let L=E.find(H=>H.repos.length>=2)??E[0];L&&(a(L.id),l([gn("repo1",L.repos[0]),gn("repo2",L.repos[1])]))}}).catch(E=>{I&&g(E.message)});let $=lt(()=>V(t).then(E=>{I&&f(E)}).catch(E=>{I&&g(E.message)}),5e3);return()=>{I=!1,$()}},[t]);let A=(I,$)=>{o(crypto.randomUUID()),l(E=>E.map(L=>L.id===I?{...L,...$}:L))},P=async()=>{if(!y){C("create"),g("");try{if(!w||d.some(I=>!w.repos.includes(I.repo)||!I.task.trim()))throw new Error("Choose project repositories and write a task for each one.");await O(t,{project:r,name:c.trim(),operationId:p,nodes:d.map(I=>({id:I.id,dependsOn:I.dependsOn,run:{repo:I.repo,project:r,pattern:"solo",task:I.task,roles:{agent:[I.provider]},options:{},loop:{...I.check.trim()?{check:I.check.trim()}:{},maxSteps:20,maxInvocations:20,maxMinutes:15,copy:[]}}}))}),o(crypto.randomUUID()),i(""),l(I=>I.map($=>({...$,task:""}))),await j()}catch(I){g(I.message)}finally{C("")}}},D=async(I,$,E={})=>{if(!y){C(I.id+$),g("");try{await O(`${t}/${encodeURIComponent(I.id)}/${$}`,{expectedRevision:I.revision,...E}),await j()}catch(L){g(L.message),await j().catch(()=>{})}finally{C("")}}};return e("section",{class:"wb-card coordination-panel","aria-label":"Coordinated repository changes",children:[e("h2",{children:"Coordinated repository changes"}),e("p",{class:"help",children:"Plan dependent changes across 2\u201310 repositories in one project. Each starts from its pinned commit in safe mode. Downstream work receives exact verified commit facts after its dependencies finish. Repositories keep separate workspaces and credentials."}),e("p",{class:"help",children:"Tasks use at most 20 agent calls and 15 minutes by default. There are no unattended native tool approval waits, inherited uploads or copied ignored files. Shipping requires a reviewed matrix and a separate explicit merge for each repository; merges can partially succeed and never push automatically."}),h?e("p",{class:"msg err",role:"alert",children:[h," Your draft is preserved."]}):null,e("details",{children:[e("summary",{children:"Create a coordinated change"}),e("div",{class:"wb-fields",children:[e("label",{children:["Project",e("select",{class:"field","aria-label":"Coordinated project",value:r,onChange:I=>{let $=I.currentTarget.value,E=s.find(L=>L.id===$);o(crypto.randomUUID()),a($),l([gn("repo1",E?.repos[0]),gn("repo2",E?.repos[1])])},children:[e("option",{value:"",children:"Choose project"}),s.map(I=>e("option",{value:I.id,children:I.name},I.id))]})]}),e("label",{children:["Change name",e("input",{class:"field","aria-label":"Coordinated change name",maxLength:120,value:c,onInput:I=>{o(crypto.randomUUID()),i(I.currentTarget.value)}})]})]}),!w||w.repos.length<2?e("p",{class:"help",children:"Add at least two repositories to a project before coordinating changes."}):null,d.map((I,$)=>e("fieldset",{class:"coordination-task","aria-label":`Coordinated task ${I.id}`,children:[e("legend",{children:["Task ",I.id]}),e("label",{children:["Repository",e("select",{class:"field","aria-label":`Repository for ${I.id}`,value:I.repo,onChange:E=>A(I.id,{repo:E.currentTarget.value}),children:[e("option",{value:"",children:"Choose repository"}),w?.repos.map(E=>e("option",{value:E,children:E},E))]})]}),e("label",{children:["Task",e("textarea",{class:"field",rows:3,"aria-label":`Task for ${I.id}`,maxLength:24e3,value:I.task,onInput:E=>A(I.id,{task:E.currentTarget.value})})]}),e("label",{children:["Provider",e("select",{class:"field","aria-label":`Provider for ${I.id}`,value:I.provider,onChange:E=>A(I.id,{provider:E.currentTarget.value}),children:[e("option",{value:"claude",children:"Claude"}),e("option",{value:"codex",children:"Codex"}),e("option",{value:"agy",children:"Antigravity"}),e("option",{value:"auto",children:"Auto"})]})]}),e("label",{children:["Verification command \xB7 blank uses repository configuration",e("input",{class:"field","aria-label":`Verification for ${I.id}`,value:I.check,onInput:E=>A(I.id,{check:E.currentTarget.value})})]}),e("div",{class:"coordination-deps",children:["Start after these verified tasks:",d.filter(E=>E.id!==I.id).map(E=>e("label",{class:"help",children:[e("input",{type:"checkbox","aria-label":`${I.id} depends on ${E.id}`,checked:I.dependsOn.includes(E.id),onChange:L=>A(I.id,{dependsOn:L.currentTarget.checked?[...I.dependsOn,E.id]:I.dependsOn.filter(H=>H!==E.id)})})," ",E.id]},E.id))]}),d.length>2?e("button",{class:"btn small",disabled:!!y,onClick:()=>l(E=>E.filter(L=>L.id!==I.id).map(L=>({...L,dependsOn:L.dependsOn.filter(H=>H!==I.id)}))),children:["Remove task ",$+1]}):null]},I.id)),e("div",{class:"wb-actions",children:[e("button",{class:"btn small",disabled:!!y||d.length>=10||d.length>=(w?.repos.length??0),onClick:()=>{let I=Array.from({length:10},($,E)=>`repo${E+1}`).find($=>!d.some(E=>E.id===$));l($=>[...$,gn(I,w?.repos.find(E=>!$.some(L=>L.repo===E)))])},children:"Add repository task"}),e("button",{class:"btn small primary",disabled:!!y||!w||w.repos.length<2||!c.trim(),onClick:P,children:"Start coordinated change"})]})]}),e("div",{class:"wb-actions",children:e("button",{class:"btn small",disabled:!!y,onClick:()=>void j().catch(I=>g(I.message)),children:"Refresh coordinated changes"})}),u.length===0?e("p",{class:"help",children:"No coordinated changes yet."}):null,u.length?e("div",{class:"wb-list",children:u.map(I=>e("article",{class:"wb-item coordination-job","aria-label":`Coordinated change ${I.name}`,children:[e("div",{class:"wb-item-head",children:[e("b",{children:I.name}),e("span",{class:fc(zu[I.status]),children:[gc(I.status)," \xB7 revision ",I.revision]}),!I.cancelRequested&&I.status!=="shipped"?e("button",{class:"btn small",disabled:!!y,onClick:()=>D(I,"cancel"),children:"Cancel coordinated change"}):null]}),e("p",{class:"help",children:["Project ",s.find($=>$.id===I.project)?.name??I.project," \xB7 ",I.id]}),I.nodes.map($=>{let E=`${I.id}:${$.id}`,L=`nodes/${encodeURIComponent($.id)}`;return e("section",{class:"coordination-node","aria-label":`Repository task ${$.id}`,children:[e("div",{class:"wb-item-head",children:[e("h3",{children:$.id}),e("span",{class:fc(Gu[$.status]),children:gc($.status)})]}),e("p",{class:"help",children:[$.run.repo," \xB7 starts at ",e("code",{children:$.baseCommit}),$.dependsOn.length?` \xB7 depends on ${$.dependsOn.join(", ")}`:" \xB7 independent",$.runId?` \xB7 attempt ${$.attempts}`:""]}),e("p",{children:$.run.task}),$.reason?e("p",{class:"help",children:$.reason}):null,$.result?e("p",{class:"help",children:["Verified branch ",$.result.branch," at ",e("code",{children:$.result.commit})," \xB7 receipt ",$.result.verificationId]}):null,$.shippedCommit?e("p",{class:"help",children:["Merged commit: ",e("code",{children:$.shippedCommit})]}):null,$.runId?e("div",{class:"wb-actions",children:e("a",{class:"btn small",href:`#/run/${encodeURIComponent($.runId)}`,children:["Open run ",$.runId]})}):null,$.status==="unknown"?e("div",{children:[e("p",{class:"help",children:["Claim ",$.claimId," \xB7 inspect existing runs before linking or retrying."]}),e("label",{children:["Matching run ID",e("input",{class:"field","aria-label":`Matching run for ${$.id}`,value:k[E]??"",onInput:H=>b(Q=>({...Q,[E]:H.currentTarget.value}))})]}),e("button",{class:"btn small",disabled:!!y||!k[E],onClick:()=>D(I,L+"/attach",{runId:k[E]}),children:["Link matching run ",$.id]}),e("label",{class:"help",children:[e("input",{type:"checkbox","aria-label":`Acknowledge unknown retry ${$.id}`,checked:S[E]??!1,onChange:H=>x(Q=>({...Q,[E]:H.currentTarget.checked}))})," I inspected existing runs and accept that retrying could duplicate work."]})]}):null,["failed","blocked","cancelled"].includes($.status)&&I.nodes.some(H=>H.status==="unknown")?e("label",{class:"help",children:[e("input",{type:"checkbox","aria-label":`Acknowledge unknown dependent retry ${$.id}`,checked:S[E]??!1,onChange:H=>x(Q=>({...Q,[E]:H.currentTarget.checked}))})," I inspected unknown dependent launches and accept that invalidating them could duplicate work."]}):null,["failed","unknown","blocked","cancelled"].includes($.status)?e("button",{class:"btn small",disabled:!!y||$.attempts>=3||$.status==="unknown"&&!S[E],onClick:()=>D(I,L+"/retry",{acknowledgeUnknown:S[E]===!0}),children:["Retry task ",$.id]}):null,$.status==="shipping-unknown"?e("div",{children:[e("p",{class:"help",children:["Shipping claim ",$.shippingClaimId," has an unknown outcome. Inspect the exact local target commit; automatic retry is disabled."]}),e("label",{children:["Proven merge commit",e("input",{class:"field","aria-label":`Shipping recovery commit for ${$.id}`,value:k[E]??"",onInput:H=>b(Q=>({...Q,[E]:H.currentTarget.value}))})]}),e("button",{class:"btn small",disabled:!!y||!k[E],onClick:()=>D(I,L+"/recover-shipping",{commit:k[E]}),children:["Recover exact shipping receipt ",$.id]})]}):null]},$.id)}),!I.cancelRequested&&I.nodes.every($=>["verified","shipped"].includes($.status))&&I.status!=="shipped"?e("section",{class:"coordination-node","aria-label":"Coordinated shipping review",children:[e("h3",{children:"Review local merge targets"}),I.nodes.filter($=>$.status!=="shipped").map($=>e("label",{children:["Target branch for ",$.id,e("input",{class:"field","aria-label":`Shipping target for ${$.id}`,value:T[`${I.id}:${$.id}`]??"main",onInput:E=>v(L=>({...L,[`${I.id}:${$.id}`]:E.currentTarget.value}))})]},$.id)),e("button",{class:"btn small",disabled:!!y,onClick:()=>D(I,"shipping-preview",{targets:Object.fromEntries(I.nodes.filter($=>$.status!=="shipped").map($=>[$.id,T[`${I.id}:${$.id}`]??"main"]))}),children:"Validate and preview shipping matrix"})]}):null,I.shipping?e("section",{class:"coordination-node","aria-label":"Pinned shipping matrix",children:[e("p",{class:"help",children:["Preview ",I.shipping.id," \xB7 expires ",new Date(I.shipping.expiresAt).toLocaleString(),". Each action is independent; previously merged repositories remain merged if another fails."]}),e("ul",{children:I.shipping.entries.map($=>{let E=I.nodes.find(L=>L.id===$.nodeId);return e("li",{children:[e("b",{children:[$.nodeId," \u2192 ",$.validation.into]}),e("p",{class:"help",children:["Source ",e("code",{children:$.validation.source})," \xB7 target ",e("code",{children:$.validation.target})," \xB7 validated tree ",e("code",{children:$.validation.tree})]}),e("button",{class:"btn small primary",disabled:!!y||I.cancelRequested||I.shipping.expiresAt<=Date.now()||E.status!=="verified",onClick:()=>D(I,`nodes/${encodeURIComponent(E.id)}/ship`,{previewId:I.shipping.id}),children:["Merge ",E.id," into ",$.validation.into]})]},$.nodeId)})})]}):null,e("details",{children:[e("summary",{children:["Coordination history \xB7 ",I.history.length]}),e("ul",{children:I.history.slice().reverse().map($=>e("li",{children:[new Date($.at).toLocaleString(),$.nodeId?` \xB7 ${$.nodeId}`:""," \xB7 ",$.detail,$.runId?` \xB7 run ${$.runId}`:"",$.commit?e(M,{children:[" \xB7 ",e("code",{children:$.commit})]}):null]},$.id))})]})]},I.id))}):null]})}var Yu=Bt(()=>import("./filtered-tasks-ES5CP4KV.js").then(t=>t.FilteredTasksPanel)),Qu=Bt(()=>import("./code-browser-VB2HGZSG.js").then(t=>t.CodeBrowser)),bc=[{label:"Code and verification",tools:[["verification","Verification"],["code","Code"],["context","Context"],["history","History"]]},{label:"Repository operations",tools:[["services","Services"],["coordination","Coordinated changes"],["filtered-tasks","Filtered tasks"]]}],Xu=t=>{let s=t.replace(/-/g," ");return s.charAt(0).toUpperCase()+s.slice(1)};function Do(t,s,n="application/json"){let r=URL.createObjectURL(new Blob([s],{type:n})),a=document.createElement("a");a.href=r,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Sr({projectId:t,initialFolder:s,initialTool:n,onNavigate:r}){let a=he.value.find(B=>B.id===t),c=t?a?.repos??[]:ee.value?[ee.value]:[],[i,d]=m(n??"verification"),[l,p]=m(s??c[0]??""),o=B=>{d(B),r?.(l,B)},u=B=>{p(B),r?.(B,i)};N(()=>{d(n??"verification")},[n]);let[f,h]=m(""),[g,y]=m(!1),[C,T]=m(null),[v,k]=m("standard"),[b,S]=m("HEAD"),[x,w]=m(""),[j,A]=m(""),[P,D]=m(1),[I,$]=m(null),[E,L]=m(""),[H,Q]=m(null),[le,de]=m(null),[ue,q]=m(""),[te,me]=m(null),[W,re]=m(null),[ne,_]=m(""),[ie,Te]=m(""),[Ie,et]=m(null),[z,U]=m([]),[oe,ke]=m(""),we=[...ve.value.values()].filter(B=>c.includes(B.repo)&&(!t||B.project===t||!B.project)),ce=we.find(B=>B.worktrees.some(xe=>xe.path===l)),tt=ce?.worktrees.find(B=>B.path===l),it=a??he.value.find(B=>B.id===oe)??he.value.find(B=>B.repos.includes(ce?.repo??l)),Xt=async(B,xe)=>Ue(async()=>{await O(B,xe),J("Updated")}),Ue=async B=>{if(!g){y(!0),h("");try{await B()}catch(xe){h(xe.message)}finally{y(!1)}}};return We(()=>{!s&&!l&&c[0]&&p(c[0])},[c.join("\0"),l]),N(()=>{$(null),T(null),de(null),Q(null),me(null),re(null),et(null),h("")},[l]),t&&!a?e("p",{role:"status",children:qs.value?"This project no longer exists.":"Loading project\u2026"}):t&&l&&!c.includes(l)&&!tt?e("p",{class:"msg warn",role:"status",children:"This repository or run worktree is unavailable in this project. Choose a repository above."}):e("div",{class:"workbench",children:[e("header",{class:"page-head",children:e("div",{class:"page-head-text",children:[e("h3",{children:"Inspect, verify, and recover"}),e("p",{children:"Check the repository, inspect code and context, and manage results with evidence."})]})}),e("div",{class:"wb-target",children:[e("label",{class:"lbl",for:"wb-folder",children:"Repository or run worktree"}),e("select",{id:"wb-folder",class:"field",value:l,disabled:g,onChange:B=>u(B.currentTarget.value),children:[c.length?c.map(B=>e("option",{value:B,children:B},B)):e("option",{value:"",children:"Choose a repository in New run"}),we.flatMap(B=>B.worktrees.map(xe=>e("option",{value:xe.path,children:[(B.task.split(`
|
|
45
|
+
`)[0]||"(no task)").slice(0,50)," \xB7 ",xe.name]},`${B.id}/${xe.name}`)))]})]}),e("div",{class:"wb-mobile-tool",children:[e("label",{class:"lbl",for:"wb-tool",children:"Repository tool"}),e("select",{id:"wb-tool",class:"field",value:i,disabled:g,onChange:B=>o(B.currentTarget.value),children:bc.map(B=>e("optgroup",{label:B.label,children:B.tools.map(([xe,F])=>e("option",{value:xe,children:F},xe))},B.label))})]}),e("div",{class:"wb-layout",children:[e("nav",{class:"wb-tabs","aria-label":"Repository tools",children:bc.map((B,xe)=>e("div",{class:"wb-group",role:"group","aria-labelledby":`wb-group-${xe}`,children:[e("div",{class:"wb-group-label",id:`wb-group-${xe}`,children:B.label}),B.tools.map(([F,R])=>e("button",{type:"button",class:"wb-tab","aria-current":i===F?"page":void 0,onClick:()=>o(F),children:R},F))]},B.label))}),e("div",{class:"wb-main",children:[!l&&i!=="coordination"&&i!=="filtered-tasks"?e("p",{class:"help wb-note",children:"Choose a repository in New run first."}):null,f?e("div",{class:"msg err",role:"alert",children:f}):null,g?e("p",{class:"help wb-note",role:"status",children:"Working\u2026"}):null,i==="verification"?e("section",{class:"wb-card",children:[e("h2",{children:"Verification profile"}),e("div",{class:"wb-row",children:[e("label",{children:["Profile ",e("select",{class:"field",value:v,onChange:B=>k(B.currentTarget.value),children:[e("option",{value:"lightweight",children:"Lightweight"}),e("option",{value:"standard",children:"Standard"}),e("option",{value:"thorough",children:"Thorough"})]})]}),e("button",{class:"btn",disabled:!l||g,onClick:()=>Ue(async()=>{let B=await V(`/api/verification/profile?repo=${G(l)}&preset=${v}`);T(B),A(B.setup??"")}),children:"Detect checks"})]}),C?e(M,{children:[e("p",{class:"help",children:[C.source?`Detected from ${C.source}. `:"","Required gates must pass. A skipped gate or flaky result cannot verify a change."]}),C.checks.map((B,xe)=>e("div",{class:"wb-check",children:[e("span",{children:B.title??B.id}),e("input",{class:"field",type:"text","aria-label":`Command for ${B.id}`,value:B.command,onInput:F=>T({...C,checks:C.checks.map((R,X)=>X===xe?{...R,command:F.currentTarget.value}:R)})}),e("label",{children:[e("input",{type:"checkbox",checked:B.required,onChange:F=>T({...C,checks:C.checks.map((R,X)=>X===xe?{...R,required:F.currentTarget.checked}:R)})})," Required"]})]},B.id)),e("button",{class:"btn small",disabled:C.checks.length>=12,onClick:()=>T({...C,checks:[...C.checks,{id:`custom-${C.checks.length+1}`,kind:"custom",command:"",required:!0,timeoutMs:3e5}]}),children:"Add custom gate"}),e("details",{children:[e("summary",{children:"Requirement evidence mapping"}),e("p",{class:"help",children:"Describe each criterion and select the checks that exercise it. A criterion with no checks, or a failing mapped check, remains uncovered. Review whether the checks actually test the stated behavior."}),(C.requirements??[]).map((B,xe)=>e("div",{children:[e("label",{children:[B.id,e("input",{class:"field","aria-label":`Description for ${B.id}`,value:B.description,onInput:F=>T({...C,requirements:C.requirements.map((R,X)=>X===xe?{...R,description:F.currentTarget.value}:R)})})]}),e("div",{class:"wb-row",children:C.checks.map(F=>e("label",{class:"check",children:[e("input",{type:"checkbox",checked:B.checks.includes(F.id),onChange:R=>T({...C,requirements:C.requirements.map((X,se)=>se===xe?{...X,checks:R.currentTarget.checked?[...X.checks,F.id]:X.checks.filter(Ce=>Ce!==F.id)}:X)})})," ",F.title??F.id]},F.id))})]},B.id)),e("button",{class:"btn small",disabled:(C.requirements?.length??0)>=48,onClick:()=>T({...C,requirements:[...C.requirements??[],{id:`criterion-${(C.requirements?.length??0)+1}`,description:"",checks:[]}]}),children:"Add criterion"})]}),e("div",{class:"wb-row",children:[e("label",{children:["Commit or branch",e("input",{class:"field",value:b,onInput:B=>S(B.currentTarget.value)})]}),e("label",{children:["Compare baseline",e("input",{class:"field",placeholder:"Optional base commit",value:x,onInput:B=>w(B.currentTarget.value)})]}),e("label",{children:["Attempts per gate",e("select",{class:"field",value:P,onChange:B=>D(Number(B.currentTarget.value)),children:[1,2,3].map(B=>e("option",{value:B,children:B}))})]})]}),e("label",{children:["Setup command",e("input",{class:"field",placeholder:"Optional, e.g. npm ci",value:j,onInput:B=>A(B.currentTarget.value)})]}),e("p",{class:"help",children:"Executes repository code in a temporary worktree at the selected commit. Uncommitted changes are excluded. Baseline comparison runs the same profile on both commits."}),e("div",{class:"wb-row",children:[e("button",{class:"btn primary",disabled:g||!C.checks.length||C.checks.some(B=>!B.command.trim()),onClick:()=>Ue(async()=>{$(null),$(await O("/api/verification",{repo:l,profile:C,baseRef:b,baseline:x,setup:j,repeats:P}))}),children:"Run verification"}),e("button",{class:"btn",onClick:()=>Do("verification-profile.json",JSON.stringify(C,null,2)),children:"Export profile"})]})]}):e("p",{class:"help",children:"Detect commands from this repository, then review the profile before executing it."}),I?e(M,{children:[e("h3",{children:["Result: ",I.state]}),e("p",{class:"help",children:["Commit ",I.commit.slice(0,12)]}),e("div",{class:"wb-scroll",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Gate"}),e("th",{children:"Required"}),e("th",{children:"Result"}),e("th",{children:"Evidence"})]})}),e("tbody",{children:I.checks.map(B=>e("tr",{children:[e("td",{children:B.check.title??B.check.id}),e("td",{children:B.check.required?"Yes":"No"}),e("td",{children:e("span",{class:`badge ${B.diagnosis==="passed"?"ok":B.diagnosis==="failed"||B.diagnosis==="regression"?"err":"warn"}`,children:Xu(B.diagnosis)})}),e("td",{children:e("details",{children:[e("summary",{children:[B.attempts.length," attempts"]}),B.attempts.map((xe,F)=>e("pre",{children:xe.output||`Exit ${xe.exitCode}`},F))]})})]},B.check.id))})]})}),I.skipped.map(B=>e("p",{class:"msg err",children:[B.check.id,": ",B.reason]})),I.requirements?.length?e("section",{"aria-label":"Requirement verification results",children:[e("h4",{children:"Requirement evidence"}),e("ul",{children:I.requirements.map(B=>e("li",{children:[B.covered?"Covered":"Uncovered",": ",B.description,B.missing.length?` \xB7 missing ${B.missing.join(", ")}`:B.covered?"":" \xB7 no checks mapped"]},B.id))})]}):null,e("button",{class:"btn",onClick:()=>Do("verification.md",I.markdown,"text/markdown"),children:"Export report"})]}):null]}):null,i==="code"?e(Qu,{folder:l},l):null,i==="context"?e("section",{class:"wb-card",children:[e("h2",{children:"Context inspector"}),e("p",{class:"help",children:"Preview explicit file context before selecting it for a task. Credential-file contents are excluded, and recognizable secrets are redacted."}),e("textarea",{class:"field","aria-label":"Context file paths",rows:5,placeholder:"One repository-relative file per line",value:E,onInput:B=>L(B.currentTarget.value)}),e("button",{class:"btn",disabled:!l||g||!E.trim(),onClick:()=>Ue(async()=>Q(await O("/api/workspace/context",{repo:l,paths:E.split(`
|
|
46
|
+
`).map(B=>B.trim()).filter(Boolean)}))),children:"Inspect context"}),H?e(M,{children:[e("p",{children:[H.bytes.toLocaleString()," bytes \xB7 approximately ",H.approximateTokens.toLocaleString()," tokens"]}),e("p",{class:"help",children:H.note}),H.files.map(B=>e("details",{children:[e("summary",{children:[B.path," ",B.sensitive?"\xB7 sensitive":`\xB7 ${B.bytes} bytes`]}),e("pre",{children:B.omitted??B.preview})]},B.path))]}):null]}):null,i==="history"?e("section",{class:"wb-card",children:[e("h2",{children:"Checkpoints and run controls"}),ce?e(M,{children:[e("p",{children:[ce.task.split(`
|
|
47
|
+
`)[0]," \xB7 ",ce.status,ce.pauseRequested?" \xB7 pause requested":""]}),e("div",{class:"wb-row",children:[e("button",{class:"btn",onClick:()=>{Y.value={view:"run",id:ce.id}},children:"Open run"}),ce.status==="running"?e("button",{class:"btn",disabled:g,onClick:()=>Xt(`/api/runs/${ce.id}/pause`,{paused:!ce.pauseRequested}),children:ce.pauseRequested?"Continue dispatch":"Pause after active work"}):null,e("label",{children:["Priority",e("select",{class:"field",value:ce.priority??0,onChange:B=>Xt(`/api/runs/${ce.id}/priority`,{priority:Number(B.currentTarget.value)}),children:[-10,0,10].map(B=>e("option",{value:B,children:B===10?"High":B===-10?"Background":"Normal"}))})]}),e("button",{class:"btn",disabled:g,onClick:()=>Ue(async()=>Do(`run-${ce.id}.json`,JSON.stringify(await V(`/api/runs/${ce.id}/export?transcript=1`),null,2))),children:"Export run evidence"})]})]}):e("p",{class:"help",children:"Select a run worktree above to pause, prioritize, fork, or apply its checkpoint files."}),e("button",{class:"btn",disabled:!l||g,onClick:()=>Ue(async()=>{let B=await V(`/api/workspace/checkpoints?repo=${G(l)}`);de(B),q(B.checkpoints[0]?.sha??"")}),children:"Load checkpoints"}),le?e(M,{children:[e("div",{class:"wb-row",children:[e("select",{class:"field","aria-label":"Checkpoint",value:ue,onChange:B=>{q(B.currentTarget.value),me(null),re(null)},children:le.checkpoints.map(B=>e("option",{value:B.sha,children:[B.sha.slice(0,8)," \xB7 ",B.subject]}))}),ce?e("button",{class:"btn",disabled:g||!ue,onClick:()=>Ue(async()=>{let B=await O(`/api/runs/${ce.id}/fork`,{commit:ue});Y.value={view:"run",id:B.id}}),children:"Fork from checkpoint"}):null]}),ce?e(M,{children:[e("textarea",{class:"field","aria-label":"Checkpoint paths",placeholder:"Files to restore from this checkpoint, one per line",value:ne,onInput:B=>_(B.currentTarget.value)}),e("p",{class:"help",children:"Applying selected files changes this worktree without committing them. The worktree must be clean and idle; existing changes are preserved by refusing the operation."}),e("button",{class:"btn",disabled:g||ce.status==="running"||!ne.trim(),onClick:()=>Ue(async()=>{await O("/api/workspace/apply-checkpoint",{repo:l,runId:ce.id,source:ue,expectedHead:le.head,paths:ne.split(`
|
|
48
|
+
`).map(B=>B.trim()).filter(Boolean)}),J("Selected checkpoint files applied; review before committing")}),children:"Apply selected files"})]}):null]}):null]}):null,i==="history"&&le?e("section",{class:"wb-card","aria-label":"Full checkpoint comparison",children:[e("h2",{children:"Compare and revert commits"}),e("p",{class:"help",children:"Compare every changed file between the selected checkpoint and the observed current HEAD. Reverting computes the inverse of one non-merge commit on a disposable checkout, then stages that reviewed change in a clean, idle owned worktree. Commit it yourself to record the revert."}),e("div",{class:"wb-row",children:[e("button",{class:"btn",disabled:g||!ue,onClick:()=>Ue(async()=>me(await O("/api/workspace/compare-checkpoint",{repo:l,from:ue,to:le.head}))),children:"Compare selected checkpoint to HEAD"}),ce?e("button",{class:"btn",disabled:g||ce.status==="running"||!ue,onClick:()=>Ue(async()=>{re(null),re(await O("/api/workspace/preview-revert",{repo:l,runId:ce.id,commit:ue,expectedHead:le.head}))}),children:"Preview inverse commit"}):null]}),te?e(M,{children:[e("p",{class:"help",children:[te.from.slice(0,12)," \u2192 ",te.to.slice(0,12)," \xB7 ",te.files.length," changed paths",te.truncated?" \xB7 preview truncated":""]}),te.stat.trim()?e("pre",{children:te.stat}):null,e("details",{children:[e("summary",{children:"Full commit patch"}),e("pre",{children:te.patch||"No changes between these commits."})]})]}):null,W&&ce?e("div",{class:"at-notice","aria-label":"Reviewed commit revert",children:[e("h4",{children:["Revert: ",W.subject]}),e("p",{class:"help",children:["Commit ",W.commit.slice(0,12)," \xB7 current HEAD ",W.head.slice(0,12),". Review the entire inverse patch before applying it. Conflicting reversions leave this worktree unchanged."]}),W.stat.trim()?e("pre",{children:W.stat}):null,e("details",{open:!0,children:[e("summary",{children:"Inverse patch to stage"}),e("pre",{children:W.patch})]}),e("button",{class:"btn primary",disabled:g||ce.status==="running",onClick:()=>Ue(async()=>{await O("/api/workspace/apply-revert",{repo:l,runId:ce.id,commit:W.commit,expectedHead:W.head,fingerprint:W.fingerprint}),re(null),J("Inverse change staged. Review and commit it to record the revert.",6e3)}),children:"Stage reviewed inverse change"})]}):null]}):null,i==="history"&&le&&ce?e("section",{class:"wb-card",children:[e("h2",{children:"Apply selected hunks"}),e("p",{class:"help",children:"Compare one existing text file against the selected checkpoint. Selected hunks remain unstaged for review; the run worktree must be clean and idle."}),e("div",{class:"wb-row",children:[e("input",{class:"field","aria-label":"File for checkpoint hunks",value:ie,placeholder:"Repository-relative file",onInput:B=>Te(B.currentTarget.value)}),e("button",{class:"btn",disabled:g||ce.status==="running"||!ie.trim(),onClick:()=>Ue(async()=>{et(await O("/api/workspace/checkpoint-hunks",{repo:l,runId:ce.id,source:ue,path:ie.trim()})),U([])}),children:"Compare hunks"})]}),Ie?e(M,{children:[e("p",{children:[Ie.hunks.length," hunks \xB7 ",Ie.source.slice(0,12)]}),Ie.hunks.map(B=>e("details",{children:[e("summary",{children:e("label",{children:[e("input",{type:"checkbox",checked:z.includes(B.id),onChange:xe=>U(xe.currentTarget.checked?[...z,B.id]:z.filter(F=>F!==B.id))})," ",B.header]})}),e("pre",{children:B.patch})]},B.id)),e("button",{class:"btn",disabled:g||!z.length||ce.status==="running",onClick:()=>Ue(async()=>{await O("/api/workspace/apply-hunks",{repo:l,runId:ce.id,source:Ie.source,path:Ie.path,expectedHead:Ie.head,hunks:z}),et(null),J("Selected hunks applied; review the unstaged changes")}),children:"Apply chosen hunks"})]}):null]}):null,i==="filtered-tasks"?e(M,{children:[e("div",{class:"wb-scope",children:[e("label",{class:"lbl",for:"filtered-tasks-project",children:"Filtered tasks project"}),e("select",{class:"field",id:"filtered-tasks-project",disabled:!!t,value:it?.id??"",onChange:B=>ke(B.currentTarget.value),children:he.value.map(B=>e("option",{value:B.id,children:B.name},B.id))})]}),it?e(M,{children:[e("p",{class:"help wb-note",children:["Manage project filesystem rules in ",e("a",{href:"#/settings/projects",children:"Settings \u2192 Projects & access"}),"."]}),e(Yu,{projectId:it.id,repos:it.repos},it.id)]}):e("p",{class:"help wb-note",children:["Create a project in ",e("a",{href:"#/settings/projects",children:"Settings"})," first."]})]}):null,i==="coordination"?e(vc,{}):null,i==="services"?ce&&tt?e(hc,{runId:ce.id,worktree:tt.name},`${ce.id}/${tt.name}`):e("p",{class:"help wb-note",children:"Select a run worktree to preview and launch its configured services."}):null]})]})]})}function yc({current:t}){if(t.view!=="inbox"&&t.view!=="automations"&&t.view!=="workspace"&&t.view!=="insights")return null;let s=t.view==="workspace"&&t.project?he.value.find(n=>n.id===t.project)?.name:void 0;return e("div",{class:"activity-page",children:[e("header",{class:"page-head",children:[e("div",{class:"page-head-text",children:e("h1",{children:s?`${s} repositories`:{inbox:"Inbox",automations:"Scheduling",workspace:"Repository tools",insights:"Insights"}[t.view]})}),t.view==="workspace"&&t.project?e("a",{class:"btn",href:`#/project/${encodeURIComponent(t.project)}`,children:"Back to project"}):null]}),t.view==="inbox"?e(ya,{mode:"inbox"}):null,t.view==="automations"?e(vr,{kind:t.kind}):null,t.view==="workspace"&&!t.project&&!ee.value?e("section",{children:[e("p",{children:["Choose a project or open a repository on ",Yt(),"."]}),e("div",{class:"project-destinations",children:[he.value.map(n=>e("a",{class:"btn",href:`#/project/${encodeURIComponent(n.id)}/repositories`,children:n.name})),e("button",{class:"btn",onClick:()=>zs(),children:"Open repository"})]})]}):null,t.view==="workspace"?e(Sr,{projectId:t.project}):null,t.view==="insights"?e(mc,{group:t.group}):null]})}function kc(){N(()=>(window.addEventListener("hashchange",Fn),window.addEventListener("pagehide",Fn),()=>{window.removeEventListener("hashchange",Fn),window.removeEventListener("pagehide",Fn),Fn()}),[]);let t=hl.value[0];return t?e(Zu,{request:t},t.id):null}function Zu({request:t}){let s=Z(null),n=Z(null),r=a=>{s.current?.close(),mo(t.id,a)};return We(()=>{let a=document.activeElement;return s.current?.showModal(),n.current?.focus(),()=>{s.current?.close(),a instanceof HTMLElement&&a.isConnected&&a.focus()}},[]),e("dialog",{ref:s,class:"picker small-dialog confirmation-dialog","aria-labelledby":`confirmation-title-${t.id}`,"aria-describedby":`confirmation-body-${t.id}`,onCancel:a=>{a.preventDefault(),a.stopPropagation(),r(!1)},onClose:()=>mo(t.id,!1),children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:`confirmation-title-${t.id}`,children:t.title})}),e("div",{class:"dialog-body",id:`confirmation-body-${t.id}`,children:t.message.split(/\n\s*\n/).map((a,c)=>e("p",{children:a},c))}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{type:"button",class:"btn",ref:n,onClick:()=>r(!1),children:"Cancel"}),e("button",{type:"button",class:`btn ${t.danger?"danger":"primary"}`,onClick:()=>r(!0),children:t.confirmLabel})]})]})})}function wc(){let[t,s]=m([]),[n,r]=m(""),[a,c]=m(!1),[i,d]=m({});N(()=>{let o=!0,u,f=An("approvals",h=>{o&&(h.type==="snapshot"&&h.records&&s(h.records),h.type==="error"&&h.status===404&&!u&&(u=lt(async()=>{let g=await V("/api/approvals");o&&s(g.filter(y=>y.status==="pending"))},2e3)))});return()=>{o=!1,f(),u?.()}},[]);let l=t[0];if(!l)return null;let p=async o=>{c(!0),r("");try{await O(`/api/approvals/${l.id}`,{decision:o,answers:i[l.id]}),s(u=>u.filter(f=>f.id!==l.id))}catch(u){r(u.message)}finally{c(!1)}};return e("aside",{class:"approval-inbox",role:"alert","aria-label":l.kind==="question"?"Agent question":"Tool approval required",children:[e("div",{class:"ai-head",children:[e(K,{name:"alert"}),e("h3",{children:l.kind==="question"?"Your agent has a question":"Permission required"}),t.length>1?e("span",{class:"ai-count",children:[t.length," pending"]}):null]}),e("div",{class:"ai-body",children:[e("p",{class:"ai-what",children:l.kind==="command"?"Run this command once":l.kind==="tool"?`Use ${l.toolName} once`:l.kind==="question"?"Answer to continue this turn":"Apply these file changes once"}),l.input?e("pre",{class:"ai-command",children:l.input}):null,l.questions?.map(o=>e("label",{children:[o.question,o.options?.length?e("div",{class:"row",children:o.options.map(u=>e("button",{class:"btn small",type:"button",onClick:()=>d(f=>({...f,[l.id]:{...f[l.id],[o.id]:u}})),children:u}))}):null,e("textarea",{class:"field","aria-label":o.question,value:i[l.id]?.[o.id]??"",onInput:u=>d(f=>({...f,[l.id]:{...f[l.id],[o.id]:u.currentTarget.value}}))})]},`${l.id}:${o.id}`)),l.command?e("pre",{class:"ai-command",children:l.command}):null,l.paths?.length?e("ul",{class:"ai-paths",children:l.paths.map(o=>e("li",{children:e("code",{children:o})},o))}):null,l.cwd?e("p",{class:"ai-folder",children:["Folder ",e("code",{children:l.cwd})]}):null,l.reason?e("p",{class:"ai-reason",children:l.reason}):null,e("p",{class:"help",children:["Expires at ",new Date(l.expiresAt).toLocaleTimeString(),". This decision grants no session-wide permissions."]}),n?e("p",{class:"msg err",children:n}):null]}),e("div",{class:"ai-actions",children:[e("button",{class:"btn primary",disabled:a||l.kind==="question"&&!l.questions?.every(o=>i[l.id]?.[o.id]?.trim()),onClick:()=>p("approve"),children:l.kind==="question"?"Send answer":"Approve once"}),e("button",{class:"btn",disabled:a,onClick:()=>p("decline"),children:"Decline"}),e("span",{class:"spacer"}),e("button",{class:"btn ghost",onClick:()=>{Y.value={view:"run",id:l.runId}},children:"Open chat"})]})]})}function Cc(){let t=()=>sn.value=!1,s=ye(!0,t),n=Z(null),[r,a]=m(""),[c,i]=m(0),d=[{id:"new",label:"New run",detail:"Actions",icon:"plus",run:()=>{Qe()}},{id:"docs",label:"Help & documentation",detail:"Guides, search and Ask code-flow using your local CLI",icon:"help",run:()=>{window.open("/docs/","_blank","noopener")}},{id:"settings",label:"Settings",detail:"Preferences, agents and remote connections",icon:"sliders",run:()=>Y.value={view:"settings"}},...Pa.filter(f=>!["workspace","automations","insights"].includes(f.id)).map(f=>({id:`settings:${f.id}`,label:f.label,detail:`Settings \xB7 ${f.keywords}`,icon:f.icon,run:()=>Y.value={view:"settings",section:f.id}})),{id:"inbox",label:"Inbox",detail:"Questions, failures and results needing review",icon:"bell",run:()=>Y.value={view:"inbox"}},{id:"automations",label:"Scheduling",detail:"Schedules and deferred runs",icon:"clock",run:()=>Y.value={view:"automations"}},{id:"workspace",label:"Repository tools",detail:"Workspace \xB7 code, checks and repositories",icon:"files",run:()=>Y.value={view:"workspace"}},{id:"insights",label:"Insights",detail:"Run results and usage",icon:"chart",run:()=>Y.value={view:"insights"}},{id:"team",label:"Board",detail:"People team collaboration tasks, hand-overs and your team inbox",icon:"people",run:()=>Y.value={view:"team"}},{id:"repo",label:"Choose repository",detail:"Actions",icon:"folder",run:()=>ct.value=!0},{id:"projects",label:"Manage projects",detail:"Actions",icon:"project",run:()=>_t.value=!0},{id:"health",label:"Check provider and Git health",detail:"Actions",icon:"alert",run:()=>hs.value=!0},{id:"files",label:"Open files panel",detail:"Actions",icon:"files",run:()=>$t("files")},{id:"terminal",label:"Open terminal",detail:"Actions",icon:"terminal",run:()=>$t("terminal")},...he.value.flatMap(f=>["board","people","automation"].map(h=>({id:`project:${f.id}:${h}`,label:`${f.name} \xB7 ${{board:"Board",people:"People",automation:"Automation"}[h]}`,detail:h==="automation"?"Project schedules backlog missions":"Project collaboration team members access",icon:h==="automation"?"clock":"people",run:()=>{h==="board"||h==="people"?location.assign(Tn(`#/project/${encodeURIComponent(f.id)}/${h}`,"local")):Y.value={view:"project",id:f.id,section:h}}}))),...he.value.map(f=>({id:`project:${f.id}`,label:f.name,detail:"Project",icon:"project",run:()=>{Y.value={view:"project",id:f.id}}})),...[...ve.value.values()].filter(f=>!f.archived).sort((f,h)=>h.createdAt-f.createdAt).map(f=>({id:`run:${f.id}`,label:f.task.split(`
|
|
49
|
+
`)[0]||f.id,detail:`Run \xB7 ${f.status} \xB7 ${f.repo}`,shown:`Run \xB7 ${Je[f.status]??f.status} \xB7 ${be(f.repo)}`,status:f.status,run:()=>Y.value={view:"run",id:f.id}}))],l=r.toLowerCase().trim().split(/\s+/).filter(Boolean),p=d.filter(f=>l.every(h=>`${f.label} ${f.detail}`.toLowerCase().includes(h))).slice(0,40),o=Math.min(c,Math.max(0,p.length-1)),u=f=>{f&&(t(),f.run())};return N(()=>{n.current?.focus()},[]),N(()=>{document.getElementById(`command-${o}`)?.scrollIntoView({block:"nearest"})},[o]),e("dialog",{class:"picker command-palette",ref:s,"aria-labelledby":"command-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head cp-head",children:[e("h3",{id:"command-title",class:"sr-only",children:"Commands and navigation"}),e("div",{class:"cp-search",children:[e(K,{name:"search"}),e("input",{ref:n,class:"field",role:"combobox","aria-label":"Find a command, project or run","aria-autocomplete":"list","aria-controls":"command-results","aria-expanded":"true","aria-activedescendant":p.length?`command-${o}`:void 0,value:r,placeholder:"Type a command, project, or task\u2026",onInput:f=>{a(f.currentTarget.value),i(0)},onKeyDown:f=>{(f.key==="ArrowDown"||f.key==="ArrowUp")&&(f.preventDefault(),i(Math.min(Math.max(0,c+(f.key==="ArrowDown"?1:-1)),Math.max(0,p.length-1)))),f.key==="Enter"&&(f.preventDefault(),u(p[o]))}})]})]}),e("div",{class:"picker-list",id:"command-results",role:"listbox","aria-label":"Matching commands",children:[p.map((f,h)=>e("div",{id:`command-${h}`,class:`command-result ${h===o?"active":""}`,role:"option","aria-selected":h===o,onMouseEnter:()=>i(h),onClick:()=>u(f),children:[f.status?e("span",{class:`cr-dot dot ${f.status}`,"aria-hidden":"true"}):e(K,{name:f.icon??"chevron"}),e("span",{class:"cr-label",children:f.label}),e("span",{class:"cr-detail",title:f.shown?f.detail:void 0,children:f.shown??f.detail})]},f.id)),p.length?null:e("p",{class:"cp-empty",children:"No commands, projects or runs match."})]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:[e("kbd",{children:"\u2191"}),e("kbd",{children:"\u2193"})," to choose \xB7 ",e("kbd",{children:"Enter"})," to open \xB7 ",e("kbd",{children:"Esc"})," to close"]}),e("button",{class:"btn",onClick:t,children:"Close"})]})]})})}var vn=t=>/(?:^|[\s:/(_-])free(?:$|[\s:)\]_-])/i.test(`${t.id} ${t.label}`);function Yn(t){return[...t].sort((s,n)=>Number(vn(n))-Number(vn(s)))}function xs({label:t,title:s,value:n,options:r,onChange:a,placeholder:c="Choose model",compact:i=!1,disabled:d=!1,class:l="",kind:p="model"}){let[o,u]=m(!1),[f,h]=m(""),[g,y]=m(!1),[C,T]=m(0),v=Z(null),k=Z(null),b=Z(null),S=Z(null),x=ja(),w=f.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean),j=g?r.filter(E=>!!E.id&&vn(E)):r,A=j.filter(E=>w.every(L=>`${E.label} ${E.id} ${E.description??""}`.toLocaleLowerCase().includes(L))),P=Math.min(C,Math.max(0,A.length-1)),D=r.find(E=>E.id===n),I=(E=!0)=>{u(!1),E&&k.current?.focus()},$=E=>{a(E),I()};return We(()=>{if(!o)return;let E=()=>{if(!k.current||!b.current)return;let Q=k.current.getBoundingClientRect(),le=Math.min(Math.max(Q.width,340),window.innerWidth-24),de=window.innerHeight-Q.bottom-20,ue=Q.top-20,q=de<280&&ue>de;Object.assign(b.current.style,{width:`${le}px`,left:`${Math.max(12,Math.min(Q.left,window.innerWidth-le-12))}px`,maxHeight:`${Math.min(420,Math.max(100,q?ue:de))}px`,top:q?"auto":`${Q.bottom+6}px`,bottom:q?`${window.innerHeight-Q.top+6}px`:"auto"})};E(),S.current?.focus();let L=Q=>{b.current?.contains(Q.target)||E()};window.addEventListener("resize",E),document.addEventListener("scroll",L,!0);let H=Q=>{v.current?.contains(Q.target)||I(!1)};return document.addEventListener("pointerdown",H),()=>{window.removeEventListener("resize",E),document.removeEventListener("scroll",L,!0),document.removeEventListener("pointerdown",H)}},[o]),N(()=>{o&&document.getElementById(`${x}-${P}`)?.scrollIntoView({block:"nearest"})},[o,P,f,g]),e("div",{class:`model-select ${i?"compact":""} ${l}`,ref:v,children:[e("button",{type:"button",class:"model-select-trigger",ref:k,disabled:d,"aria-label":t,"aria-haspopup":"listbox","aria-expanded":o,"aria-controls":o?x:void 0,title:D?.label??c,onClick:()=>{h(""),T(Math.max(0,j.findIndex(E=>E.id===n))),u(!o)},children:[e("span",{children:D?.label??(n||c)}),e(K,{name:"chevron"})]}),o?e("div",{class:"model-select-popup",ref:b,onKeyDown:E=>{E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),I())},onBlur:E=>{E.relatedTarget&&!E.currentTarget.contains(E.relatedTarget)&&I(!1)},children:[e("div",{class:"model-select-search",children:[e("div",{class:"model-select-heading",children:[e("div",{class:"pop-title",children:s??t}),p==="model"?e("button",{type:"button",class:"model-free-filter","aria-pressed":g,onClick:()=>{y(!g),T(0)},children:[e("span",{"aria-hidden":"true",children:g?"\u2713":"+"})," Free only"]}):null]}),e("input",{ref:S,class:"field",type:"search",role:"combobox","aria-label":`Search ${t}`,"aria-autocomplete":"list","aria-expanded":"true","aria-controls":x,"aria-activedescendant":A.length?`${x}-${P}`:void 0,placeholder:p==="branch"?"Search branches\u2026":"Search models\u2026",value:f,onInput:E=>{h(E.currentTarget.value),T(0)},onKeyDown:E=>{E.key==="ArrowDown"||E.key==="ArrowUp"?(E.preventDefault(),T(A.length?(P+(E.key==="ArrowDown"?1:A.length-1))%A.length:0)):E.key==="Enter"&&!E.isComposing&&(E.preventDefault(),A[P]&&$(A[P].id))}})]}),e("div",{class:"model-select-results",role:"listbox",id:x,"aria-label":t,children:A.map((E,L)=>e("button",{id:`${x}-${L}`,type:"button",role:"option","aria-selected":E.id===n,tabIndex:-1,class:`model-select-option ${L===P?"active":""}`,onClick:()=>$(E.id),children:[e("span",{children:[e("span",{class:"model-option-name",children:E.label}),E.description?e("span",{class:"model-option-description",children:E.description}):null]}),e("span",{class:"model-option-meta",children:[p==="model"&&E.id&&vn(E)?e("span",{class:"model-free-badge",children:"Free"}):null,E.id===n?e("span",{"aria-hidden":"true",children:"\u2713"}):null]})]},E.id))}),A.length?null:e("div",{class:"model-select-empty",role:"status",children:g?"No free models found. Try another search or turn off Free only.":p==="branch"?"No branches found. Try another name.":"No models found. Try another name or model ID."})]}):null]})}function bs({agent:t,onAgent:s,settings:n,onSettings:r,permissions:a,onPermissions:c,restricted:i=!1,approvalsAvailable:d=!0,providers:l,showPermissions:p=!0}){let[o,u]=m(!1),f=l??Re.value,h=f.find(w=>w.id===t),g=ps.value[t],y=g&&!("error"in g)?g:void 0,C=y?.models.find(w=>w.id===(n.model||y.defaultModel)),T=C?.efforts??y?.efforts??[],v=n.model?C?.label??n.model:"Default model",k=n.effort||"Default effort",b=w=>{let A=y?.models.find(P=>P.id===(w||y.defaultModel))?.efforts??y?.efforts??[];r({model:w,effort:A.includes(n.effort??"")?n.effort:""})},S=(w,j)=>e(M,{children:[e("span",{children:j}),w?e("span",{class:"chat-choice-check","aria-label":"Selected",children:"\u2713"}):null]}),x=w=>e(M,{children:[e("span",{children:w}),e(K,{name:"chevron"})]});return e("div",{class:"chat-controls",children:[s?e(Ve,{above:!0,label:"Provider",icon:"layers",class:"chat-choice",trigger:x(h?.displayName??t),children:w=>e(M,{children:[e(kt,{children:"Provider"}),f.map(j=>e(pe,{on:j.id===t,disabled:!j.available,sub:j.available?void 0:"Not installed",onClick:()=>{s(j.id),a.tools&&c({trust:j.id.startsWith("acp:")?"full":"standard",tools:j.id==="codex"||j.id==="claude"||j.id.startsWith("acp:")}),u(!1),w()},children:S(j.id===t,j.displayName)},j.id))]})}):e("span",{class:"chat-provider-fixed",title:"Provider stays fixed for this conversation. Start a new run to use another provider.",children:h?.displayName??t}),e(xs,{compact:!0,label:"Model",title:`Model \xB7 ${h?.displayName??t}`,value:n.model??"",placeholder:v,options:[{id:"",label:"Default model",description:y?.defaultModel??"Use the provider's default"},...y?Yn(y.models):[],...y?.allowCustom?[{id:"__custom",label:"Other model\u2026"}]:[]],onChange:w=>{w==="__custom"?u(!0):(b(w),u(!1))}}),e(Ve,{above:!0,label:"Effort",icon:"sparkle",class:"chat-choice",title:`Effort: ${k}`,trigger:x(k),children:w=>e(M,{children:[e(kt,{children:"Reasoning effort"}),e(pe,{on:!n.effort,sub:C?.defaultEffort??y?.defaultEffort??"Use the provider's default",onClick:()=>{r({...n,effort:""}),w()},children:S(!n.effort,"Default effort")}),T.map(j=>e(pe,{on:n.effort===j,onClick:()=>{r({...n,effort:j}),w()},children:S(n.effort===j,j)},j)),T.length?null:e(kt,{children:"This model offers no effort choices"})]})}),p?e(Lo,{agent:t,permissions:a,onPermissions:c,restricted:i,approvalsAvailable:d}):null,o?e("input",{class:"field chat-custom-model","aria-label":"Custom model",placeholder:"Model ID",value:n.model??"",onInput:w=>b(w.currentTarget.value.trim())}):null]})}function Lo({agent:t="codex",permissions:s,onPermissions:n,restricted:r=!1,approvalsAvailable:a=!0}){let c=s.tools?"Ask for approval":{safe:"Safe",standard:"Approve for me",trusted:"Trusted",full:"Full access"}[s.trust],i=a&&!r&&(t==="codex"||t==="claude"||t.startsWith("acp:")),d=(l,p)=>e(M,{children:[e("span",{children:p}),l?e("span",{class:"chat-choice-check","aria-label":"Selected",children:"\u2713"}):null]});return e(Ve,{above:!0,label:"Permissions",icon:"sliders",class:`chat-choice chat-permissions ${s.trust==="full"&&!s.tools?"full-access":""}`,trigger:e(M,{children:[e(K,{name:"sliders"}),e("span",{children:c}),e(K,{name:"chevron"})]}),children:l=>e(M,{children:[e(kt,{children:"How should actions be approved?"}),e(pe,{on:s.tools,disabled:!i,sub:i?"Show supported tool requests in the approval inbox.":"Requires a local Claude, Codex or ACP provider with approval support.",onClick:()=>{n({trust:t.startsWith("acp:")?"full":"standard",tools:!0}),l()},children:d(s.tools,"Ask for approval")}),e(pe,{on:!s.tools&&s.trust==="standard",disabled:r||t.startsWith("acp:"),sub:"Allow routine edits and commands. Restricted actions are blocked.",onClick:()=>{n({trust:"standard",tools:!1}),l()},children:d(!s.tools&&s.trust==="standard","Approve for me")}),e(pe,{on:!s.tools&&s.trust==="full",disabled:r,sub:"No provider sandbox. Commands, network and files outside the worktree.",onClick:()=>{n({trust:"full",tools:!1}),l()},children:d(!s.tools&&s.trust==="full","Full access")}),r?e(kt,{children:"This run's permission restrictions stay in effect."}):null]})})}function Tc(t){return{schemaVersion:1,id:`strategy-${Date.now().toString(36)}`,version:1,name:"New team strategy",description:"Describe when this strategy helps.",scope:t?"project":"personal",...t?{project:t}:{},autoEnabled:!1,parameters:["task"],roles:["builder"],workflow:void 0,task:"{{task}}",criteria:[],contracts:[],tasks:[{id:"implement",title:"Implement the task",role:"builder",kind:"implementation",instructions:"{{task}}",dependsOn:[],paths:["*"],acceptance:["The requested behavior is implemented and tested."]}]}}function ep(t){let s=URL.createObjectURL(new Blob([JSON.stringify(t,null,2)],{type:"application/json"})),n=document.createElement("a");n.href=s,n.download=`${t.id}-v${t.version}.json`,n.click(),URL.revokeObjectURL(s)}function xr({initial:t}){let s=t?.project??(vt.value||void 0),n=s?`?project=${encodeURIComponent(s)}`:"",[r,a]=m([]),[c,i]=m(t??null),[d,l]=m(!!t),[p,o]=m(t?JSON.stringify(t,null,2):""),[u,f]=m(0),[h,g]=m({task:Me.value}),[y,C]=m(""),[T,v]=m(!1),[k,b]=m([]),S=Z(null),x=async()=>a((await V(`/api/team-templates${n}`)).templates);N(()=>{let I=!0;return C(""),a([]),V(`/api/team-templates${n}`).then($=>{I&&a($.templates)},$=>{I&&C($.message)}),()=>{I=!1}},[s]);let w,j="";if(d)try{w=Yr(JSON.parse(p))}catch(I){j=I.message}let A=(I,$=!1)=>{i(I),o(JSON.stringify(I,null,2)),f($?0:I.version),l(!0),C(""),b([])},P=async()=>{if(w){v(!0),C("");try{let I=await O("/api/team-templates",{template:{...w,version:u+1},expectedVersion:u});await x(),A(I),J(`Saved ${I.name} v${I.version}`)}catch(I){C(I.message)}finally{v(!1)}}},D=()=>{if(c)try{let I=Object.fromEntries(c.parameters.map(L=>[L,h[L]??""])),$=Hi(c,I);St(c.workflow??"auto-team"),Tt($.task),ms($.criteria);let E=ge.value.find(L=>L.id===(c.workflow??"auto-team"));if(E&&c.preferences){let L=c.preferences;for(let H of E.roles)L.roles[H.id]&&At(E.id,H.id,L.roles[H.id]);for(let H of E.options)L.options[H.id]!==void 0&&pn(E,H.id,L.options[H.id]);for(let[H,Q]of Object.entries(L.agentSettings))Fs(H,Q);for(let[H,Q]of Object.entries(L.roleSettings))for(let[le,de]of Object.entries(Q))It(E.id,H,le,de)}us.value={template:c,inputs:I},J(`Using ${c.name} v${c.version}; run permissions retained`)}catch(I){C(I.message)}};return e("section",{class:"section team-template-library","aria-label":"Reusable team templates",children:[e("h3",{children:"Reusable team templates"}),e("p",{class:"help",children:"Auto can build its own plan or reuse enabled task graphs (up to six definitions of 16,000 characters per run, ordered by ID). Fixed workflows keep their original checks and execution behavior. All templates use the run's permissions."}),e("label",{class:"lbl",for:"team-template-select",children:"Saved templates"}),e("select",{class:"field",id:"team-template-select",value:c?.id??"",onChange:I=>{let $=r.find(E=>E.id===I.currentTarget.value)??null;i($),l(!1),b([]),C(""),g({task:Me.value})},children:[e("option",{value:"",children:"Choose a saved template"}),r.map(I=>e("option",{value:I.id,children:[I.name," \xB7 v",I.version," \xB7 ",I.scope,I.autoEnabled?" \xB7 available to Auto":""]},I.id))]}),c&&!d?e("div",{class:"section",children:[e("p",{children:c.description}),c.parameters.map(I=>e("label",{class:"lbl",children:[I,e("input",{class:"field",value:h[I]??"",onInput:$=>g({...h,[I]:$.currentTarget.value})})]},I)),e("p",{class:"help",children:c.workflow?`Workflow: ${ge.value.find(I=>I.id===c.workflow)?.name??c.workflow}`:`${c.tasks.length} tasks \xB7 ${c.roles.join(", ")} \xB7 independent final verification`}),e("button",{class:"btn",onClick:D,children:"Use this template"})," ",e("button",{class:"btn",onClick:()=>A(c),children:"Edit new version"})," ",e("button",{class:"btn",onClick:()=>A({...c,id:`copy-${Date.now().toString(36)}`,version:1,name:`${c.name} copy`},!0),children:"Copy"})," ",e("button",{class:"btn",onClick:()=>ep(c),children:"Export"})," ",e("button",{class:"btn",onClick:async()=>{try{let I=await V(`/api/team-templates${n}${n?"&":"?"}history=1`);b(I.templates.filter($=>$.id===c.id))}catch(I){C(I.message)}},children:"Version history"}),k.map(I=>e("details",{children:[e("summary",{children:["Version ",I.version,I.version===c.version?" \xB7 selected":""]}),e("pre",{children:JSON.stringify(I,null,2)}),e("button",{class:"btn",onClick:()=>{i(I),g({task:Me.value})},children:"Use this version"})]},I.version))]}):null,e("div",{class:"section",children:[e("button",{class:"btn",onClick:()=>A(Tc(s),!0),children:"Design a template"})," ",ln.value&&ln.value.id!=="auto-team"?e(M,{children:[e("button",{class:"btn",onClick:()=>{let I=ln.value;A({...Tc(s),name:`${I.name} template`,workflow:I.id,roles:[],tasks:[],task:Me.value||"{{task}}",preferences:Fi({roles:Vt(I),options:as(I),agentSettings:Be.value,roleSettings:rt.value[I.id]??{}})},!0)},children:"Save current workflow as template"})," "]}):null,e("button",{class:"btn",onClick:()=>S.current?.click(),children:"Import template"})," ",e("button",{class:"btn",disabled:T,onClick:async()=>{v(!0),C("");try{let I=0;for(let $ of[void 0,...s?[s]:[]]){let E=$?`composerLibrary:${$}`:"composerLibrary",L=ae.get(E);if(!L)continue;let H=await O(`/api/team-templates/migrate${$?`?project=${encodeURIComponent($)}`:""}`,JSON.parse(L));I+=H.imported}await x(),J(`Imported ${I} templates. Browser originals retained; permissions were not imported.`)}catch(I){C(I.message)}finally{v(!1)}},children:"Import browser library"}),e("input",{hidden:!0,ref:S,type:"file",accept:"application/json,.json",onChange:async I=>{let $=I.currentTarget.files?.[0];if($)try{if($.size>15e4)throw new Error("Template is too large");let E=Yr(JSON.parse(await $.text()));A({...E,id:`import-${Date.now().toString(36)}`,version:1,scope:s?"project":"personal",project:s,autoEnabled:!1},!0)}catch(E){C(E.message)}}})]}),d?e("div",{class:"section",children:[e("p",{children:["Design parameters, roles, instructions, dependencies, owned paths, and acceptance criteria below. Publishing creates version ",u+1,". The previous version stays unchanged."]}),w?e(M,{children:[e("label",{class:"lbl",children:["Name",e("input",{class:"field",value:w.name,onInput:I=>o(JSON.stringify({...w,name:I.currentTarget.value},null,2))})]}),e("label",{class:"checkpoint",children:[e("input",{type:"checkbox",checked:w.autoEnabled,disabled:!!w.workflow,onChange:I=>o(JSON.stringify({...w,autoEnabled:I.currentTarget.checked},null,2))}),e("span",{children:"Allow Auto to reuse this strategy"})]})]}):null,e("label",{class:"lbl",for:"team-template-definition",children:"Template definition"}),e("textarea",{id:"team-template-definition",class:"field mono",rows:18,spellcheck:!1,value:p,onInput:I=>o(I.currentTarget.value)}),j?e("p",{class:"err",role:"alert",children:j}):w?e("div",{class:"help",children:[e("b",{children:"Execution preview:"})," ",w.workflow?`Fixed workflow ${w.workflow}`:e("ol",{children:w.tasks.map(I=>e("li",{children:[I.title," \xB7 ",I.role," \xB7 ",I.kind,I.dependsOn.length?` \xB7 after ${I.dependsOn.join(", ")}`:""]},I.id))}),e("p",{children:"Required task criteria and independent verification survive Auto adaptations. Permissions and spending limits come from the run."})]}):null,e("button",{class:"btn primary",disabled:T||!!j,onClick:()=>void P(),children:T?"Saving\u2026":"Publish template version"})," ",e("button",{class:"btn",onClick:()=>l(!1),children:"Close editor"})]}):null,y?e("p",{class:"err",role:"alert",children:y}):null]})}var tp=new Set(["localhost","127.0.0.1","[::1]"]);function sp(t,s){try{let n=new URL(t);return n.protocol!=="http:"||!tp.has(n.hostname)||!n.port||n.username||n.password||s&&n.port===new URL(s).port?void 0:n.href}catch{return}}function Sc(t,s){let n=[...t.matchAll(/http:\/\/(?:localhost|127\.0\.0\.1|\[::1\]):\d+(?:[/?#][^\s<>"'`()\[\]]*)?/gi)];return[...new Set(n.map(([r])=>sp(r.replace(/[.,;!]+$/,""),s)).filter(r=>!!r))]}function Rr({run:t,checking:s=!1,branch:n}){let r=at(t,s,n),a=n?!!t.humanReview?.[n]:Object.keys(t.humanReview??{}).length>0;return e("dl",{class:"run-evidence","aria-label":"Run status and evidence",children:[e("div",{children:[e("dt",{children:"Execution"}),e("dd",{children:br(t)})]}),e("div",{children:[e("dt",{children:"Checks"}),e("dd",{class:r==="Passed"?"evidence-ok":["Failed","Blocked"].includes(r)?"evidence-warn":"",children:r})]}),e("div",{children:[e("dt",{children:"Agent review"}),e("dd",{children:yr(t,n)})]}),e("div",{children:[e("dt",{children:"Human review"}),e("dd",{children:a?"Recorded \xB7 see file coverage":"Not recorded"})]})]})}function $r({run:t}){return e("details",{class:"verify-profile",children:[e("summary",{children:["Verification evidence",t.verification?` \xB7 ${t.verification.checks.length} checks`:""]}),e("p",{class:"help",children:"Evidence belongs to the recorded run and commit. Review coverage and merge validation check the current branch separately."}),t.checkCantRun?e("p",{class:"msg warn",children:[t.checkCantRun.command,": ",t.checkCantRun.reason]}):null,t.lastCheck?e("p",{children:["Last check: ",e("code",{children:t.lastCheck.command})," \xB7 ",t.lastCheck.ok?"Passed":"Failed"," \xB7 ",new Date(t.lastCheck.at).toLocaleString()]}):e("p",{class:"help",children:"No check result recorded."}),t.verification?e(M,{children:[t.verification.branch?e("p",{class:"help",children:["Checked branch ",e("code",{children:t.verification.branch})]}):null,t.verification.head?e("p",{class:"help",children:["Commit ",e("code",{children:t.verification.head.slice(0,12)})]}):null,e("ul",{children:t.verification.checks.map(s=>e("li",{children:[s.check.title??s.check.id,": ",s.diagnosis,s.check.required?" (required)":"",s.reason?` \xB7 ${s.reason}`:""]},s.check.id))}),t.verification.skipped.map(s=>e("p",{class:"help",children:["Skipped ",s.check.title??s.check.id,": ",s.reason]},s.check.id)),t.verification.risk?e("p",{children:["Change risk: ",t.verification.risk.level," \xB7 ",t.verification.risk.reasons.join("; ")||"No configured sensitive-path rule matched."]}):null,t.verification.requirements?.length?e("ul",{children:t.verification.requirements.map(s=>e("li",{children:[s.covered?"Covered":"Uncovered",": ",s.description,s.missing.length?` \xB7 missing ${s.missing.join(", ")}`:""]},s.id))}):null]}):null]})}async function np(t){let s=`/api/runs/${encodeURIComponent(t)}`;try{await V(s,{method:"DELETE"})}catch(n){if(!(n instanceof st)||n.status!==404)throw n;try{await V(s)}catch(r){if(r instanceof st&&r.status===404){ao(t);return}throw r}throw new Error("This server hasn't loaded the delete update yet. Restart Code Flow, then refresh this page and try again.")}ao(t)}function xc({run:t,onClose:s}){return e(No,{runs:[t],onClose:s})}function No({runs:t,onClose:s,onDeleted:n}){let[r,a]=m(t),[c,i]=m(!1),[d,l]=m(""),p=ye(!0,()=>{c||s()}),o=t.length===1;return e("dialog",{class:"picker small-dialog",ref:p,"aria-labelledby":"delete-run-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"delete-run-title",children:o?"Delete this run?":`Delete ${r.length} ${r.length===1?"run":"runs"}?`})}),e("div",{class:"dialog-body",children:[o?e("p",{class:"delete-run-name",children:r[0]?.task.split(`
|
|
50
|
+
`)[0]}):e("ul",{class:"delete-run-list",children:r.map(u=>e("li",{children:u.task.split(`
|
|
51
|
+
`)[0]||"Untitled run"},u.id))}),e("p",{children:["This permanently deletes ",o?"the conversation and run history":"these conversations and their run history",". It cannot be undone."]}),e("p",{class:"help",children:["Git branches, worktrees and repository files are kept. Archive instead if you want to keep ",o?"the conversation":"the conversations","."]}),d?e("div",{class:"err",role:"alert",children:d}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn",disabled:c,onClick:s,children:"Cancel"}),e("button",{class:"btn danger",disabled:c,onClick:async()=>{i(!0),l("");let u=[],f=[];for(let g of r)try{await np(g.id),n?.(g.id)}catch(y){u.push(g),f.push(`${o?"":`${g.task.split(`
|
|
52
|
+
`)[0]}: `}${y.message}`)}let h=r.length-u.length;if(h&&J(h===1?"Run deleted":`${h} runs deleted`),!u.length){s();return}a(u),l(f.join(`
|
|
53
|
+
`)),i(!1)},children:c?"Deleting\u2026":o?"Delete run":`Delete ${r.length} ${r.length===1?"run":"runs"}`})]})]})})}function Rc(t,s){let n=new Set(s);for(let r=0;r<t.length;r++){let a=!1;for(let c of t)!n.has(c.id)&&c.dependsOn.some(i=>n.has(i))&&(n.add(c.id),a=!0);if(!a)break}return n}var ap=["title","body","paths","applicability"];function Qn(t){return structuredClone({title:t.title,body:t.body,paths:t.paths,applicability:t.applicability})}function Oo(t,s,n){let r=Qn(s),a=[];for(let c of ap){let i=JSON.stringify(t[c]),d=JSON.stringify(s[c]),l=JSON.stringify(n[c]);d===i?Object.assign(r,{[c]:structuredClone(n[c])}):l!==i&&l!==d&&a.push(c)}return{draft:r,conflicts:a}}function $c(t,s,n,r){let a=Oo(t,s,n);for(let c of a.conflicts){if(!r[c])throw new Error(`Choose which ${c} to keep before applying the merge`);r[c]==="latest"&&Object.assign(a.draft,{[c]:structuredClone(n[c])})}return a.draft}function Ic({endpoint:t,repo:s,entries:n,refreshKey:r,onPublished:a}){let[c,i]=m(!1),[d,l]=m(null),[p,o]=m(!1),[u,f]=m(""),[h,g]=m(0),[y,C]=m(!1);N(()=>{if(!c)return;let k=!0,b=new AbortController;return o(!0),f(""),V(`${t}/analysis?repo=${encodeURIComponent(s)}`,{signal:b.signal}).then(S=>{k&&l(S)},S=>{k&&f(S.message)}).finally(()=>{k&&o(!1)}),()=>{k=!1,b.abort()}},[c,t,s,n,r,h]);let T=k=>n.find(b=>b.id===k)?.title??k,v=async()=>{if(!(!d?.onboarding.sourceRefs.length||y)){C(!0),f("");try{await O(`${t}/analysis/publish`,{repo:s,expectedSources:d.onboarding.sourceRefs}),J("Onboarding guidance saved with its source revisions."),await a(),g(k=>k+1)}catch(k){f(k.message)}finally{C(!1)}}};return e("details",{class:"at-section memory-analysis",onToggle:k=>i(k.currentTarget.open),children:[e("summary",{children:"Advanced memory tools"}),e("p",{class:"help",children:"Inspect sources, review applicability and repeated wording, and curate accepted guidance before publishing it."}),e("button",{class:"btn small",disabled:p,onClick:()=>g(k=>k+1),children:p?"Inspecting\u2026":"Refresh memory analysis"}),u?e("p",{class:"msg err",role:"alert",children:u}):null,d?e(M,{children:[e("p",{class:"help",children:[d.graph.nodes.filter(k=>k.available).length," entries inspected",d.git.head?` at ${d.git.head.slice(0,12)}`:" \xB7 Git evidence unavailable",d.git.branch?` \xB7 ${d.git.branch}`:"",".",d.truncated?" Analysis reached a limit; omitted entries or comparisons need separate review.":""]}),e("details",{children:[e("summary",{children:"Source and derived-entry graph"}),e(rp,{graph:d.graph})]}),e("details",{children:[e("summary",{children:["Freshness and applicability \xB7 ",d.stale.length," to review"]}),d.stale.length?e("ul",{children:d.stale.map(k=>e("li",{children:[e(Xn,{id:k.id,children:T(k.id)})," \xB7 revision ",k.revision,e("ul",{children:k.reasons.map((b,S)=>e("li",{children:b.detail},S))})]},k.id))}):e("p",{class:"help",children:"No issues found by these bounded checks. This is not a semantic correctness assessment."})]}),e("details",{children:[e("summary",{children:["Repeated wording \xB7 ",d.duplicates.length," pairs"]}),e("p",{class:"help",children:"Lexical overlap is a review hint. Supported semantic claims are inspected separately below. Compare applicability before combining entries."}),d.duplicates.length?e("ul",{children:d.duplicates.map(k=>e("li",{children:[e(Xn,{id:k.a.id,children:T(k.a.id)})," and ",e(Xn,{id:k.b.id,children:T(k.b.id)})," \xB7 ",k.kind==="exact"?"Same text, ignoring whitespace":`${Math.round(k.similarity*100)}% lexical overlap`]},`${k.a.id}:${k.b.id}`))}):e("p",{class:"help",children:"No repeated wording found within the comparison limit."})]}),e("details",{children:[e("summary",{children:["Semantic claim review \xB7 ",d.claims.findings.filter(k=>k.kind==="contradiction").length," conflicts \xB7 ",d.claims.findings.filter(k=>k.kind==="equivalent").length," equivalent pairs"]}),e("p",{class:"help",children:d.claims.method}),e("p",{class:"help",children:[d.claims.claims.length," claims from ",d.claims.inspectedEntries," entries; ",d.claims.unsupported," unsupported lines or facts. ",d.claims.truncated?"A claim/comparison limit was reached.":""," Source paths and branch applicability must overlap before a pair is suggested."]}),d.claims.findings.length?e("ul",{children:d.claims.findings.map((k,b)=>e("li",{children:[e("strong",{children:[k.kind==="contradiction"?"Potential contradiction":"Equivalent supported claim",": ",k.predicate," \xB7 ",k.subject]}),e("p",{children:[e(Xn,{id:k.a.id,children:T(k.a.id)})," revision ",k.a.revision," and ",e(Xn,{id:k.b.id,children:T(k.b.id)})," revision ",k.b.revision]}),e("p",{class:"help",children:k.explanation}),e("details",{children:[e("summary",{children:"Compare claim evidence"}),e("p",{children:["Left \xB7 ",k.left.evidence.method," \xB7 characters ",k.left.evidence.start,"\u2013",k.left.evidence.end]}),e("pre",{children:k.left.evidence.text}),e("pre",{children:JSON.stringify(k.left.value)}),e("p",{children:["Right \xB7 ",k.right.evidence.method," \xB7 characters ",k.right.evidence.start,"\u2013",k.right.evidence.end]}),e("pre",{children:k.right.evidence.text}),e("pre",{children:JSON.stringify(k.right.value)})]})]},`${k.a.id}:${k.b.id}:${b}`))}):e("p",{class:"help",children:"No supported claim pairs found. This does not show that arbitrary prose is consistent."}),e("details",{children:[e("summary",{children:"Write explicit semantic facts"}),e("p",{class:"help",children:"Edit a knowledge entry to include this fenced block. Subjects and predicates identify one fact; booleans express policy, strings express exact settings, and numbers/ranges use count, time or byte units. Keep conditions in the entry's path and branch applicability. Only reviewed project guidance should be accepted."}),e("pre",{children:'```codeflow-claims\n[\n {"subject":"guest requests","predicate":"allow","value":false},\n {"subject":"cache ttl","predicate":"setting","min":5,"max":10,"unit":"minutes"}\n]\n```'}),e("p",{class:"help",children:"The local grammar also recognizes simple standalone instructions such as \u201CNever permit guest requests\u201D and \u201CSet cache TTL to 300 seconds\u201D. Conditional, compound and unsupported sentences require explicit facts; no model or external service is used."})]})]}),e("details",{children:[e("summary",{children:"Curated project onboarding"}),e("p",{class:"help",children:"Only accepted guidance written by you with trusted user origins is included. Entries needing review, imported material, private material and earlier onboarding summaries are excluded."}),d.onboarding.body?e(M,{children:[e(je,{text:d.onboarding.body}),e("p",{class:"help",children:["Sources: ",d.onboarding.sourceRefs.map(k=>`${T(k.id)} (revision ${k.revision})`).join(", "),". ",d.onboarding.omitted," entries omitted."]}),e("button",{class:"btn small primary",disabled:y||p,onClick:v,children:y?"Saving\u2026":"Save onboarding as project knowledge"}),e("p",{class:"help",children:"Saving is your explicit publication of the reviewed summary. Source revisions are rechecked before it is saved."})]}):e("p",{class:"help",children:"No eligible guidance to publish. Add or review user-authored repository guidance first."}),d.onboarding.reasons.length?e("details",{children:[e("summary",{children:"Why entries were omitted"}),e("ul",{children:d.onboarding.reasons.map(k=>e("li",{children:[T(k.id),": ",k.reason]},k.id))})]}):null]}),d.notes.map((k,b)=>e("p",{class:"help",children:k},b))]}):p?e("p",{class:"help",role:"status",children:"Inspecting project knowledge\u2026"}):null]})}function rp({graph:t}){let s=`memory-provenance-${ja().replace(/:/g,"")}`,[n,r]=m(""),a=t.nodes.slice(0,60),c=new Set(a.map(h=>h.key)),i=t.edges.filter(h=>c.has(h.from)&&c.has(h.to)),d=new Map(a.map(h=>[h.key,0]));for(let h=0;h<6;h++)for(let g of i)d.set(g.to,Math.min(5,Math.max(d.get(g.to)??0,(d.get(g.from)??0)+1)));let l=new Map,p=new Map(a.map(h=>{let g=d.get(h.key),y=l.get(g)??0;return l.set(g,y+1),[h.key,{x:12+g*220,y:12+y*65}]})),o=Math.max(220,...[...p.values()].map(h=>h.x+205)),u=Math.max(75,...[...p.values()].map(h=>h.y+60)),f=t.nodes.find(h=>h.key===n);return e(M,{children:[e("p",{class:"help",children:["Arrows go from a source revision to a derived entry. Older or deleted revisions are shown as references without restored text.",a.length<t.nodes.length?` Showing ${a.length} of ${t.nodes.length} nodes.`:""]}),a.length?e("div",{class:"memory-graph",tabIndex:0,children:e("svg",{width:o,height:u,role:"group","aria-label":"Memory provenance graph",children:[e("defs",{children:e("marker",{id:s,markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",children:e("path",{d:"M0,0 L8,4 L0,8"})})}),i.map(h=>{let g=p.get(h.from),y=p.get(h.to);return e("path",{class:"mem-edge",d:`M${g.x+190},${g.y+24} C${g.x+215},${g.y+24} ${y.x-25},${y.y+24} ${y.x},${y.y+24}`,"marker-end":`url(#${s})`},`${h.from}:${h.to}`)}),a.map(h=>{let g=p.get(h.key),y=h.title??h.id;return e("g",{class:`mem-node${h.available?"":" ref"}${n===h.key?" on":""}`,transform:`translate(${g.x},${g.y})`,role:"button",tabIndex:0,"aria-label":`${y}, revision ${h.revision}${h.available?"":", reference only"}`,onClick:()=>r(h.key),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),r(h.key))},children:[e("title",{children:[y," \xB7 revision ",h.revision]}),e("rect",{width:"190",height:"48",rx:"8"}),e("text",{x:"10",y:"20",class:"mem-title",children:y.length>25?y.slice(0,24)+"\u2026":y}),e("text",{x:"10",y:"37",children:["Revision ",h.revision,h.available?` \xB7 ${h.status}`:" \xB7 reference only"]})]},h.key)})]})}):e("p",{class:"help",children:"No entries to draw yet."}),f?e("p",{class:"help",role:"status",children:[f.title??f.id," \xB7 revision ",f.revision,". ",t.edges.filter(h=>h.to===f.key).length," source references; ",t.edges.filter(h=>h.from===f.key).length," derived references.",f.available?"":" The text of this revision is unavailable and has not been recovered."]}):null,e("details",{children:[e("summary",{children:"Read source references as a list"}),e("ul",{children:t.edges.slice(0,200).map(h=>e("li",{children:[e("code",{children:h.from})," \u2192 ",e("code",{children:h.to})]},`${h.from}:${h.to}`))}),t.edges.length>200?e("p",{class:"help",children:["Showing the first 200 of ",t.edges.length," references."]}):null]})]})}function Ac({endpoint:t,repo:s,entryId:n,onReady:r}){let[a,c]=m(null),[i,d]=m(""),[l,p]=m(!1);return N(()=>{let o=!0;return V(`${t}/analysis?repo=${encodeURIComponent(s)}`).then(u=>{if(o){let f=u.deletionImpact.find(h=>h.id===n);c(f??null),f||d("This entry is not included in the bounded preview."),p(u.truncated)}},u=>{o&&d(u.message)}).finally(()=>{o&&r()}),()=>{o=!1}},[t,s,n]),e("div",{class:"help",role:"group","aria-label":"Memory deletion impact",children:a?e(M,{children:[e("p",{children:[a.direct.length," directly derived entries; ",a.transitive.length," downstream entries retain their text and provenance."]}),e("p",{children:a.retained}),a.transitive.length?e("details",{children:[e("summary",{children:"Entries to review separately"}),e("ul",{children:a.transitive.map(o=>e("li",{children:[e(Xn,{id:o.id,children:o.id})," \xB7 revision ",o.revision]},o.id))})]}):null,l?e("p",{children:"The analysis reached a limit; additional derived entries may exist."}):null]}):i?e("p",{children:["Impact preview unavailable: ",i,". Derived text and separate transcript history are retained."]}):e("p",{role:"status",children:"Loading deletion impact\u2026"})})}function Xn({id:t,children:s}){return e("button",{type:"button",class:"mem-link",onClick:()=>{let n=document.getElementById(`memory-${t}`);n?.scrollIntoView({behavior:"smooth",block:"center"}),n?.focus({preventScroll:!0})},children:s})}var Ec={applies_to:"applies to",learned_from:"learned from",derived_from:"written with",verified_at:"verified at"};function jc({endpoint:t,repo:s,entries:n}){let[r,a]=m(!1),[c,i]=m(null),[d,l]=m(""),[p,o]=m("");N(()=>{if(!r)return;let h=!0;return i(null),l(""),V(`${t}/graph?repo=${encodeURIComponent(s)}`).then(g=>{h&&i(g)},g=>{h&&l(g.message)}),()=>{h=!1}},[r,t,s,n]);let u=new Map(c?.entities.map(h=>[h.id,h])),f=c?.relationships.filter(h=>`${u.get(h.from)?.label} ${u.get(h.to)?.label} ${Ec[h.relation]}`.toLowerCase().includes(p.toLowerCase()))??[];return e("details",{class:"knowledge-graph",onToggle:h=>a(h.currentTarget.open),children:[e("summary",{children:"Knowledge graph"}),e("p",{class:"help",children:"Connections recorded in memory paths and evidence. \u201CWritten with\u201D records context, not proof that one claim follows from another. Proposal connections remain unapproved."}),e("label",{children:["Find connections",e("input",{class:"field","aria-label":"Find knowledge connections",value:p,onInput:h=>o(h.currentTarget.value),placeholder:"Memory, file, run or commit"})]}),d?e("p",{class:"msg err",role:"alert",children:d}):c?e(M,{children:[c.truncated?e("p",{class:"help",children:"Showing the first 1,000 connections. The graph is larger than this view."}):null,f.length?e("div",{class:"knowledge-connections",tabIndex:0,role:"region","aria-label":"Knowledge connections",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Memory"}),e("th",{children:"Relationship"}),e("th",{children:"Connected item"}),e("th",{children:"Evidence"})]})}),e("tbody",{children:f.map(h=>{let g=u.get(h.from),y=u.get(h.to),C=n.find(T=>T.id===h.evidence.id);return e("tr",{children:[e("td",{children:e("a",{href:`#memory-${g.key}`,onClick:T=>{T.preventDefault(),document.getElementById(`memory-${g.key}`)?.focus()},children:g.label})}),e("td",{children:Ec[h.relation]}),e("td",{children:[y.kind,": ",y.kind==="run"?e("a",{href:`#/run/${encodeURIComponent(y.key)}`,children:y.label}):y.label]}),e("td",{children:["Revision ",h.evidence.revision," \xB7 ",C?.status==="accepted"?"Accepted":"Proposal",h.targetRevision?` \xB7 source revision ${h.targetRevision}`:""]})]},`${h.from}:${h.to}:${h.relation}`)})})]})}):e("p",{class:"help",children:"No matching connections."})]}):e("p",{role:"status",children:"Loading connections\u2026"})]})}function Pc({projectId:t,repo:s,refreshKey:n=""}){let[r,a]=m(!1),[c,i]=m(null),[d,l]=m(""),[p,o]=m(!1),[u,f]=m(!1),h=`/api/projects/${encodeURIComponent(t)}/memory`,g=async()=>{o(!0),l("");try{i(await V(`${h}?repo=${encodeURIComponent(s)}`))}catch(T){l(T.message)}finally{o(!1)}};N(()=>{if(!r)return;let T=!0;return o(!0),l(""),V(`${h}?repo=${encodeURIComponent(s)}`).then(v=>{T&&i(v)},v=>{T&&l(v.message)}).finally(()=>{T&&o(!1)}),()=>{T=!1}},[r,t,s,n]);let y=(c??[]).filter(T=>T.status!=="deleted"),C=y.filter(T=>T.status==="proposed").length;return e("details",{class:"project-memory",onToggle:T=>a(T.currentTarget.open),children:[e("summary",{children:["Project memory",c?` \xB7 ${y.length} entries${C?` \xB7 ${C} to review`:""}`:""]}),e("p",{class:"help",children:"Accepted knowledge can be used in future runs in this repository. Proposals need review before they become project guidance."}),e("p",{class:"help",children:"Deleting erases this entry's text and removes it from future retrieval. Entries written with it in context retain their own text and the source reference; review and delete those separately. Source run transcripts remain under normal run retention."}),e("div",{class:"at-row",children:[e("button",{class:"btn small",disabled:p,onClick:g,children:p?"Loading\u2026":"Refresh"}),e("button",{class:"btn small",onClick:()=>f(!u),children:u?"Cancel new entry":"Add project knowledge"})]}),d?e("p",{class:"msg err",role:"alert",children:d}):null,u?e(Mc,{endpoint:h,repo:s,onSaved:async()=>{f(!1),await g()},onCancel:()=>f(!1)}):null,c&&!y.length?e("p",{class:"help",children:"No project knowledge saved for this repository yet."}):null,c?e(Ic,{endpoint:h,repo:s,entries:c,refreshKey:n,onPublished:g}):null,c?e(jc,{endpoint:h,repo:s,entries:c}):null,e("div",{class:"memory-list",children:y.map(T=>e(op,{entry:T,endpoint:h,onChanged:g},T.id))})]})}function op({entry:t,endpoint:s,onChanged:n}){let[r,a]=m(!1),[c,i]=m(!1),[d,l]=m(""),[p,o]=m(!1),[u,f]=m(!1),h=async y=>{i(!0),l("");try{await O(`${s}/commands`,{op:y,id:t.id,expectedRevision:t.revision}),await n(),y==="delete"&&J("Memory removed. Entries written with it in context keep their text and its provenance; run transcripts are retained.",5e3)}catch(C){l(C.message)}finally{i(!1)}},g=t.origins.some(y=>y.lockedDown||y.trust!=="trusted");return e("article",{class:"memory-card",id:`memory-${t.id}`,tabIndex:-1,children:[e("div",{class:"at-row",children:[e("b",{children:t.title}),e("span",{class:`badge ${t.status==="accepted"?"ok":"warn"}`,children:t.status==="accepted"?"Accepted":"Proposal"})]}),e("div",{class:"help",children:["Revision ",t.revision," \xB7 ",t.applicability.kind==="branch"?`Branch ${t.applicability.branch}${t.applicability.commit?` at ${t.applicability.commit.slice(0,12)}`:""}`:"This repository",t.acceptedBy?` \xB7 accepted by ${t.acceptedBy==="user"?"you":t.acceptedBy}`:""]}),r?e(Mc,{entry:t,endpoint:s,repo:t.repo,onSaved:async()=>{a(!1),await n()},onCancel:()=>a(!1)}):e(je,{text:t.body}),t.paths.length?e("p",{class:"help",children:["Applies to: ",t.paths.join(", ")]}):null,t.tags.length?e("p",{class:"help",children:["Tags: ",t.tags.join(", ")]}):null,e("details",{children:[e("summary",{children:"Origin and evidence"}),g?e("p",{class:"at-notice",children:"Includes material from an untrusted or unknown source. Review the content before accepting it as future guidance."}):null,e("ul",{children:t.origins.map((y,C)=>e("li",{children:[y.kind==="user"?"User-authored":y.kind==="run"?"From a run":"Imported"," \xB7 ",y.trust,y.lockedDown?" \xB7 locked down":"",y.private?" \xB7 private origin":"",y.runId?e(M,{children:[" \xB7 ",e("a",{href:`#/run/${encodeURIComponent(y.runId)}`,children:"View source run"})]}):null,y.memberId?` \xB7 ${y.memberId}`:""]},C))}),t.sourceRefs.length?e("p",{class:"help",children:["Sources: ",t.sourceRefs.join(", ")]}):null,t.derivedFrom.length?e("p",{class:"help",children:["Derived from: ",t.derivedFrom.map(y=>`${y.id} (revision ${y.revision})`).join(", ")]}):null,t.verification?e("p",{class:"help",children:[t.verification.passed?"Verification passed":"Verification incomplete"," at ",e("code",{children:t.verification.commit.slice(0,12)}),t.verification.merged?" \xB7 merged":" \xB7 branch evidence",". ",t.verification.evidenceRefs.join(", ")]}):null]}),t.status==="accepted"?e(qo,{projectId:t.projectId,endpoint:s,id:t.id,revision:t.revision,onChanged:n}):null,t.feedback?.filter(y=>y.revision===t.revision).length?e("p",{class:"help",children:["Feedback on this revision: ",t.feedback.filter(y=>y.revision===t.revision).map(y=>y.rating).join(", "),". Stale or incorrect guidance is excluded until edited."]}):null,e("div",{class:"memory-actions",children:[t.status==="proposed"?e("button",{class:"btn small primary",disabled:c||r,onClick:()=>h("approve"),children:c?"Saving\u2026":"Accept for future runs"}):null,r?null:e("button",{class:"btn small",disabled:c,onClick:()=>a(!0),children:"Edit"}),p?e("div",{class:"memory-confirm",role:"group","aria-label":"Confirm deletion",children:[e("span",{class:"help",children:"Delete this knowledge? Its text is erased; entries written with it in context keep theirs."}),e(Ac,{endpoint:s,repo:t.repo,entryId:t.id,onReady:()=>f(!0)}),e("button",{class:"btn small danger",disabled:c||!u,onClick:()=>{o(!1),h("delete")},children:"Delete"}),e("button",{class:"btn small",disabled:c,onClick:()=>o(!1),children:"Keep"})]}):e("button",{class:"btn small danger",disabled:c||r,onClick:()=>{f(!1),o(!0)},children:"Delete\u2026"})]}),d?e("p",{class:"msg err",role:"alert",children:[d," Refresh to see the latest revision."]}):null]})}function qo({projectId:t,endpoint:s,id:n,revision:r,runId:a,onChanged:c}){let[i,d]=m("useful"),[l,p]=m(""),[o,u]=m(!1),[f,h]=m(""),[g,y]=m(""),C=async()=>{u(!0),y(""),h("");try{await O(`${s??`/api/projects/${encodeURIComponent(t)}/memory`}/commands`,{op:"feedback",id:n,expectedRevision:r,runId:a,rating:i,note:l.trim()||void 0}),h("Feedback saved for this revision."),await c?.()}catch(T){y(T.message)}finally{u(!1)}};return e("details",{class:"memory-feedback",children:[e("summary",{children:"Rate this knowledge"}),e("label",{children:["Usefulness",e("select",{class:"field","aria-label":`Memory usefulness ${n}`,value:i,onChange:T=>d(T.currentTarget.value),children:[e("option",{value:"useful",children:"Useful"}),e("option",{value:"irrelevant",children:"Not relevant"}),e("option",{value:"stale",children:"Out of date"}),e("option",{value:"incorrect",children:"Incorrect"})]})]}),e("label",{children:["Reason (optional)",e("textarea",{class:"field","aria-label":`Memory feedback ${n}`,rows:2,maxLength:1e3,value:l,onInput:T=>p(T.currentTarget.value)})]}),e("button",{class:"btn small",disabled:o,onClick:C,children:o?"Saving\u2026":"Save memory feedback"}),f?e("p",{class:"help",role:"status",children:f}):null,g?e("p",{class:"msg err",role:"alert",children:g}):null]})}function Mc({entry:t,endpoint:s,repo:n,onSaved:r,onCancel:a}){let[c,i]=m(t?.title??""),[d,l]=m(t?.body??""),[p,o]=m(t?.paths.join(`
|
|
54
|
+
`)??""),[u,f]=m(t?.applicability.kind??"repository"),[h,g]=m(t?.applicability.kind==="branch"?t.applicability.branch:""),[y,C]=m(t?.applicability.kind==="branch"?t.applicability.commit??"":""),[T,v]=m(t),[k,b]=m(t?.revision),[S,x]=m(!1),[w,j]=m(null),[A,P]=m({}),[D,I]=m(!1),[$,E]=m(""),L={title:c,body:d,paths:p.split(`
|
|
55
|
+
`).map(q=>q.trim()).filter(Boolean),applicability:u==="repository"?{kind:"repository"}:{kind:"branch",branch:h.trim(),...y.trim()?{commit:y.trim()}:{}}},H=T&&w?.latest?Oo(Qn(T),L,Qn(w.latest)):null,Q={title:"title",body:"knowledge",paths:"relevant paths",applicability:"where this applies"},le=async()=>{let q=await V(`${s}?repo=${encodeURIComponent(n)}`);j({latest:q.find(te=>te.id===t?.id)??null}),P({})},de=()=>{if(!T||!w?.latest)return;let q=$c(Qn(T),L,Qn(w.latest),A);i(q.title),l(q.body),o(q.paths.join(`
|
|
56
|
+
`)),f(q.applicability.kind),g(q.applicability.kind==="branch"?q.applicability.branch:""),C(q.applicability.kind==="branch"?q.applicability.commit??"":""),v(w.latest),b(w.latest.revision),j(null),E(""),J("Changes merged into your draft. Review it, then save.")},ue=async()=>{if(!(!c.trim()||!d.trim()||u==="branch"&&!h.trim()||D||w)){I(!0),E("");try{await O(`${s}/commands`,{op:t&&!S?"update":"create",id:S?void 0:t?.id,expectedRevision:k,repo:n,...L}),await r()}catch(q){if(E(q.message),t&&!S&&q instanceof st&&(q.status===409||q.status===404))try{await le()}catch(te){E(`${q.message}. Couldn't load the latest revision: ${te.message}`)}}finally{I(!1)}}};return e("form",{class:"memory-editor",onSubmit:q=>{q.preventDefault(),ue()},children:[e("label",{children:["Title",e("input",{class:"field","aria-label":"Memory title",maxLength:200,value:c,onInput:q=>i(q.currentTarget.value)})]}),e("label",{children:["Knowledge",e("textarea",{class:"field","aria-label":"Memory knowledge",rows:4,maxLength:16e3,value:d,onInput:q=>l(q.currentTarget.value)})]}),e("label",{children:["Relevant paths, one per line",e("textarea",{class:"field","aria-label":"Memory paths",rows:2,placeholder:"Leave empty for the whole repository",value:p,onInput:q=>o(q.currentTarget.value)})]}),e("label",{children:["Where this applies",e("select",{class:"field","aria-label":"Where memory applies",value:u,onChange:q=>f(q.currentTarget.value),children:[e("option",{value:"repository",children:"Use across this repository"}),e("option",{value:"branch",children:"Only a specific branch"})]})]}),u==="branch"?e(M,{children:[e("label",{children:["Branch",e("input",{class:"field","aria-label":"Memory branch",value:h,onInput:q=>g(q.currentTarget.value)})]}),e("label",{children:["Commit, if required",e("input",{class:"field","aria-label":"Memory commit",value:y,onInput:q=>C(q.currentTarget.value),placeholder:"Optional commit that must be present"})]})]}):e("p",{class:"help",children:"Saving makes this guidance eligible for future runs on any branch in this repository."}),w?e("section",{class:"at-notice","aria-label":"Resolve memory revision conflict",children:[e("b",{children:w.latest?`This entry is now at revision ${w.latest.revision}. Your draft is preserved.`:"This entry was removed in another session. Your draft is preserved."}),w.latest?e(M,{children:[e("details",{children:[e("summary",{children:"Latest saved knowledge"}),e("b",{children:w.latest.title}),e(je,{text:w.latest.body}),e("p",{class:"help",children:["Paths: ",w.latest.paths.join(", ")||"whole repository"," \xB7 ",w.latest.applicability.kind==="repository"?"This repository":`Branch ${w.latest.applicability.branch}${w.latest.applicability.commit?` at ${w.latest.applicability.commit}`:""}`]})]}),H?.conflicts.length?e(M,{children:[e("p",{class:"help",children:"Both versions changed these fields. Choose each one to keep. Independent edits will be combined."}),H.conflicts.map(q=>e("label",{children:["Conflict: ",Q[q],e("select",{class:"field","aria-label":`Resolve memory ${Q[q]}`,value:A[q]??"",onChange:te=>{let me=te.currentTarget.value;P(W=>({...W,[q]:me}))},children:[e("option",{value:"",children:"Choose a version\u2026"}),e("option",{value:"draft",children:"Keep my draft"}),e("option",{value:"latest",children:"Use latest saved version"})]})]},q))]}):e("p",{class:"help",children:"Your edits and the latest edits affect different fields and can be combined."}),e("button",{type:"button",class:"btn small primary",disabled:D||!!H?.conflicts.some(q=>!A[q]),onClick:de,children:"Apply reviewed merge"})]}):e(M,{children:[e("p",{class:"help",children:"You can keep editing this draft and save it as a separate entry."}),e("button",{type:"button",class:"btn small",onClick:()=>{x(!0),b(void 0),v(void 0),j(null),E("")},children:"Keep draft as new knowledge"})]}),e("button",{type:"button",class:"btn small",disabled:D,onClick:async()=>{I(!0);try{await le()}catch(q){E(q.message)}finally{I(!1)}},children:"Refresh latest revision"})]}):null,S?e("p",{class:"help",children:"This draft will be saved as a new entry."}):null,e("div",{class:"memory-actions",children:[e("button",{type:"submit",class:"btn small primary",disabled:D||!!w||!c.trim()||!d.trim()||u==="branch"&&!h.trim(),children:D?"Saving\u2026":"Save knowledge"}),e("button",{type:"button",class:"btn small",disabled:D,onClick:a,children:"Cancel"})]}),$?e("p",{class:"msg err",role:"alert",children:[$," Your draft is still here."]}):null]})}var ot=t=>({type:"object",properties:t,required:Object.keys(t),additionalProperties:!1}),Oe={type:"string"},yn={type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$",description:"Stable lowercase identifier, e.g. api, add-validation, goal; never T1 or R1"},Ze={type:"array",items:Oe},wt=t=>({type:"array",items:t}),Lc=ot({id:yn,name:Oe,role:{type:"string",enum:["coordinator","worker","reviewer"]},provider:{type:"string",description:"Exact provider ID from the supplied eligible inventory and selected pool"},model:Oe,effort:Oe,reason:Oe}),Uo=ot({id:yn,title:Oe,instructions:Oe,owner:{type:"string",description:"An active worker member ID (or coordinator for investigation). Never the reviewer: code-flow schedules independent review automatically."},kind:{type:"string",enum:["implementation","investigation"]},dependsOn:Ze,requirements:Ze,acceptance:Ze,paths:Ze}),Nc=ot({...Uo.properties,dependencyTypes:wt(ot({taskId:yn,kind:{type:"string",enum:["completion","artifact","knowledge"]}}))}),ip=wt(ot({id:{type:"string",pattern:"^[a-z][a-z0-9-]{0,27}$"},strategy:{type:"string",enum:["investigate-implement","implement-verify","bounded-repair"]},owner:Oe,requirements:Ze,acceptance:Ze,paths:Ze,dependsOn:Ze,instructions:Oe})),lp=ot({requirements:wt(ot({id:yn,description:Oe})),members:wt(Lc),tasks:wt(Uo),contracts:Ze,rationale:Oe}),cp=ot({...lp.properties,tasks:wt(Nc),subplans:ip}),Qb=ot({...cp.properties,templateUses:wt(ot({id:{type:"string",pattern:"^[a-z][a-z0-9-]{0,11}$"},templateId:yn,version:{type:"integer",minimum:1},inputs:wt(ot({name:Oe,value:Oe})),assignments:wt(ot({role:Oe,memberId:yn})),dependsOn:Ze,requirements:Ze,instructions:Oe}))}),Bo=ot({requestId:Oe,body:Oe,evidence:Ze}),Xb=ot({taskId:Oe,memberId:Oe,status:{type:"string",enum:["submitted","needs_info","failed"],description:"submitted means the assigned artifact is ready for engine integration and verification; it does not claim final checks or review passed"},checkpoint:Oe,handover:Oe,artifacts:Ze,unresolvedRequirements:Ze,questions:wt(ot({id:yn,recipient:Oe,body:Oe,blocking:{type:"boolean"}})),replies:wt(Bo),findings:wt(ot({title:Oe,body:Oe,evidence:Ze,paths:Ze}))});var Zb=ot({replies:wt(Bo),unresolved:Ze}),dp=ot({reason:Oe,addTasks:wt(Uo),reassignments:wt(ot({taskId:Oe,memberId:Oe})),retryTasks:Ze,contracts:Ze,answers:wt(Bo),addMembers:wt(Lc),retireMembers:Ze}),ey=ot({...dp.properties,addTasks:wt(Nc),contractRequirements:Ze}),up=/^[a-z][a-z0-9-]{0,39}$/,Dc=t=>new Set(t).size===t.length,bn=t=>!!t.trim();function pp(t){return t==="*"||!!t&&t.length<=500&&!/[\u0000-\u001f\u007f]/.test(t)&&!t.startsWith("/")&&!t.startsWith("-")&&!t.includes("\\")&&!t.split("/").some(s=>s==="."||s===".."||s===".git"||s==="")&&!t.includes("*")&&!/^[A-Za-z]:/.test(t)}function Oc(t,s,n=new Set){if(!t.requirements.length||!t.tasks.length)return"include requirements and at least one task";if(t.requirements.length>48||t.contracts.length>24||t.rationale.length>4e3)return"requirements, contracts, and rationale must fit the bounded plan";let r=t.members.filter(u=>u.status!=="retired");if(r.length>s.maxMembers||r.length<2)return`team size must be between 2 and ${s.maxMembers}`;if(t.tasks.length>s.maxTasks)return`the plan exceeds ${s.maxTasks} tasks`;for(let[u,f]of[["member",t.members],["task",t.tasks],["requirement",t.requirements]])if(!Dc(f.map(h=>h.id))||f.some(h=>!up.test(h.id)))return`${u} IDs must be unique short lowercase identifiers`;if(t.requirements.some(u=>!bn(u.description)||u.description.length>4e3))return"requirements need bounded descriptions";if(t.contracts.some(u=>!bn(u)||u.length>8e3))return"contracts cannot be empty or exceed 8000 characters";let a=r.filter(u=>u.role==="coordinator"),c=r.filter(u=>u.role==="reviewer");if(a.length!==1||c.length!==1)return"include exactly one coordinator and one independent reviewer";if(a[0].id!=="coordinator")return"the coordinator member ID must be coordinator (preserving its planning session identity)";if(a[0].provider!==s.coordinator)return"the coordinator must preserve the user's selected provider";let i=s.inventory.providers.filter(u=>u.available&&!u.blockedReason&&(s.pool.includes(u.id)||u.id===s.coordinator));for(let u of r){if(u.id==="user")return"user is reserved for authenticated user replies";if(u.role!=="coordinator"&&!s.pool.includes(u.provider))return`${u.id} chose a provider outside the user's worker/reviewer pool`;let f=i.find(k=>k.id===u.provider)??(n.has(u.id)?s.inventory.providers.find(k=>k.id===u.provider):void 0);if(!f)return`${u.id} chose unavailable, exhausted, or unauthorized provider ${u.provider}`;if(!bn(u.name)||u.name.length>120||!bn(u.reason)||u.reason.length>2e3)return"every member needs a bounded name and composition reason";let h=f.settingsByRole?.[u.role]??f,g=f.models?.find(k=>k.id===(u.model||f.catalog?.defaultModel)||k.aliases?.includes(u.model));if(f.catalog&&!g)return`${u.id} chose a model whose availability in this environment is unknown`;if(f.catalog&&u.effort&&!g?.efforts?.includes(u.effort))return`${u.id} chose an unsupported effort for this exact model`;if(u.role==="coordinator"&&(u.model!==(h.model??"")||u.effort!==(h.effort??"")))return"The coordinator model settings and effort must remain unchanged";let y=u.role!=="coordinator"&&"variants"in h?h.variants:void 0,T=(y?.length?[h,...y]:[h]).filter(k=>y?.length?u.model===(k.model??""):k.model?u.model===k.model:!u.model||!!g);if(!T.length)return`${u.id} must preserve supplied model settings or choose a supplied supported model (empty means default)`;let v=g?.efforts??f.efforts??[];if(!T.some(k=>k.effort?u.effort===k.effort:!u.effort||v.includes(u.effort)))return`${u.id} must preserve supplied effort settings or choose a supplied supported effort (empty means default)`}for(let u of t.tasks){let f=t.members.find(h=>h.id===u.owner);if(!f||f.role==="reviewer"||f.status==="retired"&&!["submitted","completed"].includes(u.status??""))return`${u.id} must be assigned to an active non-reviewer member. The runtime supplies final independent review and checks; remove redundant final-review tasks instead of reassigning them.`;if(u.kind==="implementation"&&f.role!=="worker")return`${u.id}: implementation belongs to a worker, keeping coordinator and reviewer read-only`;if(!bn(u.title)||u.title.length>180||!bn(u.instructions)||u.instructions.length>16e3||!u.acceptance.length||u.acceptance.length>16||u.acceptance.some(h=>!bn(h)||h.length>2e3))return`${u.id} needs bounded instructions and acceptance criteria`;if(!u.requirements.length||u.requirements.some(h=>!t.requirements.some(g=>g.id===h)))return`${u.id} must cover existing requirements`;if(u.dependencyTypes&&(Object.keys(u.dependencyTypes).some(h=>!u.dependsOn.includes(h))||Object.values(u.dependencyTypes).some(h=>!["completion","artifact","knowledge"].includes(h))))return`${u.id} has invalid typed dependencies`;if(!Dc(u.dependsOn)||u.dependsOn.some(h=>h===u.id||!t.tasks.some(g=>g.id===h)))return`${u.id} has an invalid dependency`;if(u.paths.some(h=>!pp(h))||u.kind==="implementation"&&!u.paths.length)return`${u.id} needs safe owned repository paths (directories, files, or *)`}if(t.requirements.some(u=>!t.tasks.some(f=>f.requirements.includes(u.id))))return"every requirement must have a task; requirements cannot silently disappear";let d=new Set,l=new Set,p=u=>l.has(u)?!0:d.has(u)?!1:(l.add(u),t.tasks.find(f=>f.id===u).dependsOn.some(p)?!0:(l.delete(u),d.add(u),!1));if(t.tasks.some(u=>p(u.id)))return"task dependencies must be acyclic";let o=t.members.find(u=>u.id===t.tasks.find(f=>f.kind==="implementation")?.owner)??a[0];if(c[0].provider===o.provider&&(s.differentProviderReview||i.some(u=>s.pool.includes(u.id)&&u.id!==o.provider)))return"use a reviewer from another eligible provider (or disable strict provider independence when only one provider is available)"}var mt=class extends Error{constructor(n,r=400){super(n);this.status=r}},Fo=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Ir=(t,s,n=!1)=>typeof t=="string"&&t.length<=s&&!t.includes("\0")&&(n||!!t.trim()),qc=/^[a-z][a-z0-9-]{0,39}$/,Uc=(t,s,n,r)=>typeof t=="number"&&Number.isFinite(t)?Math.max(n,Math.min(r,Math.floor(t))):s;function wa(t,s,n,r){if(!Array.isArray(t)||t.length>s||t.some(a=>!Ir(a,n)))throw new mt(`${r} must contain at most ${s} bounded, nonempty strings.`);if(new Set(t).size!==t.length)throw new mt(`${r} must not contain duplicates.`);return[...t]}function Ar(t){return{revision:t.revision,rationale:t.rationale,contracts:[...t.contracts],tasks:t.tasks.map(({id:s,title:n,instructions:r,owner:a,kind:c,dependsOn:i,dependencyTypes:d,requirements:l,acceptance:p,paths:o})=>({id:s,title:n,instructions:r,owner:a,kind:c,dependsOn:[...i],...d?{dependencyTypes:{...d}}:{},requirements:[...l],acceptance:[...p],paths:[...o]}))}}function Bc(t,s){let n=s.roles.coordinator?.[0];if(!n||!t.inventory)throw new mt("The original provider inventory is unavailable; ask the coordinator for a revised plan instead.");return{coordinator:n,pool:[...s.roles.pool??[]],inventory:structuredClone(t.inventory),maxMembers:Uc(s.options.maxMembers,4,2,6),maxTasks:Uc(s.options.maxTasks,12,1,24),differentProviderReview:s.options.differentProviderReview===!0}}function Fc(t,s,n){if(s.status!=="awaiting_approval"||s.tasks.some(i=>i.status&&i.status!=="pending"||(i.attempts??0)>0||i.startedAt!==void 0||i.finishedAt!==void 0||i.head||i.artifacts?.length))throw new mt("This team has already started work. Edit a new pending plan instead.",409);if(!Fo(t)||Object.keys(t).some(i=>!["revision","tasks","contracts","rationale"].includes(i)))throw new mt("Only tasks, contracts and rationale may be edited. Members and requirements stay fixed.");if(!Number.isSafeInteger(t.revision)||t.revision!==s.revision)throw new mt("The plan changed while you were editing. Refresh the plan and merge your edits before saving.",409);if(!Array.isArray(t.tasks)||t.tasks.length<1||t.tasks.length>n.maxTasks)throw new mt(`Keep between 1 and ${n.maxTasks} tasks.`);let r=t.tasks.map((i,d)=>{if(!Fo(i)||Object.keys(i).some(o=>!["id","title","instructions","owner","kind","dependsOn","dependencyTypes","requirements","acceptance","paths"].includes(o)))throw new mt(`Task ${d+1} contains unsupported or runtime fields.`);if(typeof i.id!="string"||!qc.test(i.id)||typeof i.owner!="string"||!qc.test(i.owner)||!Ir(i.title,180)||!Ir(i.instructions,16e3)||!["implementation","investigation"].includes(String(i.kind)))throw new mt(`Task ${d+1} needs a valid ID, owner, title, kind and instructions.`);let l=wa(i.dependsOn,n.maxTasks,40,`${i.id} dependencies`),p;if(i.dependencyTypes!==void 0){if(!Fo(i.dependencyTypes)||Object.keys(i.dependencyTypes).length>n.maxTasks||Object.entries(i.dependencyTypes).some(([o,u])=>!l.includes(o)||!["completion","artifact","knowledge"].includes(String(u))))throw new mt(`${i.id} contains invalid dependency types.`);p={...i.dependencyTypes}}return{id:i.id,title:i.title,instructions:i.instructions,owner:i.owner,kind:i.kind,dependsOn:l,...p?{dependencyTypes:p}:{},requirements:wa(i.requirements,48,40,`${i.id} requirements`),acceptance:wa(i.acceptance,16,2e3,`${i.id} acceptance criteria`),paths:wa(i.paths,64,500,`${i.id} paths`),status:"pending",attempts:0}});if(!Ir(t.rationale,4e3,!0))throw new mt("Rationale must be text of at most 4,000 characters.");let a={requirements:structuredClone(s.requirements),members:structuredClone(s.members),tasks:r,contracts:wa(t.contracts,24,8e3,"Shared contracts"),rationale:t.rationale};if(s.templateUses?.length){for(let i of s.tasks.filter(d=>s.templateUses.some(l=>d.id.startsWith(`${l.id}-`)))){let d=r.find(l=>l.id===i.id);if(!d||d.kind!==i.kind||!i.acceptance.every(l=>d.acceptance.includes(l))||!i.dependsOn.every(l=>d.dependsOn.includes(l))||!i.requirements.every(l=>d.requirements.includes(l)))throw new mt("Template tasks, dependencies and required checks must be preserved. Create a new template version to change its guarantees.");if(d.instructions!==i.instructions&&!d.instructions.startsWith(i.instructions+`
|
|
57
|
+
`))throw new mt("Template instructions can only be extended. Publish a new template version to replace them.");if(d.paths.some(l=>!i.paths.some(p=>p==="*"||l===p||l.startsWith(p+"/"))))throw new mt("Template file ownership cannot be broadened");if(i.dependsOn.some(l=>(d.dependencyTypes?.[l]??"completion")!==(i.dependencyTypes?.[l]??"completion")))throw new mt("Preserve template dependency types")}if(!s.contracts.every(i=>a.contracts.includes(i)))throw new mt("Preserve template contracts");a.templateUses=structuredClone(s.templateUses)}let c=Oc(a,n);if(c)throw new mt(c);return a}var Hc=t=>typeof t=="number"&&Number.isFinite(t);function Ho(t,s){return Hc(t)&&Hc(s)&&s>=t?[t,s]:void 0}function _c(t,s){return Ho(t.startedAt,t.status==="running"?s:t.endedAt)}function Wc(t){let s=[...t].sort((c,i)=>c[0]-i[0]),n=0,r,a=0;for(let[c,i]of s)r===void 0?(r=c,a=i):c>a?(n+=a-r,r=c,a=i):a=Math.max(a,i);return n+(r===void 0?0:a-r)}function Vc(t,s={}){let n=s.now??Date.now(),r=new Map,a=[];for(let k of t.tasks)r.has(k.id)?a.push(`Duplicate task ID: ${k.id}`):r.set(k.id,k);let c=[],i=new Map,d=new Map;for(let k of r.values()){let b=[...new Set(k.dependsOn)];i.set(k.id,b.filter(S=>r.has(S)).length);for(let S of b){if(!r.has(S)){a.push(`${k.id} depends on missing task ${S}`);continue}c.push({from:S,to:k.id,kind:k.dependencyTypes?.[S]??"completion"}),d.set(S,[...d.get(S)??[],k.id])}}let l=[...r.keys()].filter(k=>i.get(k)===0).sort(),p=[],o=new Map;for(;l.length;){let k=l.shift();p.push(k),o.set(k,Math.max(0,...r.get(k).dependsOn.filter(b=>o.has(b)).map(b=>o.get(b)+1)));for(let b of d.get(k)??[])i.set(b,i.get(b)-1),i.get(b)===0&&(l.push(b),l.sort())}p.length<r.size&&a.push("Dependencies contain a cycle. Edit the plan before dispatch.");let u=new Map;for(let k of r.values()){let b=s.steps?.filter(S=>S.taskId===k.id);if(b?.length){let S=b.map(x=>_c(x,n));S.every(x=>x!==void 0)&&u.set(k.id,S.reduce((x,w)=>x+w[1]-w[0],0))}else{let S=Ho(k.startedAt,k.status==="running"?n:k.finishedAt);S&&u.set(k.id,S[1]-S[0]),(k.attempts??0)>1&&a.push(`${k.id}: task timestamps describe the latest attempt; earlier attempts are not included.`)}}let f=new Map,h=new Map;for(let k of p){let S=r.get(k).dependsOn.filter(x=>f.has(x)).sort((x,w)=>f.get(w)-f.get(x)||h.get(w).length-h.get(x).length||x.localeCompare(w))[0];f.set(k,(S?f.get(S):0)+(u.get(k)??0)),h.set(k,[...S?h.get(S):[],k])}let g=[...p].sort((k,b)=>f.get(b)-f.get(k)||h.get(b).length-h.get(k).length||k.localeCompare(b))[0],y=g?h.get(g):[],C=Math.max(-1,...o.values())+1,T=[...r.values()].map(k=>({id:k.id,title:k.title,owner:k.owner,status:k.status??"pending",layer:o.get(k.id)??C,...u.has(k.id)?{durationMs:u.get(k.id)}:{},critical:y.includes(k.id)})),v=[];for(let k of T)(v[k.layer]??=[]).push(k.id);return{nodes:T,edges:c,layers:v,criticalPath:y,measuredCriticalPathMs:g?f.get(g):0,timedTasks:u.size,completeTiming:u.size===r.size&&p.length===r.size&&[...r.values()].every(k=>["completed","submitted"].includes(k.status??"")&&!k.evidenceStale),warnings:a}}function Jc(t,s,n=Date.now()){let r=t.status==="running"?n:t.endedAt??n,a=Math.max(0,r-t.createdAt),c=[...new Map(s.map(o=>[o.id,o])).values()],i=c.flatMap(o=>{let u=_c(o,r);return u?[{step:o,observed:u}]:[]}),d=o=>i.filter(({step:u})=>o(u)).reduce((u,{observed:f})=>u+f[1]-f[0],0),l=Wc(i.map(({observed:o})=>[Math.max(t.createdAt,o[0]),Math.min(r,o[1])]).filter(([o,u])=>u>=o)),p=(t.team?.waits??[]).flatMap(o=>{let u=Ho(o.createdAt,o.resolvedAt??r);return u?[[Math.max(t.createdAt,u[0]),Math.min(r,u[1])]]:[]}).filter(([o,u])=>u>=o);return{elapsedMs:a,occupiedMs:l,unattributedMs:Math.max(0,a-l),workerMs:d(o=>o.kind==="agent"&&!o.coordination&&o.role!=="coordinator"),coordinationMs:d(o=>o.kind==="agent"&&(o.coordination===!0||o.role==="coordinator")),checksMs:d(o=>o.kind!=="agent"),waitingMs:Wc(p),timedSteps:i.length,untimedSteps:c.length-i.length,overlaps:d(()=>!0)>l}}function Kc(t){if(typeof Intl.Segmenter!="function"||/```|~~~/.test(t))return t;let s=new Intl.Segmenter("en",{granularity:"sentence"});return t.split(/\n\s*\n/).map(n=>{if(n.length<480||n.includes(`
|
|
58
|
+
`)||/[`|*_\[\]<>]|^\s*(?:#{1,6}\s|[-+]\s|\d+[.)]\s)/.test(n))return n;let r=[],a="";for(let{segment:c}of s.segment(n))a.length>=240&&(r.push(a.trimEnd()),a=""),a+=c;return a&&r.push(a.trimEnd()),r.join(`
|
|
59
|
+
|
|
60
|
+
`)}).join(`
|
|
61
|
+
|
|
62
|
+
`)}var mp={planning:"Building the team",awaiting_approval:"Plan ready for approval",running:"Working",blocked:"Unresolved work",verifying:"Verifying the result",completed:"Finished"},Er={pending:"Planned",running:"Working",needs_info:"Waiting for information",submitted:"Ready for verification",completed:"Complete",failed:"Needs attention"},hp={unassigned:"Not assigned",in_progress:"In progress",awaiting_verification:"Awaiting verification",reviewed_unchecked:"Reviewed \xB7 no check ran",verified:"Verified"};function zc({run:t,steps:s}){let[n,r]=m("all"),[a,c]=m(!1),i=t.team;if(!i)return null;let d=o=>o==="user"?"You":i.members.find(u=>u.id===o)?.name??o,l=i.metrics,p=l.coordinatorInputTokens!==void 0&&l.coordinatorOutputTokens!==void 0;return e("section",{class:"auto-team","aria-label":"Auto team",children:[e("div",{class:"at-head",children:[e("div",{children:[e("h3",{children:"Team and workflow"}),e("span",{class:"help",children:["Revision ",i.revision," \xB7 ",i.scheduler==="event"?"Ready work starts when dependencies resolve":i.wave?`${i.wave} waves so far \xB7 limit ${i.maxWaves} per execution`:"Before the first wave"]})]}),e("span",{class:`badge ${i.gaps.length||i.status==="blocked"?"warn":i.status==="completed"?"ok":""}`,children:gt(t)?"Waiting for your answer":mp[i.status]})]}),e(yp,{run:t}),e(cc,{runId:t.id,running:t.status==="running"}),e(lc,{providers:[...new Set(i.members.map(o=>o.provider))]}),e("div",{class:"at-metrics",role:"group","aria-label":"Coordination usage",children:[e("span",{children:[e("b",{children:l.coordinatorInvocations})," coordinator calls (lifetime) \xB7 limit ",i.coordinationLimit," per execution"]}),e("span",{children:[e("b",{children:l.invocations})," total calls (lifetime) \xB7 limit ",i.invocationLimit," per execution"]}),e("span",{children:[e("b",{children:l.questionCount})," questions"]}),p?e("span",{children:[e("b",{children:Et(l.coordinatorInputTokens+l.coordinatorOutputTokens)})," coordinator tokens"]}):e("span",{children:"Coordinator tokens not reported"}),l.coordinatorMs!==void 0?e("span",{children:[e("b",{children:Le(l.coordinatorMs)})," coordinating"]}):null,l.coordinatorCostUsd!==void 0?e("span",{title:"Provider-reported API equivalent, not your subscription charge",children:[e("b",{children:ht(l.coordinatorCostUsd)})," API equivalent"]}):null]}),i.rationale?e("p",{class:"at-rationale",children:i.rationale}):null,t.status==="running"&&t.awaiting?.kind==="plan"&&i.status==="awaiting_approval"&&!t.teamRerun?e("div",{class:"at-row",children:[e("button",{class:"btn",disabled:!i.inventory,title:i.inventory?"Edit tasks and contracts while keeping the selected members, requirements and permissions":"Provider inventory is unavailable for this older plan",onClick:()=>c(!0),children:"Edit pending plan"}),e("span",{class:"help",children:"Saving changes keeps the plan pending for your approval."})]}):null,t.teamRerun?e("p",{class:"at-notice",children:["Selective rerun of ",t.teamRerun.parentRunId," from ",e("code",{children:t.teamRerun.baseCommit.slice(0,12)}),". Executes ",t.teamRerun.rerunTaskIds.join(", "),"; retained tasks are baseline inputs. All requirements need fresh final checks and independent review."]}):null,t.status!=="running"&&t.worktrees.some(o=>o.name==="integration")&&!["planning","awaiting_approval"].includes(i.status)?e(gp,{run:t},t.id):null,e(vp,{run:t,steps:s}),i.reviewFallback?e("div",{class:"at-notice",children:i.reviewFallback}):null,i.gaps.length?e("div",{class:"at-notice",children:[e("b",{children:"Still unresolved"}),e("ul",{children:i.gaps.map((o,u)=>e("li",{children:o},u))})]}):null,zt(t)?e("p",{class:"help",children:"Resume continues this team's unfinished work with a fresh execution budget. Completed work and recorded answers are kept."}):null,e("div",{class:"at-roster",role:"group","aria-label":"Team members",children:i.members.map(o=>e("article",{class:"at-member",children:[e("div",{class:"at-row",children:[e("b",{children:o.name}),e("span",{class:"badge",children:o.role.charAt(0).toUpperCase()+o.role.slice(1)})]}),e(Ee,{id:o.provider,note:[o.assignment?.model??o.model,o.assignment?.effort??o.effort].filter(Boolean).join(" \xB7 ")||"CLI defaults"}),e("div",{class:"help",children:[Ji(i,o)," \xB7 ",e("code",{children:o.id})]}),e("button",{class:"btn small",onClick:()=>r(o.id),children:["Inbox \xB7 ",i.messages.filter(u=>u.recipient===o.id&&u.delivery?.status!=="context"&&u.status!=="delivered").length," pending"]}),e("p",{children:o.assignment?.rationale??o.reason}),o.assignment?e("p",{class:"help",children:["Catalog revision ",o.assignment.catalogRevision," \xB7 ",o.assignment.source,o.assignment.stale?" \xB7 cached, stale":""]}):null,o.checkpoint?e("details",{children:[e("summary",{children:"Private checkpoint"}),e(je,{text:o.checkpoint})]}):null]},o.id))}),i.tasks.length?e("div",{class:"at-section",children:[e("h4",{children:"Workflow"}),e("ol",{class:"at-tasks",children:i.tasks.map(o=>{let u=!o.status||o.status==="pending"||o.status==="needs_info"||o.status==="failed"?Qr(i,o):[];return e("li",{class:"at-task",tabIndex:-1,id:`team-task-${o.id}`,children:[e("div",{class:"at-row",children:[e("b",{children:o.title}),e("span",{class:`badge ${o.status==="completed"?"ok":o.status==="failed"?"warn":""}`,children:Er[o.status??"pending"]})]}),e("div",{class:"help",children:[d(o.owner)," \xB7 ",o.kind," \xB7 ",o.attempts??0," attempts"]}),o.retainedBaseline?e("p",{class:"help",children:["Retained baseline input from ",o.retainedBaseline.sourceRunId," \xB7 ",e("code",{children:o.retainedBaseline.sourceTaskHead.slice(0,12)}),". This task was not executed again."]}):null,o.noNewDiff?e("p",{class:"help",children:"No new diff from this rerun turn. Acceptance requires a current-head check and independent review."}):null,o.dependsOn.length?e("div",{class:"help",children:["Needs ",o.dependsOn.map(f=>`${i.tasks.find(h=>h.id===f)?.title??f} (${o.dependencyTypes?.[f]??"completion"})`).join(", ")]}):null,o.evidenceStale?e("p",{class:"at-notice",children:"The contract changed. This task's evidence needs verification again."}):null,u.length?e("ul",{class:"at-blockers",children:u.map((f,h)=>e("li",{children:f},h))}):null,e("details",{children:[e("summary",{children:"Assignment and acceptance"}),e(je,{text:o.instructions}),e("ul",{children:o.acceptance.map((f,h)=>e("li",{children:f},h))}),o.paths.length?e("div",{class:"help",children:["Paths: ",o.paths.join(", ")]}):null,o.checkpoint?e(je,{text:o.checkpoint}):null]})]},o.id)})})]}):null,i.waits?.some(o=>o.status!=="resolved")?e("div",{class:"at-section",children:[e("h4",{children:"Waiting and escalation"}),e("ul",{children:i.waits.filter(o=>o.status!=="resolved").map(o=>e("li",{children:[e("b",{children:d(o.memberId)})," \xB7 ",o.taskId," \xB7 ",o.status,o.status==="waiting"?` \xB7 deadline ${new Date(o.deadlineAt).toLocaleTimeString()}`:"",o.reason?` \xB7 ${o.reason}`:""]},o.requestId))}),e("p",{class:"help",children:"Waiting members release their agent slots. Expired requests and unavailable recipients are escalated to the coordinator."})]}):null,i.requirements.length?e("div",{class:"at-section",children:[e("h4",{children:"Requirement coverage"}),e("ul",{class:"at-coverage",children:i.requirements.map(o=>{let u=Vi(i,o.id,t.status),f=i.tasks.filter(h=>h.requirements.includes(o.id)&&h.retainedBaseline).length;return e("li",{children:[e("span",{children:[o.description,f?e("small",{class:"help",children:[" \xB7 ",f," retained baseline task(s)"]}):null]}),e("span",{class:`badge ${u==="verified"?"ok":u==="unassigned"?"warn":""}`,children:hp[u]})]},o.id)})}),i.verification?e("p",{class:"help",children:["Checks: ",i.verification.check.replaceAll("_"," ")," \xB7 Review: ",i.verification.reviewed?i.verification.approved?"approved":"changes requested":"pending"," \xB7 Commit ",e("code",{children:i.verification.head.slice(0,12)})]}):null]}):null,i.messages.length?e("div",{class:"at-section",children:[e("div",{class:"at-row",children:[e("h4",{children:"Team messages"}),e("label",{children:["Inbox ",e("select",{class:"field","aria-label":"Member inbox",value:n,onChange:o=>r(o.currentTarget.value),children:[e("option",{value:"all",children:"All members"}),e("option",{value:"user",children:"Questions for you"}),i.members.map(o=>e("option",{value:o.id,children:o.name},o.id))]})]})]}),e("div",{class:"at-messages",children:i.messages.filter(o=>n==="all"||o.recipient===n).map(o=>e("article",{class:`at-message ${o.status}`,children:[e("div",{class:"at-row",children:[e("b",{children:[d(o.sender)," \u2192 ",d(o.recipient)]}),e("span",{class:"badge",children:o.kind==="question"?o.status==="open"?"Open question":"Answered":o.kind[0].toUpperCase()+o.kind.slice(1)})]}),e(fp,{message:o}),e("div",{class:"at-message-meta",children:[e("div",{class:"help",children:[o.origin==="user"?"From you":"From a team member",o.blocking?o.status==="open"?" \xB7 blocks dependent work":" \xB7 blocker resolved":""]}),e("div",{class:"help",children:[o.createdAt?new Date(o.createdAt).toLocaleTimeString():"",o.delivery?` \xB7 ${o.delivery.status==="steered"?"delivered during a turn":o.delivery.status==="steering"?"sent during a turn, acknowledgement pending":o.delivery.status==="context"?"included in member context":"queued for the next turn"}`:"",o.originalRecipient?` \xB7 routed from ${d(o.originalRecipient)}`:"",o.deadlineAt&&o.status==="open"?` \xB7 answer due ${new Date(o.deadlineAt).toLocaleTimeString()}`:""]})]}),o.evidence.length?e("details",{children:[e("summary",{children:"Evidence"}),e("ul",{children:o.evidence.map((u,f)=>e("li",{children:u},f))})]}):null,o.kind==="question"&&o.recipient==="user"&&o.status==="open"?gt(t)&&i.awaitingRequestId===o.id?e("p",{class:"help",children:"Answer it in the card under the run header."}):e(Gc,{run:t,message:o},o.id):null]},o.id))})]}):null,i.strategyInstances?.length?e("details",{class:"at-section",children:[e("summary",{children:"Reusable workflow steps"}),e("ul",{children:i.strategyInstances.map(o=>e("li",{children:[o.strategy," \xB7 revision ",o.revision," \xB7 ",o.taskIds.map(u=>i.tasks.find(f=>f.id===u)?.title??u).join(" \u2192 ")]},o.id))})]}):null,i.contracts.length?e("details",{class:"at-section",children:[e("summary",{children:"Shared contracts"}),i.contracts.map((o,u)=>e(je,{text:o},u))]}):null,i.contextManifests.length?e("details",{class:"at-section",children:[e("summary",{children:"Context used by each member"}),e("p",{class:"help",children:"Each turn receives its assignment, relevant shared information, and its own checkpoint."}),e("ul",{class:"at-context",children:i.contextManifests.map((o,u)=>e("li",{children:[e("b",{children:d(o.memberId)})," \xB7 ",o.taskId," \xB7 attempt ",o.attempt,e("div",{class:"help",children:["Plan ",o.revision," \xB7 commit ",e("code",{children:o.inputHead.slice(0,12)})," \xB7 ",o.checkpoint?"private checkpoint included":"no private checkpoint"]}),e("div",{class:"help",children:["Messages: ",o.messageIds.join(", ")||"none"," \xB7 Memory: ",o.memoryIds.join(", ")||"none"]})]},`${o.memberId}-${o.taskId}-${o.attempt}-${u}`))})]}):null,t.memoryManifest?e("details",{class:"at-section",children:[e("summary",{children:"Why project memory was selected"}),e("ul",{class:"at-context",children:[t.memoryManifest.included.map(o=>e("li",{children:[e("b",{children:"Included"})," \xB7 ",o.id," \xB7 revision ",o.revision,e("div",{class:"help",children:o.reason}),t.project?e(qo,{projectId:t.project,id:o.id,revision:o.revision,runId:t.id}):null]},`included-${o.id}`)),t.memoryManifest.omitted.map(o=>e("li",{children:[e("b",{children:"Omitted"})," \xB7 ",o.id," \xB7 revision ",o.revision,e("div",{class:"help",children:o.reason})]},`omitted-${o.id}`))]}),!t.memoryManifest.included.length&&!t.memoryManifest.omitted.length?e("p",{class:"help",children:"No applicable project knowledge was available for this run."}):null]}):null,i.inventory?.providers.some(o=>o.blockedReason)?e("details",{class:"at-section",children:[e("summary",{children:"Provider availability"}),e("ul",{children:i.inventory.providers.filter(o=>o.blockedReason).map(o=>e("li",{children:[e(Ee,{id:o.id}),": ",o.blockedReason]},o.id))})]}):null,a?e(bp,{run:t,onClose:()=>c(!1)}):null]})}function fp({message:t}){let s=t.body.indexOf(`
|
|
63
|
+
`),n=t.kind==="finding"&&s>0&&s<=200;return e("div",{class:"at-message-content",children:[n?e("h5",{class:"at-message-title",children:t.body.slice(0,s)}):null,e(je,{text:Kc(n?t.body.slice(s+1):t.body)})]})}function gp({run:t}){let s=t.team,[n,r]=m(!1),[a,c]=m(""),[i,d]=m([]),[l,p]=m({}),[o,u]=m(Math.max(8,t.loop.maxSteps)),[f,h]=m(t.loop.maxMinutes),[g,y]=m(!1),[C,T]=m(""),[v,k]=m(0),b=t.worktrees.find(P=>P.name==="integration").branch;N(()=>{if(!n)return;let P=!0;return c(""),T(""),V(`/api/runs/${G(t.id)}/review-coverage?branch=${G(b)}`).then(D=>{P&&c(D.head)},D=>{P&&T(D.message)}),()=>{P=!1}},[n,t.id,b,v]);let S=Rc(s.tasks,i),x=s.tasks.filter(P=>!S.has(P.id)),w=x.filter(P=>!["completed","submitted"].includes(P.status??"")||P.evidenceStale||!P.head),j=Math.max(4,S.size+2),A=async()=>{y(!0),T("");try{let P=Object.fromEntries(i.filter(I=>l[I]?.trim()).map(I=>[I,l[I].trim()])),D=await O(`/api/runs/${G(t.id)}/rerun-tasks`,{expectedHead:a,taskIds:i,instructions:P,budget:{maxSteps:o,maxInvocations:o,maxMinutes:f}});Pe({view:"run",id:D.id})}catch(P){T(P.message)}finally{y(!1)}};return e("details",{class:"at-section team-rerun",onToggle:P=>r(P.currentTarget.open),children:[e("summary",{children:"Rerun selected tasks"}),e("p",{class:"help",children:"Creates a child at the committed integration result. Selected tasks and every downstream dependency execute again; other completed tasks become explicit baseline inputs. The original run and its worker checkouts stay available. The child requires fresh checks and independent review of all requirements."}),e("p",{class:"help",children:["Baseline: ",a?e("code",{children:a.slice(0,12)}):"Loading current integration commit\u2026"," ",e("button",{class:"btn ghost small",disabled:g,onClick:()=>k(P=>P+1),children:"Refresh rerun baseline"})]}),a&&(s.verification?.head!==a||!s.verification?.approved)?e("p",{class:"at-notice",children:"This baseline has no passing parent verification at its current commit. The child starts unverified."}):null,e("fieldset",{disabled:g,children:[e("legend",{children:"Tasks to execute again"}),s.tasks.map(P=>e("div",{children:[e("label",{class:"check",children:[e("input",{type:"checkbox",checked:i.includes(P.id),onChange:D=>d(D.currentTarget.checked?[...i,P.id]:i.filter(I=>I!==P.id))}),"Rerun ",P.title]}),i.includes(P.id)?e("label",{children:["New instructions for ",P.id,e("textarea",{class:"field",rows:2,maxLength:16e3,placeholder:"Leave blank to reuse the accepted instructions",value:l[P.id]??"",onInput:D=>p({...l,[P.id]:D.currentTarget.value})})]}):null]},P.id))]}),e("div",{class:"rerun-preview",role:"group","aria-label":"Task rerun preview",children:[e("p",{children:["Execute: ",s.tasks.filter(P=>S.has(P.id)).map(P=>P.id).join(", ")||"Choose a task"]}),e("p",{children:["Retain as baseline inputs: ",x.map(P=>P.id).join(", ")||"None"]})]}),w.length?e("p",{class:"at-notice",children:["Also select unfinished or stale tasks: ",w.map(P=>P.id).join(", "),"."]}):null,e("div",{class:"at-row",children:[e("label",{children:["New invocation budget",e("input",{class:"field",type:"number",min:j,max:"200",value:o,disabled:g,onInput:P=>u(Number(P.currentTarget.value))})]}),e("label",{children:["Rerun time budget (minutes)",e("input",{class:"field",type:"number",min:"1",max:"720",value:f,disabled:g,onInput:P=>h(Number(P.currentTarget.value))})]})]}),e("p",{class:"help",children:["At least ",j," calls fund invalidated work, independent review and one recovery allowance. Provider/model/permission settings stay pinned. An unchanged implementation must still pass the current check and independent review; it does not create new fail-to-pass proof."]}),e("button",{class:"btn primary",disabled:g||!a||!i.length||!!w.length||!Number.isInteger(o)||o<j||o>200||!Number.isFinite(f)||f<1||f>720,onClick:A,children:g?"Starting child\u2026":"Start selected task rerun"}),C?e("p",{class:"msg err",role:"alert",children:C}):null]})}function vp({run:t,steps:s}){let n=t.team,r=Vc(n,{steps:s});if(!r.nodes.length)return null;let a=new Map(r.nodes.map(l=>[l.id,{x:20+l.layer*240,y:20+(r.layers[l.layer]?.indexOf(l.id)??0)*92}])),c=Math.max(240,r.layers.length*240),i=Math.max(100,...r.layers.map(l=>l.length*92+20)),d=s?Jc(t,s):null;return e("details",{class:"at-section workflow-graph",children:[e("summary",{children:["Workflow graph and timing \xB7 ",r.nodes.length," tasks"]}),e("p",{class:"help",children:"Arrows show dependencies. Highlighted tasks form the longest measured dependency chain. Untimed work, provider limits, shared files and queue delays can change the actual bottleneck."}),e("div",{class:"workflow-dag-scroll",tabIndex:0,children:e("svg",{role:"img","aria-label":`Workflow dependencies: ${r.edges.map(l=>`${l.from} to ${l.to}`).join(", ")||"independent tasks"}`,viewBox:`0 0 ${c} ${i}`,width:c,height:i,children:[e("defs",{children:e("marker",{id:`dag-arrow-${t.id}`,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:e("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),r.edges.map(l=>{let p=a.get(l.from),o=a.get(l.to),u=p.x+204,f=o.x,h=p.y+33,g=o.y+33;return e("path",{class:`dag-edge ${l.kind}`,d:`M ${u} ${h} C ${u+22} ${h}, ${f-22} ${g}, ${f} ${g}`,"marker-end":`url(#dag-arrow-${t.id})`,children:e("title",{children:[l.from," \u2192 ",l.to," \xB7 ",l.kind]})},`${l.from}-${l.to}`)}),r.nodes.map(l=>{let p=a.get(l.id);return e("g",{class:`dag-node ${l.status} ${l.critical?"critical":""}`,transform:`translate(${p.x} ${p.y})`,children:[e("title",{children:[l.title," \xB7 ",l.owner," \xB7 ",l.status,l.durationMs!==void 0?` \xB7 ${Le(l.durationMs)} measured`:" \xB7 no task timing"]}),e("rect",{width:"204",height:"66",rx:"8"}),e("text",{x:"12",y:"23",class:"dag-title",children:l.title.length>25?`${l.title.slice(0,24)}\u2026`:l.title}),e("text",{x:"12",y:"40",children:[l.owner.slice(0,20)," \xB7 ",l.durationMs===void 0?"untimed":Le(l.durationMs)]}),e("circle",{cx:"15",cy:"52.5",r:"3",class:"dag-dot"}),e("text",{x:"23",y:"56",class:"dag-status",children:Er[l.status]??l.status})]},l.id)})]})}),e("p",{class:"help",children:["Observed chain: ",r.criticalPath.map(l=>n.tasks.find(p=>p.id===l)?.title??l).join(" \u2192 ")||"unavailable",r.timedTasks?` \xB7 ${Le(r.measuredCriticalPathMs)}`:" \xB7 timing unavailable",". ",r.timedTasks,"/",r.nodes.length," tasks have timing.",r.completeTiming?"":" This is partial timing, not a completion estimate."]}),d?e("dl",{class:"workflow-timing",children:[e("div",{children:[e("dt",{children:"Since run creation"}),e("dd",{children:Le(d.elapsedMs)})]}),e("div",{children:[e("dt",{children:"Worker process time"}),e("dd",{children:Le(d.workerMs)})]}),e("div",{children:[e("dt",{children:"Coordination process time"}),e("dd",{children:Le(d.coordinationMs)})]}),e("div",{children:[e("dt",{children:"Check and setup time"}),e("dd",{children:Le(d.checksMs)})]}),e("div",{children:[e("dt",{children:"Recorded wait periods"}),e("dd",{children:Le(d.waitingMs)})]}),e("div",{children:[e("dt",{children:"Other elapsed time"}),e("dd",{children:Le(d.unattributedMs)})]})]}):null,d?e("p",{class:"help",children:["Process time sums recorded steps and can overlap. Other elapsed time includes queues, approvals and time between executions. ",d.untimedSteps?`${d.untimedSteps} steps have incomplete timing.`:""]}):null,r.warnings.length?e("ul",{class:"at-notice",children:r.warnings.map(l=>e("li",{children:l},l))}):null]})}function Wo(t){let s=n=>n.map(r=>r.trim()).filter(Boolean);return{...t,contracts:s(t.contracts),tasks:t.tasks.map(n=>({...n,paths:s(n.paths),acceptance:s(n.acceptance),dependsOn:s(n.dependsOn),requirements:s(n.requirements)}))}}function bp({run:t,onClose:s}){let n=t.team,r=ye(!0,s),[a,c]=m(()=>Ar(n)),[i,d]=m(!1),[l,p]=m(""),o="",u=24;try{let C=Bc(n,t);u=C.maxTasks,Fc(Wo(a),n,C)}catch(C){o=C.message}let f=n.revision!==a.revision,h=(C,T)=>c({...a,tasks:a.tasks.map(v=>v.id===C?{...v,...T}:v)}),g=async()=>{if(!(o||i)){d(!0),p("");try{await O(`/api/runs/${encodeURIComponent(t.id)}/team-plan`,Wo(a)),J("Plan changes saved. Review them before approving.",4e3),s()}catch(C){p(C.message)}finally{d(!1)}}},y=()=>{let C=URL.createObjectURL(new Blob([JSON.stringify(Wo(a),null,2)],{type:"application/json"})),T=document.createElement("a");T.href=C,T.download=`team-plan-${t.id}.json`,T.click(),setTimeout(()=>URL.revokeObjectURL(C),1e3)};return e("dialog",{class:"picker team-plan-editor",ref:r,"aria-labelledby":"team-plan-editor-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"team-plan-editor-title",children:"Edit pending team plan"}),e("p",{class:"help",children:"Members, requirements, model settings, permissions and execution limits stay fixed. Edit assignments, dependencies, paths, acceptance and contracts before dispatch."})]}),e("div",{class:"dialog-body",children:[f?e("div",{class:"at-notice",role:"alert",children:["The saved plan changed. Your draft is kept. Export or copy your changes before replacing it with the current plan.",e("button",{class:"btn",onClick:()=>{c(Ar(n)),p("")},children:"Replace draft with latest plan"}),e("details",{children:[e("summary",{children:"Latest plan for comparison"}),e("pre",{class:"template-preview",tabIndex:0,children:JSON.stringify(Ar(n),null,2)})]})]}):null,e("label",{class:"lbl",for:"team-plan-rationale",children:"Rationale"}),e("textarea",{class:"field",id:"team-plan-rationale",rows:3,maxLength:4e3,value:a.rationale,onInput:C=>c({...a,rationale:C.currentTarget.value})}),e("div",{class:"at-row",children:[e("h4",{children:["Tasks \xB7 ",a.tasks.length,"/",u]}),e("button",{class:"btn small",disabled:a.tasks.length>=u,onClick:()=>c({...a,tasks:[...a.tasks,{id:`task-${crypto.randomUUID().slice(0,8)}`,title:"New task",instructions:"",kind:"implementation",owner:n.members.find(C=>C.role==="worker"&&C.status!=="retired")?.id??"",dependsOn:[],requirements:n.requirements[0]?[n.requirements[0].id]:[],acceptance:[""],paths:[""]}]}),children:"Add task"})]}),a.tasks.map(C=>e("details",{class:"plan-task-editor",open:!0,children:[e("summary",{children:[e("span",{class:"pt-title",children:C.title||"Untitled task"}),e("code",{children:C.id})]}),e("div",{class:"plan-task-body",children:[e("label",{children:["Title",e("input",{class:"field","aria-label":`Title for ${C.id}`,maxLength:180,value:C.title,onInput:T=>h(C.id,{title:T.currentTarget.value})})]}),e("div",{class:"settings-grid",children:[e("label",{children:["Kind",e("select",{class:"field","aria-label":`Kind for ${C.id}`,value:C.kind,onChange:T=>{let v=T.currentTarget.value,k=n.members.find(b=>b.id===C.owner);h(C.id,{kind:v,...v==="implementation"&&k?.role!=="worker"?{owner:n.members.find(b=>b.role==="worker"&&b.status!=="retired")?.id??""}:{}})},children:[e("option",{value:"implementation",children:"Implementation"}),e("option",{value:"investigation",children:"Investigation"})]})]}),e("label",{children:["Owner",e("select",{class:"field","aria-label":`Owner for ${C.id}`,value:C.owner,onChange:T=>h(C.id,{owner:T.currentTarget.value}),children:n.members.filter(T=>T.status!=="retired"&&T.role!=="reviewer"&&(C.kind==="investigation"||T.role==="worker")).map(T=>e("option",{value:T.id,children:[T.name," \xB7 ",T.provider]},T.id))})]})]}),e("label",{children:["Instructions",e("textarea",{class:"field","aria-label":`Instructions for ${C.id}`,rows:3,maxLength:16e3,value:C.instructions,onInput:T=>h(C.id,{instructions:T.currentTarget.value})})]}),e("label",{children:["Owned paths \xB7 one per line",e("textarea",{class:"field mono","aria-label":`Paths for ${C.id}`,rows:2,value:C.paths.join(`
|
|
64
|
+
`),onInput:T=>h(C.id,{paths:T.currentTarget.value.split(`
|
|
65
|
+
`)})})]}),e("label",{children:["Acceptance criteria \xB7 one per line",e("textarea",{class:"field","aria-label":`Acceptance for ${C.id}`,rows:3,value:C.acceptance.join(`
|
|
66
|
+
`),onInput:T=>h(C.id,{acceptance:T.currentTarget.value.split(`
|
|
67
|
+
`)})})]}),e("fieldset",{children:[e("legend",{children:"Requirements covered"}),n.requirements.map(T=>e("label",{class:"check",children:[e("input",{type:"checkbox",checked:C.requirements.includes(T.id),onChange:v=>h(C.id,{requirements:v.currentTarget.checked?[...C.requirements,T.id]:C.requirements.filter(k=>k!==T.id)})}),T.description," ",e("code",{children:T.id})]},T.id))]}),e("fieldset",{children:[e("legend",{children:"Dependencies"}),a.tasks.filter(T=>T.id!==C.id).map(T=>e("div",{class:"dependency-edit",children:[e("label",{class:"check",children:[e("input",{type:"checkbox",checked:C.dependsOn.includes(T.id),onChange:v=>{let k={...C.dependencyTypes};v.currentTarget.checked||delete k[T.id],h(C.id,{dependsOn:v.currentTarget.checked?[...C.dependsOn,T.id]:C.dependsOn.filter(b=>b!==T.id),dependencyTypes:k})}}),T.title]}),C.dependsOn.includes(T.id)?e("select",{class:"field","aria-label":`Dependency ${T.id} for ${C.id}`,value:C.dependencyTypes?.[T.id]??"completion",onChange:v=>h(C.id,{dependencyTypes:{...C.dependencyTypes,[T.id]:v.currentTarget.value}}),children:[e("option",{value:"completion",children:"Completion"}),e("option",{value:"artifact",children:"Integrated artifact"}),e("option",{value:"knowledge",children:"Evidence-backed knowledge"})]}):null]},T.id))]}),e("button",{class:"btn small danger",disabled:a.tasks.length<=1,onClick:()=>c({...a,tasks:a.tasks.filter(T=>T.id!==C.id).map(T=>{let v={...T.dependencyTypes};return delete v[C.id],{...T,dependsOn:T.dependsOn.filter(k=>k!==C.id),dependencyTypes:v}})}),children:"Remove task"})]})]},C.id)),e("div",{class:"at-row",children:[e("h4",{children:"Shared contracts"}),e("button",{class:"btn small",disabled:a.contracts.length>=24,onClick:()=>c({...a,contracts:[...a.contracts,""]}),children:"Add contract"})]}),a.contracts.map((C,T)=>e("div",{class:"plan-contract-editor",children:[e("textarea",{class:"field","aria-label":`Shared contract ${T+1}`,rows:3,maxLength:8e3,value:C,onInput:v=>c({...a,contracts:a.contracts.map((k,b)=>b===T?v.currentTarget.value:k)})}),e("button",{class:"btn small",onClick:()=>c({...a,contracts:a.contracts.filter((v,k)=>k!==T)}),children:["Remove contract ",T+1]})]},T)),o?e("p",{class:"msg warn",role:"status",children:o}):e("p",{class:"help",role:"status",children:"Plan is valid. Saving changes keeps approval pending."}),l?e("p",{class:"msg err",role:"alert",children:l}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:["Based on revision ",a.revision]}),e("button",{class:"btn",onClick:y,children:"Export draft"}),e("button",{class:"btn",disabled:i,onClick:s,children:"Cancel"}),e("button",{class:"btn primary",disabled:!!o||i,onClick:g,children:i?"Saving\u2026":"Save plan changes"})]})]})})}function _o({run:t,replyChatId:s}){let n=t.team,r=n?.messages.find(i=>i.id===n.awaitingRequestId);if(!n||!r)return null;let a=n.members.find(i=>i.id===r.sender),c=n.tasks.find(i=>i.id===r.taskId);return e("section",{class:"awaiting-card team-question","aria-label":"The team needs your answer",children:[e("div",{class:"aw-head",children:[e("span",{class:"status-pill awaiting",children:"Waiting for you"}),e("b",{children:"The team needs your answer"}),e("span",{class:"help",children:[a?.name??r.sender,c?` \xB7 ${c.title}`:""]})]}),e("div",{class:"aw-body",children:e(je,{text:r.body})}),e("div",{class:"aw-actions",children:e(Gc,{run:t,message:r,replyChatId:s},r.id)})]})}var kn=new Map;function Gc({run:t,message:s,prefix:n="team-answer",replyChatId:r}){let a=`${t.id}/${s.id}`,[c,i]=m(()=>kn.get(a)??""),[d,l]=m(!1),[p,o]=m(""),[u,f]=m(!1),h=async()=>{if(!(!c.trim()||d||u)){l(!0),o("");try{await O(`/api/runs/${r??t.id}/notes`,{requestId:s.id,text:c}),kn.delete(a),f(!0)}catch(y){o(y.message)}finally{l(!1)}}};if(u)return e("p",{class:"help",role:"status",children:"Answer sent."});if(t.status!=="running")return e("p",{class:"help",children:"Press Resume in the header to continue the run, then answer here."});let g=`${n}-${s.id}`;return e("div",{class:"at-reply",children:[e("label",{class:"lbl",for:g,children:"Your answer"}),e("textarea",{class:"field",id:g,placeholder:"Your answer\u2026",rows:2,value:c,onInput:y=>{let C=y.currentTarget.value;i(C),C?kn.set(a,C):kn.delete(a),kn.size>100&&kn.delete(kn.keys().next().value)}}),e("button",{class:"btn primary small",disabled:!c.trim()||d,onClick:h,children:d?"Sending\u2026":"Send answer"}),p?e("p",{class:"msg err",role:"alert",children:p}):null]})}function yp({run:t}){let[s,n]=m(""),[r,a]=m(!1),[c,i]=m(""),d=t.team,l=d.tasks.find(h=>h.id===s)??d.tasks.find(h=>h.status==="running")??d.tasks[0];if(!l)return null;let p=d.members.find(h=>h.id===l.owner),o=Qr(d,l),u=d.messages.filter(h=>h.taskId===l.id&&h.kind==="question"&&h.status==="open"),f=async h=>{a(!0),i("");try{await O(`/api/runs/${t.id}/task-priority`,{taskId:l.id,priority:h,revision:d.revision})}catch(g){i(g.message)}finally{a(!1)}};return e("section",{class:"live-team-map","aria-label":"Live team map",children:[e("h4",{children:"Who's doing what"}),e("div",{class:"team-map-grid",children:d.tasks.map(h=>e("button",{class:`team-map-node ${h.status??"pending"}`,"aria-pressed":h.id===l.id,onClick:()=>n(h.id),children:[e("strong",{children:h.title}),e("span",{children:d.members.find(g=>g.id===h.owner)?.name??h.owner}),e("span",{children:Er[h.status??"pending"]}),e("small",{children:h.dependsOn.length?`After: ${h.dependsOn.join(", ")}`:"Independent task"})]},h.id))}),e("article",{class:"team-map-detail",children:[e("h4",{children:l.title}),e("p",{children:[p?.name??l.owner," \xB7 ",p?.provider," \xB7 ",Er[l.status??"pending"]]}),p?.assignment?e("p",{children:[p.assignment.model," \xB7 ",p.assignment.effort||"Default effort"," \u2014 ",p.assignment.rationale]}):null,e("p",{class:"help",children:["Files and areas: ",l.paths.join(", ")||"No paths assigned"]}),o.length?e("ul",{children:o.map(h=>e("li",{children:h},h))}):null,e("div",{class:"experience-actions",children:[!t.projectTeam&&t.status==="running"&&["pending","needs_info","failed"].includes(l.status??"pending")?e("label",{children:["Task priority",e("select",{class:"field",disabled:r,value:t.taskPriorities?.[l.id]??0,onChange:h=>void f(Number(h.currentTarget.value)),children:[e("option",{value:0,children:"Normal"}),e("option",{value:10,children:"High"}),e("option",{value:-10,children:"Low"})]})]}):null,e("button",{class:"btn small",onClick:()=>{let h=document.getElementById(`team-task-${l.id}`);h?.scrollIntoView({block:"center",behavior:"smooth"}),h?.focus()},children:"Inspect assignment"})]}),e("p",{class:"help",children:"Priority affects the next dispatch; dependency, file ownership and budget checks still apply."}),u.map(h=>e("div",{children:[e("p",{children:h.body}),h.recipient==="user"?e("button",{class:"btn small",onClick:()=>{let g=document.getElementById(`team-answer-${h.id}`);g?.scrollIntoView({block:"center",behavior:"smooth"}),g?.focus()},children:"Answer this question"}):e("p",{class:"help",children:["Waiting for ",d.members.find(g=>g.id===h.recipient)?.name??h.recipient]})]},h.id)),c?e("p",{role:"alert",children:c}):null]})]})}function Vo({runId:t,branch:s,readOnly:n=!1}){let[r,a]=m(!1),[c,i]=m(),[d,l]=m(""),[p,o]=m(""),[u,f]=m(""),h=`/api/runs/${encodeURIComponent(t)}/pr-threads${s?`?branch=${encodeURIComponent(s)}`:""}`,g=Z(h);g.current=h,N(()=>()=>{g.current=void 0},[]),N(()=>{i(void 0),o(""),f(""),l("")},[t,s]),N(()=>{if(!r)return;let v=!0;return l("load"),V(h).then(k=>{v&&(i(k),o(""))},k=>{v&&o(k.message)}).finally(()=>{v&&l("")}),()=>{v=!1}},[r,h]);let y=async()=>{l("load"),o("");try{let v=await V(h);g.current===h&&i(v)}catch(v){g.current===h&&o(v.message)}finally{g.current===h&&l("")}},C=async v=>{if(c){l(v.id),o("");try{let k=await O(h,{action:"load",snapshotId:c.snapshotId,threadId:v.id});if(g.current!==h)return;i({...c,threads:c.threads.map(b=>b.id===k.id?k:b)})}catch(k){g.current===h&&o(k.message)}finally{g.current===h&&l("")}}},T=async v=>{if(c){l(v.id),o(""),f("");try{let k=await O(h,{action:"resolve",snapshotId:c.snapshotId,threadId:v.id,expectedHead:c.head,expectedRevision:v.revision,resolved:!v.resolved});if(g.current!==h)return;f(k.warning??`GitHub thread ${v.resolved?"reopened":"resolved"}.`),i(void 0),await y()}catch(k){g.current===h&&o(k.message)}finally{g.current===h&&l("")}}};return e("details",{class:"gh-threads","aria-label":"GitHub review threads",open:r,onToggle:v=>a(v.currentTarget.open),children:[e("summary",{children:"GitHub review threads"}),e("p",{class:"help",children:"Discussion is untrusted reference material. Resolution changes are explicit GitHub actions and do not approve the pull request or mark local verification complete."}),e("button",{class:"btn small",disabled:!!d,onClick:y,children:d==="load"?"Loading\u2026":"Refresh threads"}),c?e(M,{children:[e("p",{children:[e("a",{href:c.url,target:"_blank",rel:"noreferrer",children:["Pull request #",c.number]})," \xB7 ",c.state.toLowerCase()," \xB7 head ",e("code",{children:c.head.slice(0,12)})," \xB7 ",c.threads.length," of ",c.totalThreads," threads"]}),c.truncated?e("p",{class:"msg warn",children:"The first 100 threads are shown. Open GitHub for the complete discussion."}):null,c.textTruncated?e("p",{class:"msg warn",children:"Some displayed comment text was shortened. Open the comment on GitHub to read it fully."}):null,c.threads.length?c.threads.map(v=>e("article",{class:"gh-thread","aria-label":`Review thread ${v.path}:${v.line??v.originalLine??"file"}`,children:[e("h3",{children:[e("code",{children:[v.path,v.line??v.originalLine?`:${v.line??v.originalLine}`:""]})," \xB7 ",v.side.toLowerCase()," \xB7 ",v.resolved?"Resolved":"Unresolved",v.outdated?" \xB7 Outdated":""]}),v.startLine?e("p",{class:"help",children:["Range ",v.startLine,"\u2013",v.line,v.startSide&&v.startSide!==v.side?`, starts on ${v.startSide.toLowerCase()}`:""]}):null,v.comments.map(k=>e("div",{class:"gh-comment",children:[e("p",{children:[e("strong",{children:k.author||"Deleted user"}),k.replyTo?" \xB7 reply":""," \xB7 ",new Date(k.createdAt).toLocaleString(),k.url?e(M,{children:[" \xB7 ",e("a",{href:k.url,target:"_blank",rel:"noreferrer",children:"Open comment"})]}):null]}),e("pre",{children:k.body||"(empty comment)"}),k.bodyTruncated?e("p",{class:"help",children:"Comment text shortened or redacted."}):null]},k.id)),v.commentsTruncated?e(M,{children:[e("p",{class:"help",children:["Showing ",v.comments.length," of ",v.totalComments," comments. Resolution requires the complete bounded discussion."]}),e("button",{class:"btn small",disabled:!!d||v.comments.length>=100,onClick:()=>C(v),children:d===v.id?"Loading\u2026":"Load complete thread"}),v.totalComments>100?e("p",{class:"help",children:"Threads over 100 comments must be resolved on GitHub."}):null]}):null,n?null:e("button",{class:"btn small",disabled:!!d||v.commentsTruncated||c.state!=="OPEN"||(v.resolved?!v.canUnresolve:!v.canResolve),onClick:()=>T(v),children:d===v.id?"Updating\u2026":v.resolved?"Reopen thread on GitHub":"Resolve thread on GitHub"})]},v.id)):e("p",{class:"help",children:"No inline review threads."})]}):null,u?e("p",{class:"msg",role:"status",children:u}):null,p?e("p",{class:"msg err",role:"alert",children:p}):null]})}function Yc({value:t,onChange:s,disabled:n}){let[r,a]=m([]),[c,i]=m("");N(()=>{let l=!0;return V("/api/remote-workers").then(p=>{l&&a(p)},p=>{l&&i(p.message)}),()=>{l=!1}},[]);let d=r.find(l=>l.id===t?.workerId);return e("div",{"aria-label":"Agent execution location",children:[e("label",{children:["Agent execution",e("select",{"aria-label":"Agent execution",value:t?.workerId??"",disabled:n,onChange:l=>{let p=r.find(o=>o.id===l.currentTarget.value);s(p?{workerId:p.id,repoMapping:p.repoMappings[0]}:void 0)},children:[e("option",{value:"",children:Xe.value.kind==="local"?"This computer":"This server"}),r.map(l=>e("option",{value:l.id,children:l.name},l.id)),t&&!d?e("option",{value:t.workerId,children:["Unavailable worker: ",t.workerId]}):null]})]}),d?e(M,{children:[e("label",{children:["Worker repository mapping",e("select",{"aria-label":"Worker repository mapping",value:t?.repoMapping,disabled:n,onChange:l=>s({workerId:d.id,repoMapping:l.currentTarget.value}),children:d.repoMappings.map(l=>e("option",{value:l,children:l},l))})]}),e("p",{class:"help",children:["Agents use the worker\u2019s installed CLI and login in a disposable checkout. Exact commits and staged references are transferred over SSH. Native approval prompts and live team tools are unavailable; replies use structured outcomes on the next turn.",d.containerProfile?` Worker container profile: ${d.containerProfile}.`:""]})]}):t?e("p",{class:"msg err",children:"This worker is no longer registered. Choose an available worker before starting."}):null,c?e("p",{class:"msg err",children:["Worker configuration could not be loaded: ",c]}):null]})}function Iy(){let[t,s]=m([]),[n,r]=m("");return N(()=>{let a=!0;return V("/api/remote-workers").then(c=>{a&&s(c)},c=>{a&&r(c.message)}),()=>{a=!1}},[]),e("section",{class:"wb-card remote-workers","aria-label":"Remote workers",children:[e("h2",{children:"Remote workers"}),e("p",{children:"Use an explicitly provisioned SSH host to run agent turns. Each turn receives an exact Git commit, its prompt and bounded staged references. Worker credentials stay on that worker."}),t.length?e("div",{class:"wb-list",children:t.map(a=>e(kp,{worker:a},a.id))}):e("p",{class:"help",children:"Register worker aliases, commands and repository mappings with CODEFLOW_REMOTE_WORKERS_FILE on the server. Prepare the host\u2019s known-host key and official CLI login separately. See docs/remote-workers.md."}),e("p",{class:"help",children:"A lost connection can leave an ambiguous outcome. Inspect the step\u2019s durable receipt before explicitly retrying. Code-flow never automatically repeats an accepted remote turn. SSH receipt metadata is retained; private recovery capabilities are excluded from backups."}),n?e("p",{class:"msg err",role:"alert",children:n}):null]})}function Qc({runId:t,step:s}){let[n,r]=m(),[a,c]=m(!1),[i,d]=m(""),[l,p]=m(!1),o=Z(0),u=`${t}/${s.id}/${s.remote?.requestId??""}`;if(N(()=>(o.current++,r(void 0),d(""),c(!1),p(!1),()=>{o.current++}),[u,s.remote?.state,s.remote?.ambiguous,s.remote?.resultHead]),!s.remote)return null;let f=n?.remote??s.remote,h=["completed","failed","cancelled"].includes(f.state),g=async(y=!1)=>{let C=o.current;c(!0),d(""),p(!1);try{let T=await O(`/api/runs/${encodeURIComponent(t)}/remote-steps/${encodeURIComponent(s.id)}/${y?"cancel":"receipt"}`,{});C===o.current&&r(T)}catch(T){C===o.current&&d(T.message)}finally{C===o.current&&c(!1)}};return e("section",{class:"remote-step-receipt","aria-label":"Remote execution receipt",children:[e("p",{children:[e("strong",{children:["SSH worker ",f.workerId]})," \xB7 ",e("span",{role:"status",children:["Receipt: ",f.state]}),f.recovered?" \xB7 inspected":""]}),e("p",{class:"help",children:["Request ",e("code",{children:f.requestId}),f.resultHead?e(M,{children:[" \xB7 result ",e("code",{children:f.resultHead.slice(0,12)})]}):null]}),f.ambiguous||f.state==="unknown"?e("p",{class:"msg err",children:"The execution outcome is unknown. Inspect or request cancellation before using Resume. Inspection never launches another agent turn."}):null,e("div",{class:"wb-actions",children:[e("button",{class:"btn small",disabled:a,onClick:()=>g(),children:a?"Contacting worker\u2026":"Inspect remote receipt"}),h?null:e("button",{class:"btn small",disabled:a,onClick:()=>p(!0),children:"Cancel remote execution"})]}),l?e("div",{class:"remote-cancel",role:"group","aria-label":"Confirm remote cancellation",children:[e("p",{children:"Request cancellation of this exact worker request? A lost connection can prevent confirmation; an unknown receipt remains unresolved."}),e("button",{class:"btn small",disabled:a,onClick:()=>g(!0),children:"Request cancellation"}),e("button",{class:"btn small",disabled:a,onClick:()=>p(!1),children:"Keep execution"})]}):null,n?.error?e("p",{class:"help",children:n.error}):null,i?e("p",{class:"msg err",role:"alert",children:i}):null]})}function kp({worker:t}){let[s,n]=m(t.repoMappings[0]??""),[r,a]=m(),[c,i]=m(!1),[d,l]=m(""),p=async()=>{i(!0),l(""),a(void 0);try{a(await O(`/api/remote-workers/${encodeURIComponent(t.id)}/probe`,{repoMapping:s}))}catch(o){l(o.message)}finally{i(!1)}};return e("article",{class:"wb-item worker-probe","aria-label":`Worker ${t.name}`,children:[e("h3",{children:t.name}),e("p",{class:"help",children:["Protocol ",t.protocol,t.containerProfile?` \xB7 Worker container: ${t.containerProfile}`:" \xB7 Worker-local official CLIs"]}),e("div",{class:"wb-row",children:[e("label",{children:["Repository mapping",e("select",{class:"field","aria-label":`Repository mapping for ${t.name}`,value:s,disabled:c,onChange:o=>{n(o.currentTarget.value),a(void 0)},children:t.repoMappings.map(o=>e("option",{value:o,children:o},o))})]}),e("button",{class:"btn",onClick:p,disabled:c,children:c?"Connecting\u2026":"Check worker connection"})]}),r?e("div",{class:"worker-probe-result",role:"status",children:[e("p",{children:r.capabilities.repoMappings.includes(s)?"Repository mapping available":"Repository mapping unavailable"}),e("ul",{children:r.capabilities.providers.map(o=>e("li",{children:[o.id,": ",o.available?"CLI installed":"CLI unavailable"]},o.id))}),e("p",{class:"help",children:["Login is checked when the selected CLI runs. Maximum source/result bundle: ",Math.floor(r.capabilities.maximumBundleBytes/1024/1024)," MiB; staged context: ",Math.floor(r.capabilities.maximumContextBytes/1024/1024)," MiB."]})]}):null,d?e("p",{class:"msg err",role:"alert",children:d}):null]})}var jr=class{constructor(s=8*1024*1024,n=1e4){this.maxBytes=s;this.maxEvents=n}records=new Map;bytes=0;add(s){if(this.records.has(s.seq))return[];let n=JSON.stringify(s).length*2;this.records.set(s.seq,{event:s,bytes:n}),this.bytes+=n;let r=[];if(this.bytes>this.maxBytes||this.records.size>this.maxEvents){for(let[a,c]of this.records)if(this.records.delete(a),this.bytes-=c.bytes,r.push(c.event),this.bytes<=this.maxBytes*.75&&this.records.size<=this.maxEvents*.75)break}return r}deleteStep(s){for(let[n,r]of this.records)r.event.type==="agent"&&r.event.stepId===s&&(this.records.delete(n),this.bytes-=r.bytes)}};function Xc(t,s){return{...t,steps:new Map(s.steps.map(n=>[n.id,n])),stepSeq:new Map(s.steps.map(n=>[n.id,s.seq])),runSeq:s.seq,seen:new Set([...t.seen].filter(n=>n<=s.seq))}}var Ko=()=>({pagedTranscript:!0,cache:new jr,pages:new Map,steps:new Map,events:new Map,built:new Map,logs:[],seen:new Set,runSeq:0,stepSeq:new Map,epoch:""}),Pr=new Map,wp=6;function Zc(t){return zo(t).version.value}function zo(t){let s=Pr.get(t);return s||(s={id:t,data:{current:Ko()},run:qe(null),problem:qe(""),persistence:qe(null),version:qe(0),users:0,stepListeners:new Set,scheduled:!1,lastSeq:0,idleSince:Date.now()},Pr.set(t,s),td(s)),s}function Cp(t){t.users++||ed(t)}function ed(t){t.stop=An(`${t.legacy?"run":"run-page"}:${t.id}`,s=>{if(!t.legacy&&s.type==="error"&&s.status===404&&s.message==="Nothing to watch called \u201Crun-page\u201D"){t.stop?.(),t.legacy=!0,t.data.current={...Ko(),pagedTranscript:!1},t.lastSeq=0,t.users&&ed(t);return}sd(t,s)},()=>t.data.current.epoch&&t.lastSeq?`${t.data.current.epoch}:${t.lastSeq}`:void 0)}function Tp(t){--t.users||(t.stop?.(),t.stop=void 0,t.idleSince=Date.now(),td())}function td(t){let s=[...Pr.values()].filter(r=>!r.users&&r!==t).sort((r,a)=>a.idleSince-r.idleSince),n=0;for(let[r,a]of s.entries())n+=a.data.current.cache.bytes*2+JSON.stringify(a.run.value).length*2,(r>=wp||n>32*1024*1024)&&Pr.delete(a.id)}function sd(t,s){if(s.type==="persistence"){t.persistence.value=s.status;return}if(s.type==="error"){t.problem.value=s.status===404?s.message:`Couldn't load this run: ${s.message}`;return}if(s.type==="hello"){if(t.persistence.value=s.persistence??null,(s.epoch!==t.data.current.epoch||!s.resumed)&&(t.data.current={...Ko(),epoch:s.epoch},t.lastSeq=0),t.data.current.pagedTranscript=!t.legacy,t.problem.value="",s.snapshot){t.data.current=Xc(t.data.current,s.snapshot),t.pending=s.snapshot.run;for(let r of s.snapshot.steps)for(let a of t.stepListeners)a(r);Mr(t)}if(s.transcript){for(let r of s.transcript.events)sd(t,r);t.lastSeq=Math.max(t.lastSeq,s.transcript.latestSeq)}return}let n=t.data.current;if(!n.seen.has(s.seq)){if(n.seen.add(s.seq),n.seen.size>2e4){let r=[...n.seen].slice(0,5e3);for(let a of r)n.seen.delete(a)}if(t.lastSeq=Math.max(t.lastSeq,s.seq),s.type==="run"){if(s.seq<n.runSeq)return;n.runSeq=s.seq,t.pending=s.run}else if(s.type==="step"){if(s.seq<(n.stepSeq.get(s.step.id)??0))return;n.stepSeq.set(s.step.id,s.seq),n.steps.set(s.step.id,s.step);for(let r of t.stepListeners)r(s.step)}else if(s.type==="agent"){let r=n.pages.get(s.stepId);if(r?.historical){r.loading&&Jo(t,n.cache.add(s));return}n.events.has(s.stepId)||n.events.set(s.stepId,[]),n.events.get(s.stepId).push(s.event)}else s.type==="log"&&n.logs.push(s);(s.type==="agent"||s.type==="log")&&Jo(t,n.cache.add(s)),Mr(t)}}function Jo(t,s){let n=t.data.current;for(let r of s)if(r.type==="agent"){let a=n.events.get(r.stepId),c=a?.indexOf(r.event)??-1;c>=0&&a.splice(c,1),n.built.delete(r.stepId);let i=n.pages.get(r.stepId);i&&(i.loaded=!1)}else if(r.type==="log"){let a=n.logs.indexOf(r);a>=0&&n.logs.splice(a,1)}}async function Dr(t,s,n){let r=zo(t),a=r.data.current;if(r.legacy)return;let c=a.pages.get(s);if(c?.loading)return;let i={before:c?.before,loading:!0,loaded:c?.loaded??!1,historical:c?.historical??!1,request:(c?.request??0)+1};a.pages.set(s,i),Mr(r);try{let d=await V(`/api/runs/${G(t)}/transcript?step=${G(s)}${n?`&before=${G(n)}`:""}`);if(r.data.current.pages!==a.pages||a.pages.get(s)!==i)return;let l=n?[]:[...a.cache.records.values()].map(p=>p.event).filter(p=>p.type==="agent"&&p.stepId===s&&p.seq>d.latestSeq);a.cache.deleteStep(s),a.events.set(s,[]),a.built.delete(s);for(let p of[...d.events,...l])p.type!=="agent"||p.stepId!==s||(a.events.get(s).push(p.event),Jo(r,a.cache.add(p)));Object.assign(i,{before:d.before,loaded:!0,historical:!!n})}catch(d){i.error=d.message,i.historical=c?.historical??!1}finally{i.loading=!1,Mr(r)}}function Mr(t){if(t.scheduled)return;t.scheduled=!0;let s=()=>{t.scheduled&&(t.scheduled=!1,Ri(()=>{t.pending&&(t.run.value=t.pending),t.pending=void 0,t.version.value++}))};requestAnimationFrame(s),setTimeout(s,250)}function Gs(t,s,n=!0){let r=zo(t),a=Z(s);return a.current=s,N(()=>{let c=i=>a.current?.(i);return r.stepListeners.add(c),()=>void r.stepListeners.delete(c)},[r]),N(()=>{if(n)return Cp(r),()=>Tp(r)},[r,n]),{run:r.run.value,persistence:r.persistence.value,problem:r.problem.value,data:r.data,version:r.version.value}}var Sp={done:"\u2713",failed:"\u2715",cancelled:"\u25A0",interrupted:"\u23F8"},Ca=new Set,nd=new Map,Yo=(t,s,n)=>{let r=n??(s?t?.agentSettings?.[s]:void 0);return[r?.model,r?.effort].filter(Boolean).join(" \xB7 ")};function ud({id:t}){let[s,n]=m(null),[r,a]=m(null),c=Z(!0),i=Z([]),[d,l]=m(!1),[p,o]=m(!1),[u,f]=m(null),[h,g]=m(!1),[y,C]=m(!1),[T,v]=m(""),[k,b]=m(null),S=Z(null),x=Z(!0),{run:w,problem:j,data:A,persistence:P,version:D}=Gs(t,z=>{c.current&&z.status==="running"&&!Xo(z)&&n(z.id)});N(()=>{w&&w.status!=="running"&&!w.seen&&!document.hidden&&za(w.id)},[w?.status,w?.seen]),N(()=>{w?.pattern==="solo"&&(co(w),nl(t).catch(z=>J(`Could not load this task\u2019s chats: ${z.message}`)))},[t,w?.pattern]),N(()=>{mn()},[t]);let I=Za.value.find(z=>z.runId===t)?.taskId;if(N(()=>{let z=U=>{if(U.key!=="["&&U.key!=="]"||U.metaKey||U.ctrlKey||U.altKey||U.target?.closest("input, textarea, select, dialog"))return;let oe=i.current;oe.length&&(U.preventDefault(),c.current=!1,a(!0),n(ke=>{let we=oe.indexOf(ke??oe.at(-1));return oe[Math.min(oe.length-1,Math.max(0,(we<0?oe.length-1:we)+(U.key==="]"?1:-1)))]}))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[]),N(()=>{s&&document.querySelector(".tl-step.selected")?.scrollIntoView({block:"nearest"})},[s]),We(()=>{let z=nd.get(t);x.current=z?.follow??!0,S.current&&z&&(S.current.scrollTop=z.top)},[t,!!w]),N(()=>{S.current&&w?.pattern==="solo"&&x.current&&(S.current.scrollTop=S.current.scrollHeight)},[t,D]),!w)return e("div",{class:"runview",children:e("div",{class:"run-scroll",children:j?e("div",{class:"thread",children:[e("p",{class:"msg err",children:j}),e("p",{children:e("a",{href:"#/",children:"\u2190 Back to a new run"})})]}):e("div",{class:"thread help",children:"Loading\u2026"})})});let $=Zo(w,A.current.steps.values());i.current=$.map(z=>z.id);let E=s===""?null:s&&i.current.includes(s)?s:$.at(-1)?.id??null,L=w.status!=="running",H=[...A.current.steps.values()].filter(z=>z.status==="running"),Q=!L&&H.some(z=>z.kind==="check")&&!H.some(z=>z.kind==="agent"),le=r??!L,de=z=>{c.current=!1,a(!0),n(z)},ue=z=>{c.current=!1,n(z===E?"":z)},q=ge.value.find(z=>z.id===w.pattern),te=ft(w),me=!!w.awaiting||gt(w),W=!!q?.chat&&!w.checkpointOnFinish,re=nc(w),ne=k?.id===w.id?k:{id:w.id,maxSteps:Math.min(w.loop.maxSteps,w.loop.maxInvocations??w.loop.maxSteps),maxMinutes:w.loop.maxMinutes},_=w.pattern==="auto-team"?4:1,ie=Number.isSafeInteger(ne.maxSteps)&&ne.maxSteps>=_&&ne.maxSteps<=200&&Number.isFinite(ne.maxMinutes)&&ne.maxMinutes>=1&&ne.maxMinutes<=720,Te=z=>{let U=document.getElementById(z);U?.scrollIntoView({block:"center",behavior:"smooth"}),(U?.querySelector("textarea, button, summary")??U)?.focus({preventScroll:!0})},Ie=async()=>{if(!(y||!ie)){C(!0),v("");try{let z=w.teamTurns?.at(-1),U=z&&ve.value.get(z.executionId);W&&U&&U.status!=="done"&&(ve.value.get(nt(w))??w).taskTeam?.enabled?await O(`/api/runs/${w.id}/team-resume`,{execution:U.id}):await O(`/api/runs/${w.id}/resume`,{budget:{maxSteps:ne.maxSteps,maxInvocations:ne.maxSteps,maxMinutes:ne.maxMinutes}})}catch(z){v(z.message)}finally{C(!1)}}},et=()=>{re&&(re.kind==="resume"?Ie():re.kind==="provider"?hs.value=!0:re.kind==="check"?g(!0):re.kind==="review"&&re.branch?Pe({view:"review",id:w.id,branch:re.branch}):re.kind==="revise"?Ds.value=[...Ds.value,{to:`main:${w.id}`,text:`Investigate and fix the failing checks (${w.loop.check||"the configured verification profile"}). Preserve the existing work and report fresh verification evidence.`,images:[]}]:Te(`run-${re.kind}`))};return e("div",{class:"runview",children:[W?e(xp,{run:w}):null,e("div",{class:"run-scroll",ref:S,onScroll:z=>{let U=z.currentTarget;x.current=U.scrollHeight-U.scrollTop-U.clientHeight<100,nd.set(t,{top:U.scrollTop,follow:x.current})},children:[P?.state==="saving"?e("p",{class:"help",role:"status",children:"Saving run\u2026"}):P?.state==="error"?e("p",{class:"msg err",role:"alert",children:["Run changes have not been saved: ",P.error]}):null,w.projectTeam&&e("p",{class:"help",children:["Standing team ",w.projectTeam.phase," \xB7 ",e("a",{href:`#/project/${w.project}`,children:"Review the opportunity, approve this result, or request a bounded team revision"})]}),e("header",{class:"run-head",children:e("div",{class:"run-title",children:[e("div",{class:"run-name",children:[e("div",{class:"run-kicker",children:[e("span",{class:`status-pill ${me?"awaiting":te}`,children:br(w)}),e("span",{class:"run-pattern",children:q?.name??w.pattern}),I?e("a",{class:"run-team-task",href:`#/team/task/${G(I)}`,title:"This run executes a task of the team board",children:"Team task"}):null]}),e("h2",{title:w.task,children:w.task.split(`
|
|
68
|
+
`)[0]||"(no task)"})]}),e("div",{class:"run-actions",children:[L&&!W?e(Ve,{label:"More run actions",icon:"more",children:z=>e(M,{children:[e(pe,{onClick:()=>{z();try{let U={id:`strategy-${Date.now().toString(36)}`,name:w.task.split(`
|
|
69
|
+
`)[0].slice(0,80),scope:w.project?"project":"personal",...w.project?{project:w.project}:{}};f(w.team?Wi(w.team,U):{schemaVersion:1,...U,version:1,description:"Saved workflow. Parameterize inputs before reuse.",autoEnabled:!1,parameters:["task"],roles:[],tasks:[],contracts:[],workflow:w.pattern,task:"{{task}}",criteria:[]})}catch(U){J(U.message)}},children:"Save as team template\u2026"}),w.projectTeam?null:e(pe,{disabled:!Ut.value||dt.value,onClick:()=>{z(),Gp(w)},children:"Edit & run again"}),e(pe,{onClick:()=>{z(),w.archived?O(`/api/runs/${w.id}/archive`,{archived:!1}).catch(U=>J(U.message)):l(!0)},children:w.archived?"Unarchive":"Archive\u2026"}),w.projectTeam?null:e(pe,{onClick:()=>{z(),o(!0)},children:"Delete\u2026"})]})}):null,L?null:e("button",{class:"btn danger",onClick:async()=>{(W||await Ae(Q?"Stop the running checks? Finished work stays on its branch; verification will be incomplete.":"Stop this run? Agents still working will be stopped; finished work stays on its branches.",{title:"Stop current work?",confirmLabel:"Stop work",danger:!0}))&&O(`/api/runs/${w.id}/cancel`).catch(z=>J(z.message))},children:[e(K,{name:"stop"})," ",Q?"Stop checks":W?"Stop":"Stop run"]})]})]})}),e("div",{class:"thread",children:[W?null:e(Rr,{run:w,checking:Q}),w.teamTemplate||w.team?.templateUses?.length?e("details",{class:"settings",children:[e("summary",{children:"Template provenance"}),e("div",{class:"settings-body",children:[w.teamTemplate?e("p",{children:["Selected: ",w.teamTemplate.template.name," v",w.teamTemplate.template.version]}):null,w.team?.templateUses?.map(z=>e("p",{children:[z.id,": ",z.templateId," v",z.version,z.instructions?` \xB7 adaptation: ${z.instructions}`:""]},z.id)),e("p",{class:"help",children:"Definitions and inputs are pinned to this run. Library edits do not change this execution."})]})]}):null,!W&&w.permissions?e("details",{class:"settings",children:[e("summary",{children:["Run permissions \xB7 ",w.permissions.trust,w.permissions.antigravityExecution==="native"?" \xB7 Unrestricted Antigravity":""]}),e("div",{class:"settings-body",children:[e("p",{children:w.permissions.antigravityExecution==="native"?"Unrestricted Antigravity uses the existing login and normal provider settings. Its read-only requests are advisory; terminal, browser, MCP, hooks and native agents are unrestricted by Code Flow, including child usage outside the worker budget. Other providers inherit the run policy.":"Workers inherit this run\u2019s policy. Planning and review turns use narrower access. Native agent delegation is disabled; Code Flow schedules the team."}),[...A.current.steps.values()].filter(z=>z.permissions).map(z=>e("p",{children:[z.title,": ",z.permissions.trust," \xB7 ",z.permissions.mode," \xB7 ",z.permissions.isolation," \xB7 command network ",z.permissions.commandNetwork," \xB7 external tools ",z.permissions.externalTools,z.permissions.implementation?e(M,{children:[e("br",{}),e("span",{class:"help",children:[z.permissions.implementation,": ",z.permissions.limitations.join(" ")]})]}):null]},z.id)),e("p",{class:"help",children:"Worktrees do not restrict reads. External browser/MCP tools retain their provider permissions unless explicitly disabled. Setup, checks and previews use their separately configured execution environment."})]})]}):null,!W&&re?e("section",{class:`next-action ${["resume","provider","check","revise"].includes(re.kind)?"needs-attention":""}`,"aria-label":"Next action",children:[e("div",{children:[e("h3",{children:re.title}),e("p",{children:re.detail}),re.kind==="resume"?e("div",{class:"resume-budget",role:"group","aria-label":"Resume budget",children:[e("div",{class:"resume-budget-fields",children:[e("label",{children:["Maximum calls",e("input",{class:"field","aria-label":"Resume maximum calls",type:"number",min:_,max:200,value:ne.maxSteps,disabled:y,onInput:z=>b({...ne,maxSteps:Number(z.currentTarget.value)})})]}),e("label",{children:["Maximum minutes",e("input",{class:"field","aria-label":"Resume maximum minutes",type:"number",min:1,max:720,value:ne.maxMinutes,disabled:y,onInput:z=>b({...ne,maxMinutes:Number(z.currentTarget.value)})})]}),e("button",{class:"btn small",disabled:y,onClick:()=>b({id:w.id,...$n}),children:"Use extended budget"})]}),e("p",{class:"help",children:["New allowance: ",ne.maxSteps," calls \xB7 ",ne.maxMinutes," minutes.",w.team?` Up to ${Oi(ne.maxSteps)} coordinator calls.`:""," Earlier usage is retained."]}),ie?null:e("p",{class:"msg err",role:"alert",children:["Choose ",_,"\u2013200 calls and 1\u2013720 minutes."]})]}):null,L&&w.worktrees.length?e("p",{class:"help",children:["Saved work: ",w.worktrees.length," ",w.worktrees.length===1?"worktree":"worktrees",". Branches and files are kept."]}):null]}),e("div",{class:"next-action-buttons",children:[e("button",{class:"btn primary",disabled:y||re.kind==="resume"&&!ie,onClick:et,children:y?"Resuming\u2026":re.label}),re.kind==="provider"?e("button",{class:"btn",disabled:y||!ie,onClick:()=>void Ie(),children:"Resume after reconnecting"}):null]})]}):null,T?e("p",{class:"msg err",role:"alert",children:T}):null,W?null:L?e(ic,{run:w}):e(rc,{run:w,steps:$}),L&&!W?e(Ep,{run:w,steps:$,onSelectStep:de}):null,W?null:e(Ip,{run:w}),w.source?.kind==="pr"&&!Object.values(w.prs??{}).includes(w.source.url)?e(Vo,{runId:w.id}):null,w.lockdown?e("div",{class:"lockdown",role:"note",children:[e("b",{children:"Locked down."})," ",w.lockdown,", so agents run in Safe mode, files like .env aren't copied in, and checks"," ",w.loop.container?"run in Docker without network":"run on this machine because you allowed it","."]}):null,e("div",{class:"msg-you",children:e("div",{class:"bubble",children:[e("div",{class:"run-task",children:e(je,{text:w.task})}),W?null:e($p,{run:w}),w.parentRunId?e("a",{class:"help",href:`#/run/${w.parentRunId}`,children:"\u21A9 previous conversation"}):null,w.supersededBy?e("a",{class:"help",href:`#/run/${w.supersededBy}`,children:"Continue with the revised goal \u2192"}):null]})}),w.taskExecution?e("a",{class:"btn",href:`#/run/${w.taskExecution.chatId}`,children:"Back to conversation"}):null,w.awaiting?e("div",{id:"run-approval",tabIndex:-1,children:e(kd,{run:w})}):null,gt(w)?e("div",{id:"run-question",tabIndex:-1,children:e(_o,{run:w})}):null,w.team?e(zc,{run:w,steps:$}):null,w.team&&w.project?e(Pc,{projectId:w.project,repo:w.repo,refreshKey:`${w.status}:${w.team.revision}`}):null,w.triage?.state==="pending"&&w.status!=="running"?e("div",{class:"awaiting-card",id:"run-triage",tabIndex:-1,children:[e("div",{class:"aw-head",children:[e("span",{class:"status-pill awaiting",children:"In your inbox"}),e("b",{children:["From your automation \u201C",w.trigger?.name,"\u201D"]}),e("span",{class:"help",children:"Approving never merges (it can open a pull request); rejecting deletes the worktrees and branches."})]}),e("div",{class:"aw-actions",children:e(xo,{run:w})})]}):null,W?e(M,{children:[e(Qo,{run:w,steps:$,data:A.current}),["failed","stopped","interrupted","cancelled"].includes(w.status)?e("div",{class:"chat-recovery",role:"status",children:[e("p",{children:w.error??w.stopReason??"Work is saved. Resume when you're ready."}),e("button",{class:"btn small",disabled:y,onClick:()=>void Ie(),children:y?"Resuming\u2026":w.providerRecovery?"Retry reply":"Resume"}),T?e("p",{class:"help",role:"alert",children:T}):null]}):null]}):e("details",{class:`work ${L?"":"live"}`,open:le,children:[e("summary",{onClick:z=>{z.preventDefault(),a(!le)},children:e(Rp,{run:w,steps:$})}),e("div",{class:"steps",role:"list","aria-label":"Steps ([ and ] to move)",children:$.length?$.map(z=>e("div",{role:"listitem",class:`step ${z.id===E?"open":""}`,children:[e("button",{type:"button",class:`tl-step ${z.id===E?"selected":""}`,"aria-expanded":z.id===E,"aria-label":`${z.title}: ${Je[z.status]??z.status}`,onClick:()=>ue(z.id),children:[e("span",{class:`ic ${z.status}`,"aria-hidden":"true",children:Sp[z.status]??""}),e("span",{class:"tt",children:z.title}),e("span",{class:"tm",children:[e(pd,{step:z}),e("span",{children:(z.kind??"agent")==="agent"?z.role:z.finalText||"running\u2026"}),z.endedAt?e("span",{children:Le(z.endedAt-z.startedAt)}):null,z.usage?e("span",{title:md(z.usage),children:[Et(z.usage.inputTokens+z.usage.outputTokens)," tok"]}):null,z.retries?e("span",{title:"Retried after a passing failure (overloaded, network)",children:["\u21BB",z.retries]}):null]})]}),z.id===E?e(Sa,{run:w,step:z,data:A.current,version:A.current.events.get(z.id)?.length??0}):null]},z.id)):e("div",{class:"tl-empty",children:"Starting\u2026"})})]}),W?null:e(jp,{run:w,data:A.current}),W?null:e(zp,{logs:A.current.logs,count:A.current.logs.length})]})]}),e(si,{run:w,steps:$,chat:W},w.id),h?e(Yp,{run:w,onClose:()=>g(!1)}):null,u?e(Xp,{template:u,onClose:()=>f(null)}):null,p?e(xc,{run:w,onClose:()=>o(!1)}):null,d?e(_p,{run:w,onClose:()=>l(!1)}):null]})}function xp({run:t}){let s=t.chatLink?.workspaceId??t.id,n=[...ve.value.values()].filter(i=>i.pattern==="solo"&&!i.archived&&i.chatLink?.kind!=="side"&&(i.chatLink?.workspaceId??i.id)===s);n.some(i=>i.id===t.id)||n.push(t),n.sort((i,d)=>i.createdAt-d.createdAt);let r=n.filter(i=>i.id===t.id||!ha(i)),a=i=>{co(i),Pe({view:"run",id:i.id})},c=i=>{let d=r.findIndex(p=>p.id===i),l=r[d];if(l){if(rl(l,!0),i===t.id){let p=r[d+1]??r[d-1];p?a(p):Pe({view:"composer"})}l.status==="running"&&J("Tab closed. The agent continues working; reopen it from this task.",5e3)}};return e(Qa,{label:"Agent chats",active:t.id,items:r.map(i=>({key:i.id,label:`${Se[i.conversationAgent??i.roles.agent?.[0]??"claude"]} \xB7 ${i.task.split(`
|
|
70
|
+
`)[0].slice(0,45)}`,title:i.task,agent:i.conversationAgent??i.roles.agent?.[0],state:i.status==="running"?"working":void 0})),onPick:i=>a(n.find(d=>d.id===i)),onClose:c,closeTitle:"Close tab \u2014 keeps history and any running work",children:e(Ve,{label:"All chats",icon:"menu",align:"end",title:"All chats on this task, including closed tabs",children:i=>e(M,{children:[e(kt,{children:"Chats on this task"}),n.map(d=>e(pe,{on:d.id===t.id,sub:`${Se[d.conversationAgent??d.roles.agent?.[0]??"claude"]} \xB7 ${Je[d.status]??d.status}${ha(d)?" \xB7 Closed tab":""}`,onClick:()=>{i(),a(d)},children:d.task.split(`
|
|
71
|
+
`)[0]},d.id))]})})})}function Rp({run:t,steps:s}){let n=s.filter(i=>i.status==="running"),r=s.filter(i=>i.status==="failed").length,a=[...new Set(s.map(i=>i.agent).filter(i=>!!i))],c=Le((t.endedAt??Date.now())-t.createdAt);return e(M,{children:[e("span",{class:`work-ic ${ft(t)}`,"aria-hidden":"true"}),e("span",{class:"work-title",children:t.status==="running"?n.length?`Working \u2014 ${n.map(i=>i.title).join(", ")}`:"Working\u2026":`${s.length} step${s.length===1?"":"s"}`}),e("span",{class:"work-meta",children:[t.status==="running"?`${s.length} step${s.length===1?"":"s"} so far \xB7 ${c}`:c,r?e("span",{class:"warn",children:[" \xB7 ",r," failed"]}):null]}),e("span",{class:"work-agents",children:a.map(i=>e(Ee,{id:i},i))}),e("span",{class:"work-chev","aria-hidden":"true"})]})}function pd({step:t,model:s}){return(t.kind??"agent")==="agent"?e(Ee,{id:t.agent,note:s}):e("span",{class:"tag-cf",children:t.kind==="check"?"Check":"Setup"})}var ad=t=>t.charAt(0).toUpperCase()+t.slice(1);function $p({run:t}){let s=t.context??{paths:[],attachments:[]};return!s.paths.length&&!s.attachments.length?null:e("div",{class:"run-chips",children:[s.paths.map(n=>e("span",{class:"chip-ctx",title:n.workingCopy?`Your ${n.note} working copy was given to the agents`:n.path,children:[e(K,{name:n.type==="dir"?"folder":"files"}),e("span",{class:"n",children:[n.path,n.type==="dir"?"/":""]}),n.note?e("span",{class:"note",children:n.note}):null]},n.path)),s.attachments.map(n=>e("span",{class:"chip-ctx",children:[e(K,{name:"attach"}),e("span",{class:"n",children:n.name}),e("span",{class:"size",children:Zt(n.size)})]},n.name))]})}function Ip({run:t}){let s=Object.entries(t.roles).filter(([,n])=>n.length);return e("div",{class:"run-meta",children:[e(Ol,{run:t}),e("span",{title:t.repo,class:"repo-line",children:[e(K,{name:"folder"})," ",be(t.repo)]}),t.trigger?e("a",{class:"src-link with-ic",href:"#/automations",title:`Started by ${t.trigger.via==="schedule"?"its schedule":t.trigger.via==="webhook"?"a webhook":t.trigger.via==="sweep"?"a sweep":"Run now"}`,children:[e(K,{name:t.trigger.via==="sweep"?"layers":"clock"})," ",t.trigger.name]}):null,t.triage&&t.triage.state!=="pending"?e("span",{class:"badge",children:t.triage.state==="empty"?"No changes \xB7 archived":ad(t.triage.state)}):null,t.source?e("a",{class:"src-link with-ic",href:Sn(t.source.url),target:"_blank",rel:"noreferrer",title:t.source.title,children:[t.source.kind==="pr"?e(K,{name:"pull"}):null,t.source.kind==="issue"?`Issue #${t.source.number}`:t.source.kind==="pr"?`PR #${t.source.number}`:`\u26A0 ${t.source.alert?.tool==="dependabot"?"Dependabot":"Code scanning"} alert ${(t.source.alert?.numbers??[t.source.number]).map(n=>`#${n}`).join(", ")}`,e(K,{name:"external"})]}):null,e("span",{children:["From ",t.baseLabel," @ ",e("code",{children:t.baseRef.slice(0,7)})]}),t.loop?.check?e("span",{title:"code-flow runs this after every change",children:["Done when ",e("code",{children:t.loop.check})," passes",t.checkCantRun?" \xB7 can't run here":t.lastCheck?t.lastCheck.ok?" \xB7 last check \u2713":" \xB7 last check \u2715":""]}):null,e("span",{class:"team-line",children:s.map(([n,r])=>e("span",{children:[ad(n),":"," ",r.map((a,c)=>e("span",{children:[c?", ":"",e(Ee,{id:a,note:Yo(t,a)})]},a))]},n))}),t.group?e("a",{class:"src-link with-ic",href:`#/insights/${encodeURIComponent(t.group.id)}`,title:"Started together with other setups on the same task",children:[e(K,{name:"compare"})," Comparison: ",t.group.label]}):null,t.trust==="full"?e("span",{class:"full-access",title:"Agents could run any command, with no sandbox",children:"\u26A0 Full access"}):null,t.conventions?e("span",{class:"with-ic",title:"The repo's AGENTS.md, CLAUDE.md\u2026 are given to every agent",children:[e(K,{name:"files"})," Conventions"]}):null,t.lessons?.length?e("span",{class:"with-ic",title:`Problems reviewers raised in earlier runs here, given to every agent:
|
|
72
|
+
${t.lessons.map(n=>`\u2022 ${n}`).join(`
|
|
73
|
+
`)}`,children:[e(K,{name:"sparkle"})," ",t.lessons.length," lesson",t.lessons.length===1?"":"s"]}):null,t.usage?e("span",{class:"usage",children:[t.usage.agentSteps,"/",t.loop.maxSteps," agent steps \xB7 ",Le((t.endedAt??Date.now())-t.createdAt)," of ",t.loop.maxMinutes," min",t.usage.inputTokens||t.usage.outputTokens?e("span",{title:Ap(t),children:[" ","\xB7 ",Et((t.usage.inputTokens??0)+(t.usage.outputTokens??0))," tokens",t.usage.costUsd?` \xB7 \u2248${ht(t.usage.costUsd)} API-equivalent`:""]}):null]}):null]})}var md=t=>`${t.inputTokens.toLocaleString()} input \xB7 ${t.outputTokens.toLocaleString()} output \xB7 ${t.cacheReadTokens.toLocaleString()} cached${t.costUsd?` \xB7 \u2248${ht(t.costUsd)}`:""}`,Ap=t=>Object.entries(t.usage.byAgent??{}).map(([s,n])=>`${s}: ${n.steps} steps, ${Et(n.inputTokens+n.outputTokens)} tokens${n.costUsd?`, \u2248${ht(n.costUsd)}`:""}, ${Le(n.ms)}`).join(`
|
|
74
|
+
`);function Ep({run:t,steps:s,onSelectStep:n,chat:r}){let a=ft(t),c=s.filter(l=>l.status==="failed"),i={done:"\u2713 Finished \u2014 the check passes",unverified:"Finished \u2014 no independent check passed",failing:"\u26A0 Finished \u2014 but the check still fails",unchecked:"\u26A0 Finished \u2014 but the check couldn't run, so nothing was tested",failed:"\u2715 Failed",cancelled:"\u25A0 Stopped by you",stopped:zt(t)?"\u25A0 Paused with unresolved work \u2014 press Resume to continue":`\u25A0 Stopped at the ${t.stopReason??"limit"} \u2014 work so far is kept below`,interrupted:"\u25A0 Interrupted \u2014 press Resume to continue where it stopped"};r&&Object.assign(i,{done:"\u2713 The check passes",unverified:"No independent check passed",failing:"\u26A0 The check fails",unchecked:"\u26A0 The check couldn't run, so nothing was tested"});let d=i[a]??t.status;return e("div",{class:`result ${a}${r?" chat":""}`,children:[d?e("div",{class:"rh",children:d}):null,t.checkCantRun?e(Xa,{cantRun:t.checkCantRun}):null,e($r,{run:t}),c.length&&t.status!=="done"?e("div",{class:"failures",children:[e("div",{class:"lbl",children:"What went wrong"}),c.slice(-5).map(l=>e("button",{type:"button",class:"failure",onClick:()=>n(l.id),children:[e("span",{class:"ic failed","aria-hidden":"true",children:"\u2715"}),e("b",{children:l.title})," ",e(pd,{step:l}),e("span",{class:"fe",children:(l.error??l.finalText??"").split(`
|
|
75
|
+
`)[0].slice(0,200)})]},l.id))]}):null,t.error?e("div",{class:"rb",children:e("div",{class:"ev error",children:t.error})}):t.review?e(Mp,{run:t}):t.summary&&!r?e("div",{class:"rb",children:e(je,{text:t.summary})}):null,t.artifacts.length?e("div",{class:"artifacts",children:t.artifacts.map(l=>e(ei,{run:t,artifact:l,steps:s},l.branch+l.label))}):null]})}function jp({run:t,data:s}){return t.followUps?.length?e(M,{children:t.followUps.map(n=>{if(n.side)return n.side.mode==="change"&&n.status!=="pending"?e(hd,{run:t,f:n},n.id):null;let r=n.stepId?s.steps.get(n.stepId):void 0;return e("div",{class:"fu",children:[n.kind==="reply"||n.kind==="comments"&&!n.from?e("div",{class:"msg-you",children:e("div",{class:"bubble",children:e(je,{text:n.message})})}):e("div",{class:"fu-sent help",children:[n.kind==="resolve-conflicts"?`Sent ${n.mergeFrom}'s merge conflicts to`:n.kind==="ci-fix"?"Sent the pull request's failing CI to":`Sent ${n.from}'s comments to`," ",e(Ee,{id:n.agent})]}),e("div",{class:`fu-answer ${n.status}`,children:[e("div",{class:"fu-head",children:[e(Ee,{id:n.agent}),e("span",{children:[Pp(n)," in ",n.worktree]}),e(Zn,{f:n,run:t})]}),r?e(Nr,{run:t,step:r,data:s,answer:n.status==="pending"?void 0:n.result}):n.result?e(je,{text:n.result}):null]})]},n.id)})}):null}function hd({run:t,f:s}){return e("div",{class:"fu-sent help side-note",children:[e(Ee,{id:s.agent})," ",s.status==="done"?"changed":"tried to change"," ",s.worktree," from the side chat"," ",e("button",{type:"button",class:"link",onClick:()=>Yi(t.id,s.side.chat),children:["\u201C",s.side.title,"\u201D"]}),e(Zn,{f:s})]})}function Zn({f:t,run:s}){let n=t.status==="pending"&&!!s&&s.status!=="running"&&s.status!=="done";return e(M,{children:[n?s.status==="interrupted"?e("span",{class:"note",title:"code-flow stopped before this turn finished. Resume the run to continue it.",children:"Interrupted"}):e("span",{class:"err",children:"\u2715 Didn't finish"}):t.status==="pending"?e("span",{class:"fu-live",children:"Working\u2026"}):t.status==="failed"?e("span",{class:"err",children:"\u2715 Didn't finish"}):null,t.pushed?e("span",{class:"ok",children:["Pushed ",t.pushed.slice(0,7)]}):t.pushError?e("span",{class:"note",title:t.pushError,children:["Push failed: ",t.pushError]}):null,t.checkPassed===!1?e("span",{class:"note",children:"check fails"}):t.checkPassed?e("span",{class:"ok",children:"check passes"}):null,t.integrity?.length?e("span",{class:"note",title:t.integrity.map(r=>`${r.file}: ${r.detail}`).join(`
|
|
76
|
+
`),children:"\u26A0 Changed tests"}):null]})}function Nr({run:t,step:s,data:n,answer:r}){let[a,c]=m(!1),i=n.events.get(s.id)?.length??0,d=r??s.finalText,l=[...n.steps.values()].filter(o=>(o.kind??"agent")==="agent"&&!Xo(o)).sort((o,u)=>o.startedAt-u.startedAt).at(-1)?.id;if(N(()=>{let o=`${t.id}:${s.id}:${s.endedAt}`;if(Es||s.id!==l||s.status!=="done"||!d||Ca.has(o))return;let u=Sc(d,location.href);if(!u.length)return;let f=new AbortController,h,g=Date.now()+15e3,y=async()=>{for(let C of u){if(f.signal.aborted||Ca.has(o))return;let T=await V("/api/preview/status",{method:"POST",body:JSON.stringify({url:C,runId:t.id}),signal:f.signal}).catch(()=>null);if(f.signal.aborted||Ca.has(o))return;if(T?.ready){Ca.add(o),to(C,t.id);return}}!f.signal.aborted&&Date.now()<g?h=setTimeout(()=>void y(),1e3):Ca.add(o)};return y(),()=>{f.abort(),clearTimeout(h)}},[t.id,s.id,s.status,s.endedAt,d,l]),s.status==="running")return e(Sa,{run:t,step:s,data:n,version:i});let p=Cd(n,s).filter(o=>o.kind==="tool").length;return e("div",{class:"turn-body",children:[e("button",{type:"button",class:"show-work","aria-expanded":a,onClick:()=>c(!a),children:[a?"Hide work":`Show work${p?` \xB7 ${p} tool call${p===1?"":"s"}`:""}`,s.endedAt?` \xB7 ${Le(s.endedAt-s.startedAt)}`:""]}),a?e(M,{children:[s.teamResponseFor?[...n.steps.values()].filter(o=>o.teamResponseFor===s.teamResponseFor&&o.id!==s.id).map(o=>e("p",{class:"help",children:[Se[o.agent??"claude"],": ",o.error??o.status,". Continued with ",Se[s.agent??"claude"],"."]},o.id)):null,e(Sa,{run:t,step:s,data:n,version:i})]}):null,d?e(je,{text:d}):s.status!=="done"&&!a?e(Sa,{run:t,step:s,data:n,version:i}):null,s.error?e("div",{class:"ev error",role:"status",children:s.error}):null]})}function Qo({run:t,steps:s,data:n}){let r=t.followUps.filter(v=>!v.side),a=new Map(r.filter(v=>v.stepId).map(v=>[v.stepId,v])),c=fd(t),i=new Map(s.filter(v=>v.teamResponseFor).map(v=>[v.teamResponseFor,v.id])),d=s.filter(v=>(v.kind??"agent")==="agent"&&!c.has(v.id)&&(!v.teamResponseFor||i.get(v.teamResponseFor)===v.id)),l=r.filter(v=>!v.stepId||!n.steps.has(v.stepId)),p=t.followUps.filter(v=>v.side?.mode==="change"&&v.status!=="pending"),o=[...d.map(v=>({at:v.startedAt,step:v})),...l.map(v=>({at:v.at,followUp:v})),...p.map(v=>({at:v.stepId&&n.steps.get(v.stepId)?.startedAt||v.at,side:v}))].sort((v,k)=>v.at-k.at),u=r.length===0&&!t.followUps.some(v=>v.side?.mode==="change"&&!!v.stepId),f=Object.values(t.roles).flat()[0],h=v=>{let k=v?.at??t.createdAt,b=r.find(S=>S.at>k)?.at??1/0;return t.notes.filter(S=>S.teamDelivery&&S.at>=k&&S.at<b)},g=v=>(t.teamTurns??[]).filter(k=>v?k.key.includes(`|follow-up ${v.id}#`):k.key.startsWith("agent|")),y=v=>g(v).some(k=>!k.report),C=v=>{let k=g(v),b=k.map(S=>ve.value.get(S.executionId)).find(S=>S?.status==="running");return e(M,{children:[b?.awaiting?e(kd,{run:b,compact:!0}):null,b&>(b)?e(_o,{run:b,replyChatId:t.id}):null,e(cd,{run:t,turns:k})]})},T=v=>e("div",{class:"team-question-history",children:[v.question?e("div",{class:"msg-agent",children:[e("div",{class:"help",children:[v.question.sender," asked"]}),e(je,{text:v.question.body})]}):null,e("div",{class:"msg-you",children:e("div",{class:"bubble",children:[e(je,{text:v.text}),e("div",{class:"help",role:"status",children:v.control?"Stopped \xB7 work saved. Resume when you\u2019re ready.":v.teamDelivery?.state==="applied"?v.requestId?"Answer sent":v.teamDelivery.taskIds?.length?`Updated ${v.teamDelivery.taskIds.join(", ")}`:"Added to the team request":v.teamDelivery?.state==="not_applied"?"Saved for your agent":"Received \xB7 updating the team\u2026"})]})})]},v.id);return e(M,{children:[!d.length&&!r.length?e(M,{children:[h().map(T),C()]}):null,o.map(({step:v,followUp:k,side:b})=>{if(b)return e(hd,{run:t,f:b},b.id);if(!v){let w=k;return e("div",{class:"fu",children:[e("div",{class:"msg-you",children:e("div",{class:"bubble",children:e(je,{text:w.message})})}),h(w).map(T),C(w),y(w)?null:e("div",{class:"fu-answer",children:[e("div",{class:"fu-head",children:[e(Ee,{id:w.agent}),w.status==="pending"&&(t.status==="running"||t.status==="done")?e("span",{class:"fu-live",children:t.status==="running"?"Up next\u2026":"Waiting\u2026"}):e(Zn,{f:w,run:t})]}),w.status==="pending"||!w.result?null:w.status==="failed"?e("div",{class:"ev error",children:w.result}):e(je,{text:w.result})]})]},w.id)}let S=a.get(v.id),x=t.notes.filter(w=>w.deliveredTo?.stepId===v.id&&!w.followUp);return e("div",{class:"fu",children:[S?e("div",{class:"msg-you",children:e("div",{class:"bubble",children:e(je,{text:S.message})})}):null,v.leadQuestion?null:h(S).map(T),x.map(w=>e("div",{class:"msg-you",children:e("div",{class:"bubble",children:[e(je,{text:w.text}),w.deliveredTo?.midTurn?e("div",{class:"help",children:"Sent while it worked"}):null]})},w.id)),v.leadQuestion?null:C(S),e("div",{class:"fu-answer",children:[e("div",{class:"fu-head",children:[e(Ee,{id:v.agent,note:Yo(t,v.agent,v.settings)}),S?e(Zn,{f:S,run:t}):v.status==="running"?e("span",{class:"fu-live",children:"Working\u2026"}):v.status==="failed"?e("span",{class:"err",children:"\u2715 Didn't finish"}):null,!S&&v.status!=="running"&&t.lastCheck&&u?t.lastCheck.ok?e("span",{class:"ok",children:"check passes"}):e("span",{class:"note",children:"check fails"}):null]}),e(Nr,{run:t,step:v,data:n})]})]},v.id)}),t.status==="running"?s.filter(v=>v.kind==="check"&&v.status==="running").map(v=>{let k=n.events.get(v.id)?.find(b=>b.kind==="tool_call"&&b.name==="$");return e("details",{class:"chat-check",children:[e("summary",{children:[e("span",{class:"spin","aria-hidden":"true"}),e("span",{children:[e("strong",{children:"Running checks"}),e("span",{class:"help",children:d.every(b=>b.status!=="running")?"The agent has finished. Verification is still running.":"Verifying the work."}),e("code",{children:k?.kind==="tool_call"?k.input:t.loop.check||v.title})]}),e("span",{class:"help",children:"Show output"})]}),e(Sa,{run:t,step:v,data:n,version:n.events.get(v.id)?.length??0})]},v.id)}):null,!d.length&&!y()&&t.status==="running"?e("div",{class:"fu-answer",children:e("div",{class:"fu-head",children:[e(Ee,{id:f}),e("span",{class:"fu-live",children:"Starting\u2026"})]})}):null]})}var fd=t=>new Set(t.followUps.filter(s=>s.side&&s.stepId).map(s=>s.stepId)),Xo=t=>!!t.sideOf||t.role==="side chat"||/^Check after side chat /.test(t.title);function Zo(t,s){let n=fd(t);return[...s].filter(r=>!n.has(r.id)&&!Xo(r))}var Pp=t=>t.side?"side chat":t.kind==="resolve-conflicts"?`resolve conflicts with ${t.mergeFrom}`:t.kind==="reply"?"your reply":t.kind==="ci-fix"?"fix failing CI":t.from?`comments from ${t.from}`:"review comments";function Mp({run:t}){let s=t.review,[n,r]=m(!1),a=t.source?.kind==="pr"?t.source:void 0;return e("div",{class:"rb council",children:[e("div",{class:"council-head",children:[e("span",{class:`badge ${s.verdict==="approve"?"ok":"warn"}`,children:s.verdict==="approve"?"Approve":"Changes requested"}),e("span",{class:"help",children:s.reviewers.map((c,i)=>e("span",{children:[i?" \xB7 ":"",e(Ee,{id:c.agent})," ",c.verdict==="approve"?"approves":`${c.issues} issue${c.issues===1?"":"s"}`]},c.agent))}),e("span",{class:"spacer"}),a?s.postedTo?e("a",{class:"badge ok",href:Sn(s.postedTo),target:"_blank",rel:"noreferrer",children:["Posted to PR #",a.number," ",e(K,{name:"external"})]}):e("button",{class:"btn small primary",disabled:n||t.status==="running",onClick:async()=>{if(await Ae(`Post this review as a comment on PR #${a.number}? Everyone with access to the PR will see it.`,{title:"Post review to GitHub?",confirmLabel:"Post review",danger:!1})){r(!0);try{await O(`/api/runs/${t.id}/post-review`),J("Review posted")}catch(c){J(c.message,5e3)}finally{r(!1)}}},children:n?"Posting\u2026":`Post to PR #${a.number}`}):null,e("button",{class:"btn small",onClick:()=>Kt(s.markdown,"Review copied as Markdown"),children:"Copy"})]}),s.proof?e(gd,{proof:s.proof}):null,s.summary?e("p",{children:s.summary}):null,s.findings.length?e("ol",{class:"findings",children:s.findings.map((c,i)=>e("li",{class:`sev-${c.severity}`,children:[e("div",{children:[e("span",{class:`sev ${c.severity}`,children:c.severity})," ",e("code",{children:c.file||"general"})," ",c.problem]}),e("div",{class:"help",children:["Fix: ",c.fix]}),e(vd,{severity:c.severity,check:c.check}),e("div",{class:"raised",children:[c.raisedBy.length>1?e("b",{children:[c.raisedBy.length," reviewers agree \xB7 "]}):null,c.raisedBy.map(d=>e(Ee,{id:d},d))]})]},i))}):e("p",{class:"help",children:"No problems found."})]})}function ei({run:t,artifact:s,steps:n,reviewing:r=!1}){let[a,c]=m(null),i=(t.worktrees??[]).find(h=>h.branch===s.branch),d=t.merges?.filter(h=>h.branch===s.branch)??[],l=t.prs?.[s.branch],p=(t.status==="done"||zt(t))&&!!i,o=t.source?.kind==="pr"?t.source:void 0,[u,f]=m(!1);return e("div",{class:"artifact",children:[e("div",{class:"ah",children:[e("b",{children:s.label}),e("code",{children:s.branch}),d.map(h=>e("span",{class:"badge ok",children:[h.pr?"PR merged into":"Merged into"," ",h.into]},h.commit)),l?e("a",{class:"badge",href:Sn(l),target:"_blank",rel:"noreferrer",children:["PR ",e(K,{name:"external"})]}):null,e("span",{class:"acts",children:[p&&!r?e("button",{class:"btn small",onClick:()=>Pe({view:"review",id:t.id,branch:s.branch}),children:"Review changes"}):null,i?e("button",{class:"btn small","aria-pressed":a==="merge",onClick:()=>c(a==="merge"?null:"merge"),children:l?"Merge PR\u2026":"Merge\u2026"}):null,i&&o&&!o.isCrossRepository&&t.status!=="running"?e("button",{class:"btn small primary",disabled:u,title:`Push this branch to ${o.headRefName}, updating PR #${o.number} (never forced)`,onClick:async()=>{if(await Ae(`Push ${s.branch} to ${o.headRefName}? This updates PR #${o.number} on GitHub.`,{title:"Push changes to GitHub?",confirmLabel:"Push changes",danger:!1})){f(!0);try{await O(`/api/runs/${t.id}/push-pr`,{branch:s.branch}),J(`Pushed to PR #${o.number}`)}catch(h){J(h.message,6e3)}finally{f(!1)}}},children:u?"Pushing\u2026":`Push to PR #${o.number}`}):null,i&&!o?e("button",{class:"btn small","aria-pressed":a==="pr",onClick:()=>c(a==="pr"?null:"pr"),children:"Open PR\u2026"}):null,e("button",{class:"btn small",onClick:()=>Kt(`git diff ${t.baseRef.slice(0,12)}...${s.branch}`,"Diff command copied"),children:"Copy diff cmd"}),e("button",{class:"btn small",onClick:()=>Kt(s.path,"Path copied"),children:"Copy path"})]})]}),t.integrity?.[s.branch]?.length?e(Dp,{issues:t.integrity[s.branch]}):null,t.proofs?.[s.branch]?e(gd,{proof:t.proofs[s.branch]}):null,t.findings?.[s.branch]?.findings.length?e(Lp,{review:t.findings[s.branch]}):null,r?null:s.stat?e("pre",{tabIndex:0,children:s.stat}):e("div",{class:"help",children:"No changes"}),!r&&i&&Hp(t)?e(Wp,{run:t,worktree:i.name}):null,a==="merge"&&i?l?e(Bp,{run:t,branch:s.branch,worktree:i.name,steps:n}):e(yd,{run:t,branch:s.branch,worktree:i.name,steps:n}):null,a==="pr"?e(Fp,{run:t,branch:s.branch}):null,l?e(Vo,{runId:t.id,branch:s.branch}):null,l&&i&&!d.some(h=>h.pr===l)?e(Op,{run:t,branch:s.branch,steps:n,worktree:i.name}):null]})}function Dp({issues:t}){return e("div",{class:"integrity",role:"note",children:[e("b",{children:"\u26A0 Changes to tests to check before merging"}),e("span",{class:"help",children:" \u2014 they can make the check pass without a real fix."}),e("ul",{children:t.map((s,n)=>e("li",{children:[e("span",{class:`sev ${s.severity}`,children:s.severity})," ",s.file?e("code",{children:s.file}):null," ",s.detail]},n))})]})}function gd({proof:t}){let s=t.tests.length?`this change's tests (${t.tests.join(", ")})`:"the existing tests";return e("div",{class:`proof ${t.status}`,role:"note",children:t.status==="proven"?e(M,{children:[e("b",{children:"\u2713 Proven: a test fails without this change"}),e("span",{class:"help",children:[" ","\u2014 ",e("code",{children:t.command})," fails on the base code with ",s,", and passes with the change."]}),e("details",{children:[e("summary",{children:"How it fails without the change"}),e("pre",{children:t.detail})]})]}):t.status==="weak"?e(M,{children:[e("b",{children:"\u26A0 Weak proof: the tests fail without this change only because they can't load"}),e("span",{class:"help",children:[" ","\u2014 ",e("code",{children:t.command})," fails on the base code with ",s,", but on an import or build error, not on what the tests check. Check a test covers the behaviour before merging."]}),e("details",{children:[e("summary",{children:"How it fails without the change"}),e("pre",{children:t.detail})]})]}):t.status==="unproven"?e(M,{children:[e("b",{children:"\u26A0 Not proven: no test fails without this change"}),e("span",{class:"help",children:[" ","\u2014 ",e("code",{children:t.command})," passes on the base code too, with ",s,". Check the change is tested before merging."]})]}):e(M,{children:[e("b",{children:"Couldn't prove a test fails without this change"}),e("span",{class:"help",children:[" \u2014 ",t.detail,"."]})]})})}function Lp({review:t}){let s=t.findings.filter(n=>n.blocking).length;return e("div",{class:`review-findings${s&&!t.stale?" blocking":""}`,role:"note",children:[e("b",{children:t.stale?"Review outdated \u2014 the result changed after this review":s?`\u26A0 ${s} review finding${s===1?" blocks":"s block"} approval`:"\u2713 No review finding blocks approval"}),e("span",{class:"help",children:[" ","\u2014 ",e(Ee,{id:t.reviewer})," ",t.round>1?`round ${t.round}`:"review",". High and medium findings block; a high one (a bug) only when its test fails."]}),e("ol",{class:"findings",children:t.findings.map((n,r)=>e("li",{class:`sev-${n.severity}`,children:[e("div",{children:[e("span",{class:`sev ${n.severity}`,children:n.severity})," ",e("code",{children:n.file||"general"})," ",n.problem," ",t.stale?e("span",{class:"help",children:"Historical finding"}):n.blocking?e("span",{class:"badge warn",children:"Blocks"}):n.severity==="low"?e("span",{class:"help",children:"Suggestion"}):null]}),n.fix?e("div",{class:"help",children:["Fix: ",n.fix]}):null,e(vd,{severity:n.severity,check:n.check})]},r))})]})}function vd({severity:t,check:s}){if(!s)return null;let n=s.path?e("code",{children:s.path}):"test";return s.status==="confirmed"?e("div",{class:"finding-check confirmed",children:[e("b",{children:"\u2713 Confirmed"}),e("span",{class:"help",children:[" ","\u2014 the reviewer's ",n," fails with ",e("code",{children:s.command}),"."]}),e("details",{children:[e("summary",{children:"How it fails"}),e("pre",{children:s.detail})]}),s.contents?e("details",{children:[e("summary",{children:"The reviewer's test"}),e("pre",{children:s.contents})]}):null]}):s.status==="refuted"?e("div",{class:"finding-check refuted",children:[e("b",{children:"\u2717 Not confirmed"}),e("span",{class:"help",children:[" ","\u2014 the reviewer's ",n," passes with ",e("code",{children:s.command}),": a false alarm."]})]}):t==="low"?null:s.status==="unverified"?e("div",{class:"finding-check unverified",children:[e("b",{children:"Couldn't run the reviewer's test"}),e("span",{class:"help",children:[" \u2014 ",s.detail,"."]})]}):e("div",{class:"finding-check unconfirmed",children:[e("b",{children:t==="high"?"\u26A0 Unconfirmed":"Not shown by a test"}),e("span",{class:"help",children:[" \u2014 ",s.detail,"."]})]})}var Np={watching:"Watching",fixing:"Fixing",green:"CI green","needs-you":"Needs you",closed:"PR closed",stopped:"Not watching"};function Op({run:t,branch:s,steps:n,worktree:r}){let a=t.watches?.[s],c=a&&["watching","fixing","green"].includes(a.state),[i,d]=m(a?.agent??bd(n,r)??"claude"),[l,p]=m(a?.maxFixes??3),[o,u]=m((a?.allow??[]).map(h=>`@${h}`).join(", ")),f=h=>O(`/api/runs/${t.id}/watch`,{branch:s,...h}).catch(g=>J(g.message,5e3));return e("div",{class:`watch ${a?.state??"off"}`,children:[a?e("div",{class:"row",children:[e("span",{class:`badge ${a.state==="green"?"ok":a.state==="needs-you"?"warn":""}`,children:Np[a.state]}),e("span",{class:"detail",children:a.detail}),a.checks?e("span",{class:"help",children:["CI: ",a.checks.pass," \u2713 \xB7 ",a.checks.fail," \u2715",a.checks.pending?` \xB7 ${a.checks.pending} running`:""]}):null,e("span",{class:"help",children:[a.fixes,"/",a.maxFixes," fixes",a.lastPolled?` \xB7 checked ${new Date(a.lastPolled).toLocaleTimeString()}`:"",` \xB7 acts on comments from you${a.allow?.length?`, ${a.allow.map(h=>`@${h}`).join(", ")}`:""}`]}),e("span",{class:"spacer"}),c?e("button",{class:"btn small",onClick:()=>f({stop:!0}),children:"Stop watching"}):null]}):null,!c&&a?.state!=="closed"?e("div",{class:"row",children:[e("span",{class:"lbl",children:"Follow through"}),e("span",{children:"When CI fails or you comment,"}),e(Or,{value:i,onChange:d,label:"Agent that fixes CI failures and comments"}),e("span",{children:"fixes it and pushes \u2014 up to"}),e("input",{class:"field inline num",type:"number",min:1,max:10,value:l,"aria-label":"Most fixes",onInput:h=>p(Number(h.currentTarget.value)||3)}),e("span",{children:"times. Never merges."}),e("button",{class:"btn small primary",onClick:()=>f({agent:i,maxFixes:l,allow:o.split(/[\s,]+/).map(h=>h.replace(/^@/,"")).filter(Boolean)}),children:a?"Watch again":"Watch PR"})]}):null,!c&&a?.state!=="closed"?e("div",{class:"row",children:[e("span",{class:"help",children:"Also act on comments from"}),e("input",{class:"field inline",placeholder:"@teammate, @reviewer",value:o,"aria-label":"Other GitHub users whose comments the agent acts on",onInput:h=>u(h.currentTarget.value)}),e("span",{class:"help",children:"\u2014 nobody else's, since these fixes are pushed without anyone reviewing them first."})]}):null]})}function qp(t){let[s,n]=m(null);N(()=>{V(`/api/branches?repo=${encodeURIComponent(t.repo)}`).then(n,()=>n(null))},[t.repo]);let r=(s?.branches??[]).filter(c=>c.kind==="local").map(c=>c.name),a=t.baseLabel!=="HEAD"&&r.includes(t.baseLabel)?t.baseLabel:s?.current??r[0]??"";return{branches:r,initial:a}}var bd=(t,s)=>[...t].reverse().find(n=>(n.kind??"agent")==="agent"&&n.worktree===s&&n.mode==="write")?.agent;function yd({run:t,branch:s,worktree:n,steps:r}){let{branches:a,initial:c}=qp(t),[i,d]=m(""),[l,p]=m(!0),[o,u]=m(!1),[f,h]=m(null),[g,y]=m(!!t.loop.verification),[C,T]=m(null),[v,k]=m(bd(r,n)??"claude"),b=i||c,S=C?.branch===s&&C.into===b&&C.report?.state==="verified"&&!C.conflicts.length,x=async(j=!1)=>{u(!0),T(null);try{T(await O(`/api/runs/${t.id}/validate-merge`,{branch:s,into:b,allowUntrusted:j}))}catch(A){if(A instanceof st&&A.confirm==="allowUntrusted"&&await Ae(`${A.message}
|
|
77
|
+
|
|
78
|
+
Run validation on this computer?`,{title:"Run validation locally?",confirmLabel:"Run validation",danger:!0})){u(!1),await x(!0);return}J(A.message,5e3)}finally{u(!1)}},w=async()=>{u(!0),h(null);try{let j=await O(`/api/runs/${t.id}/merge`,{branch:s,into:b,archiveAfter:l,requireValidation:g});j.ok?J(`Merged into ${b}${l?" and archived the run":""}`,3e3):h(j.conflicts)}catch(j){J(j.message,5e3)}finally{u(!1)}};return e("div",{class:"ship-panel",children:[e("div",{class:"row",children:[e("label",{class:"lbl",children:"Merge into"}),e("select",{class:"field",value:b,onChange:j=>d(j.currentTarget.value),children:a.map(j=>e("option",{value:j,children:j},j))}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:l,onChange:j=>p(j.currentTarget.checked)})," Archive the run afterwards (removes its worktrees, keeps branches)"]}),e("button",{class:"btn primary small",disabled:o||!b||g&&!S,onClick:w,children:o?"Merging\u2026":`Merge into ${b||"\u2026"}`})]}),t.loop.check||t.loop.verification?e("div",{class:"row",children:[e("label",{class:"check",children:[e("input",{type:"checkbox",checked:g,onChange:j=>y(j.currentTarget.checked)})," Require verification of the current merge target"]}),e("button",{class:"btn small",disabled:o||!b,onClick:()=>x(),children:"Validate merge result"}),C?.into===b?e("span",{role:"status",class:"help",children:[C.conflicts.length?`Conflicts: ${C.conflicts.join(", ")}`:`Merge verification: ${C.report?.state??"unchecked"}`," \xB7 target ",C.target.slice(0,12),C.report?` \xB7 ${C.report.checks.length} gates`:""]}):null]}):null,e("div",{class:"help",children:["If ",b||"the branch"," is checked out, code-flow merges there only when it has no uncommitted changes, and aborts cleanly on conflicts."]}),f?e("div",{class:"conflicts",children:[e("div",{class:"msg warn",children:["Merging would conflict in ",f.length," file",f.length===1?"":"s",": ",f.join(", ")]}),e("div",{class:"row",children:[e("span",{children:"Ask"}),e(Or,{value:v,onChange:k}),e("span",{children:["to merge ",b," into this branch and resolve them, then merge again."]}),e("button",{class:"btn small",onClick:()=>O(`/api/runs/${t.id}/followups`,{kind:"resolve-conflicts",worktree:n,agent:v,mergeFrom:b}).then(()=>J("Sent \u2014 the agent is resolving the conflicts"),j=>J(j.message,5e3)),children:"Ask to resolve"})]})]}):null]})}var rd={merge:"Create a merge commit",squash:"Squash and merge",rebase:"Rebase and merge"},Up={pass:"CI passing",fail:"CI failing",pending:"CI still running",none:"no CI checks"};function Bp({run:t,branch:s,worktree:n,steps:r}){let[a,c]=m(null),[i,d]=m(""),[l,p]=m(""),[o,u]=m(!0),[f,h]=m(!1),[g,y]=m(!1);N(()=>{V(`/api/runs/${t.id}/pr-merge?branch=${encodeURIComponent(s)}`).then(c,b=>d(b.message))},[t.id,s]);let C=l||a?.methods[0]||"merge",T=a?`PR #${a.number}`:"the PR",v=a?.state==="OPEN",k=async()=>{if(!(!a||!await Ae(`${rd[C]}: merge ${T} into ${a.baseRefName} on GitHub?`,{title:"Merge pull request?",confirmLabel:"Merge pull request",danger:!0}))){h(!0);try{let b=await O(`/api/runs/${t.id}/merge-pr`,{branch:s,method:C,archiveAfter:o});b.merged?J(`${b.already?`${T} was already merged`:`Merged ${T}`} into ${b.into} on GitHub${o?" and archived the run":""}`,4e3):J(`GitHub accepted the merge; ${T} merges once the repository's requirements are met`,6e3),c({...a,state:b.merged?"MERGED":a.state})}catch(b){J(b.message,6e3)}finally{h(!1)}}};return e(M,{children:[e("div",{class:"ship-panel",children:[e("div",{class:"row",children:[e("label",{class:"lbl",children:"Merge pull request"}),a?e("a",{href:Sn(a.url),target:"_blank",rel:"noreferrer",children:["#",a.number," into ",a.baseRefName," ",e(K,{name:"external"})]}):e("span",{class:"help",children:i?"\u2014":"Asking GitHub\u2026"}),v?e(M,{children:[e("select",{class:"field",value:C,"aria-label":"How to merge",onChange:b=>p(b.currentTarget.value),children:a.methods.map(b=>e("option",{value:b,children:rd[b]},b))}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:o,onChange:b=>u(b.currentTarget.checked)})," Archive the run afterwards (removes its worktrees, keeps branches)"]}),e("button",{class:"btn primary small",disabled:f||a.isDraft,onClick:k,children:f?"Merging\u2026":`Merge ${T}`})]}):null]}),i?e("div",{class:"msg err",children:i}):null,a?.state==="MERGED"?e("div",{class:"msg",children:[T," is merged into ",a.baseRefName,"."]}):null,a?.state==="CLOSED"?e("div",{class:"msg warn",children:[T," is closed. Reopen it on GitHub to merge it."]}):null,v&&a.isDraft?e("div",{class:"msg warn",children:[T," is a draft. Mark it ready for review on GitHub, then merge."]}):null,v&&a.mergeable==="CONFLICTING"?e("div",{class:"msg warn",children:["GitHub says ",T," conflicts with ",a.baseRefName,": merge ",a.baseRefName," into the branch and resolve them first."]}):null,v?e("div",{class:"help",children:[Up[a.ci],". code-flow merges it on GitHub only while it's exactly the branch you reviewed here, and deletes no branches."," ",e("button",{class:"linkish",onClick:()=>y(!g),children:g?"Hide local merge":"Merge into a local branch instead\u2026"})]}):null]}),g||i?e(yd,{run:t,branch:s,worktree:n,steps:r}):null]})}function Fp({run:t,branch:s}){let[n,r]=m(null),[a,c]=m("");N(()=>{V(`/api/runs/${t.id}/pr-targets`).then(r,u=>c(u.message))},[t.id]);let[i,d]=m(""),[l,p]=m(!1),o=i||n?.initial||"";return e("div",{class:"ship-panel",children:[e("div",{class:"row",children:[e("label",{class:"lbl",children:"Pull request into"}),e("select",{class:"field",value:o,disabled:!n,onChange:u=>d(u.currentTarget.value),children:[n?null:e("option",{value:"",children:a?"\u2014":"Asking GitHub\u2026"}),(n?.branches??[]).filter(u=>u!==s).map(u=>e("option",{value:u,children:u},u))]}),e("button",{class:"btn primary small",disabled:l||!o,onClick:async()=>{p(!0);try{let{url:u}=await O(`/api/runs/${t.id}/pr`,{branch:s,into:o});J("Pull request opened",3e3),window.open(u,"_blank","noreferrer")}catch(u){J(u.message,6e3)}finally{p(!1)}},children:l?"Opening\u2026":"Push & open PR"})]}),a?e("div",{class:"msg warn",children:a}):null,e("div",{class:"help",children:["This pushes ",e("code",{children:s})," to ",e("code",{children:"origin"})," and opens a pull request with GitHub CLI (",e("code",{children:"gh"}),"), using the run's task and summary as the description."]})]})}var Hp=t=>!t.archived;function od(t){to(t)}function Wp({run:t,worktree:s}){let n=`/api/runs/${t.id}/worktrees/${encodeURIComponent(s)}`,[r,a]=m(null),[c,i]=m(!1),[d,l]=m(t.app?.command??"");De(f=>V(n+"/serve").then(h=>f()&&a(h),()=>{}),2e3,[n]);let p=f=>O(`${n}/open`,{target:f}).then(h=>J(`Opened in ${h.openedWith}${Es?" on your computer":""}`),h=>J(h.message,5e3)),o=async()=>{try{let f=await O(n+"/serve",{command:d});a(f),Es||od(f.url)}catch(f){if(!(f instanceof st)||f.confirm!=="allowUntrusted")return J(f.message,5e3);if(!await Ae(`${f.message}
|
|
79
|
+
|
|
80
|
+
Run it on this computer anyway?`,{title:"Run repository code locally?",confirmLabel:"Run app",danger:!0}))return;await O(n+"/serve",{command:d,allowUntrusted:!0}).then(a,h=>J(h.message,5e3))}},u=r&&Es?r.url.replace("//localhost:",`//${location.hostname}:`):r?.url;return e("div",{class:"ws-tools",children:[e("span",{class:"lbl",children:Es?"On your computer":"Try it"}),e("button",{class:"btn small",onClick:()=>p("terminal"),children:"Terminal"}),e("button",{class:"btn small",onClick:()=>p("editor"),children:"Editor"}),e("button",{class:"btn small",onClick:()=>p("finder"),children:"Folder"}),r?.status==="running"?e(M,{children:[e("a",{class:"btn small primary",href:Sn(u),target:"_blank",rel:"noreferrer",title:Es?"Opens only if the app listens on your network too (e.g. vite --host)":void 0,children:["Open ",u.replace("http://","")," ",e(K,{name:"external"})]}),Es?null:e("button",{class:"btn small",title:"Show it in the side panel's Browser, where you can annotate it",onClick:()=>od(r.url),children:"Show in panel"}),e("button",{class:"btn small",onClick:()=>i(!c),children:c?"Hide logs":"Logs"}),e("button",{class:"btn small danger",onClick:()=>V(n+"/serve",{method:"DELETE"}).then(()=>a(null)),children:"Stop app"})]}):e(M,{children:[e("input",{class:"field inline mono",placeholder:"npm run dev",value:d,onInput:f=>l(f.currentTarget.value),title:"How to start the app; it gets a free port in $PORT"}),e("button",{class:"btn small",disabled:!d.trim(),onClick:()=>void o(),children:"Run app"}),r?.status==="exited"?e("span",{class:"msg warn",children:["exited (",r.exitCode,")"]}):null]}),c&&r?e("pre",{class:"serve-logs",children:r.logs.slice(-80).join(`
|
|
81
|
+
`)||"(no output yet)"}):null]})}function Or({value:t,onChange:s,label:n="Agent"}){return e("select",{class:"field inline","aria-label":n,value:t,onChange:r=>s(r.currentTarget.value),children:Re.value.filter(r=>r.available).map(r=>e("option",{value:r.id,children:r.displayName},r.id))})}function _p({run:t,onClose:s}){let[n,r]=m(!0),[a,c]=m(!1),i=ye(!0,s);return e("dialog",{class:"picker small-dialog",ref:i,"aria-labelledby":"archive-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"archive-title",children:"Archive this run"})}),e("div",{class:"dialog-body",children:[e("label",{class:"check",children:[e("input",{type:"checkbox",checked:n,onChange:d=>r(d.currentTarget.checked)})," Remove its ",(t.worktrees??[]).length," worktree",(t.worktrees??[]).length===1?"":"s"," (uncommitted changes in them are lost)"]}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:a,disabled:!n,onChange:d=>c(d.currentTarget.checked)})," Also delete its branches",t.merges?.length?"":" (nothing from this run has been merged yet)"]}),e("div",{class:"help",children:"Kept branches can be resumed or merged later; Resume re-attaches them."})]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn",onClick:s,children:"Cancel"}),e("button",{class:"btn primary",onClick:()=>O(`/api/runs/${t.id}/archive`,{cleanup:n,deleteBranches:a}).then(()=>{J("Archived"),s()},d=>J(d.message,5e3)),children:"Archive"})]})]})})}function kd({run:t,compact:s=!1}){let[n,r]=m(""),[a,c]=m(!1),i=async l=>{if(!(l==="reject"&&!await Ae("Reject and end the run? Nothing will be built.",{title:"Reject this plan?",confirmLabel:"Reject plan",danger:!0}))){c(!0);try{await O(`/api/runs/${t.id}/answer`,{decision:l,note:n}),r("")}catch(p){J(p.message,4e3)}finally{c(!1)}}},d=t.awaiting;return s?e("section",{class:"conversation-approval","aria-label":"Team plan approval",children:[e("div",{class:"conversation-approval-heading",children:[e("span",{class:"task-team-dot"}),e("b",{children:"Your team has a plan"})]}),t.team?.rationale?e("p",{children:t.team.rationale.slice(0,280)}):e("p",{children:"Review the proposed work before the team starts."}),t.team?.tasks.length?e("ul",{children:[t.team.tasks.slice(0,3).map(l=>e("li",{children:l.title},l.id)),t.team.tasks.length>3?e("li",{children:["And ",t.team.tasks.length-3," more in the full plan"]}):null]}):null,e("details",{class:"conversation-plan-details",children:[e("summary",{children:"Review full plan"}),e(je,{text:d.content}),e("label",{class:"lbl",children:["Changes to the plan",e("textarea",{class:"field",rows:2,value:n,onInput:l=>r(l.currentTarget.value)})]}),e("div",{class:"row",children:[e("button",{class:"btn small",disabled:a||!n.trim(),onClick:()=>i("revise"),children:"Ask for changes"}),e("button",{class:"btn ghost small",disabled:a,onClick:()=>i("reject"),children:"Reject plan"})]})]}),e("div",{class:"conversation-approval-actions",children:[e("button",{class:"btn primary",disabled:a,onClick:()=>i("approve"),children:a?"Sending\u2026":"Approve plan"}),e("span",{class:"help",children:"You can also send changes in the chat."})]})]}):e("div",{class:"awaiting-card",children:[e("div",{class:"aw-head",children:[e("span",{class:"status-pill awaiting",children:"Waiting for you"}),e("b",{children:d.title}),e("span",{class:"help",children:"The run is paused, and so is its time budget."})]}),e("div",{class:"aw-body",children:e(je,{text:d.content})}),e("div",{class:"aw-actions",children:[e("textarea",{class:"field",rows:2,placeholder:"What should change? (needed for \u201CAsk for changes\u201D, optional otherwise)",value:n,onInput:l=>r(l.currentTarget.value)}),e("div",{class:"row",children:[e("button",{class:"btn primary",disabled:a,onClick:()=>i("approve"),children:"\u2713 Approve"}),e("button",{class:"btn",disabled:a||!n.trim()||!!t.teamRerun,onClick:()=>i("revise"),title:t.teamRerun?"Reject this pinned rerun and create another selection to change its tasks or instructions":n.trim()?"":"Write what should change first",children:"Ask for changes"}),e("button",{class:"btn danger",disabled:a,onClick:()=>i("reject"),children:"Reject"})]})]})]})}function Vp(t,s){let n=s.find(r=>r.id===t.deliveredTo?.stepId);return n?t.deliveredTo?.midTurn?` mid-turn (${n.title})`:` (${n.title})`:""}function ti({images:t,onRemove:s}){return t.length?e("div",{class:"draft-images",children:t.map((n,r)=>e("span",{class:"draft-img",title:n.name,children:[e("img",{src:`data:image/png;base64,${n.data}`,alt:n.name}),e("span",{class:"di-name",children:n.name}),e("button",{type:"button",class:"icon-btn","aria-label":`Don't send ${n.name}`,onClick:()=>s(r),children:e(K,{name:"close"})})]},r))}):null}var wd=new Map;function id(t){let s=wd.get(t);if(s)return s;try{return{text:sessionStorage.getItem(`agent-draft:${t}`)??"",images:[]}}catch{return{text:"",images:[]}}}function si({run:t,steps:s,chat:n,onOpenChat:r}){let[a,c]=m(id(t.id).text),[i,d]=m(""),[l,p]=m(!1),o=r??(F=>Pe({view:"run",id:F})),[u,f]=m({}),[h,g]=m(null),[y,C]=m(!1),[T,v]=m(t.loop.maxInvocations??t.loop.maxSteps),[k,b]=m(t.loop.maxMinutes),[S,x]=m(id(t.id).images);N(()=>{wd.set(t.id,{text:a,images:S});try{a?sessionStorage.setItem(`agent-draft:${t.id}`,a):sessionStorage.removeItem(`agent-draft:${t.id}`)}catch{}},[t.id,a,S]);let w=Z(null),j=t.status==="running"||t.status==="done"||n&&t.worktrees.length>0;N(()=>{if(!j)return;let F=Pn(`main:${t.id}`);F.length&&(c(R=>[R.trim(),...F.map(X=>X.text)].filter(Boolean).join(`
|
|
82
|
+
|
|
83
|
+
`)),x(R=>[...R,...F.flatMap(X=>X.images)]),w.current?.focus())},[Ds.value,t.id,j]),N(()=>{let F=w.current;F&&(F.style.height="auto",F.scrollHeight&&(F.style.height=`${Math.min(F.scrollHeight,220)}px`))},[a]);let A=t.followUps.filter(F=>F.status==="pending"),P=t.status==="running"&&!!t.patternDone&&A.length>0&&A.every(F=>F.side),D=t.artifacts[0]?.branch,I=P&&!!D&&A.some(F=>F.side?.mode==="change"&&t.worktrees.find(R=>R.name===F.worktree)?.branch===D),$=t.status==="running"&&!P,E=[...new Map(s.filter(F=>(F.kind??"agent")==="agent"&&(F.mode==="write"||t.chatLink?.kind==="side")&&F.agent&&F.worktree).map(F=>[`${F.agent}@${F.worktree}`,F])).values()],L=[...new Set(Object.values(t.roles).flat())],H=t.team?.members.find(F=>F.role==="coordinator"),Q=t.pattern==="solo"?t.conversationAgent??t.roles.agent?.[0]:void 0,le=Q?E.find(F=>F.agent===Q):void 0,de=!$&&Q&&t.worktrees.some(F=>F.name==="solo")?`${Q}@solo`:$?H&&H.status!=="retired"?`member:${H.id}`:"":t.team?"team":E.at(-1)?`${E.at(-1).agent}@${E.at(-1).worktree}`:"team",ue=$?t.team?t.team.members.filter(F=>F.status!=="retired").map(F=>`member:${F.id}`):L:["team",...E.map(F=>`${F.agent}@${F.worktree}`)],q=i&&ue.includes(i)?i:de,te=q.includes("@")?q.split("@")[0]:void 0,me=Q??te,W=t.followUps.filter(F=>!F.side&&F.agent===me).at(-1),re=me?u[me]??W?.settings??t.agentSettings[me]??{}:{},ne=h??{trust:W?.trust??t.trust,tools:W?.tools??!!t.approvals.tools},_=q.startsWith("member:")?q.slice(7):void 0,ie=t.team?.members.find(F=>F.id===_),Te=_i(!!t.team,$,q),Ie=Number.isInteger(T)&&T>=Te&&T<=200&&Number.isFinite(k)&&k>=1&&k<=720;if(!j)return null;let et=async()=>{if(!(!a.trim()||y||!$&&!Ie)){C(!0);try{let F=S.map(({name:R,data:X})=>({name:R,data:X}));if($){let R=await O(`/api/runs/${t.id}/notes`,{text:a,agent:_?void 0:q||void 0,memberId:_});S.length?J("Sent. The snapshots stay here: they go with a reply once the run has finished",6e3):R.requestId?J("Answer sent to the team"):R.control?J("Stopped \u2014 work is saved"):R.teamDelivery?J("Received \u2014 updating the team with your message"):R.deliveredTo?.midTurn?J(`Sent into ${R.deliveredTo.agent}'s running turn`):J(q?`Queued for ${ie?.name??q}'s next turn`:"Queued for the next agent's turn"),c("");return}else if(q==="team"){if(I){J("Wait for the side chat to finish: a new run would start without its change",6e3);return}let R=t.artifacts[0]?.branch??t.baseLabel,{id:X}=await O("/api/runs",{repo:t.repo,task:`${t.task}
|
|
84
|
+
|
|
85
|
+
## Feedback on the previous attempt
|
|
86
|
+
${a.trim()}`,pattern:t.pattern,roles:t.roles,options:t.options,baseRef:R==="HEAD"?"":R,context:{paths:(t.context?.paths??[]).map(se=>({path:se.path})),attachments:F},agentSettings:t.agentSettings,roleSettings:t.roleSettings,trust:t.trust,project:t.project,loop:{...t.loop,maxSteps:T,maxInvocations:T,maxMinutes:k},approvals:t.approvals,parentRunId:t.id});Pe({view:"run",id:X})}else{let[R,X]=q.split("@"),se=me??R;await O(`/api/runs/${t.id}/followups`,{kind:"reply",agent:se,settings:re,trust:ne.trust,tools:ne.tools,worktree:X,message:a,attachments:F,budget:{maxSteps:T,maxInvocations:T,maxMinutes:k}}),J(P?"Queued: it goes once the side chat is done":"Sent \u2014 the agent is on it")}c(""),x([])}catch(F){J(F.message,5e3)}finally{C(!1)}}},z=async()=>{if(!(!$||!t.team||!a.trim()||y||!Ie)){C(!0);try{let{id:F}=await O(`/api/runs/${t.id}/revise-goal`,{message:a.trim(),budget:{maxSteps:T,maxInvocations:T,maxMinutes:k}});c(""),Pe({view:"run",id:F})}catch(F){J(F.message,5e3)}finally{C(!1)}}},[U,oe]=q.split("@"),ke=ie?.name??Se[U]??U,we=Se[Q??E.at(-1)?.agent??L[0]]??"the agent",ce=n?$?`Goes into ${we}'s running turn if it takes messages, otherwise it's sent as soon as the turn ends`:q==="team"?I?"Starts again from this result: wait for the side chat to finish first":"Starts again from this result":`Continues ${we}'s session on its branch${P?", once the side chat is done":""}`:$?q?_?`Sent to ${ke}'s next turn`:`Steered into ${ke}'s running turn if it takes messages, otherwise its next turn`:"Goes to the next agent that takes a turn":q==="team"?`${t.team?"Builds a revised team and plan from this result, with your approval settings":"Starts a new run with the same team, from this result"}${I?": wait for the side chat to finish first":""}`:`Continues ${ke}'s session on its branch, in ${oe}${P?", once the side chat is done":""}`,tt=n?`Message ${we}\u2026`:$?"Message the team\u2026":q==="team"?"Tell the team what to change\u2026":`Reply to ${ke}\u2026`,it=new Set(s.filter(F=>F.status==="running").map(F=>F.id)),Xt=(t.notes??[]).filter(F=>!n||F.status==="queued"||F.deliveredTo&&it.has(F.deliveredTo.stepId)&&!F.followUp),Ue=Xt.filter(F=>F.status!=="delivered"),B=Xt.filter(F=>F.status==="delivered"),xe=F=>e("span",{class:`chip-ctx note-chip ${F.status}`,title:F.text,children:e("span",{class:"n",children:[F.followUp?"\u2713 Sent as your next message":F.requestId?"\u2713 Answered the team's question":F.status==="delivered"?`\u2713 Delivered to ${t.team?.members.find(R=>R.id===F.memberId)?.name??F.deliveredTo?.agent??"the team"}${Vp(F,s)}`:n?"Sent when this turn ends":`Queued for ${t.team?.members.find(R=>R.id===F.memberId)?.name??F.agent??"next agent"}`,": ",F.text]})},F.id);return e("div",{class:"convo",children:e("div",{class:"convo-inner",children:[n?e(dd,{run:t}):null,l?e(Qp,{run:t,onClose:()=>p(!1),onOpenChat:o}):null,Ie?null:e("p",{class:"msg err",role:"alert",children:["Send is off until the budget below allows ",Te,"\u2013200 calls and 1\u2013720 minutes."]}),!n&&(!$||t.team)?e("details",{class:"followup-budget",children:[e("summary",{children:[$?"Goal revision budget":"New execution budget"," \xB7 ",T," calls \xB7 ",k," min"]}),e("div",{class:"at-row",children:[e("label",{children:["Maximum calls",e("input",{class:"field","aria-label":"Follow-up maximum calls",type:"number",min:Te,max:200,value:T,onInput:F=>v(Number(F.currentTarget.value))})]}),e("label",{children:["Maximum minutes",e("input",{class:"field","aria-label":"Follow-up maximum minutes",type:"number",min:1,max:720,value:k,onInput:F=>b(Number(F.currentTarget.value))})]})]}),e("p",{class:"help",children:[P?"A reply queued behind a side chat joins the running execution's allowance; this budget applies when a reply starts a new execution. ":"This is a new allocation. ","The result branch, project memory and applicable context are retained. Earlier spend remains in lifetime usage."]}),Ie?null:e("p",{class:"msg err",children:["Choose ",Te,"\u2013200 calls and 1\u2013720 minutes."]})]}):null,$&&B.length?e("details",{class:"activity note-history",children:[e("summary",{children:["Sent messages (",B.length,")"]}),e("div",{class:"notes",children:B.map(xe)})]},t.id):null,$&&Ue.length?e("div",{class:"notes",children:Ue.map(xe)}):null,e(ti,{images:S,onRemove:F=>x(S.filter((R,X)=>X!==F))}),e("div",{class:"chatbox",children:[e("textarea",{ref:w,rows:1,"aria-label":n?"Message agent":$?"Message the team":"Reply",placeholder:tt,value:a,onInput:F=>c(F.currentTarget.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&!F.isComposing&&(F.preventDefault(),et())}}),e("div",{class:"chatbox-bar chatbox-configurable",children:[n?null:e("label",{class:"to",children:[e("span",{class:"to-lbl",children:"To"}),e("select",{"aria-label":"Who gets this",value:q,onChange:F=>d(F.currentTarget.value),children:$?e(M,{children:t.team?t.team.members.filter(F=>F.status!=="retired").map(F=>e("option",{value:`member:${F.id}`,children:[F.name," \xB7 ",F.id," (",Se[F.provider],")"]},F.id)):e(M,{children:[e("option",{value:"",children:"Next agent"}),L.map(F=>e("option",{value:F,children:Se[F]??F},F))]})}):e(M,{children:[E.length?e("optgroup",{label:"Continue a session",children:E.map(F=>e("option",{value:`${F.agent}@${F.worktree}`,children:[Se[F.agent]??F.agent," \xB7 ",F.worktree]},`${F.agent}@${F.worktree}`))}):null,e("optgroup",{label:"Start again",children:e("option",{value:"team",disabled:I,children:["Whole team \xB7 new run",I?" (once the side chat is done)":""]})})]})})]}),!$&&q!=="team"&&me&&!(n&&(ve.value.get(nt(t))??t).taskTeam?.enabled)?e(bs,{showPermissions:t.chatLink?.kind!=="side",providers:t.chatLink?.kind==="side"?Re.value.filter(F=>F.id==="claude"||F.id==="codex"||F.id==="agy"):void 0,agent:me,onAgent:n?async F=>{try{let R=await O(`/api/runs/${t.id}/provider-chat`,{agent:F,kind:t.chatLink?.kind??"tab"});o(R.id)}catch(R){J(R.message)}}:void 0,settings:re,onSettings:F=>f({...u,[me]:F}),permissions:ne,onPermissions:g,restricted:!!t.lockdown||!!t.trigger,approvalsAvailable:!t.loop.remoteWorker&&!t.loop.agentContainer}):null,n&&Q?e(Lr,{run:t,lead:Q}):null,t.chatLink?.kind==="side"?e("span",{class:"help",children:"Read only"}):null,t.pattern==="solo"?e(Ve,{label:"Chat actions",icon:"more",class:"chat-choice chat-action-menu",above:!0,align:"end",children:F=>e(pe,{disabled:y||!t.worktrees.length,sub:"Continue with context in a new workspace tab",onClick:()=>{F(),p(!0)},children:"Fork chat\u2026"})}):null,e("span",{class:"chatbox-hint",title:ce,children:ce}),e("button",{class:"send","aria-label":"Send",title:"Send (\u21B5 \u2014 \u21E7\u21B5 for a new line)",disabled:y||!a.trim()||!$&&!Ie,onClick:et,children:e(K,{name:"send"})})]})]}),$&&t.team&&!t.awaiting?e("div",{class:"goal-revision-action",children:[e("button",{class:"btn small",disabled:y||!a.trim()||!Ie,onClick:z,children:"Revise goal"}),e("span",{class:"help",children:"Uses this message to stop the current execution and build a new team plan from integrated work, with your approval settings. Send keeps it as a member note."})]}):null]})})}var Ta=200;function Sa({run:t,step:s,data:n}){Zc(t.id);let r=Z(null),a=Z(!0),[c,i]=m(Ta),d=s?n.pages?.get(s.id):void 0;if(N(()=>{s&&n.pagedTranscript&&!n.pages.get(s.id)?.loaded&&Dr(t.id,s.id)},[t.id,s?.id,n.pages,n.pagedTranscript]),N(()=>i(Ta),[s?.id]),N(()=>{a.current&&r.current&&(r.current.scrollTop=r.current.scrollHeight)}),!s)return null;let l=Cd(n,s),p=Math.max(0,l.length-c),o=Yo(t,s.agent,s.settings);return e("div",{class:"transcript",role:"group","aria-label":`Transcript of ${s.title}`,children:[s.remote?e(Qc,{runId:t.id,step:s},`${t.id}/${s.id}`):null,e("div",{class:"tr-head",children:[d?e("span",{class:"row",children:[e("button",{class:"btn small",disabled:d.loading||!d.before,onClick:()=>{i(Ta),Dr(t.id,s.id,d.before)},children:"Earlier events"}),e("button",{class:"btn small",disabled:d.loading,onClick:()=>{i(Ta),Dr(t.id,s.id)},children:"Latest events"}),d.loading?e("span",{role:"status",children:"Loading transcript\u2026"}):null,d.historical?e("span",{children:"Viewing earlier events"}):null,d.error?e("span",{role:"alert",children:d.error}):null]}):null,o?e("span",{children:o}):null,e("span",{children:(s.kind??"agent")==="agent"?s.mode==="write"?"can edit files":"read-only":"run by code-flow"}),e("span",{children:["worktree ",s.worktree]}),s.usage?e("span",{title:md(s.usage),children:[Et(s.usage.inputTokens+s.usage.outputTokens)," tokens",s.usage.costUsd?` \xB7 \u2248${ht(s.usage.costUsd)}`:""]}):null,s.contextInput?e("span",{title:`Measured assembled invocation input. Excludes: ${s.contextInput.excluded.join(", ")}. Input hash ${s.contextInput.hash}`,children:[s.contextInput.bytes.toLocaleString()," input bytes \xB7 \u2248",s.contextInput.approximateTokens.toLocaleString()," input tokens",s.contextInput.exceeded?` \xB7 ${s.contextInput.policy==="block"?"blocked":"budget warning"}`:"",s.contextInput.resumed?" \xB7 earlier history excluded":""]}):null,s.status!=="done"?e("span",{class:`status-pill ${s.status}`,children:Je[s.status]??s.status}):null]}),e("div",{class:"tr-body",ref:r,onScroll:u=>{let f=u.currentTarget;a.current=f.scrollHeight-f.scrollTop-f.clientHeight<60},children:[p?e("button",{type:"button",class:"btn small show-earlier",disabled:c>=1e3,title:c>=1e3?n.pagedTranscript?"Use Earlier events to read more history in bounded pages":"Update the remote server to browse more history in bounded pages":void 0,onClick:()=>{a.current=!1,i(Math.min(1e3,c+Ta*5))},children:["Show earlier (",p.toLocaleString()," hidden)"]}):null,l.slice(p).map((u,f)=>e(Go,{item:u,v:u.v},p+f)),l.length?null:e("div",{class:"ev status",children:s.status==="running"?"Starting\u2026":"Nothing was recorded for this step."})]})]})}var Go=class extends xi{shouldComponentUpdate(s){return s.item!==this.props.item||s.v!==this.props.v}render(){let{item:s}=this.props;switch(s.kind){case"text":return e("div",{class:"ev text",children:e(je,{text:s.text})});case"thinking":return e("details",{class:"ev thinking",children:[e("summary",{children:["Thinking ",e("span",{class:"peek",children:s.text.replace(/\s+/g," ").slice(0,120)})]}),e("div",{class:"think-body",children:s.text})]});case"tool":return e("details",{class:`ev tool ${s.isError?"err":""}`,children:[e("summary",{children:[e("b",{children:s.name})," ",e("span",{class:"arg",children:Jp(s.input)}),s.isError?e("span",{class:"sr-only",children:" (failed)"}):null]}),e("pre",{children:s.input}),s.output!==void 0?e("pre",{children:s.output||"(no output)"}):null]});case"status":return e("div",{class:"ev status",children:s.text});case"error":return e("div",{class:"ev error",role:"alert",children:s.text})}}};function Jp(t){let s=t;try{let n=JSON.parse(t),r=["command","cmd","file_path","filePath","path","pattern","url","query","description"].find(a=>typeof n[a]=="string"&&n[a]);r&&(s=n[r],(r==="file_path"||r==="filePath"||r==="path")&&(s=s.replace(/^.*\/\.worktrees\/[^/]+\/[^/]+\//,"")))}catch{}return s.replace(/\s+/g," ").slice(0,200)}function Cd(t,s){let n=t.events.get(s.id)??[],r=t.built.get(s.id);for(r||(r={items:[],tools:new Map,count:0},t.built.set(s.id,r));r.count<n.length;r.count++)Kp(r,n[r.count],s.agent==="agy"||s.agent?.startsWith("acp:")===!0);return r.items}function Kp(t,s,n){let{items:r,tools:a}=t,c=r.at(-1);if((s.kind==="text"||s.kind==="thinking")&&s.messageId){let i=t.messages??=new Map,d=`${s.kind}:${s.messageId}`,l=i.get(d);l||(l={kind:s.kind,text:"",v:0},i.set(d,l),r.push(l)),l.text=s.delta?l.text+s.text:s.text,l.v++;return}switch(s.kind){case"text":n&&c?.kind==="text"&&c.text.length+s.text.length<=32*1024?(c.text+=s.text,c.v++):r.push({kind:"text",text:s.text,v:0});break;case"thinking":n&&c?.kind==="thinking"&&c.text.length+s.text.length<=32*1024?(c.text+=s.text,c.v++):r.push({kind:"thinking",text:s.text,v:0});break;case"tool_call":{let i=a.get(s.callId);if(i){i.name=s.name,i.input=s.input,i.v++;break}let d={kind:"tool",name:s.name,input:s.input,v:0};a.set(s.callId,d),r.push(d);break}case"tool_result":{let i=a.get(s.callId);i||(i={kind:"tool",name:"Tool result (call in an earlier page)",input:"",v:0},a.set(s.callId,i),r.push(i)),i&&(i.output=s.delta?(i.output??"")+s.output:s.output,i.isError=s.isError,i.v++);break}case"status":r.push({kind:"status",text:s.text,v:0});break;case"error":r.push({kind:"error",text:s.message,v:0});break;case"usage":{let i=[s.inputTokens&&`${s.inputTokens.toLocaleString()} in`,s.outputTokens&&`${s.outputTokens.toLocaleString()} out`,s.cacheReadTokens&&`${s.cacheReadTokens.toLocaleString()} cached`,s.costUsd&&`\u2248${ht(s.costUsd)}`].filter(Boolean);i.length&&r.push({kind:"status",text:`tokens: ${i.join(" \xB7 ")}`,v:0});break}}}function zp({logs:t}){let[s,n]=m(!1),r=s?t:t.slice(-300),a=t.filter(c=>c.level==="warn").length;return e("details",{class:"activity",children:[e("summary",{children:e("span",{children:["Activity log (",t.length,")",a?e("span",{class:"warn",children:[" \xB7 ",a," warning",a===1?"":"s"]}):null]})}),e("div",{class:"log",children:[r.length<t.length?e("button",{type:"button",class:"linkish",onClick:()=>n(!0),children:["Show all ",t.length.toLocaleString()," lines"]}):null,r.map((c,i)=>e("div",{class:c.level,children:[new Date(c.ts).toLocaleTimeString()," ",c.text]},i))]})]})}var ld=0;async function Gp(t){if(t.projectTeam){J("Use the project mission's revision controls to revise this result.",4e3),t.project&&Pe({view:"project",id:t.project,section:"automation",kind:"missions"});return}let s=++ld,n=Y.value,r=Ke(t);if(await Qe(r?.id??"",{repository:t.repo,stay:!0})&&!(s!==ld||Y.value!==n||ee.value!==t.repo)){Ps.value=structuredClone({id:t.id,repo:t.repo,loop:t.loop,approvals:t.approvals??{},source:t.source,checkpointOnFinish:t.checkpointOnFinish}),ca.value={remoteWorker:t.loop.remoteWorker,container:{enabled:!!t.loop.agentContainer,image:t.loop.agentContainer?.image??"",authVolume:t.loop.agentContainer?.authVolume??""},verification:t.loop.verification?"restored":"",verificationProfile:t.loop.verification??null,toolApprovals:t.approvals?.tools===!0,antigravityExecution:t.permissions?.antigravityExecution,permissionRequirements:[...t.permissions?.required??[]]},jt.value=t.intent,Nt.value=void 0,yt.value=null,ms([]),cn.value="",Fe.value=t.baseRef??"",dn(t.trust??"standard"),Wa(t.approvals?.plan===!0,t.pattern),Be.value=structuredClone(t.agentSettings??{}),rt.value={...rt.value,[t.pattern]:structuredClone(t.roleSettings??{})},In(t.loop.contextBudget,"Original run"),St(t.pattern);for(let[a,c]of Object.entries(t.roles))At(t.pattern,a,c);so.value={...so.value,[t.pattern]:structuredClone(t.options??{})},Tt(t.task),bt.value=new Map((t.context?.paths??[]).map(a=>[a.path,{path:a.path,type:a.type}])),Ge.value=[],t.context?.attachments?.length&&J("Attached files aren't kept \u2014 attach them again if needed",4e3),Dt.value=t.loop?.check??"",Gt.value=t.loop?.setup??"",Xi({maxMinutes:t.loop?.maxMinutes??60,maxSteps:t.loop?.maxSteps??40,maxTokens:t.loop.maxTokens,maxCostUsd:t.loop.maxCostUsd}),Ye.value=t.source?{kind:t.source.kind,number:t.source.number,title:t.source.title,url:t.source.url,headRefName:t.source.headRefName,baseRefName:t.source.baseRefName,isCrossRepository:t.source.isCrossRepository,ciLogs:!!t.source.ci,tool:t.source.alert?.tool,numbers:t.source.alert?.numbers}:null,Pe({view:"composer",project:r?.id??""})}}function Yp({run:t,onClose:s}){let[n,r]=m(t.loop.check??""),[a,c]=m(t.loop.setup??""),[i,d]=m(!1),[l,p]=m(""),o=ye(!0,()=>{i||s()}),u=t.artifacts.filter(g=>t.worktrees.some(y=>y.branch===g.branch)),[f,h]=m(u[0]?.branch??t.baseRef);return e("dialog",{ref:o,class:"picker small-dialog","aria-labelledby":"recovery-check-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"recovery-check-title",children:"Fix check command"})}),e("div",{class:"dialog-body",children:[e("p",{children:"Start a continuation from the saved branch with corrected commands. The original run and its evidence are kept."}),e("label",{children:["Continue from",e("select",{class:"field",value:f,onChange:g=>h(g.currentTarget.value),children:u.length?u.map(g=>e("option",{value:g.branch,children:[g.label," \xB7 ",g.branch]},g.branch)):e("option",{value:t.baseRef,children:["Original base \xB7 ",t.baseRef.slice(0,12)]})})]}),e("label",{children:["Setup command",e("input",{class:"field",value:a,placeholder:"e.g. npm ci",onInput:g=>c(g.currentTarget.value)})]}),e("label",{children:["Check command",e("input",{class:"field",value:n,placeholder:"e.g. npm test",onInput:g=>r(g.currentTarget.value)})]}),e("p",{class:"help",children:["Uses a single check and this run's team and permissions. New allowance: ",t.loop.maxInvocations??t.loop.maxSteps," calls \xB7 ",t.loop.maxMinutes," minutes."]}),l?e("p",{class:"msg err",role:"alert",children:l}):null]}),e("div",{class:"picker-foot",children:[e("button",{class:"btn",disabled:i,onClick:s,children:"Cancel"}),e("button",{class:"btn primary",disabled:i||!n.trim(),onClick:async()=>{if(!i){d(!0),p("");try{let g=await O("/api/runs",{repo:t.repo,project:t.project,parentRunId:t.id,baseRef:f,task:`${t.task}
|
|
87
|
+
|
|
88
|
+
Verify the preserved work using the corrected setup and check commands. Fix any remaining failures and report the evidence.`,pattern:t.pattern,roles:t.roles,options:t.options,agentSettings:t.agentSettings,roleSettings:t.roleSettings,trust:t.trust,approvals:t.approvals,context:{paths:(t.context?.paths??[]).map(y=>({path:y.path}))},loop:{...t.loop,verification:void 0,check:n.trim(),setup:a.trim()}});s(),Pe({view:"run",id:g.id})}catch(g){p(g.message)}finally{d(!1)}}},children:i?"Starting\u2026":"Start continuation"})]})]})})}function Qp({run:t,onClose:s,onOpenChat:n}){let r=t.chatLink?.kind==="side"?Re.value.filter(C=>C.id==="claude"||C.id==="codex"||C.id==="agy"):Re.value,[a,c]=m(r.find(C=>C.available)?.id??r[0]?.id??"codex"),[i,d]=m({}),[l,p]=m(""),[o,u]=m(!1),[f,h]=m(""),g=ye(!0,()=>{o||s()}),y=async()=>{if(!o){u(!0),h("");try{let C=await O(`/api/runs/${t.id}/provider-chat`,{agent:a,settings:i,message:l,kind:t.chatLink?.kind??"tab"});s(),n(C.id)}catch(C){h(C.message),u(!1)}}};return e("dialog",{class:"picker small-dialog",ref:g,"aria-labelledby":"provider-chat-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"provider-chat-title",children:"Fork chat"})}),e("div",{class:"dialog-body",children:[e("p",{class:"help",children:"Opens a new tab with this conversation and saved context. Tabs share the workspace, including uncommitted edits. Each tab has its own provider session; editing turns take turns using the workspace."}),e("fieldset",{disabled:o,style:{border:0,padding:0,margin:0},children:[e(bs,{agent:a,onAgent:C=>{c(C),d({})},providers:r,settings:i,onSettings:d,permissions:{trust:t.trust,tools:!1},onPermissions:()=>{},showPermissions:!1}),e("label",{children:["First message ",e("span",{class:"help",children:"Optional"}),e("textarea",{class:"field",rows:3,maxLength:2e4,value:l,onInput:C=>p(C.currentTarget.value),placeholder:"What should the new chat do?"})]})]}),e("p",{class:"help",children:"Without a message, the new provider reads the context and waits for your next request. Existing permission limits are retained."}),f?e("p",{class:"msg err",role:"alert",children:f}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn",disabled:o,onClick:s,children:"Cancel"}),e("button",{class:"btn primary",disabled:o||!r.some(C=>C.id===a&&C.available),onClick:()=>void y(),children:o?"Starting\u2026":"Start new chat"})]})]})})}function Xp({template:t,onClose:s}){let n=ye(!0,s);return e("dialog",{ref:n,class:"picker","aria-labelledby":"save-strategy-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"save-strategy-title",children:"Save reusable team strategy"})}),e("div",{class:"dialog-body",children:[e("p",{children:"Review and parameterize the instructions below, removing any sensitive or task-specific values. Session handles, result records, and permission grants are excluded."}),e(xr,{initial:t})]}),e("div",{class:"picker-foot",children:e("button",{class:"btn",onClick:s,children:"Close"})})]})})}var Zp=()=>new Set(ge.value.filter(t=>t.chat).map(t=>t.id));function ni(t){let s=new Map;for(let n of t.followUps){if(!n.side)continue;let r=s.get(n.side.chat)??{key:`side:${n.side.chat}`,chat:n.side.chat,title:n.side.title,turns:[],agent:n.agent,mode:n.side.mode};r.turns.push(n),r.agent=n.agent,r.mode=n.side.mode,s.set(n.side.chat,r)}return[...s.values()]}function em(t,s,n){let r=t?ni(t).find(c=>c.chat===n):void 0;if(r)return{run:t,chat:r};let a=ni(s).find(c=>c.chat===n);return a?{run:s,chat:a}:void 0}var Sd=t=>(t.pattern==="solo"||t.status==="done"||t.status==="running")&&!!Ya(t),tm=t=>{let s={failed:"failed",cancelled:"was cancelled",stopped:"stopped at a limit",interrupted:"was interrupted"};return s[t.status]?`This run ${s[t.status]}, so a side chat can't work in its worktree.`:"This run has no result worktree for a side chat to work in yet."},Td=t=>t.turns.filter(s=>s.status!=="pending").length;function ai(){let t=ae.get("sideAgent");return t&&Re.value.some(s=>s.id===t&&s.available)?t:Re.value.find(s=>s.available)?.id??"claude"}function xd(){let t=Us.value,s=Ha.value,n=Zp(),r=t.run,a=[...ve.value.values()].filter(x=>n.has(x.pattern)&&!x.archived&&x.id!==r?.id).sort((x,w)=>w.createdAt-x.createdAt),c=r?a.filter(x=>r.pattern==="solo"?x.chatLink?.kind==="side"&&nt(x)===nt(r):x.parentRunId===r.id):[],i=a.filter(x=>r?.pattern!=="solo"&&!x.chatLink&&!c.includes(x)&&(t.project?Ke(x)?.id===t.project.id:!!t.repo&&x.repo===t.repo)),d=r?ni(r):[],l=new Set(s.closed??[]),p=t.project?.name??(t.repo?be(t.repo):""),o=r?.pattern==="solo"&&eo.value==="solo"?"":eo.value??"",u=o.startsWith("side:")?d.find(x=>x.key===o):void 0,f=!u&&o&&o!=="solo"?ve.value.get(o):void 0,h=x=>r?.pattern!=="solo"||x.chatLink?.kind==="side"&&nt(x)===nt(r),g=f&&h(f)?f:void 0,y=u?.key??(g&&n.has(g.pattern)?g.id:void 0),T=[...s.chats??[],...y&&!u&&!s.chats?.includes(y)?[y]:[]].map(x=>ve.value.get(x)).filter(x=>!!x&&n.has(x.pattern)&&h(x)&&!x.archived&&!l.has(x.id)),v=u?Td(u):0;N(()=>{u&&(s.seen?.[u.key]??0)<v&&Dn({seen:{...s.seen,[u.key]:v}})},[u?.key,v]);let k=[...d.filter(x=>!l.has(x.key)).map(x=>{let w=x.turns.at(-1),j=w.status==="pending";return{key:x.key,label:x.title,title:`${x.title}
|
|
89
|
+
${Se[x.agent]??x.agent} \xB7 side chat in this run's worktree`,agent:x.agent,state:j?w.stepId&&r?.status==="running"?"working":"queued":w.status==="failed"?"failed":Td(x)>(s.seen?.[x.key]??0)&&x.key!==y?"unread":void 0}}),...T.map(x=>({key:x.id,label:x.task.split(`
|
|
90
|
+
`)[0].slice(0,60)||"(no task)",title:`${x.task.split(`
|
|
91
|
+
`)[0]}
|
|
92
|
+
${x.chatLink?"Independent conversation in the shared workspace":"A chat on its own branch"}`,agent:Object.values(x.roles).flat()[0],state:x.status==="running"?"working":!x.seen&&x.id!==y?"unread":ft(x)==="failed"?"failed":void 0}))],b=x=>{let w=k.filter(A=>A.key!==x),j=x===y?w.at(-1)?.key??"":o;x.startsWith("side:")?Dn({closed:[...s.closed??[],x],chat:j}):Dn({chats:(s.chats??[]).filter(A=>A!==x),closed:[...l,x],chat:j})},S=(x,w,j,A)=>e(pe,{on:x===y,sub:j,onClick:()=>{Mt(x),A()},children:w},x);return e(M,{children:[e(Qa,{items:k,active:y,onPick:Mt,onClose:b,label:"Open chats",children:[e("button",{type:"button",class:`icon-btn ${y?"":"on"}`,"aria-label":"New chat",title:r?"New side chat about this run":"New chat",onClick:()=>Mt(null),children:e(K,{name:"plus"})}),e(Ve,{label:"All chats",icon:"menu",title:"Every chat here, closed ones too",children:x=>e(M,{children:[d.length?e(kt,{children:"Side chats on this run"}):null,d.map(w=>S(w.key,w.title,`${Se[w.agent]??w.agent} \xB7 ${w.turns.length} message${w.turns.length===1?"":"s"}`,x)),c.length?e(kt,{children:r?.pattern==="solo"?"Side chats on this task":"Related chats"}):null,c.map(w=>S(w.id,w.task.split(`
|
|
93
|
+
`)[0].slice(0,60),`${Je[w.status]??w.status}`,x)),i.length?e(kt,{children:p?`Chats in ${p}`:"Chats"}):null,i.slice(0,30).map(w=>S(w.id,w.task.split(`
|
|
94
|
+
`)[0].slice(0,60),`${Je[w.status]??w.status}`,x)),r&&r.pattern!=="solo"?e(M,{children:[e(kt,{children:"New"}),e(pe,{sub:"A Single-agent run on a branch of its own, from this run's result",onClick:()=>{Mt("solo"),x()},children:"Separate chat"})]}):null,!d.length&&!c.length&&!i.length&&!r?e("div",{class:"pop-title",children:"No chats here yet"}):null]})})]}),u&&r?e(sm,{run:r,chat:u.chat},u.key):g&&n.has(g.pattern)?e(am,{id:g.id},g.id):r&&o!=="solo"&&Sd(r)?e(nm,{run:r},nt(r)):e(rm,{scope:t},t.key)]})}var Rd=()=>Ot.value&&en.value==="chat";function $d(t){let s=Z(null);return N(()=>{let n=s.current;n&&n.scrollHeight-n.scrollTop-n.clientHeight<160&&(n.scrollTop=n.scrollHeight)},t),s}function sm({run:t,chat:s}){let{run:n,data:r,version:a}=Gs(t.id,void 0,Rd()),c=em(n,t,s),i=$d([a,c?.chat.turns.length,c?.chat.turns.at(-1)?.status]);if(!c)return e("div",{class:"side-empty help",children:"Loading\u2026"});let{run:d,chat:l}=c,p=d.worktrees.find(o=>o.name===l.turns[0].worktree);return e(M,{children:[e("div",{class:"chat-scroll",ref:i,children:e("div",{class:"thread",children:[e("div",{class:"chat-meta",children:[e(Ee,{id:l.agent}),e("span",{class:"help",children:["Side chat in ",p?e("code",{title:p.path,children:p.branch}):"the run's worktree"]})]}),l.turns.map(o=>{let u=o.stepId?r.current.steps.get(o.stepId):void 0,f=o.side?.mode==="change";return e("div",{class:"fu",children:[e("div",{class:"msg-you",children:e("div",{class:"bubble",children:[e(je,{text:o.message}),e("div",{class:`side-mode ${f?"change":""}`,children:f?"Change":"Ask"})]})}),e("div",{class:`fu-answer ${o.status}`,children:[e("div",{class:"fu-head",children:[e(Ee,{id:o.agent}),o.status==="pending"&&d.status!=="running"?e("span",{class:"help",children:"The run stopped before this turn finished: resume the run to finish it"}):o.status==="pending"&&!u?e("span",{class:"fu-live",children:d.patternDone?"Up next\u2026":"Waits for the team to finish\u2026"}):e(Zn,{f:o})]}),u?e(Nr,{run:d,step:u,data:r.current,answer:o.status==="pending"?void 0:o.result}):o.result?e(je,{text:o.result}):null]})]},o.id)})]})}),e(Id,{run:d,chat:l})]})}function nm({run:t}){let s=Ya(t);return e(M,{children:[e("div",{class:"chat-scroll",children:e("div",{class:"side-empty",children:[e("h3",{children:t.pattern==="solo"?"Side chat":"Chat about this run"}),e("p",{class:"help",children:t.pattern==="solo"?e(M,{children:"Ask about this conversation and its files in an independent, read-only session. The main agent can keep working while you talk here."}):e(M,{children:["The agent works in this run's worktree (",e("code",{children:s.branch}),"), in a conversation of its own. ",e("b",{children:"Ask"})," reads it and changes nothing; ",e("b",{children:"Change"})," edits it, and code-flow commits the change on the run's branch and runs the check.",t.status==="running"?" While the team is working, your message waits for it to finish.":""]})})]})}),e(Id,{run:t})]})}function Id({run:t,chat:s}){let[n,r]=m(""),[a,c]=m(s?.mode??"ask"),[i,d]=m(s?.agent??(t.pattern==="solo"&&!["claude","codex","agy"].includes(ai())?"codex":ai())),[l,p]=m({}),[o,u]=m({trust:s?.turns.at(-1)?.trust??t.trust,tools:s?.turns.at(-1)?.tools??!!t.approvals.tools}),f=l[i]??s?.turns.filter(w=>w.agent===i).at(-1)?.settings??t.agentSettings[i]??{},[h,g]=m(!1),[y,C]=m(""),[T,v]=m([]),k=Ad(n,r);N(()=>{let w=Pn(s?s.key:"side:new");w.length&&(r(j=>[j.trim(),...w.map(A=>A.text)].filter(Boolean).join(`
|
|
95
|
+
|
|
96
|
+
`)),v(j=>[...j,...w.flatMap(A=>A.images)]),k.current?.focus())},[Ds.value,s?.key]);let b=s?t.worktrees.find(w=>w.name===s.turns[0].worktree):Ya(t),S=Se[i]??i,x=async()=>{if(!n.trim()||h||!b)return;g(!0),C("");let w=s?.chat??`c${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,j=s?.title??(n.trim().split(`
|
|
97
|
+
`)[0].slice(0,60)||"Side chat");try{if(t.pattern==="solo"&&!s){let A=await O(`/api/runs/${t.id}/provider-chat`,{agent:i,settings:f,message:n.trim(),kind:"side",attachments:T.map(({name:P,data:D})=>({name:P,data:D}))});r(""),v([]),Mt(A.id,`run:${t.id}`);return}await O(`/api/runs/${t.id}/followups`,{kind:"side",worktree:b.name,agent:i,settings:f,trust:o.trust,tools:o.tools,message:n.trim(),side:{chat:w,mode:a,title:j},attachments:T.map(({name:A,data:P})=>({name:A,data:P}))}),r(""),v([]),s||Mt(`side:${w}`,`run:${t.id}`)}catch(A){C(A.message)}finally{g(!1)}};return e("div",{class:"convo",children:e("div",{class:"convo-inner",children:[y?e("div",{class:"msg err",children:y}):null,e(ti,{images:T,onRemove:w=>v(T.filter((j,A)=>A!==w))}),e("div",{class:"chatbox",children:[e("textarea",{ref:k,rows:1,"aria-label":"Message",placeholder:a==="change"?`Ask ${S} for a change\u2026`:s?`Reply to ${S}\u2026`:`Ask ${S} about this run\u2026`,value:n,onInput:w=>r(w.currentTarget.value),onKeyDown:w=>{w.key==="Enter"&&!w.shiftKey&&!w.isComposing&&(w.preventDefault(),x())}}),e("div",{class:"chatbox-bar chatbox-configurable",children:[t.pattern!=="solo"?e(Ve,{above:!0,label:"Chat mode",icon:"chat",class:"chat-choice",trigger:e(M,{children:[e("span",{children:a==="ask"?"Ask":"Change"}),e(K,{name:"chevron"})]}),children:w=>e(M,{children:[e(kt,{children:"Chat mode"}),e(pe,{on:a==="ask",sub:"Read the worktree without changing files",onClick:()=>{c("ask"),w()},children:"Ask"}),e(pe,{on:a==="change",sub:"Edit the worktree, commit changes and run the check",onClick:()=>{c("change"),w()},children:"Change"})]})}):null,e(bs,{showPermissions:t.pattern!=="solo"||!!s,providers:t.pattern==="solo"&&!s?Re.value.filter(w=>w.id==="claude"||w.id==="codex"||w.id==="agy"):void 0,agent:i,onAgent:w=>{d(w),ae.set("sideAgent",w)},settings:f,onSettings:w=>p({...l,[i]:w}),permissions:o,onPermissions:u,restricted:!!t.lockdown||!!t.trigger,approvalsAvailable:!t.loop.remoteWorker&&!t.loop.agentContainer}),e("span",{class:"chatbox-hint"}),e("button",{class:"send","aria-label":"Send",title:"Send (\u21B5 \u2014 \u21E7\u21B5 for a new line)",disabled:h||!n.trim()||!b,onClick:x,children:e(K,{name:"send"})})]})]}),e("div",{class:"side-hint help",children:[t.pattern!=="solo"&&a==="change"?`Edits ${b?.branch??"the run's worktree"}; code-flow commits it and runs the check.`:"Reads the run's worktree; changes nothing.",t.status==="running"&&t.pattern!=="solo"?" Waits for the team to finish.":""]})]})})}function Ad(t,s){let n=Z(null);return N(()=>{Ms.value&&(s(r=>r?`${r}
|
|
98
|
+
|
|
99
|
+
${Ms.value}`:Ms.value),Ms.value="",n.current?.focus())},[Ms.value]),N(()=>{let r=n.current;r&&(r.style.height="auto",r.scrollHeight&&(r.style.height=`${Math.min(r.scrollHeight,220)}px`))},[t]),n}function am({id:t}){let s=Rd(),{run:n,problem:r,data:a,version:c}=Gs(t,void 0,s),i=$d([c,n?.status,n?.followUps?.length]);if(N(()=>{s&&n&&n.status!=="running"&&!n.seen&&!document.hidden&&za(n.id)},[s,n?.status,n?.seen]),r)return e("div",{class:"side-empty",children:[e("p",{class:"msg err",children:r}),e("button",{class:"btn",onClick:()=>Mt(null),children:"New chat"})]});if(!n)return e("div",{class:"side-empty help",children:"Loading\u2026"});let d=Zo(n,a.current.steps.values()),l=Object.values(n.roles).flat()[0],p=ft(n),o=n.artifacts[0]?.branch??n.worktrees[0]?.branch;return e(M,{children:[e("div",{class:"chat-scroll",ref:i,children:e("div",{class:"thread",children:[e("div",{class:"chat-meta",children:[e(Ee,{id:l}),e("span",{class:`status-pill ${p}`,children:Je[n.status]??n.status}),o?e("code",{title:"The branch this chat works on",children:o}):null,n.pattern!=="solo"?p==="failing"?e("span",{class:"note",children:"Check fails"}):p==="done"?e("span",{class:"ok",children:"Check passes"}):p==="unverified"?e("span",{class:"note",children:"Not verified"}):null:null,e("a",{class:"btn ghost small",href:`#/run/${encodeURIComponent(n.id)}`,title:"Open this chat as a run, with its branch and result",children:"Open"})]}),e("div",{class:"msg-you",children:e("div",{class:"bubble",children:e(je,{text:n.task})})}),e(Qo,{run:n,steps:d,data:a.current}),["interrupted","stopped","failed","cancelled"].includes(n.status)?e("div",{class:"chat-resume",children:[e("span",{class:"help",children:n.status==="interrupted"?"This chat was interrupted.":`This chat ${Je[n.status]?.toLowerCase()??n.status}.`}),e("button",{class:"btn small",onClick:()=>O(`/api/runs/${n.id}/resume`).catch(u=>J(u.message)),children:"\u25B6 Resume"})]}):null]})}),e(si,{run:n,steps:d,chat:!0,onOpenChat:Mt},n.id)]})}function rm({scope:t}){let s=t.run,n=s?s.artifacts.map(S=>S.branch):[],[r,a]=m(""),[c,i]=m(ai),[d,l]=m(!1),[p,o]=m(""),[u,f]=m(n[0]??""),h=Ad(r,a),g=ge.value.find(S=>S.chat),y=Se[c]??c,C=t.repo?be(t.repo):"the repository",[T,v]=m(ae.get("interactiveApprovals")==="1"),k=async()=>{if(!(!r.trim()||d||!g)){if(!t.repo)return o("Choose a repository first.");l(!0),o("");try{let{id:S,project:x}=await O("/api/runs",{repo:t.repo,project:s?void 0:t.project?.id,task:r.trim(),pattern:g.id,roles:{agent:[c]},options:{},baseRef:u||void 0,agentSettings:Be.value,trust:ut.value,approvals:{tools:T},loop:{maxMinutes:$e.value.maxMinutes,maxSteps:$e.value.maxSteps},parentRunId:s?.id});a(""),Mt(S,t.key),Fa(x),x&&t.key.startsWith("repo:")&&Mt(S,`project:${x}`)}catch(S){o(S.message)}finally{l(!1)}}},b=s&&!Sd(s);return e(M,{children:[e("div",{class:"chat-scroll",children:e("div",{class:"side-empty",children:[e("h3",{children:s?"A separate chat":`Chat with ${y}`}),e("p",{class:"help",children:s?`${b?`${tm(s)} `:""}${y} works on a branch of its own${u?", starting from the run's result":""}, and you keep talking to it; the chat is a run like any other.`:`Ask a question or ask for a change. ${y} works on its own branch of ${C} and you keep talking to it; its reply shows here and the chat is a run like any other.`}),g?null:e("p",{class:"msg warn",children:"This code-flow has no Single-agent pattern, which the chat needs."})]})}),e("div",{class:"convo",children:e("div",{class:"convo-inner",children:[p?e("div",{class:"msg err",children:p}):null,e("div",{class:"chatbox",children:[e("textarea",{ref:h,rows:1,"aria-label":"Message",placeholder:`Message ${y}\u2026`,value:r,onInput:S=>a(S.currentTarget.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&!S.isComposing&&(S.preventDefault(),k())}}),e("div",{class:"chatbox-bar chatbox-configurable",children:[e(bs,{agent:c,onAgent:S=>{i(S),ae.set("sideAgent",S)},settings:Be.value[c]??{},onSettings:S=>Fs(c,S),permissions:{trust:ut.value,tools:T},onPermissions:S=>{dn(S.trust),v(S.tools),ae.set("interactiveApprovals",S.tools?"1":"0")}}),n.length?e("label",{class:"to",title:"Start from this run's result branch, so the agent sees that work",children:[e("span",{class:"to-lbl",children:"From"}),e("select",{"aria-label":"Start from",value:u,onChange:S=>f(S.currentTarget.value),children:[e("option",{value:"",children:"HEAD"}),n.map(S=>e("option",{value:S,children:S},S))]})]}):null,e("span",{class:"chatbox-hint"}),e("button",{class:"send","aria-label":"Send",title:"Send (\u21B5 \u2014 \u21E7\u21B5 for a new line)",disabled:d||!r.trim()||!g,onClick:k,children:e(K,{name:"send"})})]})]})]})})]})}var om=Bt(()=>import("./interactive-browser-7F5ZXRUV.js").then(t=>t.BrowserTab)),im=Bt(()=>import("./changes-62ZIEQSN.js").then(t=>t.ChangesTab)),lm=Bt(()=>import("./code-browser-VB2HGZSG.js").then(t=>t.CodeBrowser)),cm=Bt(()=>import("./terminal-IWAIM4DE.js").then(t=>t.TerminalTab)),qr={chat:{label:"Chat",icon:"chat",title:"Chat with one agent about this run or repository"},changes:{label:"Changes",icon:"diff",title:"What this run changed: the whole branch or its last step, with line comments"},files:{label:"Files",icon:"files",title:"The repository's files, or a run's worktree"},terminal:{label:"Terminal",icon:"terminal",title:"A shell in the repository or a worktree"},browser:{label:"Browser",icon:"globe",title:"Open the app a run started, or any address"},notes:{label:"Notes",icon:"note",title:"Your scratchpad for this repository"}};function ri({popped:t=!1}){let s=Z(null),n=Us.value.run,r=Ei.filter(g=>g!=="changes"||n),a=r.includes(en.value)?en.value:"chat",[c,i]=m(()=>new Set([a]));N(()=>{c.has(a)||i(new Set([...c,a]))},[a]);let d=Us.value.key;N(Qi,[d]);let[l,p]=m(!1),o=g=>{g.button===0&&(g.preventDefault(),g.currentTarget.setPointerCapture(g.pointerId),p(!0))},u=g=>{p(!1);let y=g.currentTarget;y.hasPointerCapture(g.pointerId)&&y.releasePointerCapture(g.pointerId)};We(()=>{if(!Ot.value||!Wt.value||t)return;let g=y=>{y.key!=="Escape"||y.defaultPrevented||document.querySelector('dialog[open], [role="menu"]')||(y.preventDefault(),Wt.value=!1)};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[Ot.value,Wt.value,t]);let f={chat:()=>e(xd,{}),changes:()=>n?e(im,{run:n},n.id):e("div",{class:"side-empty help",children:"Open a run to see what it changed."}),files:()=>e(um,{}),terminal:()=>e(cm,{}),browser:()=>e(om,{}),notes:()=>e(pm,{})},h=!Ot.value&&!t;return We(()=>{h&&s.current?.contains(document.activeElement)&&document.querySelector('button[aria-label="Side panel"]')?.focus()},[h]),e("aside",{id:"side-panel",ref:s,tabIndex:-1,class:`side ${Ot.value?"open":""} ${t?"popped":""}`,"aria-label":"Side panel","aria-hidden":h,inert:h,children:[t||Wt.value?null:e("div",{class:`side-handle ${l?"dragging":""}`,role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":"Resize the side panel","aria-valuemin":300,"aria-valuemax":Xr.value,"aria-valuenow":jn.value,title:"Drag or use arrow keys to resize; double-click to reset",onPointerDown:o,onPointerMove:g=>{l&&Na(window.innerWidth-g.clientX)},onPointerUp:u,onPointerCancel:u,onLostPointerCapture:()=>p(!1),onDblClick:()=>Na(420),onKeyDown:g=>{let y=g.key==="ArrowLeft"?jn.value+24:g.key==="ArrowRight"?jn.value-24:g.key==="Home"?300:g.key==="End"?Xr.value:void 0;y!==void 0&&(g.preventDefault(),Na(y))}}),e(dm,{popped:t}),e("div",{class:"side-tabs",role:"tablist","aria-label":"Side panel tabs",children:r.map(g=>e("button",{type:"button",role:"tab",id:`side-tab-${g}`,"aria-selected":g===a,"aria-controls":`side-pane-${g}`,class:`side-tab ${g===a?"on":""}`,"aria-label":qr[g].label,title:qr[g].title,tabIndex:g===a?0:-1,onKeyDown:y=>{let C=r.indexOf(g),T=y.key==="ArrowRight"?(C+1)%r.length:y.key==="ArrowLeft"?(C+r.length-1)%r.length:y.key==="Home"?0:y.key==="End"?r.length-1:-1;if(T>=0){y.preventDefault();let v=r[T];$t(v),document.getElementById(`side-tab-${v}`)?.focus()}},onClick:()=>$t(g),children:[e(K,{name:qr[g].icon}),e("span",{children:qr[g].label})]},g))}),e("div",{class:"side-body",children:Us.value.waiting?e("div",{class:"side-empty help",children:"Loading\u2026"}):r.filter(g=>c.has(g)||g===a).map(g=>e("div",{id:`side-pane-${g}`,role:"tabpanel","aria-labelledby":`side-tab-${g}`,class:"side-pane",hidden:g!==a,children:f[g]()},g))})]})}function dm({popped:t}){let s=Us.value,n=s.run?"run":"project",r=s.project?.name??(s.repo?be(s.repo):""),a=s.run?s.run.task.split(`
|
|
100
|
+
`)[0]||"(no task)":"";return e("div",{class:`side-scope ${s.pinned?"pinned":""}`,children:[e("span",{class:"scope-state",title:t?`This window shows one ${n}`:s.pinned?`The panel stays on this ${n} while you open others`:"The panel follows what you open",children:[t?e(K,{name:"external"}):s.pinned?e(K,{name:"pin"}):e("span",{class:"scope-dot","aria-hidden":"true"}),t?"Own window":s.pinned?"Pinned":"Following"]}),e("span",{class:"scope-crumbs",title:[r,s.repo,a].filter(Boolean).join(`
|
|
101
|
+
`),children:[r?e("span",{class:"sc-where",children:r}):s.waiting?null:e("span",{class:"help",children:"No repository chosen"}),!s.run&&s.project&&s.project.repos.length>1?e(M,{children:[e("span",{class:"sep","aria-hidden":"true",children:"\u203A"}),e("span",{class:"sc-what",children:be(s.repo)})]}):null,s.run?e(M,{children:[e("span",{class:"sep","aria-hidden":"true",children:"\u203A"}),s.pinned?e("a",{class:"sc-what",href:`#/run/${G(s.run.id)}`,title:t?"Open this run in the main window":"Open this run",children:a}):e("span",{class:"sc-what",children:a})]}):null]}),t?null:s.pinned?e("button",{type:"button",class:"btn ghost small",title:"Follow what you open again",onClick:()=>pa(!1),children:"Follow"}):e("button",{type:"button",class:"icon-btn","aria-label":`Pin the panel to this ${n}`,title:`Pin: keep the panel on this ${n} while you open others`,disabled:!s.repo,onClick:()=>pa(!0),children:e(K,{name:"pin"})}),t?null:e("button",{type:"button",class:"icon-btn side-expand","aria-label":Wt.value?"Restore side panel":"Expand side panel",title:Wt.value?"Restore alongside chat (Esc)":"Expand to full screen","aria-pressed":Wt.value,onClick:()=>{Wt.value=!Wt.value},children:e(K,{name:Wt.value?"collapse":"expand"})}),t?null:e("button",{type:"button",class:"icon-btn","aria-label":"Close side panel",title:"Close (\\)",onClick:ia,children:e(K,{name:"close"})})]})}function um(){let[t,s,n]=pl("files"),[r,a]=m(null);N(()=>{let i=Oa.value;if(!i)return;let d=n.find(l=>l.path===i.root);d&&s(d),a({root:d?.path??t?.path??"",path:i.path}),Oa.value=null},[Oa.value]);let c=t?.path??"";return N(()=>a(i=>i?.root===c?i:null),[c]),e(M,{children:[e("div",{class:"side-toolbar",children:e(ml,{label:"Folder",place:t,places:n,onChange:s})}),t?e(lm,{compact:!0,folder:c,initialPath:r?.root===c?r.path:void 0,onClose:()=>a(null)},c):e("p",{class:"side-empty",children:"Choose a repository or run worktree."})]})}function pm(){let t=Us.value.repo,[s,n]=m(t?"repo":"general"),[r,a]=m(null),[c,i]=m(""),[d,l]=m(null),[p,o]=m(!1),u=r??(s==="repo"&&t?t:"general"),[f,h]=m(""),[g,y]=m(null),[C,T]=m([]),[v,k]=m(null),b=Z(new Map),S=Z(Promise.resolve()),x=Z(u);x.current=u;let[w,j]=m(""),[A,P]=m(!1);N(()=>{P(!1),j("Loading\u2026");let I=!0;return V(`/api/notes?key=${G(u)}`).then($=>{if(!I)return;let E=null;try{E=ae.get(`notes-draft:${u}`)}catch{}h(E??$.text),b.current.set(u,{text:$.text,revision:$.revision}),y({at:$.updatedAt,text:$.text,revision:$.revision}),k(null),T([]),j(E!==null&&E!==$.text?"Recovered your unsaved draft":""),P(!0)},$=>I&&j($.message)),()=>{I=!1}},[u]),N(()=>{if(!A||g?.text===f||v)return;j("Saving\u2026");let I=setTimeout(()=>{S.current=S.current.catch(()=>{}).then(async()=>{let $=b.current.get(u);if(!(!$||$.text===f))try{let E=await O("/api/notes",{key:u,text:f,expectedRevision:$.revision});b.current.set(u,{text:f,revision:E.revision});try{ae.get(`notes-draft:${u}`)===f&&ae.remove(`notes-draft:${u}`)}catch{}x.current===u&&(y({at:E.updatedAt,text:f,revision:E.revision}),j(""))}catch(E){if(x.current!==u)return;j(`Couldn't save: ${E.message}. Your draft is kept in this browser.`);let L=await V(`/api/notes?key=${G(u)}`).catch(()=>null);L&&L.revision!==$.revision&&x.current===u&&k(L)}})},600);return()=>clearTimeout(I)},[f,u,A,g?.revision,v]);let D=()=>{let I=document.getElementById("side-notes");return((I&&I.selectionStart!==I.selectionEnd?I.value.slice(I.selectionStart,I.selectionEnd):"")||f).trim()};return e(M,{children:[e("div",{class:"side-toolbar",children:[t?e("div",{class:"segmented small",role:"group","aria-label":"Which notes",children:[e("button",{type:"button",class:!r&&s==="repo"?"on":"","aria-pressed":!r&&s==="repo",onClick:()=>{n("repo"),a(null)},title:t,children:be(t)}),e("button",{type:"button",class:!r&&s==="general"?"on":"","aria-pressed":!r&&s==="general",onClick:()=>{n("general"),a(null)},children:"General"})]}):e("span",{class:"help",children:"General notes"}),e("span",{class:"spacer"}),e("button",{type:"button",class:"btn ghost small",title:"Add the selection (or the whole note) to the task in the composer",disabled:!f.trim(),onClick:()=>{Pe({view:"composer"},[{to:"composer",text:D(),images:[]}]),J("Added to the task")},children:"\u2192 Task"}),e("button",{type:"button",class:"btn ghost small",title:"Send the selection (or the whole note) to the chat",disabled:!f.trim(),onClick:()=>{Ms.value=D(),Mt(null),$t("chat")},children:"\u2192 Chat"})]}),e("div",{class:"notes-tools",children:[e("button",{type:"button",class:"btn ghost small","aria-expanded":p,"aria-controls":p?"notes-search":void 0,onClick:()=>o(!p),children:[e(K,{name:"search"})," Search saved notes"]}),e("span",{class:"spacer"}),e("button",{type:"button",class:"btn ghost small",disabled:!A,onClick:async()=>{try{T(await V(`/api/notes/history?key=${G(u)}`))}catch(I){j(I.message)}},children:[e(K,{name:"clock"})," Revision history"]})]}),p?e("div",{id:"notes-search",class:"notes-search",children:[e("form",{class:"notes-search-row",onSubmit:async I=>{I.preventDefault();try{l(await V(`/api/notes/search?q=${G(c)}`))}catch($){j($.message)}},children:[e("input",{class:"field","aria-label":"Search saved notes",placeholder:"Words or repository path",value:c,onInput:I=>i(I.currentTarget.value)}),e("button",{class:"btn small",children:"Search notes"})]}),d?e(M,{children:[d.hits.length?d.hits.map(I=>e("div",{class:"notes-hit",children:[e("button",{type:"button",class:"notes-hit-key",onClick:()=>{a(I.key),l(null)},children:[I.key," \xB7 revision ",I.revision]}),e("span",{class:"help",children:I.excerpt})]},I.key)):e("p",{class:"help",children:"No saved notes match."}),d.truncated?e("p",{class:"help",children:"Results are limited; narrow the query."}):null]}):null]}):null,r?e("div",{class:"notes-picked",children:[e("span",{class:"help",children:["Editing ",e("code",{children:r})]}),e("button",{class:"btn small",onClick:()=>a(null),children:"Return to current notes"})]}):null,v?e("div",{class:"notes-conflict",role:"alert",children:[e("p",{children:"This note changed in another window. Your draft is preserved."}),e("details",{children:[e("summary",{children:"Compare saved version"}),e("pre",{children:v.text})]}),e("div",{class:"row",children:[e("button",{class:"btn small",onClick:()=>{b.current.set(u,v),h(v.text),y({at:v.updatedAt,text:v.text,revision:v.revision}),k(null),ae.remove(`notes-draft:${u}`)},children:"Use saved version"}),e("button",{class:"btn small",onClick:()=>{b.current.set(u,v),y({at:v.updatedAt,text:v.text,revision:v.revision}),k(null)},children:"Save my draft over this version"})]})]}):null,C.length?e("details",{open:!0,class:"notes-history",children:[e("summary",{children:[C.length," saved revisions"]}),C.map(I=>e("div",{children:e("details",{children:[e("summary",{children:["Revision ",I.revision," \xB7 ",new Date(I.updatedAt).toLocaleString()]}),e("pre",{children:I.text||"(empty)"}),e("button",{class:"btn small",disabled:I.revision===g?.revision||g?.text!==f,onClick:async()=>{try{let $=await O("/api/notes/restore",{key:u,revision:I.revision,expectedRevision:g?.revision});b.current.set(u,$),y({at:$.updatedAt,text:$.text,revision:$.revision}),h($.text),T([]),j("Restored as a new revision")}catch($){j($.message)}},children:"Restore as new revision"})]})},I.revision))]}):null,e("textarea",{id:"side-notes",class:"notes-area","aria-label":"Notes",placeholder:"Notes to yourself: what to check, ideas, commands\u2026 Saved as you type.",spellcheck:!1,disabled:!A,value:f,onInput:I=>{h(I.currentTarget.value),ae.set(`notes-draft:${u}`,I.currentTarget.value)}}),e("div",{class:"notes-foot",children:[e("span",{children:w||(g?.at?`Saved ${es(g.at)}`:"")}),e("span",{class:"spacer"}),e("span",{children:f.length?`${f.length.toLocaleString()} characters`:""})]})]})}function Ed({folder:t,paths:s,refreshKey:n=""}){let[r,a]=m(!1),[c,i]=m(!1),[d,l]=m(""),[p,o]=m();N(()=>{if(!r||!t)return;let h=!0;return i(!0),l(""),o(void 0),V(`/api/workspace/dependencies?repo=${G(t)}`).then(g=>{h&&o(g)},g=>{h&&l(g.message)}).finally(()=>{h&&i(!1)}),()=>{h=!1}},[r,t,s.join("\0"),n]);let u=new Set(s),f=p?.edges.filter(h=>u.has(h.from)||u.has(h.to))??[];return e("details",{class:"settings change-impact",open:r,onToggle:h=>a(h.currentTarget.open),children:[e("summary",{children:"What could this change affect?"}),e("div",{class:"settings-body",children:[e("p",{class:"help",children:["Static import relationships for ",s.length," selected ",s.length===1?"file":"files",", based on saved tracked source. Unsaved edits and runtime dependencies are excluded."]}),c?e("p",{role:"status",children:"Inspecting related files\u2026"}):null,d?e("p",{class:"msg err",role:"alert",children:d}):null,p?e(M,{children:[e("p",{class:"help",children:[p.truncated?"The scan reached its limit; some relationships may be missing. ":"",p.note]}),f.length?e("ul",{children:f.map((h,g)=>e("li",{children:[e("code",{children:h.from})," imports ",e("code",{children:h.to})]},g))}):e("p",{children:"No static import relationships found for these files. This does not establish that the change has no impact."}),e("details",{children:[e("summary",{children:"Additional scan evidence"}),e("p",{children:[p.nodes.length," files \xB7 ",p.cycles.length," cycles \xB7 ",p.unresolved.length," unresolved imports"]}),e("pre",{children:JSON.stringify({cycles:p.cycles,packages:p.packages,unresolved:p.unresolved,dynamic:p.dynamic},null,2)})]})]}):null]})]})}function jd({runId:t,branch:s,refreshKey:n,onOpen:r}){let[a,c]=m(null),[i,d]=m(""),[l,p]=m(!1),[o,u]=m(""),[f,h]=m(""),g=`${t}\0${s}`,y=Z(g);y.current=g;let C=`/api/runs/${G(t)}/review-coverage`;N(()=>{let v=!0;return c(null),d(""),V(`${C}?branch=${G(s)}`).then(k=>{v&&c(k)},k=>{v&&d(k.message)}),()=>{v=!1}},[t,s,n]),N(()=>{p(!1),u(""),h("")},[t,s]);let T=async(v,k)=>{let b=g;p(!0),d("");try{let S=await O(v,k);return y.current!==b?!1:(c(S),!0)}catch(S){return y.current===b&&d(S.message),!1}finally{y.current===b&&p(!1)}};return e("details",{class:"review-coverage",children:[e("summary",{children:["Human review coverage",a?` \xB7 ${a.coverage.reviewed}/${a.coverage.changed} files \xB7 ${a.risk.level} change risk`:""]}),e("p",{class:"help",children:"Mark files after reviewing them. Coverage records your review of this commit; it resets when the branch moves. Passing checks do not imply human review."}),i?e("p",{class:"msg err",role:"alert",children:i}):null,a?e(M,{children:[e("p",{class:"help",children:["Commit ",a.head.slice(0,12),a.stale?" \xB7 previous review refers to older code":""]}),a.risk.reasons.map(v=>e("p",{class:"help",children:v},v)),e("div",{class:"rc-files",children:a.files.map(v=>e("div",{class:"rc-file",children:[e("label",{class:"check",children:[e("input",{type:"checkbox","aria-label":`Mark ${v} reviewed`,disabled:l,checked:a.reviewed.includes(v),onChange:k=>T(C,{branch:s,expectedHead:a.head,path:v,reviewed:k.currentTarget.checked})}),e("span",{class:"sr-only",children:"Reviewed"})]}),e("button",{type:"button",class:"rc-path",title:`Open ${v}`,onClick:()=>r(v),children:e("bdi",{children:v})})]},v))}),e("details",{children:[e("summary",{children:"Record human rework"}),e("p",{class:"help",children:"Track time you spent correcting or completing this result. These are your records, not estimates from agent activity."}),e("label",{children:["Minutes",e("input",{class:"field",type:"number",min:"1",max:"1440",value:o,disabled:l,onInput:v=>u(v.currentTarget.value)})]}),e("label",{children:["What changed",e("textarea",{class:"field",rows:2,maxLength:2e3,value:f,disabled:l,onInput:v=>h(v.currentTarget.value)})]}),e("button",{class:"btn small",disabled:l||!(Number(o)>=1&&Number(o)<=1440),onClick:async()=>{await T(`/api/runs/${G(t)}/human-rework`,{branch:s,expectedHead:a.head,minutes:Number(o),note:f})&&(u(""),h(""))},children:"Record rework"}),e("p",{class:"help",children:[a.rework.reduce((v,k)=>v+k.minutes,0)," minutes recorded across ",a.rework.length," entries."]}),a.rework.map(v=>e("p",{class:"help",children:[v.minutes," min \xB7 ",new Date(v.at).toLocaleDateString()," \xB7 ",v.note]},v.id))]})]}):e("p",{class:"help",children:"Loading coverage\u2026"})]})}var ea=new Map,ii=qe(0),Pd=t=>(ea.has(t)||ea.set(t,ae.json(t,[])),ea.get(t));function mm(t){return ii.value,Pd(t)}function oi(t,s){let n=s(Pd(t));ea.set(t,n),ae.set(t,JSON.stringify(n)),ii.value++}window.addEventListener("storage",t=>{t.key!==null&&!t.key.startsWith("comments:")||(t.key===null?ea.clear():ea.delete(t.key),ii.value++)});function Md({id:t,branch:s}){let{run:n,data:r}=Gs(t),a=n??ve.value.get(t),[c,i]=m(0),d=`comments:${t}:${s}`,[l,p]=m(null),[o,u]=m(null),[f,h]=m(""),[g,y]=m(""),[C,T]=m(null),v=mm(d),[k,b]=m(()=>ae.get(`${d}:general`)??""),[S,x]=m(null),[w,j]=m(!1);N(()=>{let H=!0;return h(""),V(`/api/runs/${t}/diff?branch=${G(s)}`).then(Q=>{H&&(u(Q),T(le=>Q.some(de=>de.path===le)?le:Q[0]?.path??null))},Q=>{H&&h(Q.message)}),V(`/api/runs/${t}`).then(Q=>{H&&(p(Q),y(""))},Q=>{H&&y(`Couldn't load this run: ${Q.message}. Check who the comments go to before sending.`)}),()=>{H=!1}},[t,s,c,a?.status,a?.lastCheck?.at]);let A=((a??l)?.worktrees??[]).find(H=>H.branch===s),P=Kr(()=>hm(l,A?.name),[l,A?.name]),D=S??P??"claude",I=o?.find(H=>H.path===C),$=o?.reduce((H,Q)=>({add:H.add+Q.additions,del:H.del+Q.deletions}),{add:0,del:0}),E=a?.status==="done"&&!a.projectTeam&&!!A&&!!(S??P)&&(v.length>0||k.trim().length>0),L=async()=>{if(!A||!E||w)return;j(!0);let H=fm(v,k);try{await O(`/api/runs/${t}/followups`,{kind:"comments",worktree:A.name,agent:D,message:H}),oi(d,()=>[]),ae.set(`${d}:general`,""),J("Sent \u2014 the agent is working on your comments"),Y.value={view:"run",id:t}}catch(Q){J(Q.message,5e3)}finally{j(!1)}};return e("div",{class:"review",children:[e("div",{class:"review-head",children:[e("button",{class:"btn ghost small review-back",onClick:()=>Y.value={view:"run",id:t},children:[e(K,{name:"chevron",class:"back"})," Back to run"]}),e("div",{class:"review-title",children:[e("h1",{children:"Review"}),e("code",{title:s,children:s}),$?e("span",{class:"review-totals",children:[o.length," file",o.length===1?"":"s"," \xB7 ",e("span",{class:"add",children:["+",$.add]})," ",e("span",{class:"del",children:["\u2212",$.del]})]}):null]}),e("div",{class:"review-send",children:a?.projectTeam?e("a",{class:"btn",href:`#/project/${a.project}`,children:"Use mission revision controls"}):a?.status==="done"?e(M,{children:[e("span",{class:"review-to",children:S||P?"Send to":l||g?"Choose an agent":"Loading recipient\u2026"}),e(Or,{value:D,onChange:x}),e("button",{class:"btn primary",disabled:!E||w,onClick:L,children:w?"Sending\u2026":`Send ${v.length||""} comment${v.length===1?"":"s"}`.replace(" "," ")})]}):e("span",{class:"review-to",children:"Comments can be sent once the run has finished."})})]}),a?e("div",{class:"review-overview",children:[e(Rr,{run:a,branch:s}),e("div",{class:"review-evidence-tools",children:[e($r,{run:a}),e("button",{class:"btn small",onClick:()=>i(H=>H+1),children:"Refresh changes"})]}),a.artifacts.find(H=>H.branch===s)?e("details",{class:"review-delivery",children:[e("summary",{children:"Publish changes"}),e("p",{class:"help",children:"Review the diff and evidence before publishing. Merge validation and confirmation still apply."}),e(ei,{run:a,artifact:a.artifacts.find(H=>H.branch===s),steps:[...r.current.steps.values()],reviewing:!0},s)]}):null]}):null,f?e("div",{class:"msg err review-msg",children:f}):null,g?e("div",{class:"msg warn review-msg",children:g}):null,a?.outcome?.decision==="needs-work"&&a.outcome.branch===s?e("p",{class:"help review-msg",children:"Describe what needs to change in the overall comment or on individual lines, then send your comments to start a revision on this branch."}):null,e("div",{class:"review-body",children:[e("div",{class:"review-files",children:[A&&o?.length?e(Ed,{folder:A.path,paths:o.map(H=>H.path),refreshKey:`${c}:${a?.status}:${a?.lastCheck?.at}`}):null,e(jd,{runId:t,branch:s,refreshKey:`${c}:${a?.status}:${a?.lastCheck?.at}`,onOpen:T}),o?.map(H=>{let Q=v.filter(de=>de.file===H.path).length,le=H.path.lastIndexOf("/")+1;return e("button",{type:"button",class:`rf ${H.path===C?"selected":""}`,onClick:()=>T(H.path),title:H.oldPath?`${H.oldPath} \u2192 ${H.path}`:H.path,children:[e("span",{class:`fs ${H.status}`,children:{added:"A",modified:"M",deleted:"D",renamed:"R"}[H.status]}),e("span",{class:"fp",children:[le?e("span",{class:"fdir",children:H.path.slice(0,le)}):null,e("span",{class:"fname",children:H.path.slice(le)})]}),Q?e("span",{class:"count",title:`${Q} comment${Q===1?"":"s"}`,children:Q}):null,e("span",{class:"fn",children:[e("span",{class:"add",children:["+",H.additions]})," ",e("span",{class:"del",children:["\u2212",H.deletions]})]})]},H.path)}),o&&!o.length?e("div",{class:"tree-empty",children:"No changes on this branch."}):null,e("div",{class:"general",children:[e("label",{class:"lbl",for:"general",children:"Overall comment"}),e("textarea",{id:"general",class:"field",rows:4,placeholder:"Anything that isn't about one line\u2026",value:k,onInput:H=>{b(H.currentTarget.value),ae.set(`${d}:general`,H.currentTarget.value)}})]})]}),e("div",{class:"review-diff",role:"region","aria-label":I?`Diff of ${I.path}`:"Diff",children:I?e(gm,{file:I,comments:v.filter(H=>H.file===I.path),onAdd:H=>oi(d,Q=>[...Q,H]),onRemove:H=>oi(d,Q=>Q.filter(le=>le!==H))},I.path):o?null:e("div",{class:"tree-empty",children:"Loading diff\u2026"})})]})]})}var hm=(t,s)=>[...t?.steps??[]].reverse().find(n=>(n.kind??"agent")==="agent"&&n.worktree===s&&n.mode==="write")?.agent;function fm(t,s=""){return[t.map((r,a)=>`${a+1}. ${r.file}:${r.line}${r.side==="old"?" (a removed line)":""} \u2014 \`${r.code.trim().slice(0,140)}\`
|
|
102
|
+
${r.text.trim()}`).join(`
|
|
103
|
+
`),s.trim()?`General: ${s.trim()}`:""].filter(Boolean).join(`
|
|
104
|
+
|
|
105
|
+
`)}function gm({file:t,comments:s,onAdd:n,onRemove:r}){let a=Kr(()=>vm(t.patch),[t.patch]),[c,i]=m(null),[d,l]=m(""),[p,o]=m(-1),u=Z(null),f=Z(null);if(N(()=>{c&&f.current?.focus()},[c]),t.binary)return e("div",{class:"tree-empty",children:"Binary file \u2014 no text diff."});let h=(v,k)=>s.filter(b=>b.side===v&&b.line===k),g=v=>v.type==="add"||v.type==="del"||v.type==="ctx",y=a[p]&&g(a[p])?p:a.findIndex(g),C=v=>{u.current?.querySelector(`tr[data-i="${v}"]`)?.focus(),i(null)},T=v=>{let k=[...u.current?.querySelectorAll("tr.dl[tabindex]")??[]],b=k.indexOf(v.currentTarget),S={ArrowDown:1,ArrowUp:-1,PageDown:20,PageUp:-20,Home:-k.length,End:k.length};return b<0||!(v.key in S)||v.altKey||v.ctrlKey||v.metaKey?!1:(v.preventDefault(),k[Math.max(0,Math.min(k.length-1,b+S[v.key]))].focus(),!0)};return e("div",{children:[e("div",{class:"diff-file-head",children:[t.oldPath?`${t.oldPath} \u2192 `:"",t.path,t.truncated?e("span",{class:"help",children:" \xB7 diff truncated"}):null]}),e("table",{class:"diff",children:e("tbody",{ref:u,children:a.map((v,k)=>{let b=v.type==="del"?"old":"new",S=b==="old"?v.old:v.new,x=g(v),w=x?h(b,S):[],j=c&&x&&c.side===b&&c.line===S,A=()=>{!x||S===void 0||(i({side:b,line:S,code:v.text}),l(""))};return[e("tr",{class:`dl ${v.type}`,"data-i":k,tabIndex:x?k===y?0:-1:void 0,onClick:A,onFocus:()=>o(k),onKeyDown:P=>{P.target!==P.currentTarget||T(P)||(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),A())},title:x?"Click or press Enter to comment on this line":void 0,children:[e("td",{class:"ln",children:v.old??""}),e("td",{class:"ln",children:v.new??""}),e("td",{class:"code",children:[e("span",{class:"sign",children:v.type==="add"?"+":v.type==="del"?"\u2212":" "}),v.text]})]},`r${k}`),...w.map((P,D)=>e("tr",{class:"comment-row",children:e("td",{colSpan:3,children:e("div",{class:"comment",children:[e("span",{children:P.text}),e("button",{class:"btn ghost small",onClick:()=>r(P),children:"Remove"})]})})},`c${k}-${D}`)),j?e("tr",{class:"comment-row",children:e("td",{colSpan:3,children:e("div",{class:"comment editing",children:[e("textarea",{ref:f,class:"field",rows:3,"aria-label":`Comment on line ${S}`,placeholder:"What should change here?",value:d,onInput:P=>l(P.currentTarget.value),onKeyDown:P=>{P.key==="Enter"&&(P.metaKey||P.ctrlKey)&&d.trim()&&(n({file:t.path,side:b,line:S,code:v.text,text:d}),C(k)),P.key==="Escape"&&C(k)}}),e("div",{class:"row",children:[e("button",{class:"btn small",onClick:()=>C(k),children:"Cancel"}),e("button",{class:"btn small primary",disabled:!d.trim(),onClick:()=>{n({file:t.path,side:b,line:S,code:v.text,text:d}),C(k)},children:["Add comment ",e("span",{class:"kbd",children:"\u2318\u21B5"})]})]})]})})},`e${k}`):null]})})})]})}function vm(t){let s=[],n=0,r=0,a=!1;for(let c of t.split(`
|
|
106
|
+
`)){let i=c.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)/);if(i){n=Number(i[1]),r=Number(i[2]),a=!0,s.push({type:"hunk",text:c});continue}a&&(c.startsWith("+")?s.push({type:"add",text:c.slice(1),new:r++}):c.startsWith("-")?s.push({type:"del",text:c.slice(1),old:n++}):c.startsWith(" ")?s.push({type:"ctx",text:c.slice(1),old:n++,new:r++}):c.startsWith("\\")&&s.push({type:"note",text:c}))}return s}var Dd=25,bm=t=>/^(critical|high|error)$/i.test(t??"")?"high":/^(medium|warning)$/i.test(t??"")?"medium":"";function Ld(){let t=Ss.value,s=ye(!!t,()=>Ss.value=null),[n,r]=m(null),[a,c]=m(),[i,d]=m(""),[l,p]=m(new Set),[o,u]=m(""),[f,h]=m(!1),[g,y]=m("07:00"),[C,T]=m(!1);N(()=>{if(!t)return;r(null),d(""),u(""),h(!1);let $={project:ze.value.project?.id,repo:ee.value};if(c($),!$.repo)return d("Choose a repository first");let E=!0;return V(`/api/github/sweep?repo=${G($.repo)}&kind=${t.sweep}`).then(L=>{E&&(r(L),p(new Set(L.items.filter(H=>H.selected).map(H=>H.key))))},L=>{E&&d(L.message)}),()=>{E=!1}},[t]);let v=t?ge.value.find($=>$.id===t.pattern):void 0,k=Vt(v),b=n?.items??[],S=$=>!$.manual&&!!$.source&&!!$.task,x=b.filter($=>l.has($.key)&&S($)),w=o.trim().toLowerCase(),j=b.filter($=>!w||`${$.ref} ${$.title} ${$.detail} ${$.note??""}`.toLowerCase().includes(w)),A=v?fn(v,k,!1)||(x.length>Dd?`Pick at most ${Dd}; the rest can go in a later sweep`:""):"",P=$=>{let E=new Set(l);E.has($)?E.delete($):E.add($),p(E)},D=$=>{let E=new Set(l);for(let L of j)S(L)&&($?E.add(L.key):E.delete(L.key));p(E)},I=async()=>{if(!(!t||!v||A||!x.length||C)){if(!a||a.project!==ze.value.project?.id||a.repo!==ee.value){d("The draft destination changed. Close this backlog and choose it again for the intended project.");return}T(!0),d("");try{let $=await O("/api/sweeps",{kind:t.sweep,name:t.name,max:5,schedule:f?{at:g}:void 0,run:{repo:a.repo,project:a.project,projectSelection:"explicit",pattern:v.id,roles:k,options:as(v),baseRef:Fe.value,agentSettings:Be.value,roleSettings:rt.value[v.id]??{},trust:ut.value,loop:{check:Dt.value.trim(),setup:Gt.value.trim(),maxMinutes:$e.value.maxMinutes,maxSteps:$e.value.maxSteps,copy:ns.value?.config.copy}},items:x.map(L=>({key:L.key,task:L.task,source:L.source}))});await Promise.all([Un(),rn()]),J([`Started ${((L,H)=>`${L} ${H}${L===1?"":"s"}`)($.started.length,"run")}`,$.skipped.length?`${$.skipped.length} already had one`:"",$.failed.length?`${$.failed.length} couldn't start (${$.failed[0].key}: ${$.failed[0].error})`:"",$.automation?"saved as a daily sweep":""].filter(Boolean).join(" \xB7 "),$.failed.length?8e3:5e3),Ss.value=null,Y.value={view:"inbox"}}catch($){d($.message)}finally{T(!1)}}};return e("dialog",{class:"picker sweep-dialog",ref:s,"aria-labelledby":"sweep-title",children:t?e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"sweep-title",children:[e(K,{name:"layers"})," ",t.name]}),e("div",{class:"help",children:t.description}),e("p",{class:"help",children:["Project: ",a?.project," \xB7 ",e("code",{children:a?.repo})]}),e("div",{class:"row",children:e("input",{class:"field",placeholder:"Filter by number, title, label, severity\u2026","aria-label":"Filter",value:o,onInput:$=>u($.currentTarget.value)})}),n?e("div",{class:"sweep-tools",children:[e("span",{children:[e("b",{children:x.length})," of ",b.filter(S).length," picked"]}),e("button",{type:"button",class:"linkish",onClick:()=>D(!0),children:["Pick all",w?" shown":""]}),e("button",{type:"button",class:"linkish",onClick:()=>D(!1),children:"None"})]}):null]}),e("div",{class:"picker-list sweep-list",children:[i?e("div",{class:"msg err pad",children:i}):null,n?.notices.map($=>e("div",{class:"config-note bad",children:$},$)),!n&&!i?e("div",{class:"help pad",children:"Loading from GitHub\u2026"}):null,n&&!b.length?e("div",{class:"help pad",children:"Nothing open \u2014 all clear."}):null,n&&b.length&&!j.length?e("div",{class:"help pad",children:"Nothing matches."}):null,j.map($=>e("label",{class:`sweep-item ${S($)?"":"manual"} ${l.has($.key)&&S($)?"on":""}`,children:[e("input",{type:"checkbox",checked:l.has($.key)&&S($),disabled:!S($),onChange:()=>P($.key)}),e("span",{class:"si-main",children:[e("span",{class:"si-title",children:[e("span",{class:"si-ref",children:$.ref})," ",$.title]}),e("span",{class:"si-detail",children:[$.severity?e("span",{class:`sev ${bm($.severity)}`,children:$.severity}):null," ",$.detail]}),$.note?e("span",{class:`si-note ${$.manual?"warn":""}`,children:[$.note,$.existingRun?e(M,{children:[" \xB7 ",e("a",{href:`#/run/${$.existingRun}`,onClick:()=>Ss.value=null,children:"open it"})]}):null]}):null]}),e("a",{class:"si-link",href:$.url,target:"_blank",rel:"noreferrer",title:"Open on GitHub","aria-label":`Open ${$.ref} on GitHub`,onClick:E=>E.stopPropagation(),children:e(K,{name:"external"})})]},$.key))]}),e("div",{class:"sweep-how",children:[v?e("div",{class:"help",children:["Each runs ",e("b",{children:v.name}),": ",ta(v,k,!1),"."," ",e("button",{type:"button",class:"linkish",onClick:()=>{St(v.id),Ss.value=null},children:"Change the team"})]}):null,e("label",{class:"check",children:[e("input",{type:"checkbox",checked:f,onChange:$=>h($.currentTarget.checked)})," Also check every day at"," ",e("input",{class:"field inline",type:"time",value:g,"aria-label":"Time of day",disabled:!f,onInput:$=>y($.currentTarget.value||"07:00")})," and start runs for new ones (up to 5 each time)"]})]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:A||"Results wait in the inbox for you to approve. Nothing is merged automatically."}),e("button",{class:"btn",type:"button",onClick:()=>Ss.value=null,children:"Cancel"}),e("button",{class:"btn primary",type:"button",disabled:!!A||!x.length||C,onClick:I,children:C?"Starting\u2026":`Start ${x.length} run${x.length===1?"":"s"}`})]})]}):null})}function Nd(t){return[t.task,t.id,t.repo,t.pattern,t.branchPrefix,t.source?`#${t.source.number} ${t.source.title}`:"",t.externalSource?.title??"",t.trigger?.name??"",t.group?.label??""].join(`
|
|
107
|
+
`).toLowerCase()}function Ur({host:t,onManage:s}){let[n,r]=m(null),[a,c]=m(""),[i,d]=m(!1),[l,p]=m(0),[o,u]=m(!1),[f,h]=m("");De(async v=>{d(!0);try{let k=await ds(`/api/ssh-hosts/${encodeURIComponent(t.id)}/team-server/status`);v()&&(r(k),c(""))}catch(k){v()&&(r(null),c(k.message))}finally{v()&&d(!1)}},6e4,[t.id,l]);let g=n?.state==="running"&&n.access==="ready"&&!!n.address,y=a?"Status unavailable":n?n.state==="not-installed"?"Not set up":n.state==="unavailable"?"Not responding":"Running":"Checking\u2026",C=!n||n.state!=="running"?"Not verified":g?"HTTPS enabled":n.access==="disabled"?"Not enabled":n.access==="error"?"Needs attention":"Setup incomplete",T=async()=>{if(!(o||!await Ae(`Permanently delete the team server on ${t.name}?
|
|
108
|
+
|
|
109
|
+
This stops the server and erases its shared projects, tasks, accounts, certificates and settings. Automatic startup is removed. This cannot be undone.
|
|
110
|
+
|
|
111
|
+
Repository folders and the SSH workspace stay in place.`,{title:`Delete team server on ${t.name}?`,confirmLabel:"Delete permanently",danger:!0}))){u(!0),h("");try{await ds(`/api/ssh-hosts/${encodeURIComponent(t.id)}/team-server/installation`,{method:"DELETE"}),r({state:"not-installed"}),p(v=>v+1)}catch(v){h(v.message)}finally{u(!1)}}};return e("section",{class:"settings-card ssh-team-status","aria-label":`Team server on ${t.name}`,children:[e("div",{class:"ssh-team-status-head",children:[e("div",{children:[e("p",{class:"ssh-team-eyebrow",children:"Team hosting"}),e("h2",{children:["Team server on ",t.name]})]}),e("span",{class:`badge ${n?.state==="running"?"ok":"warn"}`,role:"status",children:y})]}),e("p",{class:"help",children:["Teammates connect to the team server on ",t.name,". Your own computer does not need incoming access."]}),e("dl",{class:"ssh-team-status-facts",children:[e("div",{children:[e("dt",{children:"Secure access"}),e("dd",{children:e("span",{class:`badge ${g?"ok":"warn"}`,children:C})})]}),e("div",{children:[e("dt",{children:"Network"}),e("dd",{children:n?.network??"Not verified"})]}),e("div",{class:"ssh-team-status-address",children:[e("dt",{children:"Team address"}),e("dd",{children:g?e(M,{children:[e("code",{children:n.address}),e("button",{class:"btn small",onClick:()=>void Kt(n.address,"Team address copied"),children:"Copy address"})]}):"Not available"})]})]}),e("p",{class:"help",children:g?"Teammates need access to this network and their own team account. HTTPS is enabled on the server; connectivity from a teammate\u2019s computer has not been tested.":n?.state==="not-installed"?"Set up a team server here to share projects and create teammate accounts.":n?.state==="running"?"Open team server setup to configure secure access on this server.":"The team server\u2019s access status could not be verified. Check the SSH connection and refresh. Checking status does not start or change the server."}),a?e("p",{class:"msg err",role:"alert",children:a}):null,f?e("p",{class:"msg err",role:"alert",children:f}):null,e("div",{class:"settings-actions",children:[s?e("button",{class:"btn primary",disabled:o,onClick:s,children:n?.state==="running"?"Manage team server":"Set up team server"}):e("a",{class:"btn primary",href:"#/settings/connections/host",children:"Manage team server"}),e("button",{class:"btn",disabled:i||o,onClick:()=>p(v=>v+1),children:i?"Checking\u2026":"Refresh status"}),s&&n&&n.state!=="not-installed"?e("button",{class:"btn danger",disabled:o||i,onClick:()=>void T(),children:o?"Deleting\u2026":"Delete team server"}):null]}),s&&n?.state!=="not-installed"?e("p",{class:"help",children:"Manage team server to edit projects, repositories, secure access and accounts. To restart it, stop the server in setup, then start it again."}):null]})}var ym=Bt(()=>import("./terminal-IWAIM4DE.js").then(t=>t.TermView));function Od(){let[t,s]=m(null),[n,r]=m(""),a=async(c=()=>!0)=>{try{let i=await V("/api/team-terminals");c()&&(s(i),r(""))}catch(i){c()&&(s(null),r(i.message))}};return De(a,0,[Lt.value]),{data:t,error:n,setError:r,load:a}}var li=t=>V(`/api/team-terminals/${G(t)}`,{method:"DELETE",headers:{"content-type":"application/json"},body:"{}"});function Br({board:t}){let{data:s,error:n,setError:r,load:a}=Od(),[c,i]=m(!1),d=async p=>{if(!(!s||c)){i(!0);try{await vs("/api/team-terminals/settings",{revision:s.revision,grant:p}),await a()}catch(o){await a(),r(o.message)}finally{i(!1)}}},l=async p=>{i(!0);try{await li(p),await a()}catch(o){r(o.message)}finally{i(!1)}};return e("section",{class:"settings-card",children:[e("h3",{children:"Teammate terminals"}),e("p",{class:"help",children:"A separate permission from agent tasks. A terminal runs as your operating-system user and can access files and credentials outside the project. The project selects its starting folder; it does not sandbox commands. Grant this only to people you trust with your computer."}),e("p",{class:"help",children:"Two terminals per teammate, eight in total. Sessions close after 30 minutes without keyboard input, on access revocation, or when Code Flow stops. The app shows each terminal\u2019s output only to its creator. Detached processes and changes already made may outlive a closed terminal."}),n?e("p",{class:"msg err",role:"alert",children:n}):null,s?e(M,{children:[s.available?null:e("p",{class:"msg warn",children:"Team terminals are unavailable while filesystem restrictions are active."}),t.projects.map(p=>e(km,{project:p,saved:s.grants.find(o=>o.projectId===p.id),busy:c,save:d},p.id)),e("h4",{children:"Open teammate terminals"}),s.sessions.length?e("ul",{children:s.sessions.map(p=>e("li",{children:[p.displayName," \xB7 ",t.projects.find(o=>o.id===p.projectId)?.name??p.projectId," \xB7 ",p.repository," ",e("button",{class:"btn small danger",disabled:c,onClick:()=>void l(p.id),children:"Close terminal"})]},p.id))}):e("p",{class:"help",children:"No open teammate terminals."}),e("details",{children:[e("summary",{children:"Recent terminal activity"}),e("p",{class:"help",children:"Records opens and closes, without saving command text or output."}),e("ul",{children:s.audit.slice(-20).reverse().map((p,o)=>e("li",{children:[new Date(p.at).toLocaleString()," \xB7 ",p.session.displayName," \xB7 ",p.action," \xB7 ",p.session.repository,p.reason?` \xB7 ${p.reason}`:""]},`${p.at}-${o}`))})]})]}):e("p",{class:"help",children:"Loading terminal permissions\u2026"})]})}function km({project:t,saved:s,busy:n,save:r}){let a=()=>s??{projectId:t.id,enabled:!1,userIds:[]},[c,i]=m(a);N(()=>i(a()),[JSON.stringify(s)]);let d=t.members.filter(l=>l.userId!=="owner"&&Ne(l.role,"contributor"));return e("fieldset",{class:"team-keys",disabled:n,children:[e("legend",{children:["Terminal access \xB7 ",t.name]}),e("label",{children:[e("input",{type:"checkbox",checked:c.enabled,onChange:l=>i({...c,enabled:l.currentTarget.checked})})," Allow unrestricted host terminals for this project"]}),d.map(l=>e("label",{class:"row-inline",children:[e("input",{type:"checkbox",checked:c.userIds.includes(l.userId),onChange:p=>i({...c,userIds:p.currentTarget.checked?[...c.userIds,l.userId]:c.userIds.filter(o=>o!==l.userId)})}),l.displayName]},l.userId)),d.length?null:e("p",{class:"help",children:"Add a project contributor in Projects & access first."}),e("div",{class:"settings-actions",children:e("button",{class:"btn small primary",disabled:n||JSON.stringify(c)===JSON.stringify(s),onClick:()=>void r({...c,userIds:c.userIds.filter(l=>d.some(p=>p.userId===l))}),children:"Save terminal permissions"})})]})}function qd({board:t,project:s}){let{data:n,error:r,setError:a,load:c}=Od(),[i,d]=m(!1),[l,p]=m(""),[o,u]=m(""),f=t.projects.filter(v=>(!s||v.id===s)&&n?.grants.some(k=>k.projectId===v.id&&k.allowed)).flatMap(v=>v.repositories.map(k=>({key:`${v.id}/${k.key}`,projectId:v.id,repository:k.key,label:`${v.name} \xB7 ${k.label}`}))),h=f.find(v=>v.key===l)??f[0],g=n?.sessions.filter(v=>!s||v.projectId===s)??[],y=g.find(v=>v.id===o)??g[0],C=async(v,k,b)=>{if(!i){d(!0),a("");try{b&&await li(b);let S=await O("/api/team-terminals",{projectId:v,repository:k,cols:100,rows:24});u(S.id),await c()}catch(S){await c(),a(S.message)}finally{d(!1)}}},T=async v=>{d(!0);try{await li(v),await c()}catch(k){a(k.message)}finally{d(!1)}};return n&&!f.length&&!g.length&&!r?null:e("section",{class:"team-section",children:[e("h3",{children:"Your host terminals"}),e("p",{class:"help",children:"Commands run on the host computer using its installed tools and user permissions. Each terminal is yours; other teammates cannot attach through Code Flow. Closing this page leaves the shell open until you close it or it reaches the 30-minute input timeout."}),r?e("p",{class:"msg err",role:"alert",children:r}):null,e("div",{class:"team-actions",children:[e("label",{children:["Starting repository",e("select",{class:"field","aria-label":"Terminal starting repository",value:h?.key??"",onChange:v=>p(v.currentTarget.value),children:f.map(v=>e("option",{value:v.key,children:v.label},v.key))})]}),e("button",{class:"btn small primary",disabled:i||!h||!n?.available||(n?.sessions.length??0)>=2,onClick:()=>h&&void C(h.projectId,h.repository),children:"Open terminal"}),g.length?e("label",{children:["Open session",e("select",{class:"field","aria-label":"Your terminal session",value:y?.id??"",onChange:v=>u(v.currentTarget.value),children:g.map((v,k)=>e("option",{value:v.id,children:[v.repository," \xB7 terminal ",k+1]},v.id))})]}):null,y?e("button",{class:"btn small danger",disabled:i,onClick:()=>void T(y.id),children:"Close terminal"}):null]}),y?e("div",{class:"team-terminal-screen",children:e(ym,{id:y.id,places:[],split:!1,focused:!1,shown:!0,onFocus:()=>{},onReplace:()=>void C(y.projectId,y.repository,y.id),transport:wm(y.id)},y.id)}):e("p",{class:"help",children:"No terminal open. Python 3 PTY support is required on the host."})]})}function wm(t){let s=`/api/team-terminals/${G(t)}`;return{async input(n){let r=n.binary===void 0?"data":"binary",a=n[r]??"";for(let c of a.match(/[\s\S]{1,4096}/gu)??[])await O(`${s}/input`,{[r]:c})},resize:n=>O(`${s}/resize`,{cols:Math.min(500,Math.max(2,n.cols)),rows:Math.min(200,Math.max(1,n.rows))}),watch(n){let r=new EventSource(Qs(`${s}/events`));return r.onmessage=a=>{try{n(JSON.parse(a.data))}catch{}},r.onerror=()=>n({type:"error",status:0,message:"Terminal connection lost or access ended. Reconnecting if available\u2026"}),()=>r.close()}}}var Fr=t=>["queued","starting","running","stopping"].includes(t.state);function ci(){let[t,s]=m(null),[n,r]=m(""),a=async(c=()=>!0)=>{try{let i=await V("/api/host-execution");c()&&(s(i),r(""))}catch(i){c()&&(s(null),r(i.message))}};return De(a,0,[Lt.value]),{data:t,error:n,setError:r,load:a}}function Hr({board:t}){let{data:s,error:n,setError:r,load:a}=ci(),[c,i]=m(1),[d,l]=m(!1);N(()=>{s&&i(s.concurrency)},[s?.concurrency]);let p=async o=>{if(!s||d)return!1;l(!0),r("");try{return await vs("/api/host-execution/settings",{revision:s.revision,...o}),await a(),!0}catch(u){return await a(),r(u.message),!1}finally{l(!1)}};return e("section",{class:"settings-card",children:[e("h3",{children:"Run teammates\u2019 tasks on this computer"}),e("p",{class:"help",children:"Grant trusted teammates permission to queue agent tasks using this computer\u2019s installed CLIs and logins. Each task gets a Git worktree. Agent and test commands run with this host\u2019s permissions; a project grant is not an operating-system sandbox."}),e("p",{class:"help",children:"Map each repository above to a repository belonging to its project. Teammates can start tasks they own, see progress, cancel their requests and download checkpoints. The host owner handles agent approvals. Terminal access requires a separate grant below."}),n?e("p",{class:"msg err",role:"alert",children:n}):null,s?e(M,{children:[s.available?null:e("p",{class:"msg warn",children:"Host execution is unavailable while filesystem restrictions are active."}),e("div",{class:"settings-actions",children:[e("label",{children:["Concurrent host tasks",e("input",{class:"field",type:"number",min:1,max:4,value:c,onInput:o=>i(Number(o.currentTarget.value))})]}),e("button",{class:"btn small",disabled:d||c===s.concurrency||!Number.isInteger(c)||c<1||c>4,onClick:()=>void p({concurrency:c}),children:"Save queue limit"})]}),t.projects.map(o=>e(Cm,{project:o,saved:s.policies.find(u=>u.projectId===o.id),busy:d,save:p},o.id)),t.projects.length?null:e("p",{class:"help",children:"Create a project and teammate accounts to grant execution."})]}):e("p",{class:"help",children:"Loading host execution settings\u2026"})]})}function Cm({project:t,saved:s,busy:n,save:r}){let a=()=>s??{projectId:t.id,enabled:!1,userIds:[],agent:"codex",trust:"standard",maxMinutes:30,maxSteps:20},[c,i]=m(a);N(()=>i(a()),[JSON.stringify(s)]);let d=t.members.filter(p=>p.userId!=="owner"&&Ne(p.role,"contributor")),l=p=>i({...c,...p});return e("fieldset",{class:"team-keys",disabled:n,children:[e("legend",{children:t.name}),e("label",{children:[e("input",{type:"checkbox",checked:c.enabled,onChange:p=>l({enabled:p.currentTarget.checked})})," Allow host execution for this project"]}),e("div",{class:"settings-grid",children:[e("label",{children:["Host CLI",e("select",{"aria-label":"Host CLI",class:"field",value:c.agent,onChange:p=>l({agent:p.currentTarget.value}),children:[e("option",{value:"codex",children:"Codex"}),e("option",{value:"claude",children:"Claude Code"}),e("option",{value:"agy",children:"Antigravity"})]})]}),e("label",{children:["Agent permissions",e("select",{"aria-label":"Agent permissions",class:"field",value:c.trust,onChange:p=>l({trust:p.currentTarget.value}),children:[e("option",{value:"safe",children:"Safe"}),e("option",{value:"standard",children:"Standard"})]})]}),e("label",{children:["Minutes per task",e("input",{class:"field",type:"number",min:1,max:120,value:c.maxMinutes,onInput:p=>l({maxMinutes:Number(p.currentTarget.value)})})]}),e("label",{children:["Steps per task",e("input",{class:"field",type:"number",min:1,max:100,value:c.maxSteps,onInput:p=>l({maxSteps:Number(p.currentTarget.value)})})]})]}),e("p",{class:"help",children:"Choose which project contributors may use this computer:"}),d.map(p=>e("label",{class:"row-inline",children:[e("input",{type:"checkbox",checked:c.userIds.includes(p.userId),onChange:o=>l({userIds:o.currentTarget.checked?[...c.userIds,p.userId]:c.userIds.filter(u=>u!==p.userId)})}),p.displayName]},p.userId)),d.length?null:e("p",{class:"help",children:"Give a teammate the contributor or maintainer role in Projects & access first."}),e("div",{class:"settings-actions",children:e("button",{class:"btn small primary",disabled:n||JSON.stringify(c)===JSON.stringify(s),onClick:()=>void r({policy:{...c,userIds:c.userIds.filter(p=>d.some(o=>o.userId===p))}}),children:"Save host permissions"})})]})}function Ud({task:t,meId:s}){let{data:n,error:r,setError:a,load:c}=ci(),[i,d]=m(!1),l=n?.policies.find(h=>h.projectId===t.projectId),p=n?.jobs.filter(h=>h.taskId===t.id)??[],o=[...p].reverse().find(Fr)??p.at(-1),u=n?.available&&l?.allowed&&t.owner?.userId===s,f=async(h,g)=>{if(!i){d(!0),a("");try{await O(h,g),await c()}catch(y){a(y.message)}finally{d(!1)}}};return e("div",{class:"team-section",children:[e("h3",{children:"Host computer"}),r?e("p",{class:"msg err",role:"alert",children:r}):null,o?e("p",{role:"status",children:[o.state==="queued"?"Queued for the host computer":`Host task: ${o.state}`," \xB7 requested by ",o.displayName,o.message?` \xB7 ${o.message}`:""]}):null,u&&!p.some(Fr)?e("button",{class:"btn small primary",disabled:i||t.status==="done"||t.attempts.some(h=>["claimed","running","unknown"].includes(h.state))||t.handoff?.state==="offered",onClick:()=>void f(`/api/host-execution/tasks/${G(t.id)}`,{revision:t.revision}),children:"Run on host computer"}):null,o&&Fr(o)&&o.userId===s?e("button",{class:"btn small",disabled:i||o.state==="stopping",onClick:()=>void f(`/api/host-execution/jobs/${G(o.id)}/cancel`,{}),children:o.state==="queued"?"Remove from queue":"Stop host task"}):null,e("p",{class:"help",children:l?.allowed?`Uses ${l.agent} on the host. Your browser can close after queuing. Progress and downloadable checkpoints appear on this task.`:"The host owner can grant execution in Settings \u2192 Team. You can also run this task from your own linked Code Flow installation."}),l?.allowed&&t.owner?.userId!==s?e("p",{class:"help",children:"Take ownership of this task to queue it on the host."}):null]})}function Wr({board:t,project:s}){let{data:n,error:r,setError:a,load:c}=ci(),[i,d]=m(""),l=(n?.jobs??[]).filter(o=>(!s||o.projectId===s)&&Fr(o)),p=async o=>{d(o.id);try{await O(`/api/host-execution/jobs/${G(o.id)}/cancel`,{}),await c()}catch(u){a(u.message)}finally{d("")}};return e("section",{class:"team-section","aria-label":"Host execution queue",children:[e("h3",{children:"Host queue"}),r?e("p",{class:"msg err",role:"alert",children:r}):null,!n&&!r?e("p",{class:"help",children:"Loading\u2026"}):l.length?e("ol",{children:l.map(o=>e("li",{children:[e("a",{href:`#/team/task/${G(o.taskId)}`,children:t.tasks.find(u=>u.id===o.taskId)?.title??o.taskId})," \xB7 ",o.state," \xB7 ",o.displayName,o.message?` \xB7 ${o.message}`:""," ",(t.me.userId==="owner"||t.me.userId===o.userId)&&o.state!=="stopping"?e("button",{class:"btn small",disabled:!!i,onClick:()=>void p(o),children:o.state==="queued"?"Remove":"Stop"}):null]},o.id))}):e("p",{class:"help",children:"No host tasks queued or running."}),n?e("p",{class:"help",children:["Up to ",n.concurrency," host task",n.concurrency===1?"":"s"," at a time, in queue order. You see tasks in your projects."]}):null]})}function Bd(t){if(!t||typeof t!="object"||Array.isArray(t))return"Expected a task draft object";let s=t;if(Object.keys(s).some(n=>!["title","goal","acceptance"].includes(n)))return"Unexpected task draft field";for(let[n,r]of[["title",200],["goal",16384],["acceptance",8192]]){let a=s[n];if(typeof a!="string"||!a.trim()||a.length>r||a.includes("\0"))return`Draft ${n} must contain 1\u2013${r} characters`}}function Fd({projectId:t,repository:s,baseRef:n,onBusy:r,onApply:a}){let c=Re.value.filter(P=>P.available),[i,d]=m(c[0]?.id??""),[l,p]=m(""),[o,u]=m(fs.value?.mappings[t]?.[s]??""),[f,h]=m(""),[g,y]=m(!1),[C,T]=m(!1),[v,k]=m(""),[b,S]=m(),x=Z(!0),w=Z(r);w.current=r,N(()=>{!i&&c[0]&&d(c[0].id)},[i,Re.value]),N(()=>(x.current=!0,()=>{x.current=!1}),[]),N(()=>{if(!g||!f)return;let P=!0,D,I=async()=>{try{let $=await V(`/api/runs/${G(f)}`);if(!P)return;if($.status==="running"){k(""),D=setTimeout(I,1500);return}if($.status!=="done")throw new Error($.error||$.stopReason||`Draft ${$.status}. Open the drafting run for details, or try again.`);let E;try{E=JSON.parse($.summary??"")}catch{throw new Error("The agent did not return a usable draft. Try again or create the task manually.")}let L=Bd(E);if(L)throw new Error(L);S(E),k(""),y(!1),w.current(!1)}catch($){if(!P)return;k($.message);let E=$.status;if(E===0||E!==void 0&&E>=500){D=setTimeout(I,3e3);return}y(!1),w.current(!1)}};return I(),()=>{P=!1,clearTimeout(D)}},[f,g]);let j=async()=>{if(!(g||!l.trim())){y(!0),r(!0),k(""),S(void 0),h("");try{let P=await O("/api/team-link/draft",{projectId:t,repository:s,idea:l,agent:i,repo:o.trim(),baseRef:n,agentSettings:Be.value});x.current&&h(P.runId)}catch(P){x.current&&(k(P.message),y(!1),r(!1))}}},A=async()=>{T(!0);try{await O(`/api/runs/${G(f)}/cancel`,{})}catch(P){k(P.message)}finally{T(!1)}};return e("section",{class:"team-section team-draft-assistant","aria-label":"Draft with agent",children:[e("h3",{children:"Draft with agent"}),e("p",{class:"help",children:"Describe your idea. An agent reads the selected repository and proposes a goal, scope, plan and acceptance criteria. Review the draft before creating a shared task. Limit: 5 minutes and 2 agent calls."}),e("label",{children:["Idea",e("textarea",{class:"field",rows:3,maxLength:16384,value:l,disabled:g,onInput:P=>p(P.currentTarget.value)})]}),e("label",{children:["Drafting agent",e("select",{class:"field",value:i,disabled:g,onChange:P=>d(P.currentTarget.value),children:[e("option",{value:"",disabled:!0,children:"Choose an installed agent"}),c.map(P=>e("option",{value:P.id,children:P.displayName},P.id))]})]}),e("label",{children:["Repository folder",e("input",{class:"field mono",value:o,disabled:g,placeholder:"/absolute/path/to/your/clone",onInput:P=>u(P.currentTarget.value)})]}),e("button",{type:"button",class:"btn small",disabled:g||!ee.value,onClick:()=>u(ee.value),children:"Use current repository"}),c.length?null:e("p",{class:"help",children:"Install and sign in to an agent on this computer to draft tasks. You can still create a task manually."}),e("div",{class:"team-actions",children:[e("button",{type:"button",class:"btn",disabled:g||!l.trim()||!o.trim()||!s||!c.some(P=>P.id===i),onClick:()=>void j(),children:g?"Drafting\u2026":b?"Generate again":"Generate draft"}),g&&f?e("button",{type:"button",class:"btn",disabled:C,onClick:()=>void A(),children:C?"Stopping\u2026":"Stop drafting"}):null,f?e("a",{href:`#/run/${G(f)}`,target:"_blank",rel:"noopener",children:"Open drafting run"}):null]}),g?e("p",{class:"help",role:"status",children:"The agent is reading repository context and preparing your draft."}):null,v?e("p",{class:"msg err",role:"alert",children:v}):null,b?e("div",{class:"team-draft-preview",children:[e("h4",{children:b.title}),e("p",{class:"team-comment-text",children:b.goal}),e("h4",{children:"Acceptance criteria"}),e("p",{class:"team-comment-text",children:b.acceptance}),e("button",{type:"button",class:"btn primary",onClick:()=>a(b),children:"Use draft in form"}),e("p",{class:"help",children:"This replaces the title, goal and acceptance fields. You can edit them before saving."})]}):null]})}function sa({project:t,shared:s=!1,embedded:n=!1,navigate:r}){let[a,c]=m(!1),[i,d]=m(""),[l,p]=m(!1),[o,u]=m(Date.now());De(()=>{xt(),s||_s(),u(Date.now())},s?0:15e3,[Lt.value,s]),De(()=>u(Date.now()),15e3,[],s);let f=Xe.value,h=!s&&f.kind==="ssh"?f:null,g=Jt.value,y=t;if(!g)return e("div",{class:"team-page","aria-busy":!gl.value,children:[!s&&!h&&!n?e(os,{}):null,rs.value?e("p",{class:"msg err",role:"alert",children:[rs.value," ",e("button",{class:"btn small",onClick:()=>void xt(),children:"Retry"})]}):e("p",{class:"help",role:"status",children:"Loading the team board\u2026"})]});if(t&&!g.projects.some(A=>A.id===t))return e("div",{class:"team-page",children:[e("p",{role:"alert",children:"This project is unavailable on this board. Choose a project you have access to."}),e("button",{class:"btn",onClick:()=>r({view:"team"}),children:"All board projects"})]});let C=g.me.userId,T=A=>A.owner?.userId===C||A.reviewer?.userId===C||A.collaborators.some(P=>P.userId===C)||A.handoff?.state==="offered"&&A.handoff.to.userId===C,v=g.tasks.filter(A=>!y||A.projectId===y),k=v.filter(A=>(!a||T(A))&&(!i||A.status===i)),b=g.projects.some(A=>Ne(A.role,"contributor")&&(!y||A.id===y)),S=i?[i]:Vn,x=A=>g.projects.find(P=>P.id===A.projectId),w=A=>{let P=k.filter(D=>D.status===A).sort((D,I)=>I.updatedAt-D.updatedAt);return e("section",{class:"team-column","aria-labelledby":`team-col-${A}`,children:[e("h2",{id:`team-col-${A}`,children:[Vs[A],e("span",{class:"team-count",children:P.length})]}),P.map(D=>e(Tm,{task:D,me:C,project:y?void 0:x(D),now:o,onOpen:()=>r({view:"team-task",id:D.id})},D.id)),P.length?null:e("p",{class:"team-column-empty",children:"No tasks"})]},A)},j=fs.value;return e("div",{class:"team-page",children:[!s&&!h&&!n?e(os,{}):null,rs.value?e("p",{class:"msg err",role:"alert",children:rs.value}):null,e("div",{class:"page-head",children:[e("div",{class:"page-head-text",children:[n?e("h2",{children:"Board"}):e("h1",{children:"Board"}),e("p",{children:h?`Tasks, ownership and reviews on ${h.name}.`:y?`${g.projects.find(A=>A.id===y)?.name??"This project"} \xB7 Tasks, ownership, and reviews in one place.`:"Shared tasks, ownership, and reviews in one place."})]}),e("div",{class:"page-head-actions",children:[e("button",{class:"btn",onClick:()=>r({view:"team-people",...y?{project:y}:{}}),children:"People"}),b?e("button",{type:"button",class:"btn primary","aria-expanded":!!l,disabled:!!l,onClick:()=>p("manual"),children:[e(K,{name:"plus"})," New task"]}):null,b&&!s?e("button",{type:"button",class:"btn",disabled:!!l,onClick:()=>p("agent"),children:"Draft with agent"}):null]})]}),h&&!n?e(M,{children:[e(Ur,{host:h},h.id),e("div",{class:"team-board-context",children:[e("strong",{children:["Viewing this computer\u2019s board \xB7 ",h.name]}),e("p",{children:"Tasks below belong to this computer. To use the shared team board, connect your computer with the team address and account from team server setup."})]})]}):null,s?e(qd,{board:g,project:y}):null,!h&&(s||j&&!j.linked)?e(Wr,{board:g,project:y}):null,!s&&!h&&j&&!j.linked&&!g.tasks.length?e("div",{class:"settings-callout team-callout",children:[e(K,{name:"people"}),e("div",{children:[e("strong",{children:"Not connected to a team server"}),e("p",{children:"Connect this computer in Connections \u2192 Share access to work on a shared board, or create tasks here to use this computer as the team server."}),e("a",{href:"#/settings/connections/sharing",children:["Open Connections \u2192 Share access ",e("span",{"aria-hidden":"true",children:"\u2192"})]})]})]}):null,g.projects.length>1||y?e("div",{class:"team-chips",role:"group","aria-label":"Project",children:[e("button",{type:"button",class:"chip-tpl","aria-pressed":!y,onClick:()=>r({view:"team"}),children:"All projects"}),g.projects.map(A=>e("button",{type:"button",class:"chip-tpl","aria-pressed":y===A.id,onClick:()=>r({view:"team",project:A.id}),children:A.name},A.id))]}):null,l&&b?e(Sm,{b:g,projectId:y,shared:s,draftWithAgent:l==="agent",onDone:A=>{let P=l==="agent";p(!1),xt(),P&&r({view:"team-task",id:A.id})},onCancel:()=>p(!1)},y??""):null,e("div",{class:"team-toolbar",children:[e("div",{class:"segmented small",role:"group","aria-label":"Whose tasks",children:[e("button",{type:"button",class:a?"":"on","aria-pressed":!a,onClick:()=>c(!1),children:"All"}),e("button",{type:"button",class:a?"on":"","aria-pressed":a,onClick:()=>c(!0),children:"Mine"})]}),e("label",{class:"team-filter",children:["Status",e("select",{class:"field",value:i,onChange:A=>d(A.currentTarget.value),children:[e("option",{value:"",children:"All statuses"}),Vn.map(A=>e("option",{value:A,children:Vs[A]},A))]})]}),e("span",{class:"help",role:"status",children:[k.length," of ",v.length," tasks",a?" involve you":""]})]}),g.projects.length?null:e("p",{class:"team-empty",children:s?"You have no role in a shared project yet. Ask the owner for one.":"Create a project first: the board's tasks belong to projects, and teammates see the projects their accounts have a role in."}),e("div",{class:"team-board",children:[k.length?e("div",{class:`team-columns ${S.length===1?"single":""}`,children:S.map(w)}):e("section",{class:"team-board-empty","aria-label":"Task board",children:[e("div",{class:"team-workflow","aria-label":"Task workflow",children:Vn.map(A=>e("span",{children:[Vs[A],e("span",{class:"team-count",children:v.filter(P=>P.status===A).length})]},A))}),e("div",{class:"team-board-empty-body",children:[e(K,{name:"people"}),e("h2",{children:v.length?"No tasks match these filters":"Your board is ready for its first task"}),e("p",{children:v.length?"Try another status or show everyone\u2019s tasks.":"Give a task a goal and an owner. Follow its progress here, from planning through review to done."}),a||i?e("button",{class:"btn",onClick:()=>{c(!1),d("")},children:"Clear filters"}):b?e("button",{class:"btn primary",disabled:!!l,onClick:()=>p("manual"),children:[e(K,{name:"plus"})," Create first task"]}):e("p",{class:"help",children:s?"Ask your project maintainer for access to create tasks.":"Add a project to start creating tasks."})]})]}),e(xm,{shared:s,navigate:r})]})]})}function Tm({task:t,me:s,project:n,now:r,onOpen:a}){let c=t.attempt,i=c?sr(c,r):!1,d=c?nr(c,r):!1,l=t.handoff?.state==="offered"&&t.handoff.to.userId===s,p=(t.unreadMentions??0)>0||l;return e("button",{type:"button",class:`team-card ${p?"needs-you":""}`,onClick:a,children:[e("span",{class:"tc-title",children:t.title}),e("span",{class:"tc-meta",children:[t.owner?e(M,{children:[e("span",{class:"team-avatar","aria-hidden":"true",children:va(t.owner.displayName)}),e("span",{children:Ft(t.owner,s)})]}):e("span",{children:"Unassigned"}),e("code",{children:t.repository}),n?e("span",{children:n.name}):null]}),c?e("span",{class:`tc-attempt ${d?"team-stale":i?"team-live":""}`,children:[i?e("span",{class:"dot running","aria-hidden":"true"}):null,d?`Connection lost \xB7 ${c.runnerName}`:`${er[c.state]} on ${c.runnerName}`,c.progress.stage&&!d?` \xB7 ${c.progress.stage}`:""]}):null,e("span",{class:"pills",children:[t.reviewer?e("span",{class:"badge",children:["Reviewer ",t.reviewer.userId===s?"you":t.reviewer.displayName]}):null,t.reviewState==="approved"?e("span",{class:"badge ok",children:"Approved"}):t.reviewState==="changes-requested"?e("span",{class:"badge warn",children:"Changes requested"}):t.reviewState==="pending"?e("span",{class:"badge",children:"Review pending"}):null,t.handoff?.state==="offered"?e("span",{class:"badge warn",children:["Hand-over to ",Ft(t.handoff.to,s)]}):null,t.blocker?e("span",{class:"badge warn",title:t.blocker,children:"Blocked"}):null,p?e("span",{class:"badge warn",children:"Needs you"}):null]})]})}function Sm({b:t,projectId:s,shared:n,draftWithAgent:r,onDone:a,onCancel:c}){let i=t.projects.filter(W=>Ne(W.role,"contributor")),[d,l]=m(s&&i.some(W=>W.id===s)?s:i[0]?.id??""),p=i.find(W=>W.id===d),[o,u]=m(""),[f,h]=m(p?.repositories[0]?.key??""),[g,y]=m(""),[C,T]=m(""),[v,k]=m(""),[b,S]=m(""),[x,w]=m(""),[j,A]=m(!1),[P,D]=m(!1),[I,$]=m(!!r),[E,L]=m(!1),H=j||P,[Q,le]=m("");N(()=>{h(p?.repositories[0]?.key??""),S(r?t.me.userId:""),w("")},[d]);let de=Ne(p?.role,"maintainer"),ue=p?.members??[],q=ue.filter(W=>Ne(W.role,"contributor")&&(de||W.userId===t.me.userId)),te=ue.filter(W=>Ne(W.role,"reviewer")),me=async W=>{if(W.preventDefault(),!(H||!p)){A(!0),le("");try{let re=await O("/api/team/tasks",{projectId:d,repository:f,title:o.trim(),goal:g,acceptance:C,...v.trim()?{baseRef:v.trim()}:{},...b?{owner:b}:{},...x?{reviewer:x}:{}});J("Task created"),a(re)}catch(re){le(re.message)}finally{A(!1)}}};return e("form",{id:"team-new",class:"team-section team-new","aria-labelledby":"team-new-title",onSubmit:W=>void me(W),children:[e("h2",{id:"team-new-title",children:"New task"}),E?e("p",{class:"help",role:"status",children:"Draft applied. Review and edit the fields, then create the task."}):null,e("div",{class:"team-fields",children:[i.length>1?e("label",{children:["Project",e("select",{class:"field",value:d,disabled:H,onChange:W=>l(W.currentTarget.value),children:i.map(W=>e("option",{value:W.id,children:W.name},W.id))})]}):null,e("label",{children:["Repository",e("select",{class:"field",required:!0,value:f,disabled:H||!p?.repositories.length,onChange:W=>h(W.currentTarget.value),children:p?.repositories.map(W=>e("option",{value:W.key,children:[W.label," (",W.key,")"]},W.key))})]}),e("label",{children:["Base branch",e("input",{class:"field",maxLength:100,placeholder:p?.repositories.find(W=>W.key===f)?.defaultBranch??"The repository's default branch",value:v,disabled:H,onInput:W=>k(W.currentTarget.value)})]})]}),p&&!p.repositories.length?e("p",{class:"msg warn",role:"status",children:[p.name," has no repository keys yet. A maintainer defines repository keys in Connections \u2192 Share access",!n&&de?e(M,{children:[": ",e("a",{href:"#/settings/connections/manage",children:"open Connections \u2192 Share access"})]}):null,"."]}):null,!n&&I?e(Fd,{projectId:d,repository:f,baseRef:v,onBusy:D,onApply:W=>{u(W.title),y(W.goal),T(W.acceptance),$(!1),L(!0)}},`${d}/${f}`):null,e("div",{class:"team-fields",children:[e("label",{children:["Title",e("input",{class:"field",required:!0,maxLength:200,value:o,disabled:H,onInput:W=>u(W.currentTarget.value)})]}),e("label",{children:["Owner",e("select",{class:"field",value:b,disabled:H,onChange:W=>S(W.currentTarget.value),children:[e("option",{value:"",children:"Unassigned"}),q.map(W=>e("option",{value:W.userId,children:W.userId===t.me.userId?`${W.displayName} (you)`:W.displayName},W.userId))]})]}),e("label",{children:["Reviewer",e("select",{class:"field",value:x,disabled:H,onChange:W=>w(W.currentTarget.value),children:[e("option",{value:"",children:"None yet"}),te.map(W=>e("option",{value:W.userId,children:W.userId===t.me.userId?`${W.displayName} (you)`:W.displayName},W.userId))]})]})]}),e("label",{class:"team-wide",children:["Goal",e("textarea",{class:"field",rows:4,maxLength:16384,placeholder:"What should be true when this task is done, and why it matters",value:g,disabled:H,onInput:W=>y(W.currentTarget.value)})]}),e("label",{class:"team-wide",children:["Acceptance criteria",e("textarea",{class:"field",rows:3,maxLength:8192,placeholder:"How a reviewer will check the result",value:C,disabled:H,onInput:W=>T(W.currentTarget.value)})]}),Q?e("p",{class:"msg err",role:"alert",children:Q}):null,e("div",{class:"team-actions",children:[e("button",{type:"submit",class:"btn primary",disabled:H||!p?.repositories.length||!o.trim(),children:j?"Creating\u2026":"Create task"}),e("button",{type:"button",class:"btn",disabled:H,onClick:c,children:"Cancel"})]})]})}function xm({shared:t,navigate:s}){let[n,r]=m(null),[a,c]=m(""),[i,d]=m(!1);De(async u=>{try{let f=await ga();u()&&(r(f.items),c(""))}catch(f){u()&&c(f.message)}},t?0:15e3,[Lt.value]),N(()=>{if(!Wn.value)return;Wn.value=!1;let u=document.getElementById("team-inbox-title");u?.scrollIntoView({block:"start"}),u?.focus()},[Wn.value]);let l=async u=>{if(!i){d(!0);try{await bl(u);let f=await ga();r(f.items),xt()}catch(f){c(f.message)}finally{d(!1)}}},p=Hn.value,o=(n??[]).slice().sort((u,f)=>+!!u.readAt-+!!f.readAt||f.at-u.at);return e("section",{class:"team-inbox","aria-labelledby":"team-inbox-title",children:[e("div",{class:"team-inbox-head",children:[e("h2",{id:"team-inbox-title",tabIndex:-1,children:["Inbox",p?e("span",{class:"team-count warn",children:p}):null]}),p?e("button",{type:"button",class:"btn small",disabled:i,onClick:()=>void l("all"),children:"Mark all read"}):null]}),a?e("p",{class:"msg err",role:"alert",children:a}):null,n===null&&!a?e("p",{class:"help",role:"status",children:"Loading\u2026"}):null,n&&!n.length?e("p",{class:"pp-empty",children:"Nothing yet. Assignments, mentions, review requests and hand-overs land here."}):null,o.map(u=>e("div",{class:`team-inbox-item ${u.readAt?"":"is-unread"}`,children:[e("button",{type:"button",class:"ti-open",onClick:()=>{u.readAt||l([u.id]),s({view:"team-task",id:u.taskId})},children:[e("span",{class:"ti-title",children:[Sl[u.kind]??u.kind,u.readAt?"":e("span",{class:"sr-only",children:" (unread)"})," \xB7 ",u.taskTitle]}),e("span",{class:"ti-text",children:u.text}),e("span",{class:"ti-meta",children:[u.by.displayName," \xB7 ",pt(u.at)]})]}),u.readAt?null:e("button",{type:"button",class:"btn small ghost",disabled:i,"aria-label":`Mark read: ${u.taskTitle}`,onClick:()=>void l([u.id]),children:"Mark read"})]},u.id))]})}var Rm=/(?<![A-Za-z0-9_.@-])@([A-Za-z0-9][A-Za-z0-9._-]{0,63})/g;function Hd(t,s){let n=new Map(s.map(c=>[c.username.toLowerCase(),c])),r=[],a=0;for(let c of t.matchAll(Rm)){let i=c[1].toLowerCase();for(;i&&!n.has(i)&&/[._-]$/.test(i);)i=i.slice(0,-1);let d=n.get(i);if(!d)continue;let l=c.index,p=l+1+i.length;l>a&&r.push(t.slice(a,l)),r.push(e("strong",{class:"team-mention",title:d.displayName,children:t.slice(l,p)},l)),a=p}return a<t.length&&r.push(t.slice(a)),r}function _r({id:t,shared:s=!1,navigate:n}){let[r,a]=m(null),[c,i]=m(""),[d,l]=m(""),[p,o]=m(Date.now()),[u,f]=m(null),[h,g]=m(null),y=xn(),C=async()=>{let ne=y();try{let _=await vl(t);ne()&&(a(_),i(""),gs.value=_)}catch(_){ne()&&(a(null),gs.value=null,f(null),g(null),i(_.message))}};De(()=>{C(),xt(),s||(_s(),mn()),o(Date.now())},s?0:15e3,[t,Lt.value,s]),De(()=>o(Date.now()),15e3,[],s),N(()=>((document.getElementById("main-content")??window).scrollTo({top:0}),()=>{gs.value?.id===t&&(gs.value=null)}),[t]);let T=async(ne,_,ie)=>{if(d)return!1;l(ne),i("");try{let Te=await _();return Te&&typeof Te=="object"&&"id"in Te&&(a(Te),gs.value=Te),ie?.(),!0}catch(Te){return Te instanceof st&&Te.status===409?(J("Task changed; reloading",3e3),await C()):(Te instanceof st&&[401,403,404].includes(Te.status)&&(a(null),gs.value=null,f(null),g(null),xt()),i(Te.message)),!1}finally{l("")}},v=Jt.value;if(!r)return e("div",{class:"team-page",children:[s?null:e(os,{}),c?e("p",{class:"msg err",role:"alert",children:[c," ",e("button",{class:"btn small",onClick:()=>void C(),children:"Retry"})," ",e("button",{class:"btn small",onClick:()=>n({view:"team"}),children:"Back to the board"})]}):e("p",{class:"help",role:"status",children:"Loading the task\u2026"})]});let k=v?.me.userId,b=v?.projects.find(ne=>ne.id===r.projectId),S=b?.role??(k==="owner"?"maintainer":v?.me.roles[r.projectId]),x=b?.members??[],w=Ne(S,"contributor"),j=Ne(S,"reviewer"),A=Ne(S,"maintainer"),P=!!k&&r.owner?.userId===k,D=$l(r),I=Rl(r),$=Al(r),E=r.handoff?.state==="offered"?r.handoff:void 0,L=!!E&&E.to.userId===k,H=!!E&&E.from.userId===k,Q=fs.value,le=!s&&P&&Q!==null,de=D?Za.value.find(ne=>ne.attemptId===D.id):void 0,ue=!!D&&!!de&&Il(D,r),q=(ne,_="Saving\u2026")=>T(_,()=>vs(`/api/team/tasks/${G(t)}`,{revision:r.revision,...ne})),te=ne=>E&&T(ne==="decline"?"Declining\u2026":"Cancelling\u2026",()=>O(`/api/team/tasks/${G(t)}/handoff/${G(E.id)}`,{action:ne,revision:r.revision}),()=>J(ne==="decline"?"Hand-over declined":"Hand-over cancelled")),me=(ne,_,ie,Te)=>T(ie,async()=>{await O(`/api/team-link/tasks/${G(t)}${ne}`,_)},()=>{J(Te),C(),mn()}),W=D?nr(D,p):!1,re=D?sr(D,p):!1;return e("div",{class:"team-page team-task",children:[s?null:e(os,{}),e("nav",{class:"team-back","aria-label":"Team board",children:e("a",{href:s?"#/team":`#/team/project/${G(r.projectId)}`,onClick:ne=>{ne.preventDefault(),n({view:"team",project:r.projectId})},children:[e(K,{name:"chevron",class:"back"})," ",b?.name??"Team board"]})}),e($m,{task:r,role:S,meId:k,members:x,canEdit:w,maintainer:A,busy:d,save:q,act:T,navigate:n}),c?e("p",{class:"msg err",role:"alert",children:c}):null,d?e("p",{class:"help",role:"status",children:d}):null,e("div",{class:"team-task-layout",children:[e("div",{class:"team-main",children:[e(Im,{task:r,canEdit:w,busy:d,save:q}),e("section",{class:"team-section","aria-labelledby":"tt-exec",children:[e("h2",{id:"tt-exec",children:"Execution"}),D?e(Am,{attempt:D,meId:k,live:re,stale:W}):e("p",{class:"help",children:["No attempt yet.",r.owner?"":" Take the task to run it on your computer."]}),e("div",{class:"team-actions",children:[de?.runId?e("a",{class:"btn small",href:`#/run/${G(de.runId)}`,children:"Open run"}):null,le?e(M,{children:[L?e(M,{children:[e("button",{type:"button",class:"btn small primary",disabled:!!d,onClick:()=>f("accept"),children:"Accept and download"}),e("button",{type:"button",class:"btn small",disabled:!!d,onClick:()=>void te("decline"),children:"Decline"})]}):null,!E&&!I&&r.status!=="done"?e("button",{type:"button",class:"btn small primary",disabled:!!d,onClick:()=>f("start"),children:"Build with agents"}):null,I&&de?e("button",{type:"button",class:"btn small",disabled:!!d,onClick:async()=>{await Ae("Stop the attempt running on this computer? Its run can be resumed later and its work is kept.",{title:"Stop this attempt?",confirmLabel:"Stop attempt",danger:!0})&&me("/stop",{},"Stopping\u2026","Attempt stopped")},children:"Stop"}):null,ue?e("button",{type:"button",class:"btn small",disabled:!!d,onClick:()=>void me("/resume",{},"Resuming\u2026","Attempt resumed"),children:"Resume"}):null,!E&&!I?e("button",{type:"button",class:"btn small",disabled:!!d,onClick:()=>f("handover"),children:"Hand over\u2026"}):null]}):null,D?.state==="unknown"&&(P&&w||A)?e("button",{type:"button",class:"btn small",disabled:!!d,onClick:()=>f("recover"),children:"Recover attempt\u2026"}):null,E&&!le&&L?e("button",{type:"button",class:"btn small",disabled:!!d,onClick:()=>void te("decline"),children:"Decline hand-over"}):null,E&&(H||A)?e("button",{type:"button",class:"btn small",disabled:!!d,onClick:async()=>{await Ae("Cancel this hand-over? The task stays with its current owner.",{title:"Cancel hand-over?",confirmLabel:"Cancel hand-over",danger:!0})&&te("cancel")},children:"Cancel hand-over"}):null,!r.owner&&w&&k?e("button",{type:"button",class:"btn small",disabled:!!d||!!rr(r,S,k),title:rr(r,S,k),onClick:()=>void q({owner:k},"Taking the task\u2026"),children:"Take this task"}):null]}),E?e("p",{class:"msg warn",role:"status",children:["Hand-over offered to ",Ft(E.to,k)," by ",Ft(E.from,k)," ",pt(E.offeredAt),E.note?`: ${E.note}`:""]}):null,s?e(Ud,{task:r,meId:k},r.id):null,!s&&P&&Q===null?e("p",{class:"help",children:"This computer's team link is not available here, so the task cannot be run from this page."}):null]}),e(jm,{task:r,latest:$,meId:k,canEdit:w,maintainer:A,shared:s,busy:d,act:T,onFetch:g,reload:C}),e(Pm,{task:r,latest:$,meId:k,members:x,canEdit:w,canComment:j,busy:d,act:T}),e(Dm,{task:r,meId:k,members:x,canEdit:w,canComment:j,isOwner:P,maintainer:A,busy:d,act:T})]}),e("div",{class:"team-aside",children:[e(Em,{task:r,role:S,meId:k,members:x,canEdit:w,busy:d,save:q}),e(Lm,{task:r,canEdit:w,busy:d,act:T}),e("details",{class:"team-section team-history",children:[e("summary",{children:["History ",e("span",{class:"team-count",children:r.audit.length})]}),e("ol",{children:r.audit.slice().reverse().map((ne,_)=>e("li",{children:[e("span",{class:"th-when",children:tr(ne.at)})," ",e("strong",{children:ne.by.displayName})," ",ne.action,ne.detail?e("span",{class:"th-detail",children:[" \u2014 ",ne.detail]}):null]},`${ne.at}-${_}`))})]})]})]}),u==="start"?e(Nm,{task:r,checkpoint:$,onClose:()=>f(null),onStarted:()=>{f(null),J("Agents started on this computer"),C(),mn()}}):null,u==="handover"&&k?e(qm,{task:r,meId:k,members:x,onClose:()=>f(null),onDone:()=>{f(null),J("Hand-over offered"),C()}}):null,u==="recover"&&D?.state==="unknown"?e(Om,{task:r,attempt:D,onClose:()=>f(null),onDone:()=>{f(null),J("Attempt recovered"),C(),mn()}}):null,u==="accept"&&E?e(Wd,{title:"Accept and download",help:`The checkpoint is downloaded into your clone of ${r.repository} before the task becomes yours; a failed download changes nothing.`,action:"Accept and download",initial:Q?.mappings[r.projectId]?.[r.repository]??"",onClose:()=>f(null),submit:async ne=>{await O(`/api/team-link/tasks/${G(t)}/accept`,{handoffId:E.id,...ne?{repo:ne}:{}}),f(null),J("Hand-over accepted"),C()}}):null,h?e(Wd,{title:"Fetch to this computer",help:`Imports checkpoint ${Js(h.commit)} into the repository below as a branch; nothing is checked out.`,action:"Fetch",initial:Q?.mappings[r.projectId]?.[r.repository]??"",required:!0,onClose:()=>g(null),submit:async ne=>{let _=await O(`/api/team-link/checkpoints/${G(h.id)}/fetch`,{repo:ne});g(null),J(`Fetched as branch ${_.branch}`,5e3)}}):null]})}function $m({task:t,role:s,meId:n,members:r,canEdit:a,maintainer:c,busy:i,save:d,act:l,navigate:p}){let[o,u]=m(!1),[f,h]=m(t.title),[g,y]=m(!1),[C,T]=m(t.blocker??"");N(()=>{o||h(t.title)},[t.title,o]),N(()=>{g||T(t.blocker??"")},[t.blocker,g]);let v=ar(t,"done",s),k=b=>b==="blocked"?ar(t,"blocked",s,"pending"):ar(t,b,s);return e("div",{class:"page-head team-task-head",children:[e("div",{class:"page-head-text",children:[o?e("form",{class:"team-title-edit",onSubmit:b=>{b.preventDefault(),f.trim()&&f.trim()!==t.title?d({title:f.trim()}).then(S=>{S&&u(!1)}):u(!1)},children:[e("label",{class:"sr-only",for:"tt-title",children:"Title"}),e("input",{id:"tt-title",class:"field",required:!0,maxLength:200,value:f,disabled:!!i,onInput:b=>h(b.currentTarget.value),onKeyDown:b=>{b.key==="Escape"&&(u(!1),h(t.title))}}),e("button",{type:"submit",class:"btn small primary",disabled:!!i||!f.trim(),children:"Save"}),e("button",{type:"button",class:"btn small",onClick:()=>{u(!1),h(t.title)},children:"Cancel"})]}):e("h1",{children:[t.title,a?e("button",{type:"button",class:"icon-btn team-edit","aria-label":"Edit the title",title:"Edit the title",disabled:!!i,onClick:()=>u(!0),children:e(K,{name:"note"})}):null]}),e("p",{class:"team-task-meta",children:[e("span",{class:`status-pill ${Cl[t.status]}`,children:Vs[t.status]}),e("code",{children:t.repository}),t.baseRef?e("span",{children:["base ",e("code",{children:t.baseRef})]}):null,e("span",{children:t.owner?e(M,{children:["Owned by ",Ft(t.owner,n)]}):"Unassigned"}),t.reviewer?e("span",{children:["Reviewed by ",Ft(t.reviewer,n)]}):null,e("span",{children:["Updated ",pt(t.updatedAt)]}),t.labels.map(b=>e("span",{class:"badge",children:b},b))]}),t.status==="blocked"&&t.blocker?e("p",{class:"msg warn",role:"status",children:[e("strong",{children:"Blocked:"})," ",t.blocker]}):null]}),e("div",{class:"page-head-actions",children:[e("label",{class:"team-status",children:["Status",e("select",{class:"field",value:t.status,disabled:!a||!!i,onChange:b=>{let S=b.currentTarget.value;if(S==="blocked"){y(!0);return}d({status:S})},children:Vn.map(b=>{let S=b===t.status?void 0:k(b);return e("option",{value:b,disabled:!!S,title:S,children:Vs[b]},b)})})]}),c?e("button",{type:"button",class:"btn small danger",disabled:!!i,onClick:async()=>{await Ae("Delete this task, its checkpoints and its discussion? This cannot be undone.",{title:"Delete this task?",confirmLabel:"Delete task",danger:!0})&&l("Deleting\u2026",async()=>{await _n(`/api/team/tasks/${G(t.id)}`,{revision:t.revision})},()=>{J("Task deleted"),p({view:"team",project:t.projectId})})},children:"Delete task"}):null,a&&v&&t.status!=="done"?e("p",{class:"help",children:["Done is unavailable: ",v,"."]}):null,g?e("form",{class:"team-blocker",onSubmit:b=>{b.preventDefault(),C.trim()&&d({status:"blocked",blocker:C.trim()}).then(S=>{S&&y(!1)})},children:[e("label",{for:"tt-blocker",children:"What blocks the task?"}),e("textarea",{id:"tt-blocker",class:"field",rows:2,required:!0,maxLength:1e3,value:C,disabled:!!i,onInput:b=>T(b.currentTarget.value)}),e("div",{class:"team-actions",children:[e("button",{type:"submit",class:"btn small primary",disabled:!!i||!C.trim(),children:"Mark blocked"}),e("button",{type:"button",class:"btn small",onClick:()=>y(!1),children:"Cancel"})]})]}):null]})]})}function Im({task:t,canEdit:s,busy:n,save:r}){let[a,c]=m(t.goal),[i,d]=m(t.acceptance),l=Z({goal:t.goal,acceptance:t.acceptance});N(()=>{a===l.current.goal&&c(t.goal),l.current.goal=t.goal},[t.goal]),N(()=>{i===l.current.acceptance&&d(t.acceptance),l.current.acceptance=t.acceptance},[t.acceptance]);let p=(o,u,f,h,g,y,C)=>e("div",{class:"team-text",children:[e("label",{for:o,children:u}),s?e(M,{children:[e("textarea",{id:o,class:"field",rows:f.split(`
|
|
112
|
+
`).length>4?8:4,maxLength:g,value:f,disabled:!!n,onInput:T=>y(T.currentTarget.value)}),f!==h?e("div",{class:"team-actions",children:[e("button",{type:"button",class:"btn small primary",disabled:!!n,onClick:C,children:["Save ",u.toLowerCase()]}),e("button",{type:"button",class:"btn small",disabled:!!n,onClick:()=>y(h),children:"Discard"}),e("span",{class:"help",children:"Unsaved changes"})]}):null]}):h?e("p",{id:o,class:"team-prose",children:h}):e("p",{id:o,class:"help",children:"Not written yet."})]});return e("section",{class:"team-section","aria-labelledby":"tt-text",children:[e("h2",{id:"tt-text",children:"Goal and acceptance"}),p("tt-goal","Goal",a,t.goal,16384,c,()=>void r({goal:a})),p("tt-acceptance","Acceptance criteria",i,t.acceptance,8192,d,()=>void r({acceptance:i}))]})}function Am({attempt:t,meId:s,live:n,stale:r}){let a=t.progress;return e(M,{children:[e("p",{class:"team-task-meta",children:[e("span",{class:`status-pill ${r?"failing":Tl[t.state]}`,children:r?"Connection lost":er[t.state]}),e("span",{children:["on ",e("strong",{children:t.runnerName})," by ",Ft(t.user,s)]}),n?e("span",{class:"team-live",children:[e("span",{class:"dot running","aria-hidden":"true"}),"Live \xB7 heard ",pt(t.lastHeartbeatAt)]}):e("span",{children:["Last heard ",pt(t.lastHeartbeatAt)]})]}),r?e("p",{class:"msg warn",role:"status",children:"Connection lost; execution status unknown. This task stays reserved until the runner reconnects and reports its state. Recover it only after confirming the original agent has stopped."}):null,e("dl",{class:"team-kv",children:[a.stage?e(M,{children:[e("dt",{children:"Stage"}),e("dd",{children:a.stage})]}):null,a.steps?e(M,{children:[e("dt",{children:"Steps"}),e("dd",{children:[a.steps.done,a.steps.total!==void 0?` of ${a.steps.total}`:""]})]}):null,a.runStatus||a.verdict?e(M,{children:[e("dt",{children:"Run"}),e("dd",{children:[a.runStatus??"",a.verdict?`${a.runStatus?" \xB7 ":""}check ${a.verdict}`:""]})]}):null,a.tests?e(M,{children:[e("dt",{children:"Tests"}),e("dd",{children:[e("span",{class:`badge ${a.tests.ok?"ok":"warn"}`,children:a.tests.ok?"Passing":"Failing"})," ",e("code",{children:a.tests.command})," \xB7 ",pt(a.tests.at)]})]}):null,a.branch||t.branch?e(M,{children:[e("dt",{children:"Branch"}),e("dd",{children:[e("code",{children:a.branch??t.branch}),a.head??t.head?e(M,{children:[" at ",e("code",{children:Js(a.head??t.head)})]}):null]})]}):null,e("dt",{children:"Base"}),e("dd",{children:[e("code",{children:Js(t.baseCommit)}),t.fromCheckpointId?" \xB7 continued from a checkpoint":""]}),e("dt",{children:"Started"}),e("dd",{children:[tr(t.startedAt??t.createdAt),t.endedAt?` \xB7 ended ${pt(t.endedAt)}`:""]}),t.reason?e(M,{children:[e("dt",{children:"Reason"}),e("dd",{children:t.reason})]}):null]}),a.summary?e("pre",{class:"team-prose",children:a.summary}):null,a.blockers?.length?e("div",{class:"msg warn",role:"status",children:[e("strong",{children:"Blockers"}),e("ul",{class:"team-list",children:a.blockers.map((c,i)=>e("li",{children:c},i))})]}):null,a.changedFiles?.length?e("details",{class:"team-files",children:[e("summary",{children:[a.changedFiles.length," changed file",a.changedFiles.length===1?"":"s"]}),e("ul",{class:"team-list mono",children:a.changedFiles.map(c=>e("li",{children:c},c))})]}):null]})}function Em({task:t,role:s,meId:n,members:r,canEdit:a,busy:c,save:i}){let d=Jt.value,l=d?.projects.find(x=>x.id===t.projectId),p=Ne(s,"maintainer"),o=r.filter(x=>Ne(x.role,"contributor")&&(p||x.userId===n));t.owner&&!o.some(x=>x.userId===t.owner.userId)&&o.unshift({userId:t.owner.userId,username:t.owner.userId,displayName:t.owner.displayName,role:"contributor",online:!1});let u=r.filter(x=>Ne(x.role,"reviewer")),f=(d?.tasks??[]).filter(x=>x.projectId===t.projectId&&x.id!==t.id),h=rr(t,s,n),[g,y]=m(t.baseRef??""),[C,T]=m(t.labels.join(", "));N(()=>y(t.baseRef??""),[t.baseRef]),N(()=>T(t.labels.join(", ")),[t.labels.join(", ")]);let[v,k]=m(0),b=`${t.dependsOn.join(",")}:${v}`,S=!a||!!c;return e("section",{class:"team-section","aria-labelledby":"tt-fields",children:[e("h2",{id:"tt-fields",children:"Details"}),e("div",{class:"team-fields column",children:[e("label",{children:["Owner",e("select",{class:"field",value:t.owner?.userId??"",disabled:S||!!h,title:h,onChange:x=>void i({owner:x.currentTarget.value||null}),children:[e("option",{value:"",children:"Unassigned"}),o.map(x=>e("option",{value:x.userId,children:x.userId===n?`${x.displayName} (you)`:x.displayName},x.userId))]}),h&&a?e("span",{class:"help",children:h}):null]}),e("label",{children:["Reviewer",e("select",{class:"field",value:t.reviewer?.userId??"",disabled:S,onChange:x=>void i({reviewer:x.currentTarget.value||null}),children:[e("option",{value:"",children:"None"}),u.map(x=>e("option",{value:x.userId,children:x.userId===n?`${x.displayName} (you)`:x.displayName},x.userId))]})]}),e("label",{children:["Repository",e("select",{class:"field",value:t.repository,disabled:S,onChange:x=>void i({repository:x.currentTarget.value}),children:[l?.repositories.some(x=>x.key===t.repository)?null:e("option",{value:t.repository,children:t.repository}),l?.repositories.map(x=>e("option",{value:x.key,children:[x.label," (",x.key,")"]},x.key))]})]}),e("label",{children:["Base branch",e("input",{class:"field",maxLength:100,value:g,disabled:S,placeholder:"The repository's default branch",onInput:x=>y(x.currentTarget.value),onBlur:()=>{g.trim()!==(t.baseRef??"")&&i({baseRef:g.trim()||null})},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.currentTarget.blur())}})]}),e("label",{children:["Labels",e("input",{class:"field",maxLength:450,value:C,disabled:S,placeholder:"Comma-separated, up to 10",onInput:x=>T(x.currentTarget.value),onBlur:()=>{let x=[...new Set(C.split(",").map(w=>w.trim()).filter(Boolean))].slice(0,10);x.join(", ")!==t.labels.join(", ")&&i({labels:x})},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.currentTarget.blur())}})]}),r.length?e("fieldset",{class:"team-checks",disabled:S,children:[e("legend",{children:"Collaborators"}),r.filter(x=>x.userId!==t.owner?.userId).map(x=>e("label",{class:"check",children:[e("input",{type:"checkbox",checked:t.collaborators.some(w=>w.userId===x.userId),onChange:w=>{let j=t.collaborators.map(A=>A.userId).filter(A=>A!==x.userId);w.currentTarget.checked&&j.push(x.userId),i({collaborators:j.slice(0,20)})}})," ",x.userId===n?`${x.displayName} (you)`:x.displayName]},x.userId))]}):null,f.length?e("label",{children:["Depends on",e("select",{class:"field",multiple:!0,size:Math.min(5,Math.max(2,f.length)),disabled:S,onChange:x=>void i({dependsOn:[...x.currentTarget.selectedOptions].map(w=>w.value).slice(0,20)}).then(w=>{w||k(j=>j+1)}),children:f.map(x=>e("option",{value:x.id,selected:t.dependsOn.includes(x.id),children:[x.title," \xB7 ",Vs[x.status]]},x.id))},b)]}):null]}),e("dl",{class:"team-kv",children:[e("dt",{children:"Created"}),e("dd",{children:[tr(t.createdAt)," by ",t.createdBy.displayName]}),e("dt",{children:"Project"}),e("dd",{children:l?.name??t.projectId}),t.dependsOn.length?e(M,{children:[e("dt",{children:"Depends on"}),e("dd",{children:t.dependsOn.map(x=>f.find(w=>w.id===x)?.title??x).join(", ")})]}):null]})]})}function jm({task:t,latest:s,meId:n,canEdit:r,maintainer:a,shared:c,busy:i,act:d,onFetch:l,reload:p}){let o=t.checkpoints.slice().sort((u,f)=>f.at-u.at);return e("section",{class:"team-section","aria-labelledby":"tt-checkpoints",children:[e("h2",{id:"tt-checkpoints",children:["Checkpoints",e("span",{class:"team-count",children:o.length})]}),o.length?null:e("p",{class:"help",children:"None yet. An attempt publishes a checkpoint (a Git bundle of its commits plus the context the next agent needs) when it finishes or is handed over."}),o.map(u=>e("article",{class:"team-item",children:[e("div",{class:"team-task-meta",children:[e("code",{children:Js(u.commit)}),e("code",{children:u.branch}),e("span",{children:Zt(u.size)}),e("span",{children:["by ",Ft(u.createdBy,n)]}),e("span",{children:pt(u.at)}),u===s?e("span",{class:"badge ok",children:"Latest"}):null,u.bundle==="pending"?e("span",{class:"badge warn",children:"Uploading"}):u.bundle==="deleted"?e("span",{class:"badge warn",children:"Bundle deleted"}):null,u.testResults?e("span",{class:`badge ${u.testResults.ok?"ok":"warn"}`,children:["Tests ",u.testResults.ok?"passing":"failing"]}):null]}),u.note?e("p",{class:"team-comment-text",children:u.note}):null,u.remaining?e("details",{children:[e("summary",{children:"Remaining work"}),e("pre",{class:"team-prose",children:u.remaining})]}):null,u.changedFiles.length?e("details",{children:[e("summary",{children:[u.changedFiles.length," changed file",u.changedFiles.length===1?"":"s"]}),e("ul",{class:"team-list mono",children:u.changedFiles.map(f=>e("li",{children:f},f))})]}):null,e("div",{class:"team-actions",children:[!c&&r&&u.bundle==="available"?e("button",{type:"button",class:"btn small",disabled:!!i,onClick:()=>l(u),children:"Fetch to this computer\u2026"}):null,r&&u.bundle==="available"?e("a",{class:"btn small",href:Qs(`/api/team/checkpoints/${G(u.id)}/bundle`),download:`checkpoint-${u.id.slice(0,8)}.bundle`,children:"Download bundle"}):null,a&&u.bundle!=="deleted"?e("button",{type:"button",class:"btn small danger",disabled:!!i,onClick:async()=>{await Ae("Delete this checkpoint's bundle? Teammates can no longer download or continue from it.",{title:"Delete checkpoint bundle?",confirmLabel:"Delete bundle",danger:!0})&&d("Deleting\u2026",async()=>{await _n(`/api/team/checkpoints/${G(u.id)}`)},()=>void p())},children:"Delete"}):null]})]},u.id))]})}function Pm({task:t,latest:s,meId:n,members:r,canEdit:a,canComment:c,busy:i,act:d}){let[l,p]=m(t.reviewer?.userId??""),[o,u]=m("approve"),[f,h]=m(""),g=r.filter(T=>Ne(T.role,"reviewer")),y=t.reviews.slice().sort((T,v)=>v.at-T.at),C=s?y.filter(T=>T.checkpointId===s.id&&!T.stale)[0]:void 0;return e("section",{class:"team-section","aria-labelledby":"tt-reviews",children:[e("h2",{id:"tt-reviews",children:["Reviews",C?e("span",{class:`badge ${C.verdict==="approve"?"ok":"warn"}`,children:C.verdict==="approve"?"Approved":"Changes requested"}):t.reviewer&&s?e("span",{class:"badge",children:"Pending"}):null]}),a?e("form",{class:"team-inline",onSubmit:T=>{T.preventDefault(),l&&d("Requesting a review\u2026",()=>O(`/api/team/tasks/${G(t.id)}/review-request`,{reviewer:l,revision:t.revision}),()=>J("Review requested"))},children:[e("label",{children:["Request a review from",e("select",{class:"field",value:l,disabled:!!i,onChange:T=>p(T.currentTarget.value),children:[e("option",{value:"",children:"Choose a reviewer"}),g.map(T=>e("option",{value:T.userId,children:T.userId===n?`${T.displayName} (you)`:T.displayName},T.userId))]})]}),e("button",{type:"submit",class:"btn small",disabled:!!i||!l,children:"Request review"})]}):null,c&&s?e("form",{class:"team-review-form",onSubmit:T=>{T.preventDefault(),d("Recording the review\u2026",()=>O(`/api/team/tasks/${G(t.id)}/reviews`,{checkpointId:s.id,verdict:o,text:f,revision:t.revision}),()=>{h(""),J("Review recorded")})},children:[e("fieldset",{disabled:!!i,children:[e("legend",{children:["Record a review of checkpoint ",e("code",{children:Js(s.commit)})]}),e("label",{class:"check",children:[e("input",{type:"radio",name:"tt-verdict",value:"approve",checked:o==="approve",onChange:()=>u("approve")})," Approve"]}),e("label",{class:"check",children:[e("input",{type:"radio",name:"tt-verdict",value:"request-changes",checked:o==="request-changes",onChange:()=>u("request-changes")})," Request changes"]})]}),e("label",{for:"tt-review-text",children:"Review notes"}),e("textarea",{id:"tt-review-text",class:"field",rows:3,maxLength:4e3,value:f,disabled:!!i,onInput:T=>h(T.currentTarget.value)}),e("div",{class:"team-actions",children:e("button",{type:"submit",class:"btn small primary",disabled:!!i||o==="request-changes"&&!f.trim(),children:"Record review"})})]}):c?e("p",{class:"help",children:"Reviews attach to a checkpoint; this task has none yet."}):null,y.map(T=>e("article",{class:"team-item",children:[e("div",{class:"team-task-meta",children:[e("span",{class:`badge ${T.verdict==="approve"?"ok":"warn"}`,children:T.verdict==="approve"?"Approved":"Changes requested"}),e("span",{children:["by ",Ft(T.by,n)]}),e("code",{children:Js(T.commit)}),e("span",{children:pt(T.at)}),T.stale?e("span",{class:"badge",children:"Stale \xB7 a newer checkpoint exists"}):null]}),T.text?e("p",{class:"team-comment-text",children:T.text}):null]},T.id)),y.length?null:e("p",{class:"help",children:"No reviews recorded."})]})}var Mm={proposed:"Proposed",approved:"Approved",declined:"Declined",delivered:"Delivered to the agent"};function Dm({task:t,meId:s,members:n,canEdit:r,canComment:a,isOwner:c,maintainer:i,busy:d,act:l}){let[p,o]=m(""),[u,f]=m(!1),h=[...t.discussion.map(y=>({kind:"comment",at:y.at,comment:y})),...t.instructions.map(y=>({kind:"instruction",at:y.at,instruction:y}))].sort((y,C)=>y.at-C.at),g=(y,C)=>l(C==="approve"?"Approving\u2026":"Declining\u2026",()=>O(`/api/team/tasks/${G(t.id)}/instructions/${G(y.id)}`,{action:C}));return e("section",{class:"team-section","aria-labelledby":"tt-discussion",children:[e("h2",{id:"tt-discussion",children:["Discussion",e("span",{class:"team-count",children:h.length})]}),e("div",{class:"team-timeline",children:[h.length?null:e("p",{class:"help",children:"No comments yet. Mention a teammate with @username to notify them."}),h.map(y=>y.kind==="comment"?e("article",{class:`team-comment ${y.comment.kind}`,children:[e("div",{class:"team-comment-head",children:[e("span",{class:"team-avatar","aria-hidden":"true",children:va(y.comment.by.displayName)}),e("strong",{children:Ft(y.comment.by,s)}),y.comment.kind==="system"?e("span",{class:"badge",children:"System"}):y.comment.kind==="review-request"?e("span",{class:"badge",children:"Review request"}):null,e("span",{children:pt(y.comment.at)})]}),e("p",{class:"team-comment-text",children:Hd(y.comment.text,n)})]},y.comment.id):e("article",{class:`team-comment instruction ${y.instruction.state}`,children:[e("div",{class:"team-comment-head",children:[e("span",{class:"team-avatar","aria-hidden":"true",children:va(y.instruction.by.displayName)}),e("strong",{children:Ft(y.instruction.by,s)}),e("span",{class:`badge ${y.instruction.state==="declined"?"warn":y.instruction.state==="proposed"?"":"ok"}`,children:["Send to agent \xB7 ",Mm[y.instruction.state]]}),e("span",{children:pt(y.instruction.at)}),y.instruction.decidedBy?e("span",{children:[y.instruction.state==="declined"?"declined":"approved"," by ",Ft(y.instruction.decidedBy,s)]}):null]}),e("p",{class:"team-comment-text",children:Hd(y.instruction.text,n)}),y.instruction.state==="proposed"&&(c||i)?e("div",{class:"team-actions",children:[e("button",{type:"button",class:"btn small primary",disabled:!!d,onClick:()=>void g(y.instruction,"approve"),children:"Approve"}),e("button",{type:"button",class:"btn small",disabled:!!d,onClick:()=>void g(y.instruction,"decline"),children:"Decline"})]}):null]},y.instruction.id))]}),a?e("form",{class:"team-composer",onSubmit:y=>{y.preventDefault();let C=p.trim();C&&l(u?"Sending to the agent\u2026":"Posting\u2026",()=>O(`/api/team/tasks/${G(t.id)}/${u?"instructions":"comments"}`,{text:C}),()=>{o(""),u&&J(c?"Instruction approved; the agent receives it on its next heartbeat":"Instruction proposed to the task owner",4e3)})},children:[e("label",{for:"tt-comment",children:u?"Instruction for the agent":"Comment"}),e("textarea",{id:"tt-comment",class:"field",rows:3,maxLength:4e3,value:p,disabled:!!d,placeholder:u?"What the running agent should do next":"Write a comment; @username notifies a teammate",onInput:y=>o(y.currentTarget.value),onKeyDown:y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),y.currentTarget.form?.requestSubmit())}}),e("div",{class:"team-actions",children:[e("button",{type:"submit",class:"btn small primary",disabled:!!d||!p.trim(),children:u?"Send to agent":"Post comment"}),r?e("label",{class:"check",children:[e("input",{type:"checkbox",role:"switch","aria-checked":u,checked:u,disabled:!!d,onChange:y=>f(y.currentTarget.checked)})," Send to agent"]}):null,u?e("span",{class:"help",children:c?"Your instructions are approved at once and reach the agent as a note at its next heartbeat.":"The task owner or a project maintainer approves instructions before the agent sees them."}):null]})]}):e("p",{class:"help",children:"A project reviewer role is needed to comment."})]})}function Lm({task:t,canEdit:s,busy:n,act:r}){let[a,c]=m("");return e("section",{class:"team-section","aria-labelledby":"tt-decisions",children:[e("h2",{id:"tt-decisions",children:["Decisions",e("span",{class:"team-count",children:t.decisions.length})]}),e("p",{class:"help",children:"Choices that bind the work: every checkpoint carries them to the next agent."}),t.decisions.length?e("ul",{class:"team-list decisions",children:t.decisions.map(i=>e("li",{children:[e("span",{children:i.text}),e("span",{class:"help",children:[i.by.displayName," \xB7 ",pt(i.at)]})]},i.id))}):null,s?e("form",{class:"team-inline",onSubmit:i=>{i.preventDefault();let d=a.trim();d&&r("Adding the decision\u2026",()=>O(`/api/team/tasks/${G(t.id)}/decisions`,{text:d}),()=>c(""))},children:[e("label",{children:["Add a decision",e("input",{class:"field",maxLength:2e3,value:a,disabled:!!n,onInput:i=>c(i.currentTarget.value)})]}),e("button",{type:"submit",class:"btn small",disabled:!!n||!a.trim(),children:"Add"})]}):null]})}function Nm({task:t,checkpoint:s,onClose:n,onStarted:r}){let a=ye(!0,n);N(()=>{On()},[]);let c=fs.value,i=c?.mappings[t.projectId]?.[t.repository]??"",d=ge.value,[l,p]=m(i),[o,u]=m(()=>{let q=c?.defaults?.pattern;return q&&d.some(te=>te.id===q)?q:d.some(te=>te.id==="solo")?"solo":d[0]?.id??""}),f=d.find(q=>q.id===o),h=Re.value.filter(q=>q.available),[g,y]=m({}),[C,T]=m(Be.value),[v,k]=m(""),[b,S]=m($e.value.maxMinutes),[x,w]=m($e.value.maxSteps),[j,A]=m(()=>{let q=c?.defaults?.trust;return q&&q in xa?q:ut.value}),P=!!s&&s.bundle==="available",[D,I]=m(P),[$,E]=m(!1),[L,H]=m(""),Q=q=>{let me=(g[q.id]??c?.defaults?.roles?.[q.id]??q.default).filter(W=>h.some(re=>re.id===W));return q.id in g||me.length?q.multiple?me:me.slice(0,1):h[0]?[h[0].id]:[]},le=f?.id==="auto-team"?4:1,de=!!f&&h.length>0&&!!l.trim()&&f.roles.every(q=>q.optional||Q(q).length>0)&&Number.isInteger(x)&&x>=le&&x<=200&&Number.isInteger(b)&&b>=1&&b<=720&&(!f.requiresCheck||!!v.trim()),ue=async q=>{if(q.preventDefault(),!($||!f||!de)){E(!0),H("");try{await O(`/api/team-link/tasks/${G(t.id)}/start`,{...l.trim()?{repo:l.trim()}:{},pattern:f.id,roles:Object.fromEntries(f.roles.map(te=>[te.id,Q(te)])),trust:j,agentSettings:C,loop:{...v.trim()?{check:v.trim()}:{},maxMinutes:b,maxSteps:x},...D&&s?{fromCheckpointId:s.id}:{}}),r()}catch(te){H(te.message),E(!1)}}};return e("dialog",{class:"picker team-build-dialog",ref:a,"aria-labelledby":"tt-start-title",children:e("form",{class:"picker-inner",onSubmit:q=>void ue(q),children:[e("div",{class:"picker-head",children:[e("h3",{id:"tt-start-title",children:"Build with agents"}),e("p",{class:"help",children:"Build on this computer in a worktree of your clone. Progress, checks and a checkpoint return to this task for review."})]}),e("div",{class:"dialog-body",children:[e("label",{for:"tt-start-repo",children:["Repository path for ",e("code",{children:t.repository})]}),e("div",{class:"row-inline",children:[e("input",{id:"tt-start-repo",class:"field mono",value:l,placeholder:i||"/absolute/path/to/your/clone",disabled:$,onInput:q=>p(q.currentTarget.value)}),e("button",{type:"button",class:"btn small",disabled:$||!ee.value,title:ee.value||"Choose a repository in the composer first",onClick:()=>p(ee.value),children:"Use current repository"})]}),!i&&!l?e("p",{class:"help",children:"No folder is mapped for this repository key yet; the path you enter here is used for this attempt (map it for good in Connections \u2192 Share access)."}):null,e("label",{for:"tt-start-pattern",children:"Workflow"}),e("select",{id:"tt-start-pattern",class:"field",value:o,disabled:$,onChange:q=>{u(q.currentTarget.value),y({})},children:d.map(q=>e("option",{value:q.id,children:q.name},q.id))}),f?e(M,{children:[e("p",{class:"help",children:f.summary}),e("fieldset",{class:"team-roles",disabled:$,children:[e("legend",{children:"Agents"}),f.roles.map(q=>q.multiple?e("fieldset",{class:"team-checks",children:[e("legend",{children:q.label}),h.map(te=>e("label",{class:"check",children:[e("input",{type:"checkbox",checked:Q(q).includes(te.id),onChange:me=>y({...g,[q.id]:me.currentTarget.checked?[...Q(q),te.id]:Q(q).filter(W=>W!==te.id)})}),te.displayName]},te.id))]},q.id):e("label",{children:[q.label,e("select",{class:"field","aria-label":q.label,value:Q(q)[0]??"",onChange:te=>y({...g,[q.id]:te.currentTarget.value?[te.currentTarget.value]:[]}),children:[q.optional?e("option",{value:"",children:"None"}):null,h.map(te=>e("option",{value:te.id,children:te.displayName},te.id))]})]},q.id))]})]}):null,h.length?null:e("p",{class:"msg warn",children:"Install and sign in to an agent on this computer before building."}),e("details",{children:[e("summary",{children:"Models and reasoning"}),e("fieldset",{disabled:$,children:h.filter(q=>f?.roles.some(te=>Q(te).includes(q.id))).map(q=>e(hn,{agent:q,used:!0,settings:C[q.id]??{},onChange:te=>T({...C,[q.id]:{...C[q.id],...te}})},q.id))})]}),e("label",{children:["Check command",e("input",{class:"field",maxLength:1e3,required:f?.requiresCheck,placeholder:"Use repository default, or enter e.g. npm test",value:v,disabled:$,onInput:q=>k(q.currentTarget.value)})]}),e("div",{class:"team-fields",children:[e("label",{children:["Time budget (minutes)",e("input",{class:"field",type:"number",min:1,max:720,value:b,disabled:$,onInput:q=>S(Number(q.currentTarget.value))})]}),e("label",{children:["Agent call budget",e("input",{class:"field",type:"number",min:le,max:200,value:x,disabled:$,onInput:q=>w(Number(q.currentTarget.value))})]})]}),e("label",{for:"tt-start-trust",children:"Agent permissions"}),e("select",{id:"tt-start-trust",class:"field",value:j,disabled:$,onChange:q=>A(q.currentTarget.value),children:Object.keys(xa).map(q=>e("option",{value:q,children:xa[q].label},q))}),e("p",{class:j==="full"?"msg warn":"help",children:xa[j].help}),s?e("label",{class:"check",children:[e("input",{type:"checkbox",checked:D,disabled:$||!P,onChange:q=>I(q.currentTarget.checked)})," Continue from the latest checkpoint (",Js(s.commit),", ",pt(s.at),")",P?"":" \u2014 its bundle is not available"]}):null,L?e("p",{class:"msg err",role:"alert",children:L}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:$?"Starting\u2026":""}),e("button",{type:"button",class:"btn",disabled:$,onClick:n,children:"Cancel"}),e("button",{type:"submit",class:"btn primary",disabled:$||!de,children:"Build with agents"})]})]})})}function Om({task:t,attempt:s,onClose:n,onDone:r}){let a=ye(!0,n),[c,i]=m(""),[d,l]=m(!1),[p,o]=m(!1),[u,f]=m("");return e("dialog",{class:"picker small-dialog",ref:a,"aria-labelledby":"tt-recover-title",children:e("form",{class:"picker-inner",onSubmit:async h=>{if(h.preventDefault(),!(p||!d||!c.trim())){o(!0),f("");try{await O(`/api/team/attempts/${G(s.id)}/recover`,{revision:t.revision,reason:c.trim(),confirmedStopped:!0}),r()}catch(g){f(g.message),o(!1)}}},children:[e("div",{class:"picker-head",children:[e("h3",{id:"tt-recover-title",children:"Recover attempt"}),e("p",{class:"help",children:["Check ",s.runnerName," first. Stop the original agent or shut down its computer before releasing this task. Recovery prevents that attempt from resuming and lets you start from a checkpoint."]})]}),e("div",{class:"dialog-body",children:[e("label",{for:"tt-recover-reason",children:"How did you confirm execution stopped?"}),e("textarea",{id:"tt-recover-reason",class:"field",required:!0,rows:3,maxLength:1e3,value:c,disabled:p,onInput:h=>i(h.currentTarget.value)}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:d,disabled:p,onChange:h=>l(h.currentTarget.checked)})," I confirmed the original agent has stopped."]}),u?e("p",{class:"msg err",role:"alert",children:u}):null]}),e("div",{class:"picker-foot",children:[e("button",{type:"button",class:"btn",disabled:p,onClick:n,children:"Cancel"}),e("button",{type:"submit",class:"btn primary",disabled:p||!d||!c.trim(),children:"Release task"})]})]})})}function qm({task:t,meId:s,members:n,onClose:r,onDone:a}){let c=ye(!0,r),i=n.filter(v=>v.userId!==s&&Ne(v.role,"contributor")),[d,l]=m(i[0]?.userId??""),[p,o]=m(""),[u,f]=m(!1),[h,g]=m(!1),[y,C]=m(""),T=async v=>{if(v.preventDefault(),!(h||!d)){g(!0),C("");try{await O(`/api/team-link/tasks/${G(t.id)}/handover`,{to:d,note:p,includeUncommitted:u}),a()}catch(k){C(k.message),g(!1)}}};return e("dialog",{class:"picker small-dialog",ref:c,"aria-labelledby":"tt-handover-title",children:e("form",{class:"picker-inner",onSubmit:v=>void T(v),children:[e("div",{class:"picker-head",children:[e("h3",{id:"tt-handover-title",children:"Hand over"}),e("p",{class:"help",children:"Offers the task with a checkpoint of your work; the teammate continues from it on their own computer once they accept."})]}),e("div",{class:"dialog-body",children:[e("label",{for:"tt-handover-to",children:"Teammate"}),e("select",{id:"tt-handover-to",class:"field",required:!0,value:d,disabled:h,onChange:v=>l(v.currentTarget.value),children:[i.length?null:e("option",{value:"",children:"No other contributor in this project"}),i.map(v=>e("option",{value:v.userId,children:[v.displayName,v.online?" \xB7 online":""]},v.userId))]}),e("label",{for:"tt-handover-note",children:"Note for them"}),e("textarea",{id:"tt-handover-note",class:"field",rows:4,maxLength:4e3,value:p,disabled:h,placeholder:"Where you stopped, what to look at first",onInput:v=>o(v.currentTarget.value)}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:u,disabled:h,onChange:v=>f(v.currentTarget.checked)}),' Include uncommitted changes (committed on the run branch as "Hand-over checkpoint")']}),y?e("p",{class:"msg err",role:"alert",children:y}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:h?"Creating the checkpoint\u2026":""}),e("button",{type:"button",class:"btn",disabled:h,onClick:r,children:"Cancel"}),e("button",{type:"submit",class:"btn primary",disabled:h||!d,children:"Offer hand-over"})]})]})})}function Wd({title:t,help:s,action:n,initial:r,required:a=!1,onClose:c,submit:i}){let d=ye(!0,c),[l,p]=m(r),[o,u]=m(!1),[f,h]=m("");return e("dialog",{class:"picker small-dialog",ref:d,"aria-labelledby":"tt-path-title",children:e("form",{class:"picker-inner",onSubmit:async g=>{if(g.preventDefault(),!o){u(!0),h("");try{await i(l.trim())}catch(y){h(y.message),u(!1)}}},children:[e("div",{class:"picker-head",children:[e("h3",{id:"tt-path-title",children:t}),e("p",{class:"help",children:s})]}),e("div",{class:"dialog-body",children:[e("label",{for:"tt-path",children:"Repository path"}),e("div",{class:"row-inline",children:[e("input",{id:"tt-path",class:"field mono",required:a,value:l,placeholder:r||"/absolute/path/to/your/clone",disabled:o,onInput:g=>p(g.currentTarget.value)}),e("button",{type:"button",class:"btn small",disabled:o||!ee.value,title:ee.value||"Choose a repository in the composer first",onClick:()=>p(ee.value),children:"Use current repository"})]}),!r&&!a?e("p",{class:"help",children:"Leave empty to use the folder mapped for this repository key in Connections \u2192 Share access."}):null,f?e("p",{class:"msg err",role:"alert",children:f}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:o?"Working\u2026":""}),e("button",{type:"button",class:"btn",disabled:o,onClick:c,children:"Cancel"}),e("button",{type:"submit",class:"btn primary",disabled:o||a&&!l.trim(),children:n})]})]})})}var di=()=>location.reload(),is=t=>t instanceof Error?t.message:"The request failed";function LC({onSignedIn:t=di}){let[s,n]=m(""),[r,a]=m(""),[c,i]=m(!1),[d,l]=m(""),p=Z(null);return e("main",{class:"shared-surface shared-login",children:e("div",{class:"shared-card",children:[e("div",{class:"shared-brand",children:["code",e("span",{children:"-flow"})]}),e("h1",{children:"Sign in to shared projects"}),e("p",{class:"shared-lede",children:"Sign in with the account you created from a project invitation, or the one your owner shared. Your project role determines which tasks, reviews and results you can access."}),e("form",{class:"shared-form",onSubmit:async o=>{if(o.preventDefault(),!c){i(!0),l("");try{await O("/api/auth/login",{username:s,password:r}),a(""),t()}catch(u){a(""),l(is(u)),p.current?.focus()}finally{i(!1)}}},children:[e("label",{for:"shared-username",children:"Username"}),e("input",{id:"shared-username",class:"field",value:s,maxLength:64,autoComplete:"username",required:!0,onInput:o=>n(o.currentTarget.value)}),e("label",{for:"shared-password",children:"Password"}),e("input",{ref:p,id:"shared-password",class:"field",type:"password",value:r,autoComplete:"current-password",required:!0,onInput:o=>a(o.currentTarget.value)}),d?e("p",{class:"shared-error",role:"alert",children:d}):null,e("button",{class:"btn primary shared-submit",type:"submit",disabled:c||!s||!r,children:c?"Signing in\u2026":"Sign in"})]}),e("p",{class:"help",children:"The owner can still use the recovery link printed in the server terminal. Network sign-in requires HTTPS."})]})})}function Vd({projects:t,projectId:s}){let[n,r]=m(null),[a,c]=m(""),[i,d]=m(""),[l,p]=m(""),[o,u]=m(""),[f,h]=m(!0),[g,y]=m({}),[C,T]=m(!1),[v,k]=m(""),[b,S]=m(""),x=A=>{c(A?.id??""),d(A?.username??""),p(A?.displayName??""),h(A?.enabled??!0),y(A?.roles??{}),u(""),k(""),S("")},w=async()=>{T(!0);try{r(await V("/api/accounts")),k("")}catch(A){k(is(A))}finally{T(!1)}};N(()=>{w()},[]);let j=async()=>{if(n){T(!0),k(""),S("");try{let A=a?await V(`/api/accounts/${G(a)}`,{method:"PUT",body:JSON.stringify({revision:n.revision,displayName:l,enabled:f,roles:g,...o?{password:o}:{}})}):await O("/api/accounts",{revision:n.revision,username:i,displayName:l,password:o,roles:g});r(A);let P=a?A.users.find(D=>D.id===a):A.users.find(D=>D.username===i.toLowerCase());x(P),S("Account saved. Updated accounts must sign in again.")}catch(A){k(is(A))}finally{u(""),T(!1)}}};return e("section",{class:"shared-surface shared-accounts","aria-label":"Shared project accounts",children:[e("h2",{children:"Shared project accounts"}),e("p",{class:"help",children:"Viewers can inspect assigned results. Reviewers can also record file reviews and leave comments. Contributors can also own team tasks and run them on their own computer; maintainers can also assign any task owner, define repository keys, delete tasks and checkpoints, revoke runners, cancel hand-overs and approve instructions to agents. Execution on this server, merges, terminals, secrets and system settings stay with the owner."}),e("label",{for:"shared-account",children:"Account"}),e("select",{id:"shared-account",class:"field",value:a,disabled:C,onChange:A=>x(n?.users.find(P=>P.id===A.currentTarget.value)),children:[e("option",{value:"",children:"New account\u2026"}),n?.users.map(A=>e("option",{value:A.id,children:[A.displayName," (",A.username,")",A.enabled?"":" \xB7 disabled"]},A.id))]}),e("form",{class:"shared-form",onSubmit:A=>{A.preventDefault(),j()},children:[e("label",{for:"account-username",children:"Account username"}),e("input",{id:"account-username",class:"field",value:i,required:!0,maxLength:64,disabled:!!a||C,autoComplete:"off",onInput:A=>d(A.currentTarget.value)}),e("label",{for:"account-name",children:"Display name"}),e("input",{id:"account-name",class:"field",value:l,required:!0,maxLength:120,disabled:C,onInput:A=>p(A.currentTarget.value)}),e("label",{for:"account-password",children:a?"Replace password (leave empty to keep)":"Initial password"}),e("input",{id:"account-password",class:"field",type:"password",value:o,required:!a,minLength:15,autoComplete:"new-password",disabled:C,onInput:A=>u(A.currentTarget.value)}),e("p",{class:"help",children:"Use at least 15 characters. Passwords are not returned or stored in browser preferences."}),a?e("label",{class:"check",children:[e("input",{type:"checkbox",checked:f,disabled:C,onChange:A=>h(A.currentTarget.checked)})," Account enabled"]}):null,e("fieldset",{class:"shared-roles-set",disabled:C,children:[e("legend",{children:"Assigned project roles"}),e("p",{id:"shared-roles-help",class:"help",children:[ho.map(A=>`${fa(A)} ${fl[A]}`).join(" \xB7 "),"."]}),e("div",{class:"shared-roles",children:t.filter(A=>!s||A.id===s).map(A=>e(M,{children:[e("label",{for:`shared-role-${A.id}`,children:A.name},`${A.id}-label`),e("select",{id:`shared-role-${A.id}`,class:"field","aria-describedby":"shared-roles-help",value:g[A.id]??"",onChange:P=>{let D={...g};P.currentTarget.value?D[A.id]=P.currentTarget.value:delete D[A.id],y(D)},children:[e("option",{value:"",children:"No access"}),ho.map(P=>e("option",{value:P,children:fa(P)},P))]},A.id)]}))}),Object.keys(g).filter(A=>!t.some(P=>P.id===A)).map(A=>e("p",{class:"help",children:["Unavailable project ",A," ",e("button",{class:"btn ghost",type:"button",onClick:()=>{let P={...g};delete P[A],y(P)},children:"Remove assignment"})]},A))]}),e("div",{class:"shared-row",children:[e("button",{class:"btn primary",type:"submit",disabled:C||!n,children:a?"Save account changes":"Create account"}),e("button",{class:"btn",type:"button",disabled:C,onClick:()=>void w(),children:"Reload accounts"}),a?e("button",{class:"btn",type:"button",disabled:C||!n,onClick:async()=>{T(!0),k("");try{r(await O(`/api/accounts/${G(a)}/revoke-sessions`,{revision:n.revision})),S("All sessions for this account were revoked.")}catch(A){k(is(A))}finally{T(!1)}},children:"Sign out all sessions"}):null]})]}),v?e("p",{role:"alert",class:"shared-error",children:[v," Your draft has been kept; reload current accounts before retrying a conflicting save."]}):null,b?e("p",{role:"status",children:b}):null]})}var _d=(t=location.hash)=>{let s=ji(t);return s.view==="team"||s.view==="team-task"||s.view==="team-people"?s:void 0};function NC({identity:t,onSignOut:s=di}){let[n,r]=m(()=>_d());We(()=>{let U=()=>r(_d());return window.addEventListener("hashchange",U),U(),()=>window.removeEventListener("hashchange",U)},[]);let a=U=>{let oe=U?Is(U):"#/";location.hash===oe?r(U):location.hash=oe};N(()=>{ga().catch(()=>{})},[]);let c=Hn.value,i=n?"team":"results",[d,l]=m([]),[p,o]=m(""),[u,f]=m(""),[h,g]=m({runs:[],total:0}),[y,C]=m(""),[T,v]=m(null),[k,b]=m(""),[S,x]=m([]),[w,j]=m(null),[A,P]=m(null),[D,I]=m(""),[$,E]=m(""),[L,H]=m(!1),[Q,le]=m("Connecting"),[de,ue]=m(0),[q,te]=m(!1),me=Z(!1),W=Z(0),re=Z(0),ne=Z(0),_=Z({project:p,query:u,selected:y,branch:k});_.current={project:p,query:u,selected:y,branch:k};let ie=async U=>{let oe=++W.current,ke=_.current;te(!0);try{let we=new URLSearchParams({limit:"50",...ke.project?{project:ke.project}:{},...ke.query?{q:ke.query}:{},...U?{cursor:U}:{}}),ce=await V(`/api/runs?${we}`);if(oe!==W.current)return;g(tt=>({...ce,runs:U?[...new Map([...tt.runs,...ce.runs].map(it=>[it.id,it])).values()]:ce.runs}))}catch(we){oe===W.current&&E(is(we))}finally{oe===W.current&&te(!1)}};N(()=>{let U=!0;return V("/api/projects").then(oe=>{U&&l(oe)},oe=>{U&&E(is(oe))}),()=>{U=!1}},[]),N(()=>{E("");let U=setTimeout(()=>void ie(),200);return()=>{clearTimeout(U),W.current++}},[p,u]);let Te=()=>void V("/api/auth/self").then(U=>{(U.kind!=="shared"||U.revision!==t.revision)&&di()},()=>{}),Ie=U=>{le(U==="connected"?"Connected":"Reconnecting"),U==="reconnecting"&&Te()};N(()=>{if(i!=="results")return;let U=new EventSource(Qs("/api/events?limit=50"));U.onopen=()=>Ie("connected"),U.onerror=()=>Ie("reconnecting");let oe;return U.onmessage=()=>{clearTimeout(oe),oe=setTimeout(()=>{ie();let ke=_.current.selected,we=re.current;ke&&V(`/api/runs/${G(ke)}`).then(ce=>{_.current.selected===ke&&re.current===we&&v(ce)},()=>{_.current.selected===ke&&re.current===we&&(v(null),C(""))})},150)},()=>{U.close(),clearTimeout(oe)}},[i]),N(()=>{let U=++re.current;if(v(null),b(""),x([]),j(null),P(null),I(""),!!y)return Promise.all([V(`/api/runs/${G(y)}`),V(`/api/runs/${G(y)}/collaboration`)]).then(([oe,ke])=>{U===re.current&&(v(oe),b(oe.worktrees[0]?.branch??""),P(ke))},oe=>{U===re.current&&E(is(oe))}),()=>{re.current++}},[y]),N(()=>{let U=++ne.current;if(j(null),x([]),!(!y||!k))return Promise.all([V(`/api/runs/${G(y)}/diff?branch=${G(k)}`),V(`/api/runs/${G(y)}/review-coverage?branch=${G(k)}`),V(`/api/runs/${G(y)}/collaboration`)]).then(([oe,ke,we])=>{U===ne.current&&(x(oe),j(ke),P(we))},oe=>{U===ne.current&&E(is(oe))}),()=>{ne.current++}},[y,k,de]);let et=!!T?.project&&Ne(t.roles[T.project],"reviewer");return e("main",{class:"shared-surface shared-page",children:[e("header",{class:"shared-top",children:[e("span",{class:"shared-brand",children:["code",e("span",{children:"-flow"})]}),e("span",{class:"spacer"}),e("span",{class:`connection-status ${Q==="Connected"?"connected":Q==="Connecting"?"connecting":"reconnecting"}`,role:"status",children:[e("span",{class:"cs-dot","aria-hidden":"true"}),e("span",{class:"cs-label",children:Q})]}),e("button",{type:"button",class:"btn small shared-bell","aria-label":`Team inbox${c?`, ${c} unread`:""}`,title:"Team inbox",onClick:()=>{Wn.value=!0,a({view:"team"})},children:[e(K,{name:"bell"}),c?e("span",{class:"team-badge","aria-hidden":"true",children:c}):null]}),e("button",{class:"btn small",onClick:async()=>{try{await O("/api/auth/logout"),s()}catch(U){E(is(U))}},children:["Sign out ",t.displayName]})]}),Object.values(t.roles).some(U=>Ne(U,"contributor"))?e("details",{class:"shared-connect-help",children:[e("summary",{children:"Connect your computer to run team tasks"}),e("p",{class:"help",children:["In your own CodeFlow, open Settings \u2192 Connections \u2192 Share access \u2192 Join a team. Paste this link, sign in as ",t.username,", and choose your repository folders. Work runs on your computer using your own agents."]}),e("button",{class:"btn small",onClick:()=>void Kt(El(location.origin,t.username),"Connection link copied"),children:"Copy connection link"})]}):null,e("div",{class:"shared-tabs",role:"tablist","aria-label":"Shared dashboard",children:["results","team"].map(U=>e("button",{type:"button",role:"tab",id:`shared-tab-${U}`,class:"shared-tab","aria-selected":i===U,"aria-controls":`shared-panel-${U}`,tabIndex:i===U?0:-1,onClick:()=>a(U==="team"?{view:"team"}:void 0),onKeyDown:oe=>{if(!["ArrowRight","ArrowLeft","Home","End"].includes(oe.key))return;oe.preventDefault();let ke=oe.key==="Home"?"results":oe.key==="End"||U==="results"?"team":"results";a(ke==="team"?{view:"team"}:void 0),requestAnimationFrame(()=>document.getElementById(`shared-tab-${ke}`)?.focus())},children:U==="results"?"Results":e(M,{children:["Board",c?e("span",{class:"team-badge","aria-hidden":"true",children:c}):null]})},U))}),e("div",{id:"shared-panel-team",role:"tabpanel","aria-labelledby":"shared-tab-team",hidden:i!=="team",children:n?e(Um,{route:n,go:a,onState:Ie}):null}),e("div",{id:"shared-panel-results",role:"tabpanel","aria-labelledby":"shared-tab-results",hidden:i!=="results",children:[e("div",{class:"page-head",children:e("div",{class:"page-head-text",children:[e("h1",{children:"Shared project review"}),e("p",{children:"View assigned project results and record human reviews. Comments stay in this collaboration thread and are not sent to coding agents."})]})}),$?e("p",{role:"alert",class:"shared-error",children:$}):null,e("div",{class:"shared-layout",children:[e("aside",{class:"shared-runs","aria-label":"Assigned project run history",children:[e("div",{class:"shared-filters",children:[e("label",{for:"shared-project-filter",children:"Shared project"}),e("select",{id:"shared-project-filter",class:"field",value:p,onChange:U=>{o(U.currentTarget.value),C("")},children:[e("option",{value:"",children:"All assigned projects"}),d.map(U=>e("option",{value:U.id,children:[U.name," \xB7 ",t.roles[U.id]]},U.id))]}),e("label",{for:"shared-run-search",children:"Search shared runs"}),e("input",{id:"shared-run-search",class:"field",type:"search",value:u,onInput:U=>f(U.currentTarget.value)})]}),e("p",{class:"shared-count",children:[h.runs.length," of ",h.total," results"]}),e("div",{class:"shared-run-list",children:h.runs.map(U=>e("button",{class:`shared-run ${y===U.id?"on":""}`,"aria-pressed":y===U.id,onClick:()=>C(U.id),children:[e("span",{class:`dot ${U.status}`,"aria-hidden":"true"}),e("span",{class:"t",children:U.task})," ",e("small",{children:[U.status," \xB7 ",new Date(U.createdAt).toLocaleString()]})]},U.id))}),h.nextCursor?e("div",{class:"shared-more",children:e("button",{class:"btn small",disabled:L||q,onClick:()=>void ie(h.nextCursor),children:"Load older shared runs"})}):null,!q&&!h.total?e("p",{class:"shared-empty",children:"No shared results match these filters."}):null]}),e("section",{class:"shared-result","aria-label":"Shared run result",children:T?e(M,{children:[e("div",{class:"shared-block shared-result-head",children:[e("h2",{children:T.task}),e("p",{class:"shared-meta",children:[e("span",{class:"sr-only",children:"Status: "}),e("span",{class:`status-pill ${T.status}`,children:T.status}),T.verdict?e("span",{class:"badge",children:T.verdict}):null,T.verification?e("span",{class:"badge",children:["verification ",T.verification.state]}):null]}),T.truncation.task||T.truncation.summary||T.truncation.error||T.truncation.omittedSteps?e("p",{class:"help",role:"status",children:["This shared result is a bounded preview",T.truncation.omittedSteps?`; ${T.truncation.omittedSteps} earlier steps are omitted`:"",". Ask the owner for any additional evidence needed."]}):null,T.summary?e("pre",{class:"shared-prose",children:T.summary}):null,T.error?e("p",{class:"shared-error",role:"alert",children:T.error}):null,T.stopReason?e("p",{children:T.stopReason}):null,T.steps?.length?e("div",{class:"shared-steps",children:T.steps.map(U=>e("details",{children:[e("summary",{children:[U.title," \xB7 ",U.status]}),U.finalText?e("pre",{class:"shared-prose",children:U.finalText}):null,U.error?e("p",{class:"shared-error",children:U.error}):null,U.finalTextTruncated||U.errorTruncated?e("p",{class:"help",children:"Step output is truncated in the shared preview."}):null]},U.id))}):null,e("div",{class:"shared-actions",children:e("a",{class:"btn small",href:Qs(`/api/runs/${G(T.id)}/export`),target:"_blank",rel:"noopener noreferrer",children:"Export shared result"})})]}),e("div",{class:"shared-block shared-review",children:[T.worktrees.length?e(M,{children:[e("label",{for:"shared-result-branch",children:"Result branch"}),e("select",{id:"shared-result-branch",class:"field",value:k,onChange:U=>b(U.currentTarget.value),children:T.worktrees.map(U=>e("option",{value:U.branch,children:[U.name," \xB7 ",U.branch]},U.branch))}),w?e("p",{class:"shared-coverage",children:[w.coverage.reviewed," of ",w.coverage.changed," visible files reviewed at ",w.head.slice(0,12),w.stale?" \xB7 earlier review is stale":"",w.omittedCount?` \xB7 ${w.omittedCount} omitted files require owner review`:""]}):null,S.map(U=>e("article",{class:"shared-review-file",children:[e("div",{class:"shared-file-head",children:[e("h3",{children:U.path}),e("p",{children:[U.status," \xB7 +",U.additions," \u2212",U.deletions,U.truncated?" \xB7 preview truncated":""]})]}),U.binary?e("p",{class:"help",children:"Binary file"}):e("pre",{class:"shared-diff",children:U.patch.split(`
|
|
113
|
+
`).map((oe,ke)=>e("span",{class:oe.startsWith("@@")?"dh":oe.startsWith("+")?"da":oe.startsWith("-")?"dd":void 0,children:oe},ke))}),w?e("label",{class:"check shared-reviewed",children:[e("input",{type:"checkbox",checked:w.reviewed.includes(U.path),disabled:!et||L,onChange:async oe=>{if(me.current)return;me.current=!0;let ke=oe.currentTarget.checked,we=_.current,ce=ke?[...new Set([...w.reviewed,U.path])]:w.reviewed.filter(tt=>tt!==U.path);j({...w,reviewed:ce,coverage:{...w.coverage,reviewed:ce.length,percent:w.files.length?Math.round(ce.length/w.files.length*100):100}}),H(!0),E("");try{let tt=await O(`/api/runs/${G(T.id)}/review-coverage`,{branch:k,expectedHead:w.head,path:U.path,reviewed:ke});_.current.selected===we.selected&&_.current.branch===we.branch&&j(tt)}catch(tt){_.current.selected===we.selected&&_.current.branch===we.branch&&j(w),E(is(tt))}finally{me.current=!1,H(!1)}}})," Reviewed ",U.path]}):null]},U.path))]}):null,e("div",{class:"shared-actions",children:e("button",{class:"btn small",disabled:L||!k,onClick:()=>ue(U=>U+1),children:"Refresh result evidence"})})]}),e("div",{class:"shared-block shared-thread",children:[e("h3",{children:"Human collaboration comments"}),A?.comments.map(U=>e("article",{class:"shared-comment",children:[e("strong",{children:U.actor.name}),e("p",{class:"help",children:[U.branch," \xB7 ",U.head.slice(0,12)," \xB7 ",new Date(U.at).toLocaleString()]}),e("p",{class:"shared-comment-text",children:U.text})]},U.id)),et&&w?e("form",{class:"shared-form",onSubmit:async U=>{if(U.preventDefault(),me.current)return;me.current=!0;let oe=_.current;H(!0),E("");try{let ke=await O(`/api/runs/${G(T.id)}/collaboration`,{branch:k,expectedHead:w.head,text:D});_.current.selected===oe.selected&&(P(ke),I(""))}catch(ke){E(is(ke))}finally{me.current=!1,H(!1)}},children:[e("label",{for:"shared-review-comment",children:"Comment on this result commit"}),e("textarea",{id:"shared-review-comment",class:"field",rows:4,maxLength:4e3,value:D,onInput:U=>I(U.currentTarget.value)}),e("button",{class:"btn primary",disabled:L||!D.trim(),children:"Record human comment"})]}):e("p",{class:"help",children:"A project reviewer can record comments and file coverage. The owner controls execution and shipping."})]})]}):e("p",{class:"shared-empty",children:"Choose a run to inspect its result."})})]})]})]})}function Um({route:t,go:s,onState:n}){let r=Z(n);return r.current=n,N(()=>kl(a=>r.current(a)),[]),e("div",{class:"shared-team",children:t.view==="team-task"?e(_r,{id:t.id,shared:!0,navigate:s},t.id):t.view==="team-people"?e(na,{project:t.project,shared:!0,navigate:s}):e(sa,{project:t.project,shared:!0,navigate:s})})}var Bm=Bt(()=>import("./team-server-wizard-2GLDWS6D.js").then(t=>t.TeamServerWizard));function ZC(){let t=Xe.value,[s,n]=m(!1);De(()=>{xt(),_s()},15e3,[Lt.value]);let r=fs.value,a=Jt.value;return s&&t.kind!=="host"?e(Bm,{onClose:()=>{n(!1),xt()}}):t.kind==="ssh"?e(M,{children:[e(Ur,{host:t,onManage:()=>n(!0)},t.id),e("section",{class:"settings-card",children:[e("h3",{children:["SSH workspace \xB7 ",t.name]}),e("p",{class:"help",children:"The workspace you opened over SSH has its own projects and task board. Manage the shared team server\u2019s projects, accounts and HTTPS in the setup above."}),e("a",{class:"btn",href:"/#/settings/connections/join",children:"Connect your computer to a team"})]})]}):e(M,{children:[t.kind!=="host"?e("section",{class:"settings-card",children:[e("h3",{children:"Host a team"}),e("p",{class:"help",children:"Set up a shared board on this computer or a connected remote server, with secure access and teammate accounts in one guided flow. Existing team connections stay connected."}),e("button",{class:"btn primary",onClick:()=>n(!0),children:"Set up team server"})]}):null,t.kind==="local"?e(os,{}):null,t.kind==="local"?e(Jd,{link:r}):e("section",{class:"settings-card",children:[e("h3",{children:"This computer"}),e("p",{class:"help",children:"A team link belongs to the computer whose agents run the work. Connect from the code-flow on your own computer; this workspace runs on a remote server."}),e("p",{class:"help",children:"Use Set up team server to install a separate team server on a connected SSH machine. The wizard configures its projects, HTTPS and teammate accounts."})]}),t.kind==="local"?e(Kd,{link:r,b:a}):null,e(Fm,{link:r,b:a}),a?.me.userId==="owner"&&r&&!r.linked?e(M,{children:[e(Hr,{board:a}),e(Wr,{board:a}),e(Br,{board:a})]}):null,e(Hm,{b:a})]})}function eT(){De(()=>{xt(),_s()},15e3,[Lt.value]);let t=fs.value,s=Jt.value;return e("div",{class:"team-join-settings",children:[e(os,{hideWhenEmpty:!0}),e(Jd,{link:t}),t?.linked?e("section",{class:"settings-card","aria-label":"Project readiness",children:[e("h3",{children:"Your team projects"}),e("p",{class:"help",children:"Your account is connected. Choose a local repository folder for each project you want to work on. Tasks you start here run on this computer."}),s?s.projects.length?e("ul",{class:"join-project-list",children:s.projects.map(n=>{let r=n.repositories.filter(c=>!t.mappings[n.id]?.[c.key]),a=Ne(n.role,"contributor");return e("li",{children:[e("div",{children:[e("b",{children:n.name}),e("span",{class:"help",children:[Ne(n.role,"maintainer")?"Maintainer":a?"Contributor":"Review access"," \xB7 ",a?n.repositories.length?r.length?`Choose ${r.length} local ${r.length===1?"folder":"folders"} below`:"Repositories connected":"Ask a maintainer to add a repository":"Ready to review"]})]}),e("a",{class:"btn small",href:Tn(`#/team/project/${encodeURIComponent(n.id)}`),children:"Open project board"})]},n.id)})}):e("p",{role:"status",children:"No projects have been shared with this account yet. Ask the owner for a project invitation."}):e("p",{role:"status",children:rs.value||"Loading your projects\u2026"})]}):null,t?.linked?e(Kd,{link:t,b:s}):null]})}function Jd({link:t}){let[s,n]=m(""),[r,a]=m(""),[c,i]=m(""),[d,l]=m(""),[p,o]=m(!1),[u,f]=m(""),[h,g]=m(!1),y;try{s.trim()&&(y=or(s))}catch{}N(()=>{t&&!t.linked&&!d&&t.machineName&&l(t.machineName)},[t?.machineName]);let C=async v=>{if(v.preventDefault(),!p){o(!0),f("");try{let k=or(s);if(k.invitation)throw new Error("Open the invitation first to join the project and choose your account.");let b=await O("/api/team-link/connect",{url:k.url,username:r.trim(),password:c,...d.trim()?{name:d.trim()}:{}});i(""),J("Connected to the team server"),location.hash="#/settings/connections/join",go(b.id)}catch(k){i(""),f(k.message)}finally{o(!1)}}},T=async()=>{if(!(!t||!await Ae(`Disconnect this computer from ${t.hubName||t.url||"the team server"}? Its runner credential is revoked; attempts you ran here stay on the board as they are.`,{title:"Disconnect this computer?",confirmLabel:"Disconnect",danger:!0}))){o(!0),f("");try{await _n("/api/team-link"),J("Disconnected"),go("local")}catch(v){f(v.message)}finally{o(!1)}}};return e("section",{class:"settings-card","aria-busy":p,children:[e("h3",{children:t?.linked&&!h?"This computer":"Connect to your team"}),t?t.linked&&!h?e(M,{children:[e("p",{class:"help",children:"Linked to a team server: its board shows under Team, and tasks you start here publish their progress and checkpoints to it."}),e("dl",{class:"team-kv",children:[e("dt",{children:"Connection"}),e("dd",{children:e("span",{class:`badge ${t.connection==="connected"?"ok":"warn"}`,children:t.connection==="connected"?"Connected":t.connection==="reconnecting"?"Reconnecting\u2026":t.connection==="offline"?"Offline":"Checking\u2026"})}),e("dt",{children:"Team server"}),e("dd",{children:[e("code",{children:t.url}),t.hubName?` \xB7 ${t.hubName}`:""]}),e("dt",{children:"Signed in as"}),e("dd",{children:t.user?`${t.user.displayName} (${t.user.username})`:"unknown"}),e("dt",{children:"Machine name"}),e("dd",{children:t.machineName??t.runner?.name??"\u2014"}),e("dt",{children:"Runner"}),e("dd",{children:t.runner?e(M,{children:[e("span",{class:`badge ${t.runner.revokedAt?"warn":t.runner.online?"ok":""}`,children:t.runner.revokedAt?"Revoked":t.runner.online?"Online":"Offline"})," ",e("span",{class:"help",children:["last seen ",pt(t.runner.lastSeenAt)]})]}):e("span",{class:"help",children:"Not reported yet"})}),t.lastSync?e(M,{children:[e("dt",{children:"Last sync"}),e("dd",{children:pt(t.lastSync)})]}):null]}),t.error?e("p",{class:"msg err",role:"alert",children:t.error}):null,e("div",{class:"settings-actions",children:[e("button",{class:"btn primary",disabled:p,onClick:()=>g(!0),children:"Add team connection"}),e("button",{class:"btn",disabled:p,onClick:()=>void T(),children:"Disconnect this team"})]})]}):e("form",{class:"team-connect",onSubmit:v=>void C(v),children:[e("p",{class:"help",children:"Join a teammate's board: the team server is another code-flow reachable over HTTPS (through Tailscale or another network), and you sign in with the shared account its owner created for you with the contributor or maintainer role. This computer stays the only place your agents run. You can save several team servers and keep using your own board."}),e("div",{class:"settings-grid",children:[e("label",{children:["Team server URL",e("input",{class:"field",type:"url",required:!0,placeholder:"Paste a team address, invitation or connection link",value:s,disabled:p,autoComplete:"url",onInput:v=>{let k=v.currentTarget.value;n(k);try{let b=or(k);b.username&&a(b.username)}catch{}}})]}),y?.invitation?null:e(M,{children:[e("label",{children:["Username",e("input",{class:"field",required:!0,maxLength:64,value:r,disabled:p,autoComplete:"username",onInput:v=>a(v.currentTarget.value)})]}),e("label",{children:["Password",e("input",{class:"field",type:"password",required:!0,value:c,disabled:p,autoComplete:"current-password",onInput:v=>i(v.currentTarget.value)})]}),e("label",{children:["Machine name",e("input",{class:"field",maxLength:80,value:d,disabled:p,placeholder:"How teammates see this computer",onInput:v=>l(v.currentTarget.value)})]})]})]}),y?.invitation?e("div",{children:[e("p",{class:"help",children:["First accept the invitation on ",y.url,". Then return here with your account to connect this computer."]}),e("a",{class:"btn primary",href:y.invitation,target:"_blank",rel:"noreferrer",children:"Open invitation"})]}):e(M,{children:[e("p",{class:"help",children:"Connect to your team\u2019s Wi-Fi or Tailscale network first. After signing in, choose your local repository folders."}),e("div",{class:"settings-actions",children:e("button",{type:"submit",class:"btn primary",disabled:p||!s.trim()||!r.trim()||!c,children:p?"Connecting\u2026":"Connect this computer"})})]}),h?e("button",{type:"button",class:"btn",onClick:()=>g(!1),children:"Cancel"}):null]}):e("p",{class:"help",children:fo.value?`The team link could not be read: ${fo.value}`:"Loading\u2026"}),u?e("p",{class:"msg err",role:"alert",children:u}):null]})}function Kd({link:t,b:s}){let[n,r]=m({}),[a,c]=m(""),[i,d]=m(""),l=(s?.projects??[]).flatMap(o=>o.repositories.map(u=>({project:o,ref:u,key:`${o.id}/${u.key}`,saved:t?.mappings[o.id]?.[u.key]??""}))),p=async(o,u,f,h)=>{if(!a){c(h),d("");try{await vs("/api/team-link/mappings",{projectId:o,repository:u,path:f}),J("Repository mapped"),await _s(),r(g=>{let y={...g};return delete y[h],y})}catch(g){d(g.message)}finally{c("")}}};return e("section",{class:"settings-card",children:[e("h3",{children:"Repositories"}),e("p",{class:"help",children:"Tasks name a repository by its key; map each key to your clone so attempts, hand-overs and fetched checkpoints land there. Paths stay on this computer and never reach the team server."}),s?l.length?e("div",{class:"team-mappings",children:l.map(({project:o,ref:u,key:f,saved:h})=>{let g=n[f]??h,y=g!==h,C=`team-map-${f.replace(/[^a-zA-Z0-9_-]/g,"_")}`;return e("div",{class:"team-mapping",children:[e("label",{for:C,children:[o.name," \xB7 ",u.label," ",e("code",{children:u.key}),u.remote?e("span",{class:"help",children:[" ",u.remote]}):null]}),e("div",{class:"row-inline",children:[e("input",{id:C,class:"field mono",placeholder:"/absolute/path/to/your/clone",value:g,disabled:!!a,onInput:T=>r({...n,[f]:T.currentTarget.value})}),e("button",{type:"button",class:"btn small",disabled:!!a,onClick:()=>{Ns.value={title:`Choose ${u.label} repository`,choose:T=>r(v=>({...v,[f]:T}))},ct.value=!0},children:"Choose folder"}),e("button",{type:"button",class:"btn small",disabled:!!a||!ee.value,title:ee.value||"Choose a repository in the composer first",onClick:()=>r({...n,[f]:ee.value}),children:"Use current repository"}),e("button",{type:"button",class:"btn small primary",disabled:!!a||!y||!g.trim(),onClick:()=>void p(o.id,u.key,g.trim(),f),children:a===f?"Saving\u2026":"Save"})]}),!h&&!y?e("span",{class:"help",children:"Not mapped on this computer."}):null]},f)})}):e("p",{class:"help",children:["No repository keys yet. A maintainer defines them per project",t?.linked?" on the team server":" in the Team server card below","."]}):e("p",{class:"help",children:rs.value||"Loading the board\u2026"}),i?e("p",{class:"msg err",role:"alert",children:i}):null]})}function Fm({link:t,b:s}){let n=!!t&&!t.linked,[r,a]=m(null),[c,i]=m(""),[d,l]=m(!1),[p,o]=m("");De(async h=>{if(n)try{let g=await V("/api/remote");h()&&a(g)}catch{h()&&a(null)}},3e4,[n],n),N(()=>{s&&s.me.userId==="owner"&&i(s.me.displayName)},[s?.me.displayName]);let u=(s?.projects??[]).filter(h=>Ne(h.role,"maintainer")),f=wl(r);return e("section",{class:"settings-card",children:[e("h3",{children:"Team server"}),t?n?e(M,{children:[e("p",{class:"help",children:"This computer is a team server: teammates reach its board over HTTPS with shared accounts, and work runs on their own computers or through the host permissions below."}),e("dl",{class:"team-kv",children:[e("dt",{children:"Address"}),e("dd",{children:f?e(M,{children:[e("code",{children:f})," ",e("button",{type:"button",class:"btn small",onClick:()=>void Kt(f,"Address copied"),children:"Copy"}),e("span",{class:"help",children:" Teammates enter this address under Connections \u2192 Share access \u2192 Connect this computer. Never share the phone link from Settings \u2192 Remote access: its path is a secret."})]}):r?.tailscaleUrl||r?.lanUrls?.length?e("span",{class:"help",children:["Remote access is on without HTTPS. ",e("a",{href:"#/settings/connections/devices",children:"Set up secure remote access in Settings \u2192 Remote access"}),": teammates sign in and connect their computers over https:// only."]}):e("span",{class:"help",children:[e("a",{href:"#/settings/connections/devices",children:"Turn on secure remote access in Settings \u2192 Remote access"})," so teammates can reach this computer."]})}),e("dt",{children:"Accounts"}),e("dd",{children:[e("a",{class:"btn small",href:"#/settings/connections/manage",children:"Accounts & roles"}),e("span",{class:"help",children:" Give teammates the contributor role to own and run tasks, maintainer to manage project repository keys. Only the hub owner manages other accounts\u2019 runners."})]})]}),s?.me.userId==="owner"?e("form",{class:"team-inline",onSubmit:async h=>{if(h.preventDefault(),!d){l(!0),o("");try{await vs("/api/team/profile",{displayName:c.trim()}),J("Name saved"),xt()}catch(g){o(g.message)}finally{l(!1)}}},children:[e("label",{children:["Your name on the board",e("input",{class:"field",required:!0,maxLength:120,value:c,disabled:d,onInput:h=>i(h.currentTarget.value)})]}),e("button",{type:"submit",class:"btn small",disabled:d||!c.trim()||c.trim()===s.me.displayName,children:"Save name"})]}):null]}):e("p",{class:"help",children:["This computer is linked to ",t.hubName||t.url,": the board, the accounts and the runners live there.",u.length?" As a maintainer you can edit repository keys below.":""]}):e("p",{class:"help",children:"Loading\u2026"}),p?e("p",{class:"msg err",role:"alert",children:p}):null,s&&u.map(h=>e(ui,{project:h,revision:s.revision},h.id)),s&&t&&!u.length?e("p",{class:"help",children:n?"Create a project to define its repository keys.":"Repository keys are edited by project maintainers."}):null]})}function ui({project:t,revision:s}){let[n,r]=m(t.repositories.map(g=>({...g}))),[a,c]=m(!1),[i,d]=m(""),l=JSON.stringify(t.repositories),p=JSON.stringify(n)!==l,o=Z(p);o.current=p,N(()=>{o.current||r(t.repositories.map(g=>({...g})))},[l]);let u=(g,y)=>r(n.map((C,T)=>T===g?{...C,...y}:C)),f=async()=>{if(a)return;c(!0),d("");let g=n.map(y=>({key:y.key.trim(),label:y.label.trim()||y.key.trim(),...y.remote?.trim()?{remote:y.remote.trim()}:{},...y.defaultBranch?.trim()?{defaultBranch:y.defaultBranch.trim()}:{}}));try{await vs(`/api/team/projects/${G(t.id)}/repositories`,{repositories:g,revision:s}),J("Repository keys saved"),xt()}catch(y){y instanceof st&&y.status===409?(J("Board changed; reloading",3e3),xt()):d(y.message)}finally{c(!1)}},h=(g,y)=>`team-keys-${t.id}-${g}-${y}`;return e("fieldset",{class:"team-keys",disabled:a,children:[e("legend",{children:["Repository keys \xB7 ",t.name]}),e("p",{class:"help",children:"A key is up to 64 lowercase letters, digits or dashes and starts with a letter; the remote and default branch are hints for teammates."}),n.map((g,y)=>e("div",{class:"team-key-row",children:[e("label",{for:h(y,"key"),children:"Key"}),e("input",{id:h(y,"key"),class:"field mono",required:!0,pattern:"[a-z][a-z0-9-]{0,63}",maxLength:64,value:g.key,onInput:C=>u(y,{key:C.currentTarget.value})}),e("label",{for:h(y,"label"),children:"Label"}),e("input",{id:h(y,"label"),class:"field",maxLength:80,value:g.label,onInput:C=>u(y,{label:C.currentTarget.value})}),e("label",{for:h(y,"remote"),children:"Remote"}),e("input",{id:h(y,"remote"),class:"field mono",maxLength:300,placeholder:"git@github.com:org/repo.git",value:g.remote??"",onInput:C=>u(y,{remote:C.currentTarget.value})}),e("label",{for:h(y,"branch"),children:"Default branch"}),e("input",{id:h(y,"branch"),class:"field mono",maxLength:100,placeholder:"main",value:g.defaultBranch??"",onInput:C=>u(y,{defaultBranch:C.currentTarget.value})}),e("button",{type:"button",class:"btn small ghost","aria-label":`Remove repository key ${g.key||y+1}`,onClick:()=>r(n.filter((C,T)=>T!==y)),children:"Remove"})]},y)),e("div",{class:"settings-actions",children:[e("button",{type:"button",class:"btn small",disabled:n.length>=50,onClick:()=>r([...n,{key:"",label:""}]),children:"Add repository"}),e("button",{type:"button",class:"btn small primary",disabled:!p||n.some(g=>!/^[a-z][a-z0-9-]{0,63}$/.test(g.key.trim())),onClick:()=>void f(),children:"Save repository keys"}),p?e("button",{type:"button",class:"btn small",onClick:()=>r(t.repositories.map(g=>({...g}))),children:"Discard"}):null]}),i?e("p",{class:"msg err",role:"alert",children:i}):null]})}function Hm({b:t}){let[s,n]=m(null),[r,a]=m(""),[c,i]=m(""),d=async(o=()=>!0)=>{try{let u=await V("/api/team/runners");o()&&(n(Array.isArray(u)?u:u.runners??[]),i(""))}catch(u){o()&&i(u.message)}};De(d,15e3,[Lt.value]);let l=async o=>{if(await Ae(`Revoke the runner ${o.name}? Its computer must connect again to work on the board. Active tasks stay reserved until execution is confirmed stopped.`,{title:"Revoke runner access?",confirmLabel:"Revoke access",danger:!0})){a(o.id),i("");try{await _n(`/api/team/runners/${G(o.id)}`),J("Runner revoked"),await d()}catch(u){i(u.message)}finally{a("")}}},p=(s??[]).slice().sort((o,u)=>+!!o.revokedAt-+!!u.revokedAt||u.lastSeenAt-o.lastSeenAt);return e("section",{class:"settings-card",children:[e("h3",{children:"Runners"}),e("p",{class:"help",children:["The computers connected to the board",t?.me.userId==="owner"?" (every teammate's, as the team server's owner)":" with your account",". Revoking one ends its credential; the work it did stays."]}),c?e("p",{class:"msg err",role:"alert",children:c}):null,s===null&&!c?e("p",{class:"help",role:"status",children:"Loading\u2026"}):null,s&&!s.length?e("p",{class:"help",children:"No runner has connected yet."}):null,p.length?e("div",{class:"pd-list",children:p.map(o=>e("div",{class:"pd-row",children:[e("span",{class:"pd-name",children:o.name}),e("span",{class:`badge ${o.revokedAt?"warn":o.online?"ok":""}`,children:o.revokedAt?"Revoked":o.online?"Online":"Offline"}),e("span",{class:"pd-when",children:[xl(t,o.userId)," \xB7 last seen ",pt(o.lastSeenAt)]}),o.revokedAt?null:e("button",{type:"button",class:"btn small",disabled:!!r,onClick:()=>void l(o),children:r===o.id?"Revoking\u2026":"Revoke"})]},o.id))}):null]})}function na({project:t,shared:s=!1,embedded:n=!1,navigate:r}){De(()=>void xt(),s?0:15e3,[Lt.value,s]);let a=Jt.value;if(!a)return e("p",{role:rs.value?"alert":"status",children:rs.value||"Loading people\u2026"});let c=a.projects.filter(l=>!t||l.id===t);if(!c.length)return e("p",{role:"status",children:"No accessible project here. Ask the project owner for access."});let i=!s&&Da==="local"&&a.me.userId==="owner",d={...a,projects:c};return e("section",{class:"team-page project-people","aria-label":"Project people",children:[!s&&!n?e(os,{}):null,e("h2",{children:"People"}),e("p",{class:"help",children:"Project members and access. Task ownership and progress are on the Board."}),e("button",{class:"btn",onClick:()=>r({view:"team",...t?{project:t}:{}}),children:"Open Board"}),c.map(l=>e("section",{class:"settings-card",children:[e("h3",{children:l.name}),e("ul",{children:l.members.map(p=>e("li",{children:[p.displayName," \xB7 ",fa(p.role)]},p.userId))}),Ne(l.role,"maintainer")?e(ui,{project:l,revision:a.revision}):null]},l.id)),i?e(M,{children:[e(jl,{projects:c,projectId:t}),e(Vd,{projects:he.value,projectId:t}),e(Hr,{board:d}),e(Br,{board:d})]}):e("p",{class:"help",children:"The project owner manages accounts and grants. Your role controls the actions available here."})]})}function zd(t){let[s,n]=m({board:!1,automation:!1});return De(async r=>{let a=await Promise.allSettled([V("/api/team/board?teamConnection=local"),V("/api/automations"),V("/api/deferred-runs"),V(`/api/project-teams?project=${encodeURIComponent(t)}`)]);if(!r())return;let[c,i,d,l]=a,p=c.status==="fulfilled"&&(c.value.tasks.some(u=>u.projectId===t)||c.value.projects.some(u=>u.id===t&&(u.repositories.length>0||u.members.some(f=>f.userId!=="owner")))),o=i.status==="fulfilled"&&i.value.some(u=>u.run.project===t)||d.status==="fulfilled"&&d.value.some(u=>u.run.project===t)||l.status==="fulfilled"&&l.value.teams.length>0;n(u=>({board:u.board||p,automation:u.automation||o}))},15e3,[t]),s}function mi({id:t,section:s,repository:n,tool:r,kind:a}){let c=zd(t),i=he.value.find(o=>o.id===t);if(!i)return e("div",{class:"project-page",children:[e("p",{role:"status",children:qs.value?"This project is unavailable. Its existing runs and saved draft are retained.":"Loading project\u2026"}),e("a",{class:"btn",href:"#/",children:"Open new run"})]});let d=o=>{let u=Is({view:"project",id:t,...o?{section:o}:{}});return o==="board"||o==="people"?Tn(u,"local"):u},l=o=>{o.view==="team"&&o.project===t?Y.value={view:"project",id:t,section:"board"}:o.view==="team-people"&&o.project===t?Y.value={view:"project",id:t,section:"people"}:Y.value=o};if((s==="board"||s==="people")&&Da!=="local")return e("p",{role:"status",children:["Opening this project's board on ",Yt(),"\u2026 ",e("a",{href:d(s),children:"Continue"})]});let p=n??(i.repos.length===1?i.repos[0]:void 0);return e("div",{class:"project-page",children:[e("header",{class:"page-head",children:[e("div",{class:"page-head-text pp-title",children:[e("h1",{children:i.name}),e("p",{class:"project-computer-label",children:[e(K,{name:"terminal"}),"Computer: ",Yt()]})]}),e("div",{class:"page-head-actions",children:[e("button",{class:"btn primary",disabled:!Ut.value||dt.value,onClick:()=>void Qe(t),children:[e(K,{name:"plus"}),"New run"]}),e(Ve,{label:"Project actions",icon:"more",children:o=>e(M,{children:[e(pe,{onClick:()=>{o(),da(t)},children:"Edit project"}),e(pe,{onClick:()=>{o(),Y.value={view:"project",id:t,section:"settings"}},children:"Project settings"})]})})]})]}),e("nav",{class:"project-tabs","aria-label":"Project navigation",children:[[[void 0,"Overview"],["runs","Runs"],["repositories","Repositories"]].map(([o,u])=>e("a",{class:`btn ${s===o?"primary":""}`,href:d(o),"aria-current":s===o?"page":void 0,children:u})),c.board||s==="board"?e("a",{class:"btn",href:d("board"),"aria-current":s==="board"?"page":void 0,children:"Board"}):null,c.automation||s==="automation"?e("a",{class:"btn",href:d("automation"),"aria-current":s==="automation"?"page":void 0,children:"Automation"}):null,e("a",{class:"btn",href:d("settings"),"aria-current":s==="settings"?"page":void 0,children:"Project settings"}),e(Ve,{label:"More project tools",icon:"more",trigger:e("span",{children:"More"}),class:"project-more",children:o=>e(M,{children:["board","people","automation"].map(u=>e(pe,{onClick:()=>{o(),u==="board"||u==="people"?location.assign(d(u)):Y.value={view:"project",id:t,section:u}},children:{board:"Board",people:"People",automation:"Automation"}[u]}))})})]}),s?s==="board"?e(sa,{project:t,embedded:!0,navigate:l}):s==="people"?e(na,{project:t,embedded:!0,navigate:l}):s==="automation"?e(vr,{projectId:t,kind:a},t):s==="runs"?e(_m,{projectId:t},t):s==="repositories"?e(M,{children:[e("div",{class:"project-repository-head",children:[e("h2",{children:"Repositories"}),e("button",{class:"btn",onClick:()=>zs(t),children:[e(K,{name:"plus"}),"Add repository"]})]}),i.repos.length?e("div",{class:"project-repository-list",children:i.repos.map(o=>e("a",{class:`pp-card project-repository ${p===o?"selected":""}`,href:Is({view:"project",id:t,section:"repositories",repository:o,tool:"code"}),children:[e("strong",{children:be(o)}),e("code",{children:o}),e("span",{children:"Open repository tools \u2192"})]}))}):e("p",{class:"help",children:["No repositories yet. Add a repository from ",Yt()," to use its files and tools."]}),p?e(Sr,{projectId:t,initialFolder:p,initialTool:r,onNavigate:(o,u)=>{Y.value={view:"project",id:t,section:"repositories",repository:o,tool:u}}},`${t}:${p}`):i.repos.length?e("p",{class:"help",children:"Choose a repository to inspect its files, checks, services and history."}):null]}):e(M,{children:[e("section",{class:"pp-card project-start",children:[e("h2",{children:"Project settings"}),e("p",{children:"Manage the project's name and repository membership."}),e("button",{class:"btn",onClick:()=>da(t),children:"Edit project"})]}),e(kr,{project:t}),i.repos.map(o=>e(sc,{repository:o},o)),e("a",{class:"btn",href:Is({view:"project",id:t,section:"automation",kind:"missions"}),children:"Manage project missions"})]}):e(M,{children:[e("section",{class:"project-start pp-card","aria-label":"Start work",children:[e("h2",{children:vt.value===t&&Me.value.trim()?"Continue your draft":"What would you like to work on?"}),e("p",{children:i.repos.length?"Describe the outcome, choose your agents, and review the result here.":"Add a repository to start a run in this project."}),vt.value===t&&Me.value.trim()?e("p",{class:"draft-preview",children:Me.value.slice(0,240)}):null,e("button",{class:"btn primary",disabled:!Ut.value||dt.value,onClick:()=>i.repos.length?void Qe(t):zs(t),children:i.repos.length?vt.value===t&&Me.value.trim()?"Continue draft":"Describe a task":"Add repository"})]}),e(ur,{projectId:t}),e(Wm,{id:t},t),e("a",{class:"btn",href:d("runs"),children:"View run history"})]})]})}function Wm({id:t}){let[s,n]=m(null),[r,a]=m(""),[c,i]=m({waiting:100,running:100,results:8}),[d,l]=m(!1);De(async o=>{l(!0);try{let u=await V(`/api/projects/${G(t)}/summary`);for(let f of["waiting","running","results"]){let h=u.sections[f];for(;o()&&h.nextCursor&&h.runs.length<c[f];){let g=await V(`/api/runs?limit=${Math.min(100,c[f]-h.runs.length)}&project=${G(t)}§ion=${f}&cursor=${G(h.nextCursor)}`);h={...g,runs:[...h.runs,...g.runs]}}u.sections[f]=h}o()&&(n(u),a(""))}catch(u){o()&&a(u.message)}finally{o()&&l(!1)}},15e3,[t,c.waiting,c.running,c.results]);let p=o=>i(u=>({...u,[o]:u[o]+100}));return e(M,{children:[e("div",{class:"ins-cards pp-numbers",children:[e(pi,{label:"Runs this week",value:s?String(s.week.runs):"\u2013"}),e(pi,{label:"Checks passed",value:s?.week.runs?`${s.week.passed} of ${s.week.runs}`:"\u2013"}),e(pi,{label:"API-equivalent",value:s?.week.costUsd?ht(s.week.costUsd):"\u2013",hint:"Claude's cost, as a measure of size"})]}),r?e("p",{class:"msg err",role:"alert",children:r}):null,s?["waiting","running","results"].map(o=>{let u=s.sections[o];return o!=="results"&&!u.total?null:e(Gd,{title:{waiting:"Needs you",running:"Running",results:"Recent results"}[o],count:u.total,runs:u.runs,attention:o==="waiting",empty:"No results yet. Start a run above.",more:u.nextCursor?()=>p(o):void 0,moreCount:Math.max(0,u.total-u.runs.length),loading:d},o)}):e("p",{class:"help",children:"Loading project history\u2026"})]})}function pi({label:t,value:s,hint:n}){return e("div",{class:"ins-card",title:n,children:[e("div",{class:"ic-label",children:t}),e("div",{class:"ic-value",children:s})]})}function _m({projectId:t}){let[s,n]=m(""),[r,a]=m(!1),[c,i]=m([]),[d,l]=m(null),[p,o]=m(null),[u,f]=m(!1),[h,g]=m(""),y=Z(0),C=async S=>{let x=++y.current;f(!0),g("");try{let w=new URLSearchParams({project:t,limit:"100",q:s.trim()});S&&w.set("cursor",S);let j=await V(`/api/runs?${w}`);if(x!==y.current)return;i(A=>S?[...A,...j.runs]:j.runs),o(s.trim()),l(j.nextCursor??null)}catch(w){x===y.current&&g(w.message)}finally{x===y.current&&f(!1)}};N(()=>{let S=setTimeout(()=>void C(),150);return()=>{clearTimeout(S),y.current++}},[t,s]);let T=new Map(c.map(S=>[S.id,ve.value.get(S.id)??S]));for(let S of ve.value.values())Ke(S)?.id===t&&T.set(S.id,S);let v=s.trim().toLowerCase().split(/\s+/).filter(Boolean),k=new Set(p===s.trim()?c.map(S=>S.id):[]),b=[...T.values()].filter(S=>Ke(S)?.id===t&&!S.deleted&&(r||!S.archived)&&(S.cold&&k.has(S.id)||v.every(x=>Nd(S).includes(x)))).sort((S,x)=>x.createdAt-S.createdAt);return e("section",{"aria-label":"Project run history",children:[e("div",{class:"project-history-controls",children:[e("label",{children:["Search this project's runs",e("input",{class:"field",type:"search",value:s,onInput:S=>n(S.currentTarget.value)})]}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:r,onChange:S=>a(S.currentTarget.checked)}),"Include archived runs"]})]}),h?e("p",{class:"msg err",role:"alert",children:[h," ",e("button",{class:"btn small",onClick:()=>void C(),children:"Retry"})]}):null,e(Gd,{title:"Run history",count:b.length,runs:b,empty:u?"Loading runs\u2026":"No runs match this view."}),d?e("button",{class:"btn",disabled:u,onClick:()=>void C(d),children:u?"Loading\u2026":"Load older runs"}):null]})}function Gd({title:t,runs:s,count:n,empty:r,more:a,moreCount:c=0,attention:i=!1,loading:d=!1}){return e("section",{class:`pp-card ${i?"attention":""}`,"aria-label":t,children:[e("div",{class:"pp-card-head",children:[e("h2",{children:t}),n?e("span",{class:`pp-count ${i?"warn":""}`,children:n}):null]}),s.length?e("div",{class:"pp-list",children:s.map(l=>e(Vm,{run:l},l.id))}):r?e("p",{class:"pp-empty",children:r}):null,a?e("button",{type:"button",class:"pp-more",disabled:d,onClick:a,children:["Show ",Math.min(100,c)," more"]}):null]})}function Vm({run:t}){let s=ft(t),n=ge.value.find(d=>d.id===t.pattern)?.name??t.pattern,r=t.merges.length>0,a=Object.keys(t.prs).length>0,c=(d,l)=>e("span",{class:`status-pill ${d}`,children:l}),i=t.awaiting?c("awaiting","Waiting for you"):s==="failing"?c("failing","Check fails"):s==="done"?c("done","Check passes"):t.status!=="done"?c(t.status,Je[t.status]??t.status):c(s,at(t));return e("a",{class:"pp-row",href:`#/run/${encodeURIComponent(t.id)}`,title:t.task,children:[e("span",{class:`dot ${s}`,"aria-hidden":"true"}),e("span",{class:"t",children:t.task.split(`
|
|
114
|
+
`)[0]||"(no task)"}),e("span",{class:"pills",children:[i,t.archived?c("","Archived"):null,r?c("","Merged"):a?c("","PR open"):null]}),e("span",{class:"m",children:[n," \xB7 ",es(t.createdAt)]})]})}function Yd(){let[t,s]=m(null),[n,r]=m(""),a=window.codeflowDesktop;return N(()=>{if(!a)return;let i=!0,d=!1,l=a.onUpdateState(p=>{d=!0,s(p),r("")});return a.getUpdateState().then(p=>{i&&!d&&s(p)},()=>{i&&r("Could not connect to the desktop updater. Try again.")}),()=>{i=!1,l()}},[a]),{state:t,error:n,bridge:a,act:async i=>{r("");try{s(await i())}catch{r("Could not connect to the desktop updater. Try again.")}}}}function BT(){let{state:t,error:s,bridge:n,act:r}=Yd();if(!n)return null;let a=t&&["checking","downloading","installing"].includes(t.phase),c=t?.phase==="downloaded",i=t?.phase==="available";return e("section",{class:"settings-card","aria-label":"App updates","aria-busy":!!a,children:[e("h3",{children:"App updates"}),e("div",{class:"settings-row",children:[e("div",{children:[e("strong",{children:["Code Flow",t?` ${t.currentVersion}`:""]}),e("p",{role:"status","aria-live":"polite",children:t?.message??"Connecting to the desktop updater\u2026"})]}),e("div",{class:"settings-row-control",children:e("button",{class:`btn ${c||i?"primary":""}`,disabled:!!a||t?.phase==="unsupported",onClick:()=>void r(c?()=>n.installUpdate():i?()=>n.downloadUpdate():()=>n.checkForUpdates()),children:t?.phase==="checking"?"Checking\u2026":t?.phase==="downloading"?"Downloading\u2026":t?.phase==="installing"?"Restarting\u2026":c?"Restart to update":i?t.canInstall?"Download update":"Download installer":"Check for updates"})})]}),t?.releaseUrl?e("div",{class:"settings-actions",children:[e("a",{href:t.releaseUrl,target:"_blank",rel:"noreferrer",children:"Release notes \u2197"}),t.phase==="error"&&t.downloadUrl?e("button",{class:"btn small",onClick:()=>void r(()=>n.openUpdateInstaller()),children:"Download installer"}):null]}):null,t?.checkedAt?e("p",{class:"help",children:["Last checked ",new Date(t.checkedAt).toLocaleString(),"."]}):null,s?e("p",{class:"msg err",role:"alert",children:s}):null]})}function Qd({collapsed:t}){let{state:s}=Yd();if(!s||!["available","downloading","downloaded"].includes(s.phase))return null;let n=s.phase==="downloaded"?"Restart to update":s.phase==="downloading"?"Downloading update\u2026":"Update available";return e("a",{class:"desktop-update-notice",href:"#/settings/general",title:n,"aria-label":n,children:[e(K,{name:"refresh"}),t?null:e("span",{children:n})]})}function Xd(){let[t,s]=m(null),[n,r]=m(""),a=JSON.stringify(he.value.map(c=>[c.id,c.name,c.repos]));return N(()=>{if(Xe.value.kind==="host")return;let c=!0,i=!1,l=lt(async()=>{if(!(i||document.hidden)){i=!0;try{let p=await ds("/api/workspace-projects");c&&(s({...p,currentComputerId:As??"local"}),r(""))}catch{c&&(s(null),r("Connected projects unavailable"))}finally{i=!1}}},15e3);return()=>{c=!1,l()}},[a,Xe.value.kind]),{directory:t,error:n}}function hi({directory:t,error:s,query:n,children:r}){return t?t.computers.length===1?e(M,{children:r}):e(M,{children:t.computers.map(a=>{let c=a.id===t.currentComputerId,i=a.projects.filter(d=>`${a.name} ${d.name}`.toLocaleLowerCase().includes(n.trim().toLocaleLowerCase())).sort((d,l)=>d.name.localeCompare(l.name)||d.id.localeCompare(l.id));return!c&&n.trim()&&!i.length?null:e("details",{class:"computer-projects",open:!0,"data-computer-id":a.id,children:[e("summary",{class:"rail-title",children:[a.name,e("span",{class:"computer-project-count",children:c?"Current":a.projects.length})]}),e("div",{role:"group","aria-label":`${a.name} projects`,children:c?r:a.error?e("p",{class:"rail-empty",role:"status",children:a.error}):i.length?i.map(d=>{let l=Ma(a.id,`#/project/${encodeURIComponent(d.id)}`);return e("a",{class:"connected-project-link",href:l,title:`Open ${d.name} on ${a.name}`,children:e("span",{children:d.name})},d.id)}):e("p",{class:"rail-empty",children:"No projects yet"})})]},a.id)})}):s||Xe.value.kind==="host"?e(M,{children:[r,s?e("p",{class:"rail-empty",role:"status",children:s}):null]}):e("p",{class:"rail-empty",role:"status",children:"Loading projects\u2026"})}var Jm=[["all","All"],["attention","Needs you"],["running","Running"],["passed","Passed"],["failing","Failing"],["flagged","Tests changed"]],Km=5,Zd=t=>t.awaiting||gt(t)?"Waiting for you":zt(t)?"Unresolved work":t.triage?.state==="pending"?"In your inbox":ft(t)==="failing"?"Check failing":ft(t)==="unchecked"?"Check can't run":ft(t)==="unverified"?"Finished \xB7 not verified":Je[t.status]??t.status,zm=t=>es(t).replace(" ago","").replace("just now","now");function eu(){let t=Xd(),s=t.directory,n=s&&s.computers.length>1?s.computers.find(R=>R.id===s.currentComputerId):void 0,[r,a]=m(!1),[c,i]=m(!1),[d,l]=m(!1),[p,o]=m(new Set),[u,f]=m(null),[h,g]=m(!1),[y,C]=m(""),[T,v]=m(new Set),k=dl.value,b=il.value,S=ll.value,x=Y.value,w=x.view==="run"||x.view==="review"?x.id:void 0,j=x.view==="project"?x.id:void 0,A=Li([...ve.value.values()]),P=new Map(A.map(R=>[R.root.id,R])),D=R=>P.get(R.id)?.chats??[R],I=R=>D(R).every(X=>X.archived),$=R=>D(R).some(X=>X.status==="running"),E=R=>D(R).some(Rn),L=R=>D(R).some(Ni),H=R=>P.get(R.id)?.updatedAt??R.createdAt,Q=R=>{let X=D(R).filter(se=>!se.archived).sort((se,Ce)=>zr(Ce)-zr(se));return X.find(se=>se.awaiting||gt(se))??X.find(se=>se.status==="running")??X.find(Rn)??X[0]??R},le=w&&ve.value.get(w)?nt(ve.value.get(w)):w,de=A.map(R=>R.root),ue=de.filter(R=>D(R).some(X=>cl(X)&&(!X.archived||k.archived))),q=de.filter(I).length,te=ue.filter(R=>!$(R)),me=te.map(R=>R.id).join(","),W=te.filter(R=>p.has(R.id));N(()=>{let R=new Set(me.split(","));o(X=>new Set([...X].filter(se=>R.has(se))))},[me]);let re=R=>o(X=>{let se=new Set(X);return se.delete(R),se}),ne=R=>o(X=>{let se=new Set(X);return se.has(R)?se.delete(R):se.add(R),se}),_=async R=>R.pattern==="solo"?await V(`/api/runs/${R.id}/chats`):[R],ie=async(R,X)=>{let se=await _(R);if(se.some(Ce=>Ce.status==="running"))throw new Error("Finish or stop all chats in this task before archiving it");for(let Ce of se)await O(`/api/runs/${Ce.id}/archive`,{archived:X,cleanup:!1})},Te=async R=>{try{let X=(await Promise.all(R.map(_))).flat();if(X.some(se=>se.status==="running"))throw new Error("Finish or stop all chats in this task before deleting it");f(X.sort((se,Ce)=>+!se.taskExecution-+!Ce.taskExecution||+!se.chatLink-+!Ce.chatLink))}catch(X){J(X.message)}},Ie=async R=>{g(!0),C("");let X=[],se=0;for(let Ce of W)try{await ie(Ce,R),re(Ce.id),se++}catch(Ct){X.push(`${Ce.task.split(`
|
|
115
|
+
`)[0]}: ${Ct.message}`)}se&&J(`${se} ${se===1?"run":"runs"} ${R?"archived":"unarchived"}`),C(X.join(`
|
|
116
|
+
`)),g(!1)},et=ue.filter(E),z=So().length,U=Hn.value,oe=La.value,ke=Re.value.filter(R=>!R.available||Ts.value?.find(X=>X.id===R.id)?.signedIn===!1).length,we=R=>{Y.value=R,Pt.value=!1},ce=R=>{Qe(R.id)},tt=R=>Bn({collapsed:k.collapsed.includes(R)?k.collapsed.filter(X=>X!==R):[...k.collapsed,R]}),it=(R,X)=>{let se=Q(R),Ce=I(R),Ct=$(R),fe=le===nt(R),Rt=()=>{let Ys=D(R).filter(cs=>!cs.archived),Ea=Ys.filter(cs=>cs.chatLink?.kind!=="side"),Si=Ea.filter(cs=>!ha(cs)),Jr=Si.length?Si:Ea,ra=Ys.find(cs=>cs.awaiting||gt(cs)),Tu=Jr.find(cs=>cs.id===(fe?w:al.value[nt(R)]))??Jr.find(Rn)??Jr.at(-1)??R;ra?.chatLink?.kind==="side"&&(Mt(ra.id,`run:${nt(R)}`),$t("chat")),we({view:"run",id:ra&&ra.chatLink?.kind!=="side"?ra.id:Tu.id})},Ti=(R.usage?.inputTokens??0)+(R.usage?.outputTokens??0),Aa=Ke(R),Cu=[Zd(se),L(R)?"tests changed in ways that could hide failures":"",ge.value.find(Ys=>Ys.id===R.pattern)?.name??R.pattern,Aa?Aa.repos.length>1?`${Aa.name} \xB7 ${be(R.repo)}`:Aa.name:be(R.repo),es(H(R)),Ti?`${Et(Ti)} tok`:"",R.usage?.costUsd?ht(R.usage.costUsd):""].filter(Boolean);return e("div",{class:`rail-run-row ${d?"selecting":""}`,role:"group","aria-label":R.task.split(`
|
|
117
|
+
`)[0]||"Untitled run",children:[d?e("input",{type:"checkbox",class:"rail-run-check","aria-label":`Select ${R.task.split(`
|
|
118
|
+
`)[0]||"Untitled run"}`,checked:p.has(R.id),disabled:h||!!u||Ct,onChange:()=>ne(R.id)}):null,e("button",{type:"button",class:`run-item ${fe?"active":""} ${E(R)?"unseen":""} ${Ce?"archived":""}`,title:`${R.task.split(`
|
|
119
|
+
`)[0]}
|
|
120
|
+
${Cu.join(" \xB7 ")}`,"aria-current":fe?"page":void 0,disabled:d&&(h||!!u||Ct),onClick:()=>d?ne(R.id):Rt(),children:[e("span",{class:`dot ${ft(se)}`,"aria-hidden":"true"}),e("span",{class:"t",children:[R.trigger?e(K,{name:R.trigger.via==="sweep"?"layers":R.trigger.via==="webhook"?"globe":"clock",class:"inline-icon"}):null,R.group?e(K,{name:"compare",class:"inline-icon"}):null,R.task.split(`
|
|
121
|
+
`)[0]||"(no task)"]}),e("span",{class:"m",children:[L(R)?e("span",{class:"flag",children:e(K,{name:"alert"})}):null,X]}),e("span",{class:"sr-only",children:[" ","\xB7 ",Zd(se),Ce?" \xB7 archived":""]})]},R.id),d?null:e(Ve,{above:!0,class:"chat-choice rail-run-menu",label:"Run actions",icon:"more",children:Ys=>e(M,{children:[e(pe,{disabled:Ct,onClick:()=>{Ys(),ie(R,!Ce).then(()=>J(Ce?"Run unarchived":"Run archived"),Ea=>J(Ea.message))},children:Ce?"Unarchive":"Archive"}),e(pe,{disabled:Ct||!!R.projectTeam,sub:R.projectTeam?"Project mission history is retained. Archive instead.":void 0,onClick:()=>{Ys(),Te([R])},children:"Delete\u2026"})]})})]},R.id)},Xt=R=>e("span",{class:"proj-actions",children:[e("button",{type:"button",class:"icon-btn",disabled:!Ut.value||dt.value,"aria-label":`New run in ${R.name}`,title:`New run in ${R.name}`,onClick:()=>ce(R),children:e(K,{name:"plus"})}),e("button",{type:"button",class:"icon-btn","aria-label":`Edit ${R.name}`,title:"Rename, repositories, delete",onClick:()=>da(R.id),children:e(K,{name:"more"})})]}),Ue=R=>{if(!R.runs.length)return e("div",{class:"proj quiet",role:"group","aria-label":R.name,children:e("div",{class:`proj-head ${j&&j===R.project?.id?"here":""}`,children:[R.project?e("button",{type:"button",class:"proj-name",title:`Open ${R.name}: ${R.project.repos.join(", ")}`,"aria-current":j===R.project.id?"page":void 0,onClick:()=>we({view:"project",id:R.project.id}),children:[e("span",{class:"pn",children:R.name}),R.archived?e("span",{class:"pc",children:[R.archived," archived"]}):null]}):e("span",{class:"proj-name",children:e("span",{class:"pn",children:R.name})}),R.project?Xt(R.project):null]})},R.key);let X=k.collapsed.includes(R.key),se=T.has(R.key)||S,Ce=X?R.runs.filter(fe=>nt(fe)===le):se?R.runs:R.runs.slice(0,Km),Ct=X?0:R.runs.length-Ce.length;return e("div",{class:"proj",role:"group","aria-label":R.name,children:[e("div",{class:`proj-head ${j&&j===R.project?.id?"here":""}`,children:[e("button",{type:"button",class:"proj-fold","aria-expanded":!X,"aria-label":`${X?"Show":"Hide"} the runs in ${R.name}`,title:X?"Show its runs":"Hide its runs",onClick:()=>tt(R.key),children:e(K,{name:"chevron",class:"caret"})}),e("button",{type:"button",class:"proj-toggle","aria-current":R.project&&j===R.project.id?"page":void 0,title:R.project?`Open ${R.name}: ${R.project.repos.join(", ")}`:"Runs whose project was deleted",onClick:()=>R.project?we({view:"project",id:R.project.id}):tt(R.key),children:[e("span",{class:"pn",children:R.name}),X&&R.runs.length?e("span",{class:"pc",children:R.runs.length}):null]}),R.project?Xt(R.project):null]}),Ce.map(fe=>it(fe,zm(H(fe)))),Ct>0?e("button",{type:"button",class:"rail-more",onClick:()=>v(new Set([...T,R.key])),children:["Show ",Ct," more"]}):null]},R.key)},B;if(k.group==="status"){let R=[["Needs you",et],["Running",ue.filter(se=>$(se)&&!E(se))],["Recent",ue.filter(se=>!I(se)&&!$(se)&&!E(se))],["Archived",ue.filter(I)]],X=se=>Ke(se)?.name??be(se.repo);B=R.map(([se,Ce])=>Ce.length?e("section",{"aria-label":se,children:[e("div",{class:"rail-title rail-section",children:[se,se==="Needs you"?e("span",{class:"count",children:Ce.length}):null]}),Ce.map(Ct=>it(Ct,X(Ct)))]},se):null)}else{let R=new Map(he.value.map(fe=>[fe.id,{key:fe.id,project:fe,name:fe.name,runs:[],last:0,archived:0}])),X=fe=>{let Rt=Ke(fe)?.id??qt;return R.has(Rt)||R.set(Rt,{key:Rt,name:"No project",runs:[],last:0,archived:0}),R.get(Rt)};for(let fe of de){let Rt=X(fe);Rt.last=Math.max(Rt.last,H(fe)),I(fe)&&Rt.archived++}for(let fe of ue)E(fe)||X(fe).runs.push(fe);let se=[...R.values()].sort((fe,Rt)=>Rt.last-fe.last||fe.name.localeCompare(Rt.name)),Ce=se.filter(fe=>fe.runs.length),Ct=S?[]:se.filter(fe=>!fe.runs.length&&fe.project);B=e(M,{children:[et.length?e("section",{"aria-label":"Needs you",children:[e("div",{class:"rail-title rail-section",children:["Needs you ",e("span",{class:"count",children:et.length})]}),et.map(fe=>it(fe,Ke(fe)?.name??be(fe.repo)))]}):null,e("section",{"aria-label":"Projects",children:[e("div",{class:"rail-title rail-section",children:["Projects",e("button",{type:"button",class:"icon-btn","aria-label":"New project",title:"New project",onClick:()=>{ws.value="new",_t.value=!0},children:e(K,{name:"plus"})})]}),e(hi,{directory:s,error:t.error,query:b.q,children:[n?se.filter(fe=>fe.runs.length||!S&&fe.project).sort((fe,Rt)=>fe.name.localeCompare(Rt.name)||fe.key.localeCompare(Rt.key)).map(Ue):Ce.map(Ue),!n&&Ct.length?e(M,{children:[e("button",{type:"button",class:"rail-more quiet","aria-expanded":c,onClick:()=>i(!c),children:[e(K,{name:"chevron",class:"caret"}),Ct.length," more project",Ct.length===1?"":"s"]}),c?Ct.map(Ue):null]}):null]})]})]})}let xe=!ue.length,F=S?ue.length:de.length;return e("nav",{class:`rail ${Pt.value?"open":""}`,"aria-label":"Runs",children:[e("div",{class:"rail-head",children:[e("a",{class:"brand",href:"#/","aria-label":"code-flow: new run",onClick:()=>Pt.value=!1,children:e("span",{class:"brand-name",children:["code",e("span",{children:"-flow"})]})}),e("button",{type:"button",class:"icon-btn rail-toggle","aria-label":oe?"Expand sidebar":"Collapse sidebar",title:oe?"Expand sidebar":"Collapse sidebar","aria-expanded":!oe,"aria-controls":"run-navigation",onClick:()=>En(!oe),children:e(K,{name:"sidebar"})}),e("button",{type:"button",class:"icon-btn rail-close","aria-label":"Close menu",onClick:()=>Pt.value=!1,children:e(K,{name:"close"})})]}),e("button",{class:"btn primary new-run",disabled:!Ut.value||dt.value,"aria-label":"New run",title:"New run (n)",onClick:()=>void Qe(),children:[e(K,{name:"plus"})," ",e("span",{children:"New run"})]}),e("div",{class:"rail-destinations",role:"group","aria-label":"Work navigation",children:[e("a",{class:"nav-item",href:"#/inbox","aria-label":`Inbox${z?`, ${z} need attention`:""}`,title:"Inbox","aria-current":x.view==="inbox"?"page":void 0,children:[e(K,{name:"bell"}),e("span",{children:"Inbox"}),z?e("span",{class:"count",children:z}):null]}),e("a",{class:"nav-item",href:"#/automations",title:"Scheduling","aria-label":"Scheduling","aria-current":x.view==="automations"?"page":void 0,children:[e(K,{name:"clock"}),e("span",{children:"Scheduling"})]})]}),oe?e("button",{type:"button",class:"icon-btn rail-search-button","aria-label":"Search runs",title:"Search runs (/)",onClick:()=>{En(!1),requestAnimationFrame(()=>document.getElementById("run-search")?.focus())},children:e(K,{name:"search"})}):null,e("div",{class:"rail-search",children:[e(K,{name:"search"}),e("input",{id:"run-search",class:"field",type:"search",placeholder:"Search runs","aria-label":"Search runs (press / to focus)",value:b.q,onInput:R=>Hs({q:R.currentTarget.value}),onKeyDown:R=>{R.key==="Escape"?(Hs({q:""}),R.currentTarget.blur()):(R.key==="ArrowDown"||R.key==="Enter")&&(R.preventDefault(),document.querySelector(".rail .run-item")?.[R.key==="Enter"?"click":"focus"]())}})]}),!oe&&(de.length>0||d)?e("div",{class:"rail-selection",children:[e("div",{class:"rail-selection-head",children:[e("button",{type:"button",class:"btn small ghost",disabled:h||!!u,"aria-pressed":d,onClick:()=>{l(!d),o(new Set),C("")},children:d?"Done selecting":"Select runs"}),d?e("span",{role:"status",children:[W.length," selected"]}):null]}),d?e(M,{children:[e("div",{class:"rail-bulk-actions",children:[e("button",{type:"button",class:"btn small",disabled:h||!!u||!te.length,onClick:()=>o(W.length===te.length?new Set:new Set(te.map(R=>R.id))),children:W.length&&W.length===te.length?"Clear selection":"Select loaded"}),e("button",{type:"button",class:"btn small",disabled:h||!W.length,onClick:()=>void Ie(!0),children:"Archive"}),W.some(I)?e("button",{type:"button",class:"btn small",disabled:h,onClick:()=>void Ie(!1),children:"Unarchive"}):null,e("button",{type:"button",class:"btn small danger",disabled:h||!W.length||W.some(R=>!!R.projectTeam),onClick:()=>void Te(W),children:"Delete\u2026"})]}),e("span",{class:"help",children:h?"Updating runs\u2026":"Only stopped runs on this computer. Select loaded includes matching runs in folded projects."}),W.some(R=>!!R.projectTeam)?e("span",{class:"help",children:"Project mission history is retained for recovery and approvals. Archive these runs instead."}):null,y?e("div",{class:"err",role:"alert",children:y}):null]}):null]}):null,q||k.archived?e("button",{type:"button",class:"rail-archive-toggle","aria-label":k.archived?"Hide archived runs":"Show archived runs","aria-pressed":k.archived,onClick:()=>Bn({archived:!k.archived}),children:[e(K,{name:"archive"}),k.archived?"Hide archived runs":"Show archived runs",e("span",{children:q})]}):null,r?e("div",{class:"rail-filters",id:"rail-filters",children:[e("div",{class:"rf-row",children:[e("span",{class:"rf-label",children:"View and filter runs"}),e("button",{type:"button",class:"icon-btn","aria-label":"Close filters",onClick:()=>{a(!1),document.getElementById("run-search")?.focus()},children:e(K,{name:"close"})})]}),e("div",{class:"rf-row",children:[e("span",{class:"rf-label",children:"Group by"}),e("div",{class:"segmented small",role:"group","aria-label":"Group by",children:["project","status"].map(R=>e("button",{type:"button",class:k.group===R?"on":"","aria-pressed":k.group===R,onClick:()=>Bn({group:R}),children:R==="project"?"Project":"Status"},R))})]}),e("div",{class:"chips",role:"group","aria-label":"Status",children:Jm.map(([R,X])=>e("button",{type:"button",class:"chip-tpl","aria-pressed":b.status===R,onClick:()=>Hs({status:R}),children:X},R))}),e("select",{class:"field","aria-label":"Pattern",value:b.pattern,onChange:R=>Hs({pattern:R.currentTarget.value}),children:[e("option",{value:"",children:"Any pattern"}),ge.value.map(R=>e("option",{value:R.id,children:R.name},R.id))]}),e("select",{class:"field","aria-label":"Agent",value:b.agent,onChange:R=>Hs({agent:R.currentTarget.value}),children:[e("option",{value:"",children:"Any agent"}),Re.value.map(R=>e("option",{value:R.id,children:R.displayName},R.id))]}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:b.thisRepo,onChange:R=>Hs({thisRepo:R.currentTarget.checked})})," ",ee.value?`Only ${be(ee.value)}`:"Only the selected repository"]}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:k.archived,onChange:R=>Bn({archived:R.currentTarget.checked})})," Show archived runs"]})]}):null,S?e("div",{class:"rail-hint",children:[ue.length," of ",de.length," tasks",e("button",{type:"button",onClick:()=>Hs({q:"",status:"all",pattern:"",agent:"",thisRepo:!1}),children:"Clear"})]}):null,e("div",{class:"rail-list",id:"run-navigation",children:[k.group==="status"?e(hi,{directory:s,error:t.error,query:b.q,children:B}):B,xe?e("div",{class:"rail-empty",children:S?"No runs match":n?"No runs in this workspace yet":"No runs yet \u2014 start one on the right"}):null]}),e("div",{class:"rail-history",role:"region","aria-label":"Run history pages",children:[e("span",{class:"help",role:"status",children:oo.value?"Searching history\u2026":el.value===null?"Loading history\u2026":`${F} ${S?"matching ":""}task${F===1?"":"s"} loaded`}),ro.value?e("button",{type:"button",class:"btn small",disabled:oo.value||io.value,onClick:()=>void ol(),children:io.value?"Loading\u2026":"Load older runs"}):null,sl.value?e("span",{class:"help",role:"status",children:[tl.value," running or attention items at last refresh. Older attention is paged; use Load older runs to include more."]}):null,lo.value?e("div",{class:"help",role:"alert",children:[lo.value,e("button",{class:"btn small",onClick:()=>void Un(),children:"Retry history"})]}):null,S&&!b.q.trim()&&ro.value?e("span",{class:"help",children:"Filters apply to loaded pages. Load older runs to include more history."}):null]}),e(Qd,{collapsed:oe}),e("div",{class:"rail-foot",children:e(Ve,{class:"rail-menu",label:"Application menu",icon:"more",trigger:e(M,{children:[e("span",{class:"rail-menu-avatar",children:e(K,{name:"layers"})}),e("span",{class:"rail-menu-label",children:e("strong",{children:"Code Flow"})}),U+z?e("span",{class:"rail-menu-count","aria-label":`${U+z} items need attention`,children:U+z>99?"99+":U+z}):null,e(K,{name:"more"})]}),children:R=>e(M,{children:[bo.value||Pi.value||U?e(pe,{on:x.view==="team"||x.view==="team-task"||x.view==="team-people",onClick:()=>{R(),we({view:"team"})},children:[e(K,{name:"people"}),e("span",{children:"Board"}),U?e("span",{class:"rail-menu-meta","aria-label":`${U} unread`,children:U}):null]}):null,e(pe,{on:x.view==="settings",onClick:()=>{R(),we({view:"settings"})},children:[e(K,{name:"sliders"}),e("span",{children:"Settings"}),e("kbd",{class:"rail-menu-meta",children:"\u2318,"})]}),e(pe,{sub:`${Re.value.length} providers${ke?` \xB7 ${ke} need setup`:""}`,onClick:()=>{R(),Pt.value=!1,hs.value=!0},children:[e(K,{name:"sparkle"}),e("span",{children:"Agents & usage"})]}),e(pe,{onClick:()=>{R(),we({view:"workspace"})},children:[e(K,{name:"files"}),e("span",{children:"Repository tools"})]}),e(pe,{onClick:()=>{R(),we({view:"insights"})},children:[e(K,{name:"chart"}),e("span",{children:"Insights"})]}),e(pe,{onClick:()=>{R(),we({view:"automations"})},children:[e(K,{name:"clock"}),e("span",{children:"Scheduling"}),z?e("span",{class:"rail-menu-meta","aria-label":`${z} runs need attention`,children:z}):null]}),e(pe,{onClick:()=>{R(),we({view:"settings",section:"notifications"})},children:[e(K,{name:"bell"}),e("span",{children:"Notifications"})]}),e("div",{class:"rail-menu-divider",role:"separator"}),e(pe,{on:r,onClick:()=>{R(),En(!1),a(!r),r||requestAnimationFrame(()=>document.querySelector("#rail-filters button")?.focus())},children:[e(K,{name:"sliders"}),e("span",{children:"View and filter runs"})]}),e(pe,{on:k.archived,onClick:()=>{R(),Bn({archived:!k.archived})},children:[e(K,{name:"archive"}),e("span",{children:k.archived?"Hide archived runs":"Show archived runs"}),e("span",{class:"rail-menu-meta",children:q})]}),e(pe,{onClick:()=>{R(),Pt.value=!1,tn.value=!0},children:[e(K,{name:"keyboard"}),e("span",{children:"Keyboard shortcuts"}),e("kbd",{class:"rail-menu-meta",children:"?"})]}),e("a",{class:"pop-item",role:"menuitem",href:"/docs/",target:"_blank",rel:"noreferrer",onClick:R,children:e("span",{class:"pi-main",children:[e(K,{name:"help"}),e("span",{children:"Help & documentation"}),e(K,{name:"external",class:"rail-menu-meta"})]})})]})})}),u?e(No,{runs:u,onDeleted:re,onClose:()=>f(null)}):null]})}var Gm=Bt(()=>import("./settings-UB5Q4AQM.js").then(t=>t.SettingsView));function BS(){return e(M,{children:[Y.value.view==="side"?e(Ym,{tab:Y.value.tab}):e(Qm,{}),e(kc,{})]})}function Ym({tab:t}){return N(()=>(en.value=t,Ot.value=!0,document.addEventListener("click",tu),()=>document.removeEventListener("click",tu)),[]),N(()=>{document.title=`code-flow \xB7 ${t}`},[t]),e("div",{class:"popped",children:[e(ri,{popped:!0}),e("div",{class:"sr-only",role:"status","aria-live":"polite",children:qa.value}),Xs.value?e("div",{class:"toast",role:"status",children:Xs.value.text},Xs.value.id):null]})}function tu(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let s=t.target?.closest?.("a[href^='#/']");!s||s.getAttribute("target")||(t.preventDefault(),Pe(zi(s.getAttribute("href"))))}function Qm(){let t=Zr.value?"side-panel":"main-content";return N(()=>{let s=Xe.value;document.title=`${Ja.value?`(${Ja.value}) `:""}code-flow${s.kind==="ssh"?` \xB7 SSH ${s.name}`:""}`},[Ja.value,Xe.value]),N(()=>(window.addEventListener("keydown",nu),()=>window.removeEventListener("keydown",nu)),[]),N(()=>{yl()},[]),N(()=>{Pt.value=!1},[Y.value]),e(M,{children:[e("a",{class:"skip-link",href:`#${t}`,onClick:s=>{s.preventDefault(),document.getElementById(t)?.focus()},children:Zr.value?"Skip to side panel":"Skip to main content"}),e(wc,{}),e("div",{class:`app ${Ot.value?"with-side":""} ${Ot.value&&Wt.value?"side-expanded":""} ${La.value?"rail-collapsed":""}`,style:`--side-w:${jn.value}px`,children:[e(eu,{}),Pt.value?e("div",{class:"rail-scrim","aria-hidden":"true",onClick:()=>Pt.value=!1}):null,e("div",{class:"main-col",children:[e(Xm,{}),e("main",{id:"main-content",tabIndex:-1,children:Y.value.view==="run"?e(ud,{id:Y.value.id},Y.value.id):Y.value.view==="review"?e(Md,{id:Y.value.id,branch:Y.value.branch},`${Y.value.id}:${Y.value.branch}`):Y.value.view==="project"?e(mi,{...Y.value},Y.value.id):Y.value.view==="workspace"&&Y.value.project?e(mi,{id:Y.value.project,section:"repositories"},Y.value.project):["inbox","automations","workspace","insights"].includes(Y.value.view)?e(yc,{current:Y.value},Y.value.view==="workspace"?`workspace:${Y.value.project??""}`:Y.value.view):Y.value.view==="settings"?e(Gm,{section:Y.value.section,group:Y.value.group}):Y.value.view==="team"?e(sa,{project:Y.value.project,navigate:Pe},"team"):Y.value.view==="team-people"?e(na,{project:Y.value.project,navigate:Pe},Y.value.project??"all"):Y.value.view==="team-task"?e(_r,{id:Y.value.id,navigate:Pe},Y.value.id):Y.value.view==="invalid"?e("div",{class:"composer",role:"alert",children:[e("h1",{children:"This link is invalid"}),e("p",{class:"lede",children:"The address contains an invalid or unsupported destination. Your saved work is available from the project and run lists."}),e("button",{class:"btn primary",onClick:()=>Y.value={view:"composer"},children:"Open new run"})]}):!Ut.value||dt.value||Y.value.view==="composer"&&Y.value.project!==void 0&&Y.value.project!==vt.value?e("div",{class:"composer",role:"status",children:la.value||"Restoring your project draft\u2026"}):e(au,{},vt.value)})]}),e(ri,{})]}),e(nh,{}),e(Gl,{}),e(Ld,{}),_t.value?e(Nl,{}):null,ks.value?e(ql,{},ks.value.repository):null,hs.value?e(sh,{}):null,tn.value?e(th,{}):null,sn.value?e(Cc,{}):null,e("div",{class:"sr-only",role:"status","aria-live":"polite",children:qa.value}),Xs.value?e("div",{class:"toast",role:"status",children:Xs.value.text},Xs.value.id):null]})}var su=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)?"\u2318":"Ctrl ";function Xm(){let t=Ii.value==="dark";return e("header",{class:"topbar",children:[e("button",{class:"icon-btn menu-btn","aria-label":"Show runs","aria-expanded":Pt.value,onClick:()=>Pt.value=!Pt.value,children:e(K,{name:"menu"})}),e(cr,{}),e(Zm,{}),e("span",{class:`connection-status ${qn.value.state}`,role:"status",title:qn.value.state==="connected"?"Live updates are connected":"Live updates are unavailable; displayed run information may be out of date",children:[e("span",{class:"cs-dot","aria-hidden":"true"}),e("span",{class:"cs-label",children:qn.value.state==="connected"?"Connected":qn.value.state==="offline"?"Offline":qn.value.state==="reconnecting"?"Reconnecting\u2026":"Connecting\u2026"})]}),e("button",{class:"btn ghost command-btn","aria-label":"Open command palette",title:`Commands and navigation (${su}K)`,onClick:()=>sn.value=!0,children:[e(K,{name:"search"}),e("kbd",{class:"kbd-key","aria-hidden":"true",children:[su,"K"]})]}),e("button",{class:"icon-btn","aria-label":t?"Use the light theme":"Use the dark theme",title:t?"Light theme":"Dark theme",onClick:Ai,children:e(K,{name:t?"sun":"moon"})}),e("button",{class:"icon-btn side-btn","aria-pressed":Ot.value,"aria-label":"Side panel",title:"Side panel: chat, files, terminal, browser, notes (\\\\)",onClick:()=>Ot.value?ia():$t(),children:e(K,{name:"panel"})})]})}function Zm(){let t=Y.value,s=t.view==="run"||t.view==="review"?ve.value.get(t.id):void 0,n=e("span",{class:"sep","aria-hidden":"true",children:"/"}),r;if(s){let a=Ke(s);r=e(M,{children:[a?e("a",{class:"crumb",href:`#/project/${encodeURIComponent(a.id)}`,title:s.repo,children:a.name}):e("span",{class:"crumb",title:s.repo,children:"No project"}),n,e("span",{class:`crumb title ${t.view==="run"?"here":""}`,title:s.task,"aria-current":t.view==="run"?"page":void 0,children:s.task.split(`
|
|
122
|
+
`)[0]||"(no task)"}),t.view==="review"?e(M,{children:[n,e("span",{class:"crumb here","aria-current":"page",children:"Review"})]}):null]})}else if(t.view==="project")r=e(M,{children:[e("a",{class:"crumb",href:`#/project/${encodeURIComponent(t.id)}`,"aria-current":t.section?void 0:"page",children:he.value.find(a=>a.id===t.id)?.name??"Project"}),t.section?e(M,{children:[n,e("span",{class:"crumb here","aria-current":"page",children:{runs:"Runs",repositories:"Repositories",settings:"Project settings",board:"Board",people:"People",automation:"Automation"}[t.section]})]}):null]});else if(t.view==="team"||t.view==="team-task"||t.view==="team-people"){let a=t.view==="team-task"?gs.value?.id===t.id?gs.value.title:Jt.value?.tasks.find(i=>i.id===t.id)?.title??"Task":void 0,c=t.view==="team"&&t.project?Jt.value?.projects.find(i=>i.id===t.project)?.name:void 0;r=a!==void 0?e(M,{children:[e("a",{class:"crumb",href:"#/team",children:"Board"}),n,e("span",{class:"crumb title here",title:a,"aria-current":"page",children:a})]}):c?e(M,{children:[e("a",{class:"crumb",href:"#/team",children:"Board"}),n,e("span",{class:"crumb here","aria-current":"page",children:c})]}):e("span",{class:"crumb here","aria-current":"page",children:t.view==="team-people"?"People":"Board"})}else if(t.view==="inbox"||t.view==="automations"||t.view==="workspace"||t.view==="insights")r=e(M,{children:[t.view==="workspace"&&t.project?e(M,{children:[e("a",{class:"crumb",href:`#/project/${encodeURIComponent(t.project)}`,children:he.value.find(a=>a.id===t.project)?.name??"Project"}),n]}):null,e("span",{class:"crumb here","aria-current":"page",children:{inbox:"Inbox",automations:"Scheduling",workspace:"Repositories",insights:"Insights"}[t.view]})]});else if(t.view==="settings"){let a=t.section?Pa.find(c=>c.id===t.section):void 0;r=a?e(M,{children:[e("a",{class:"crumb",href:"#/settings",children:"Settings"}),n,e("span",{class:"crumb here","aria-current":"page",children:a.label})]}):e("span",{class:"crumb here","aria-current":"page",children:"Settings"})}else{let a=t.view==="composer"?"New run":"";r=a?e("span",{class:"crumb here","aria-current":"page",children:a}):null}return e("nav",{class:"crumbs-bar","aria-label":"Where you are",children:r})}function FS(t){if(Y.value.view==="side")return;let s=(Y.value.view==="run"||Y.value.view==="review")&&Y.value.id===t.id,n={done:at(t)==="Failed"?"finished, but its check fails":at(t)==="Blocked"?"finished, but its check couldn't run":at(t)==="Passed"?"finished, with passing checks":"finished, without passing verification",failed:"failed",stopped:zt(t)?"has unresolved work":"stopped at a limit",interrupted:"was interrupted"},r=t.status!=="running"&&!t.awaiting?ul(t):void 0,a=t.awaiting?`code-flow: ${t.awaiting.title.toLowerCase()}`:gt(t)?"code-flow: your team needs an answer":r?`code-flow: PR needs you \u2014 ${r.detail}`:`code-flow: run ${n[t.status]??t.status}`;if(qa.value=`${a.replace(/^code-flow: /,"")}: ${t.task.split(`
|
|
123
|
+
`)[0].slice(0,120)}`,!Pl()||s&&!document.hidden)return;let c;try{c=new Notification(a,{body:t.task.split(`
|
|
124
|
+
`)[0],tag:t.id})}catch{return J(a.replace(/^code-flow: /,""),5e3)}c.onclick=()=>{window.focus(),Pe({view:"run",id:t.id}),c.close()}}var eh=[["\u2318, / Ctrl+,","Settings"],["\u2318K / Ctrl+K","Commands, projects and runs"],["/","Search runs"],["j / k","Next / previous run in the list"],["[ / ]","Previous / next step of the open run"],["n","New run"],["p","Pick the project for new runs, Insights and Scheduling"],["i","Insights"],["a","Scheduling"],["\u2318\u21B5","Start the run, or send what you typed"],["Esc","Close a dialog, or leave the search box"],["\\","Show or hide the side panel"],["?","This list"]];function nu(t){if((t.metaKey||t.ctrlKey)&&!t.altKey&&t.key===","&&!t.defaultPrevented&&!document.querySelector("dialog[open]")){t.preventDefault(),Pe({view:"settings"});return}if((t.metaKey||t.ctrlKey)&&!t.altKey&&t.key.toLowerCase()==="k"){t.preventDefault(),sn.value=!sn.value;return}if(t.metaKey||t.ctrlKey||t.altKey||t.defaultPrevented||t.target?.closest("input, textarea, select, [contenteditable=true], dialog"))return;let n=r=>{t.preventDefault(),Pe(r)};switch(t.key){case"/":{t.preventDefault(),En(!1),Pt.value=!0;let r=()=>document.getElementById("run-search");r()?.focus(),document.activeElement!==r()&&requestAnimationFrame(()=>r()?.focus());return}case"n":t.preventDefault(),Qe();return;case"p":t.preventDefault(),ss.value=Y.value.view==="composer"?"composer":"filter",_t.value=!0;return;case"i":return n({view:"insights"});case"a":return n({view:"automations"});case"?":t.preventDefault(),tn.value=!0;return;case"\\":t.preventDefault(),Ot.value?ia():$t();return;case"j":case"k":{let r=[...document.querySelectorAll(".rail .run-item")];if(!r.length)return;t.preventDefault();let a=r.findIndex(i=>i.classList.contains("active")),c=r[a<0?0:Math.min(r.length-1,Math.max(0,a+(t.key==="j"?1:-1)))];c.click(),c.scrollIntoView({block:"nearest"});return}}}function th(){let t=ye(!0,()=>tn.value=!1);return e("dialog",{class:"picker small-dialog",ref:t,"aria-labelledby":"shortcuts-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"shortcuts-title",children:"Keyboard shortcuts"})}),e("div",{class:"dialog-body",children:e("table",{class:"shortcuts",children:e("tbody",{children:eh.map(([s,n])=>e("tr",{children:[e("td",{children:e("kbd",{children:s})}),e("td",{children:n})]},s))})})}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn primary",onClick:()=>tn.value=!1,children:"Done"})]})]})})}function sh(){let t=ye(!0,()=>hs.value=!1);N(()=>{no()},[]);let s=r=>r===void 0?"?":`${Math.round(r*100)}%`,n=r=>r?new Date(r).toLocaleString([],{weekday:"short",hour:"2-digit",minute:"2-digit"}):"";return e("dialog",{class:"picker small-dialog health",ref:t,"aria-labelledby":"health-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"health-title",children:"Health"}),e("div",{class:"help",children:"What code-flow can see about each CLI \u2014 it uses the CLIs' own commands and never reads their credentials."})]}),e("div",{class:"dialog-body",children:[Ts.value?null:e("div",{class:"help",children:"Checking\u2026"}),Ts.value?.map(r=>e("div",{class:"health-row",children:[e("div",{class:"hr-title",children:[e("span",{class:`agent ${r.id}`,children:r.name}),e("span",{class:`badge ${r.installed&&r.signedIn!==!1?"ok":""}`,children:r.installed?r.signedIn===!1?"Signed out":r.signedIn?`Signed in \xB7 ${r.account??""}`:"Installed":"Not installed"}),e("span",{class:"help",children:r.version})]}),r.quota&&Object.keys(r.quota.windows).length?e("div",{class:"quota",children:Object.entries(r.quota.windows).map(([a,c])=>e("div",{class:"q",children:[e("span",{children:[a.replace("_","-")," window"]}),e("span",{class:"bar",children:e("span",{style:`width:${Math.min(100,Math.round((c.utilization??0)*100))}%`})}),e("span",{children:[s(c.utilization)," used",c.resetsAt?` \xB7 resets ${n(c.resetsAt)}`:""]})]},a))}):r.quota?.status==="limited"?e("div",{class:"msg warn",children:"Hit a usage limit recently."}):r.installed?e("div",{class:"help",children:r.id==="claude"?"Quota shows after the next Claude step.":"This CLI doesn't report remaining quota."}):null,r.warnings?.map(a=>e("div",{class:"msg warn",children:a},a)),r.fix?e("div",{class:"msg warn",children:r.fix}):null]},r.id)),Bs.value?e("div",{class:"health-row",children:[e("div",{class:"hr-title",children:[e("span",{class:"agent",children:"git"}),e("span",{class:`badge ${Bs.value.ok?"ok":""}`,children:Bs.value.ok?"OK":Bs.value.installed?"Too old":"Not found"}),e("span",{class:"help",children:Bs.value.version})]}),Bs.value.warning?e("div",{class:"msg warn",children:Bs.value.warning}):null]}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn",onClick:()=>no(),children:"Check again"}),e("button",{class:"btn primary",onClick:()=>hs.value=!1,children:"Done"})]})]})})}function nh(){let[t,s]=m(null),[n,r]=m(""),[a,c]=m(""),[i,d]=m(!1),l=Z(null),p=Z(!1),o=()=>{p.current=!1,h.current++,ct.value=!1,Ns.value=null},u=ye(ct.value,o),f=Ns.value,h=Z(0),g=Z(!1),y=async(b,S=i)=>{if(!ct.value)return;p.current=!0;let x=++h.current;g.current=!1,c("Loading\u2026");let w=new URLSearchParams;b&&w.set("path",b),S&&w.set("hidden","1");try{let j=await V(`/api/fs?${w}`);if(x!==h.current||!ct.value)return;s(j),!g.current&&document.activeElement!==l.current&&r(j.path),c(j.isRepo?"\u2713 This folder is a git repository":"Open a folder marked Git, or type a path")}catch(j){if(x!==h.current||!ct.value)return;c(j.message),!t&&b&&y(void 0,S)}};We(()=>{ct.value&&!p.current&&y(ee.value||void 0),ct.value||(p.current=!1)},[ct.value]);let C=b=>{o(),f?f.choose(b):Ba(b)},T=t?t.path.split("/").filter(Boolean):[],v=t&&t.path===t.home?Gi():[],k=(b,S,x,w)=>e("div",{class:"dir",title:x,children:[e("button",{type:"button",class:"dir-browse","aria-label":`Open folder ${S}`,onClick:()=>y(x),children:[e("span",{class:"di",children:b}),e("span",{class:"dn",children:S}),w?e("span",{class:"git-badge",children:"Git"}):null]}),w?e("button",{class:"btn small",type:"button",onClick:j=>{j.stopPropagation(),C(x)},children:"Use"}):null]},x);return e("dialog",{class:"picker",ref:u,"aria-labelledby":"folder-picker-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"folder-picker-title",children:f?f.title:"Choose a repository"}),e("div",{class:"row",children:[e("button",{class:"btn",type:"button",title:"Parent folder","aria-label":"Parent folder",disabled:!t?.parent,onClick:()=>t?.parent&&y(t.parent),children:"\u2191"}),e("button",{class:"btn",type:"button",title:"Home folder","aria-label":"Home folder",onClick:()=>y(t?.home),children:"~"}),e("input",{class:"field",type:"text",spellcheck:!1,"aria-label":"Folder path",ref:l,value:n,onInput:b=>{p.current=!0,g.current=!0,r(b.currentTarget.value)},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),y(b.currentTarget.value.trim()))}}),e("button",{class:"btn",type:"button",onClick:()=>y((l.current?.value??n).trim()),children:"Go"})]}),e("nav",{class:"crumbs","aria-label":"Folder breadcrumbs",children:[e("button",{type:"button","aria-label":"The root folder",onClick:()=>y("/"),children:"/"}),T.map((b,S)=>e("span",{children:[e("button",{type:"button","aria-current":S===T.length-1?"location":void 0,onClick:()=>y("/"+T.slice(0,S+1).join("/")),children:b}),S<T.length-1?"/":""]},S))]})]}),e("div",{class:"picker-list",children:[v.length?e("div",{class:"picker-section",children:"Recent"}):null,v.map(b=>k("\u2605",t?b.replace(t.home,"~"):b,b,!0)),v.length?e("div",{class:"picker-section",children:"Folders"}):null,t?.entries.map(b=>k(b.isRepo?"\u25C6":"\u25B8",b.name,b.path,b.isRepo)),t&&!t.entries.length?e("div",{class:"picker-section",children:"No subfolders"}):null,t?.truncated?e("div",{class:"picker-section",children:"Showing the first 500 \u2014 type a path above"}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:a}),e("label",{children:[e("input",{type:"checkbox",checked:i,onChange:b=>{d(b.currentTarget.checked),y(t?.path,b.currentTarget.checked)}})," ","Hidden folders"]}),e("button",{class:"btn",type:"button",onClick:o,children:"Cancel"}),e("button",{class:"btn primary",type:"button",disabled:!t||n.trim()!==t.path||a==="Loading\u2026",onClick:()=>{let b=(l.current?.value??n).trim();t&&b===t.path&&a!=="Loading\u2026"&&C(t.path)},children:f?.title==="Open repository"?"Open this repository":f?"Add this folder":"Use this folder"})]})]})})}function ye(t,s){let[n,r]=m(null),a=Z(new WeakMap);return N(()=>{if(!n)return;t&&!n.open&&n.showModal(),!t&&n.open&&(a.current.set(n,(a.current.get(n)??0)+1),n.close());let c=()=>{let i=a.current.get(n)??0;if(i){a.current.set(n,i-1);return}s()};return n.addEventListener("close",c),()=>n.removeEventListener("close",c)},[n,t]),r}function ah(t){let s=ae.json("taskTeamPreferences",null);return s?{...s,enabled:!1,coordinator:t}:{enabled:!1,preset:"adaptive",coordinator:t,providers:["claude","codex"],settings:{},maxMembers:4,maxCalls:20,maxMinutes:30,approvePlan:!1}}function Lr({run:t,config:s,lead:n,project:r,onChange:a,disabledReason:c,toolApprovals:i}){let[d,l]=m(!1),o=(t?ve.value.get(nt(t))??t:void 0)?.taskTeam??s,u=t?[...ve.value.values()].find(b=>b.taskExecution?.taskId===nt(t)&&b.status==="running"):void 0,[f,h]=m(!1),[g,y]=m("");if(t&&(t.chatLink?.kind==="side"||t.checkpointOnFinish||t.trigger||t.loop.remoteWorker||t.loop.agentContainer))return null;let C=async b=>{h(!0),y("");try{if(t){let S=await O(`/api/runs/${t.id}/task-team`,b);ve.value=new Map(ve.value).set(S.id,S)}else a?.(b);ae.set("taskTeamPreferences",JSON.stringify(b))}catch(S){throw y(S.message),S}finally{h(!1)}},T=!!o?.enabled&&!c,v=o??ah(n),k=Re.value.filter(b=>b.available&&["claude","codex","agy"].includes(b.id)).flatMap(b=>{let S=ps.value[b.id];return[{id:`${b.id}:`,label:`${Se[b.id]} \xB7 Default model`},...S&&!("error"in S)?S.models.map(x=>({id:`${b.id}:${x.id}`,label:`${Se[b.id]} \xB7 ${x.label}`})):[]]});return e(M,{children:[e("button",{class:`btn ghost task-team-toggle ${T?"on":""}`,type:"button",role:"switch","aria-label":"Team","aria-checked":T,disabled:!!c||f,title:c??(T?"Turn Team off":"Turn Team on"),onClick:()=>{C({...v,enabled:!T}).catch(()=>{})},children:[e("span",{class:"team-switch-track","aria-hidden":"true",children:e("span",{})}),"Team ",e("span",{class:"team-state",children:u?T?"Working":"Stopping\u2026":T?"On":"Off"})]}),T?e(M,{children:[e(xs,{compact:!0,label:"Lead model",title:"Team lead model",value:`${v.coordinator}:${v.settings[v.coordinator]?.model??""}`,options:k,disabled:f,onChange:b=>{let S=b.indexOf(":"),x=b.slice(0,S),w=b.slice(S+1);C({...v,coordinator:x,settings:{...v.settings,[x]:{model:w}}}).catch(()=>{})}}),e("button",{type:"button",class:"btn ghost small task-team-advanced",onClick:()=>l(!0),children:"Advanced"})]}):null,g?e("span",{class:"help",role:"alert",children:g}):null,d?e(rh,{value:v,project:r??t?.project,toolApprovals:i??!!t?.approvals.tools,running:t?.status==="running",onClose:()=>l(!1),onSave:async b=>{await C(b),l(!1)}}):null]})}function rh({value:t,project:s,running:n,toolApprovals:r,onSave:a,onClose:c}){let[i,d]=m(()=>structuredClone(t)),[l,p]=m([]),[o,u]=m(!1),[f,h]=m(""),g=ye(!0,()=>{o||c()}),y=Re.value.filter(b=>["claude","codex","agy"].includes(b.id));N(()=>{let b=!0;return V(`/api/team-templates${s?`?project=${encodeURIComponent(s)}`:""}`).then(S=>{b&&p(S.templates.filter(x=>x.workflow!=="solo"))},S=>{b&&h(S.message)}),()=>{b=!1}},[s]);let C=b=>d({...i,...b}),T=l.find(b=>b.id===i.template?.id),v=i.enabled&&r&&(i.coordinator==="agy"||i.providers.includes("agy"))?"This task requires interactive tool approvals, which Antigravity does not support. Choose Claude or Codex, or change the task's permissions before enabling Antigravity.":"",k=async()=>{u(!0),h("");try{await a(i)}catch(b){h(b.message),u(!1)}};return e("dialog",{ref:g,class:"picker task-team-dialog","aria-labelledby":"task-team-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("div",{children:[e("h3",{id:"task-team-title",children:"Team setup"}),e("p",{class:"help",children:"Your agent answers questions directly and brings in teammates for work."})]}),e("label",{class:"task-team-switch",children:[e("span",{children:i.enabled?"Team enabled":"Team disabled"}),e("input",{type:"checkbox",role:"switch","aria-label":"Enable Team",disabled:o,checked:i.enabled,onChange:b=>C({enabled:b.currentTarget.checked})})]})]}),e("div",{class:"dialog-body",children:[e("fieldset",{disabled:o,children:[e("label",{class:"lbl",children:["Template",e("select",{class:"field","aria-label":"Team template",value:i.template?`saved:${i.template.id}`:i.preset,onChange:b=>{let S=b.currentTarget.value,x=l.find(w=>`saved:${w.id}`===S);if(!x)C({preset:S,template:void 0});else{let w=x.preferences;C({template:{id:x.id,version:x.version,inputs:{}},...w?{maxMembers:typeof w.options.maxMembers=="number"?Math.max(3,Math.min(6,w.options.maxMembers)):i.maxMembers,coordinator:w.roles.coordinator?.[0]??w.roles.planner?.[0]??i.coordinator,providers:[...new Set(Object.values(w.roles).flat().filter(j=>["claude","codex","agy"].includes(j)))],settings:{...i.settings,...w.agentSettings,...w.roleSettings.pool,...w.roleSettings.coordinator}}:{}})}},children:[e("optgroup",{label:"Built-in",children:[e("option",{value:"adaptive",children:"Adaptive team"}),e("option",{value:"build-review",children:"Build and review"}),e("option",{value:"investigate",children:"Research and investigate"})]}),l.length?e("optgroup",{label:"Saved teams and workflows",children:l.map(b=>e("option",{value:`saved:${b.id}`,children:[b.name," \xB7 v",b.version]},b.id))}):null]})]}),e("p",{class:"help",children:T?.description??(i.preset==="investigate"?"Investigate and report findings without changing source files.":"Assign useful work to selected providers and review the combined result.")}),T?.parameters.filter(b=>b!=="task").map(b=>e("label",{class:"lbl",children:[b,e("input",{class:"field",value:i.template?.inputs[b]??"",onInput:S=>C({template:{...i.template,inputs:{...i.template.inputs,[b]:S.currentTarget.value}}})})]},b)),e("label",{class:"lbl",children:["Team lead",e("select",{class:"field","aria-label":"Team lead",value:i.coordinator,onChange:b=>C({coordinator:b.currentTarget.value}),children:y.map(b=>e("option",{value:b.id,disabled:!b.available,children:[b.displayName,b.available?"":" \xB7 unavailable"]},b.id))})]}),e("p",{class:"help",children:"Coordinates this team and gives the final answer. If unavailable, another selected provider can continue with the conversation context."}),e("div",{class:"task-team-members",role:"group","aria-label":"Team providers",children:y.map(b=>{let S=i.providers.includes(b.id),x=S||i.coordinator===b.id;return e("div",{class:"task-team-member",children:[e("label",{children:[e("input",{type:"checkbox","aria-label":`Use ${b.displayName}`,checked:S,disabled:!b.available,onChange:w=>C({providers:w.currentTarget.checked?[...i.providers,b.id]:i.providers.filter(j=>j!==b.id)})}),e("b",{children:b.displayName}),e("span",{class:"help",children:S?"Available teammate":i.coordinator===b.id?"Team lead":"Not selected"})]}),x?e(bs,{agent:b.id,settings:i.settings[b.id]??{},onSettings:w=>C({settings:{...i.settings,[b.id]:w}}),permissions:{trust:"standard",tools:!1},onPermissions:()=>{},showPermissions:!1}):null]},b.id)})}),i.providers.includes("agy")||i.coordinator==="agy"?e("p",{class:"help",children:"Antigravity supports workspace files, live teammate messages and the shared browser. Code Flow runs terminal checks. Computer actions require Full access; interactive tool approvals are unavailable. Side chats use enforced read-only isolation."}):null,e("details",{class:"task-team-limits",children:[e("summary",{children:"Limits and approval"}),e("div",{class:"task-team-limit-grid",children:[["maxMembers","Maximum members",3,6],["maxCalls","Maximum calls",4,200],["maxMinutes","Maximum minutes",1,720]].map(([b,S,x,w])=>e("label",{children:[S,e("input",{class:"field",type:"number",min:x,max:w,value:i[b],onInput:j=>C({[b]:Number(j.currentTarget.value)})})]},b))}),e("label",{children:[e("input",{type:"checkbox",checked:i.approvePlan,onChange:b=>C({approvePlan:b.currentTarget.checked})})," Let me approve the plan before teammates start"]})]}),n?e("p",{class:"help",role:"status",children:"New settings apply on Resume or the next conversation turn. Turning Team off stops its active execution, preserves partial work, and hands control back to your agent."}):e("p",{class:"help",children:"Turning Team off keeps these settings for next time. Existing task permissions stay in effect."})]}),f||v?e("p",{class:"msg err",role:"alert",children:f||v}):null]}),e("div",{class:"picker-foot",children:[e("button",{class:"btn",disabled:o,onClick:c,children:"Cancel"}),e("button",{class:"btn primary",disabled:o||!i.providers.length||!!v,onClick:()=>void k(),children:o?"Saving\u2026":"Apply team settings"})]})]})})}function cd({run:t,turns:s=t.teamTurns??[]}){return s.length?e("section",{class:"task-team-activity","aria-label":"Team activity",children:s.map(n=>{let r=ve.value.get(n.executionId),a=r?.status==="running",c=r?.team?.members??[],i=t.notes.some(l=>l.teamDelivery?.executionId===n.executionId&&["received","replanning"].includes(l.teamDelivery.state)),d=r?.team?.tasks.filter(l=>l.status==="completed"||l.status==="submitted").length??0;return e("div",{children:[e("details",{class:"task-team-disclosure",children:[e("summary",{children:[e("span",{class:`task-team-dot ${a?"working":""}`}),i?"Updating the team\u2026":n.state==="stopping"?"Handing back to your agent\u2026":a?r?.awaiting?"Plan needs approval":r?.team?.status==="planning"?"Planning":"Working":n.resolutionReview?.approved===!1?"Changes applied \xB7 review needs attention":n.resolutionReview?.error?"Changes applied \xB7 review needs refresh":n.resolutionCheck?.ok===!1?"Changes applied \xB7 check needs attention":n.state==="preserved"?"Work preserved \xB7 needs attention":r?.status==="done"?n.reviewStale?"Changes applied \xB7 review needs refresh":"Finished":"Stopped \xB7 work preserved",e("span",{class:"task-team-count",children:r?.team?.tasks.length?`${d}/${r.team.tasks.length} complete`:""}),e("span",{class:"task-team-expand",children:"View activity"})]}),e("div",{class:"task-team-progress",children:[c.length?e("div",{children:c.map(l=>e("span",{class:"chip-ctx",children:[l.name," \xB7 ",Se[l.provider]," \xB7 ",l.status??"idle"]},l.id))}):null,r?.team?.tasks.map(l=>e("div",{children:[l.title,e("span",{class:"help",children:[" \xB7 ",l.status??"planned"]})]},l.id)),r?.team?.providerChanges?.map(l=>e("p",{class:"help",children:[l.role==="reviewer"?"Review":l.role==="coordinator"?"Coordination":"Assignment"," continued with ",Se[l.to]," after ",Se[l.from]," became unavailable."]})),r?.error?e("p",{class:"help",children:r.error}):null,e(ih,{run:t,execution:n.executionId}),n.resolutionCheck?e("details",{children:[e("summary",{children:["Combined workspace check: ",n.resolutionCheck.ok?"passed":"failed"]}),e("pre",{class:"task-check-output",children:n.resolutionCheck.output||"Check completed without output."})]}):null,n.resolutionReview?e("div",{class:"help",role:"status",children:[n.resolutionReview.error??(n.resolutionReview.approved===void 0?"Reviewing combined changes\u2026":n.resolutionReview.approved?"Combined changes reviewed":"Review found changes to address"),n.resolutionReview.issues?.map(l=>e("p",{children:[l.file,": ",l.problem]}))]}):null,n.reviewStale?e("p",{class:"help",children:"Independent review covered the team's original result. Your combined edits need a fresh review; a passing check does not replace it."}):null,r?.awaiting?e("p",{class:"help",children:"Review and approve the plan in Team details to continue."}):null,e("a",{class:"btn small",href:`#/run/${n.executionId}`,children:"Team details"})]})]}),!a&&t.status==="done"&&t.teamTurns?.at(-1)?.key===n.key?e(oh,{run:t,execution:n.executionId,stopped:!!r&&r.status!=="done",reviewStale:!!n.reviewStale||!!n.resolutionReview?.error,checkFailed:n.resolutionCheck?.ok===!1,conflicts:!!n.reconciliation}):null]},n.key)})}):null}function oh({run:t,execution:s,stopped:n,checkFailed:r,conflicts:a,reviewStale:c}){let[i,d]=m(!1),[l,p]=m("");if(a||!n&&!r&&!c)return null;let o=async()=>{d(!0),p("");try{await O(`/api/runs/${t.id}/${n?"team-resume":r?"team-recheck":"team-review"}`,{execution:s})}catch(u){p(u.message)}finally{d(!1)}};return e("div",{class:"task-team-recovery",children:[e("button",{class:"btn small",disabled:i,onClick:()=>void o(),children:i?"Continuing\u2026":n?"Resume team":r?"Check again":"Refresh review"}),l?e("span",{class:"help",role:"alert",children:l}):null]})}function ih({run:t,execution:s}){let[n,r]=m(!1);return!n&&!t.teamTurns?.find(a=>a.executionId===s)?.reconciliation?null:e(M,{children:[e("p",{class:"help",children:"Some of your edits overlap the team\u2019s changes. Both versions are saved."}),e("button",{class:"btn small",disabled:t.status==="running",onClick:()=>r(!0),children:"Resolve conflicts"}),n?e(lh,{run:t,execution:s,close:()=>r(!1)}):null]})}function lh({run:t,execution:s,close:n}){let r=`/api/runs/${t.id}/team-resolution?execution=${encodeURIComponent(s)}`,[a,c]=m(),[i,d]=m(0),[l,p]=m(!1),[o,u]=m(""),f=ye(!0,()=>{l||n()}),[h,g]=m({}),y=async()=>{p(!0);try{c(await V(r)),g({}),d(0),u("")}catch(k){u(k.message)}finally{p(!1)}};N(()=>{y()},[]);let C=a?.files[i],T=C?h[C.path]:void 0,v=async()=>{if(a){p(!0);try{await O(r,{current:a.current,choices:a.files.map(k=>({path:k.path,...h[k.path]}))}),n()}catch(k){u(k.message)}finally{p(!1)}}};return e("dialog",{ref:f,class:"picker task-conflict-dialog","aria-label":"Resolve team changes",children:[e("div",{class:"picker-head",children:[e("h3",{children:"Resolve changes"}),e("button",{class:"icon-btn","aria-label":"Close conflict resolution",disabled:l,onClick:n,children:"\xD7"})]}),e("div",{class:"picker-body",children:[e("p",{children:"Your edits and the team\u2019s work are preserved. Choose a version for each conflict, or edit the combined result. Other changes merge automatically."}),a?.files.length?e("select",{class:"field","aria-label":"Conflicting file",disabled:l,value:i,onChange:k=>d(Number(k.currentTarget.value)),children:a.files.map((k,b)=>e("option",{value:b,children:[h[k.path]?"\u2713 ":"",k.path]}))}):a?e("p",{children:"No conflicts remain. Apply to merge the remaining changes."}):e("p",{children:"Comparing changes\u2026"}),C?e(M,{children:[e("div",{class:"task-conflict-versions",children:[["base","Starting version"],["current","Your version"],["team","Team version"]].map(([k,b])=>e("section",{children:[e("h3",{children:b}),e("pre",{children:C[k].exists?C[k].binary?"Binary file or symbolic link \u2014 choose a version":C[k].text:"File deleted / absent"})]}))}),e("div",{class:"row",children:[["current","Keep yours"],["team","Use team version"],["edited","Edit result"]].map(([k,b])=>e("button",{class:`btn small ${T?.choice===k?"primary":""}`,"aria-pressed":T?.choice===k,disabled:l||k==="edited"&&(C.current.binary||C.team.binary),onClick:()=>g({...h,[C.path]:{choice:k,...k==="edited"?{text:T?.text??C.current.text}:{}}}),children:b}))}),T?.choice==="edited"?e("textarea",{class:"field task-conflict-editor","aria-label":"Resolved file contents",disabled:l,value:T.text,onInput:k=>g({...h,[C.path]:{choice:"edited",text:k.currentTarget.value}})}):null]}):null,o?e("p",{class:"msg err",role:"alert",children:o}):null]}),e("div",{class:"picker-foot",children:[e("button",{class:"btn",disabled:l,onClick:()=>void y(),children:"Refresh comparison"}),e("button",{class:"btn primary",disabled:l||!a||a.files.some(k=>!h[k.path]),onClick:()=>void v(),children:l?"Working\u2026":"Apply and check"})]})]})}function dd({run:t}){if(t.chatLink?.kind==="side")return null;let s=[...ve.value.values()].find(c=>c.taskExecution?.taskId===nt(t)&&c.status==="running");if(!s)return null;let n=ve.value.get(nt(t)),r=t.notes.some(c=>c.teamDelivery?.executionId===s.id&&["received","replanning"].includes(c.teamDelivery.state)),a=s.team?.members.filter(c=>c.status==="working").length??0;return e("div",{class:"task-team-live",role:"status",children:[e("span",{children:r?"Updating the team with your message\u2026":n?.taskTeam?.enabled===!1?"Stopping team \xB7 preserving work\u2026":s.awaiting?"Team plan needs your approval":s.team?.awaitingRequestId?"Team needs your answer":s.team?.status==="planning"?"Team is planning\u2026":a?`Team \xB7 ${a} working`:"Team is checking the result\u2026"}),e("a",{href:`#/run/${s.id}`,children:"Team details"})]})}var Ra=qe({});function ru({remote:t,nativeAntigravity:s=!1}){let n=Z(0),[r,a]=m(),[c,i]=m(!1),[d,l]=m("");async function p(o=!1,u){let f=++n.current;i(!0),l("");try{let h=o?await O("/api/model-catalog",{...u===void 0?{}:{allowResearch:u},antigravityExecution:s?"native":"isolated"}):await V(`/api/model-catalog?antigravityExecution=${s?"native":"isolated"}`);if(f!==n.current)return;a(h),Ra.value=Object.fromEntries(h.providers.map(g=>[g.provider,{models:g.catalog.models.filter(y=>y.availability==="reported").map(y=>({id:y.id,label:y.label,efforts:y.efforts??[]})),efforts:[],defaultModel:g.catalog.defaultModel,allowCustom:!1}]))}catch(h){f===n.current&&l(h.message)}finally{f===n.current&&i(!1)}}return N(()=>(a(void 0),Ra.value={},t||p(),()=>{n.current++}),[t,s]),e("section",{class:"section","aria-label":"Automatic worker models",children:[e("h4",{children:"Automatic worker selection"}),e("p",{class:"help",children:"Auto chooses each worker's provider, model and effort. Your coordinator stays fixed. Use the worker pool and model selections below to restrict or pin workers."}),t?e("p",{class:"help",children:"Models are discovered in the selected execution environment when the run starts. Local model lists do not establish remote or container compatibility."}):e(M,{children:[e("button",{class:"btn",disabled:c,onClick:()=>void p(!0),children:c?"Discovering models\u2026":"Refresh model catalog"}),e("label",{class:"checkpoint",children:[e("input",{type:"checkbox",checked:r?.allowResearch??!1,disabled:c||r?.offline,onChange:o=>void p(!0,o.currentTarget.checked)}),e("span",{children:"Allow research from official provider documentation"})]}),e("p",{class:"help",children:[r?.offline?"Offline: using cached information. ":"","CLI listings report candidates; they do not prove account access or successful execution. Unknown facts stay unknown."]}),r?.providers.map(o=>e("details",{children:[e("summary",{children:[o.provider," \xB7 ",o.catalog.state," \xB7 ",o.catalog.models.length," models"]}),o.blockedReason?e("p",{class:"help",children:["Unsupported for managed workers: ",o.blockedReason]}):null,o.limitations?.map(u=>e("p",{class:"help",children:u},u)),o.catalog.issue?e("p",{class:"help",children:o.catalog.issue}):null,e("ul",{children:o.catalog.models.map(u=>e("li",{children:[e("code",{children:u.id})," \xB7 ",u.efforts===null?"Effort support unknown":u.efforts.length?u.efforts.join(", "):"No effort control",e("p",{class:"help",children:[u.source," \xB7 ",new Date(u.verifiedAt).toLocaleString()," \xB7 ",u.availability,". Context: ",u.documented?.contextTokens??"unknown","; pricing: ",u.documented?.pricing?`$${u.documented.pricing.inputPerMillion}/$${u.documented.pricing.outputPerMillion} per million input/output tokens`:"unknown",". ",u.observations.length," run observations."]})]},u.id))})]},o.provider))]}),d?e("p",{role:"alert",children:d}):null]})}var ou=["claude","codex","agy"],iu={auto:"Auto",claude:"Claude Code",codex:"Codex",agy:"Antigravity"};function ax(t,s){return t==="claude"?{model:s==="quick"?"haiku":"sonnet",effort:s==="quick"?void 0:"low"}:{effort:"low"}}function rx(t,s,n){return t==="claude"&&/haiku/i.test(s??"")?[]:n?.models.find(r=>r.id===(s||n.defaultModel))?.efforts??n?.efforts??[]}function fi(t){let s=t;if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Invalid prompt improvement settings");if(s.agent!=="auto"&&!ou.includes(s.agent))throw new Error("Choose Auto, Claude Code, Codex or Antigravity for prompt improvement");if(s.defaultMode!=="quick"&&s.defaultMode!=="repo")throw new Error("Choose Quick or Repo as the default improvement mode");let n={};if(s.providers!==void 0&&(!s.providers||typeof s.providers!="object"||Array.isArray(s.providers)))throw new Error("Invalid prompt improvement provider settings");for(let r of ou)for(let a of["quick","repo"]){let c=s.providers?.[r]?.[a];if(c===void 0)continue;if(!c||typeof c!="object"||Array.isArray(c))throw new Error("Invalid prompt improvement model settings");let i={};for(let d of["model","effort"]){let l=c[d];if(l!==void 0){if(typeof l!="string"||l.length>200||/[\x00-\x1f\x7f]/.test(l))throw new Error(`Invalid prompt improvement ${d}`);i[d]=l.trim()}}(n[r]??={})[a]=i}return{agent:s.agent,defaultMode:s.defaultMode,providers:n}}function ch(){try{let t=ae.get("improveSettings");if(t)return fi(JSON.parse(t))}catch{}return{agent:"auto",defaultMode:ae.get("improveMode")==="repo"?"repo":"quick",providers:{}}}var Rs=qe(ch());function dx(t){Rs.value=fi(t),ae.set("improveSettings",JSON.stringify(Rs.value))}var Ht=t=>!!t&&typeof t=="object"&&!Array.isArray(t),lu=t=>typeof t=="string"&&/^[a-zA-Z0-9_-]{1,100}$/.test(t),ls=(t,s)=>typeof t=="string"&&t.length<=s,du=t=>typeof t=="string"&&(["claude","codex","agy"].includes(t)||/^acp:[a-z][a-z0-9-]{0,40}$/.test(t)||/^plugin:[a-z][a-z0-9-]{0,40}\/[a-z][a-z0-9-]{0,40}$/.test(t)),wn=(t,s,n)=>typeof t=="number"&&Number.isInteger(t)&&t>=s&&t<=n,He=t=>{throw new Error(t)};function cu(t){if(!Ht(t))return He("Model settings must be an object.");let s={};for(let[n,r]of Object.entries(t)){if(!du(n)||!Ht(r)||r.model!==void 0&&!ls(r.model,256)||r.effort!==void 0&&!ls(r.effort,64))return He("A preset contains invalid provider model settings.");if(r.variants!==void 0&&(!Array.isArray(r.variants)||r.variants.length>128||r.variants.some(a=>!Ht(a)||!ls(a.model,256)||!a.model.trim()||a.effort!==void 0&&!ls(a.effort,64))))return He("Invalid model variants.");s[n]={...r.model!==void 0?{model:r.model}:{},...r.effort!==void 0?{effort:r.effort}:{},...Array.isArray(r.variants)?{variants:r.variants.map(a=>({model:a.model,...a.effort!==void 0?{effort:a.effort}:{}}))}:{}}}return s}function gi(t,s){if(!Ht(t))return He("A preset is missing its configuration.");let n=s.find(l=>l.id===t.pattern);if(!n)return He(`Unknown workflow: ${String(t.pattern)}.`);if(!Ht(t.roles)||!Ht(t.options)||!Ht(t.roleSettings))return He("A preset must contain roles, options and role settings.");let r={};for(let[l,p]of Object.entries(t.roles)){let o=n.roles.find(u=>u.id===l);if(!o||!Array.isArray(p)||p.length>(o.multiple?4:1)||p.some(u=>u!=="auto"&&!du(u))||new Set(p).size!==p.length)return He(`Invalid assignments for role ${l}.`);r[l]=[...p]}for(let l of n.roles)if(!l.optional&&!r[l.id]?.length)return He(`A preset needs an assignment for ${l.label}.`);let a={};for(let[l,p]of Object.entries(t.options)){let o=n.options.find(u=>u.id===l);if(!o||(o.type==="boolean"?typeof p!="boolean":typeof p!="number"||!Number.isFinite(p)||p<(o.min??0)||p>(o.max??1e4)))return He(`Invalid workflow option ${l}.`);a[l]=p}let c={};for(let[l,p]of Object.entries(t.roleSettings)){if(!n.roles.some(o=>o.id===l))return He(`Unknown role settings: ${l}.`);c[l]=cu(p)}if(!["safe","standard","trusted","full"].includes(String(t.trust))||typeof t.approvePlan!="boolean"||!Ht(t.limits)||!wn(t.limits.maxMinutes,1,720)||!wn(t.limits.maxSteps,1,200))return He("Invalid permissions, approval choice or execution limits.");if(t.limits.maxTokens!==void 0&&!wn(t.limits.maxTokens,1,1e9)||t.limits.maxCostUsd!==void 0&&(typeof t.limits.maxCostUsd!="number"||!Number.isFinite(t.limits.maxCostUsd)||t.limits.maxCostUsd<=0||t.limits.maxCostUsd>1e6)||t.toolApprovals!==void 0&&typeof t.toolApprovals!="boolean")return He("Invalid reported usage ceilings or tool approval preference.");for(let l of["check","setup","baseRef"])if(t[l]!==void 0&&!ls(t[l],1e4))return He(`Invalid ${l} setting.`);let i=Object.fromEntries(["check","setup","baseRef"].filter(l=>t[l]!==void 0).map(l=>[l,t[l]])),d=Ui(t.contextBudget);return{...i,pattern:n.id,roles:r,options:a,agentSettings:cu(t.agentSettings),roleSettings:c,trust:t.trust,limits:{maxMinutes:t.limits.maxMinutes,maxSteps:t.limits.maxSteps,...t.limits.maxTokens!==void 0?{maxTokens:t.limits.maxTokens}:{},...t.limits.maxCostUsd!==void 0?{maxCostUsd:t.limits.maxCostUsd}:{}},approvePlan:t.approvePlan,...t.toolApprovals!==void 0?{toolApprovals:t.toolApprovals}:{},...d?{contextBudget:d}:{}}}function aa(t){return[...new Set([...[t.task,...t.criteria].join(`
|
|
125
|
+
`).matchAll(/\{\{([a-zA-Z][a-zA-Z0-9_]{0,39})\}\}/g)].map(s=>s[1]))]}function Vr(t,s){for(let r of aa(t))if(!s[r]?.trim())return He(`Enter a value for ${r}.`);let n=r=>r.replace(/\{\{([a-zA-Z][a-zA-Z0-9_]{0,39})\}\}/g,(a,c)=>s[c].trim());return{task:n(t.task),criteria:t.criteria.map(n)}}function $s(t,s){if(!Ht(t)||t.schemaVersion!==1||!Array.isArray(t.presets)||!Array.isArray(t.templates)||t.presets.length>100||t.templates.length>100)return He("Expected a version 1 code-flow library with at most 100 presets and 100 templates.");let n=t.presets.map(a=>{if(!Ht(a)||!lu(a.id)||!ls(a.name,80)||!a.name.trim()||!wn(a.revision,1,1e6)||!wn(a.updatedAt,0,Number.MAX_SAFE_INTEGER)||!Array.isArray(a.history)||a.history.length>10)return He("Invalid team preset metadata.");let c=a.history.map(i=>!Ht(i)||!wn(i.revision,1,a.revision-1)||!wn(i.updatedAt,0,Number.MAX_SAFE_INTEGER)?He("Invalid preset revision history."):{revision:i.revision,updatedAt:i.updatedAt,config:gi(i.config,s)});return new Set(c.map(i=>i.revision)).size!==c.length?He("Duplicate preset revision."):{id:a.id,name:a.name.trim(),revision:a.revision,updatedAt:a.updatedAt,config:gi(a.config,s),history:c}}),r=t.templates.map(a=>{if(!Ht(a)||!lu(a.id)||!ls(a.name,80)||!a.name.trim()||!s.some(l=>l.id===a.pattern)||!ls(a.task,1e5)||!a.task.trim()||!Array.isArray(a.criteria)||a.criteria.length>100||a.criteria.some(l=>!ls(l,2e3)))return He("Invalid task template.");if(a.intent!==void 0&&!["bug","feature","review","explore"].includes(String(a.intent)))return He("Invalid template task intent.");let c={...a.intent?{intent:a.intent}:{},id:a.id,name:a.name.trim(),pattern:a.pattern,task:a.task,criteria:a.criteria};if(aa(c).length>24)return He("A template can have at most 24 parameters.");let i=a.config===void 0?void 0:gi(a.config,s);if(i&&i.pattern!==c.pattern)return He("Template workflow and agent configuration must match.");let d;if(a.runOptions!==void 0){let l=a.runOptions;if(!Ht(l)||!["","lightweight","standard","thorough"].includes(String(l.verification))||!Ht(l.container)||typeof l.container.enabled!="boolean"||!ls(l.container.image,500)||!ls(l.container.authVolume,500))return He("Invalid template execution settings.");d={verification:l.verification,container:{enabled:l.container.enabled,image:l.container.image,authVolume:l.container.authVolume}}}return{...c,...i?{config:i}:{},...d?{runOptions:d}:{}}});return new Set(n.map(a=>a.id)).size!==n.length||new Set(r.map(a=>a.id)).size!==r.length?He("Duplicate library identifiers."):{schemaVersion:1,presets:n,templates:r}}function $a(t,s){let n=s.map(r=>r.trim()).filter(Boolean);return n.length?`${t.trim()}
|
|
126
|
+
|
|
127
|
+
Acceptance criteria:
|
|
128
|
+
${n.map((r,a)=>`${a+1}. ${r}`).join(`
|
|
129
|
+
`)}`:t}function uu(){let t=ts.value,[s,n]=m(""),r=a=>{try{In(a),n("")}catch(c){n(c.message)}};return e("fieldset",{class:"context-budget",children:[e("legend",{children:"Invocation context budget"}),e("label",{class:"check",children:[e("input",{type:"checkbox",checked:!!t,onChange:a=>r(a.currentTarget.checked?{maxPromptBytes:65536,policy:"warn"}:void 0)}),"Set an explicit input budget for each provider launch"]}),e("p",{class:"help",children:"Measured immediately before dispatch from the assembled prompt and JSON schema. Earlier CLI conversations, provider system instructions, file reads and image tokens are excluded. Reference file sizes below are separate estimates."}),t?e(M,{children:[e("label",{class:"lbl",for:"context-max-bytes",children:"Maximum explicit input bytes"}),e("input",{class:"field",id:"context-max-bytes",type:"number",min:1,max:67108864,value:t.maxPromptBytes??"",placeholder:"No byte ceiling",onInput:a=>r({...t,maxPromptBytes:a.currentTarget.value?Number(a.currentTarget.value):void 0})}),e("label",{class:"lbl",for:"context-max-tokens",children:"Maximum approximate input tokens"}),e("input",{class:"field",id:"context-max-tokens",type:"number",min:1,max:16777216,value:t.maxApproximateTokens??"",placeholder:"No estimated token ceiling",onInput:a=>r({...t,maxApproximateTokens:a.currentTarget.value?Number(a.currentTarget.value):void 0})}),e("label",{class:"lbl",for:"context-budget-policy",children:"When the explicit input exceeds this budget"}),e("select",{class:"field",id:"context-budget-policy",value:t.policy,onChange:a=>r({...t,policy:a.currentTarget.value}),children:[e("option",{value:"warn",children:"Record a warning and continue"}),e("option",{value:"block",children:"Block the provider launch"})]}),e("p",{class:"help",children:["Active budget: ",t.maxPromptBytes?`${t.maxPromptBytes.toLocaleString()} bytes`:"no byte ceiling"," \xB7 ",t.maxApproximateTokens?`${t.maxApproximateTokens.toLocaleString()} estimated tokens`:"no estimated token ceiling"," \xB7 ",t.policy,". Token ceilings are approximate guards, not a guarantee about a provider\u2019s context window."]})]}):null,s?e("p",{class:"msg err",role:"alert",children:s}):null]})}var Cn={schemaVersion:1,presets:[],templates:[]};function yi(){let t=Ts.value;return!t||t.some(s=>s.installed&&s.signedIn!==!1&&s.compatible!==!1)?null:e("div",{class:"banner provider-setup",role:"status",children:[e("p",{children:"Connect a provider to start a conversation or run a team."}),e("a",{class:"btn",href:"#/settings/agents",children:"Connect a provider"})]})}function pu(){return e("details",{class:"settings acceptance-editor",children:[e("summary",{children:[e("span",{class:"st",children:"Acceptance criteria"}),e("span",{class:"ss",children:[Cs.value.filter(t=>t.trim()).length||"Optional"," \xB7 explicit requirements for the team"]})]}),e("div",{class:"settings-body",children:[e("label",{class:"lbl",for:"acceptance-criteria",children:"One requirement per line"}),e("textarea",{id:"acceptance-criteria",class:"field",rows:4,placeholder:`The new behavior has automated tests.
|
|
130
|
+
Existing API clients continue to work.`,value:Cs.value.join(`
|
|
131
|
+
`),onInput:t=>ms(t.currentTarget.value.split(`
|
|
132
|
+
`))}),e("p",{class:"help",children:"These requirements are included in the run's task and in saved automations. Review them before starting."})]})]})}function mu({repository:t=ee.value,setup:s=Gt.value,check:n=Dt.value,base:r=Fe.value,loading:a=an.value,pattern:c,roles:i,providers:d}={}){let[l,p]=m(null),[o,u]=m(!1),[f,h]=m(""),[g,y]=m(!1),C=JSON.stringify([t,r,s,n,c,i,d]),T=Z(C);T.current=C;let v=Z(0);N(()=>{++v.current,u(!1),p(null),h(""),y(!1)},[C]);let k=async b=>{let S=++v.current,x=C;u(!0),h(""),p(null);try{let w=await O("/api/readiness",{repo:t,baseRef:r,setup:s,check:n,execute:b,pattern:c,roles:i,providers:d});if(S!==v.current||T.current!==x)return;p(w),y(b)}catch(w){S===v.current&&T.current===x&&h(w.message)}finally{S===v.current&&T.current===x&&u(!1)}};return e("details",{class:"settings readiness",children:[e("summary",{children:[e("span",{class:"st",children:"Repository readiness"}),e("span",{class:"ss",children:o?"Checking\u2026":l?`${g?"Commands validated":"Inspection complete"} \xB7 ${l.ok?"ready":"needs attention"}`:"Check the repository and provider setup"})]}),e("div",{class:"settings-body",children:[e("p",{class:"help",children:"Inspect readiness checks configuration and installed tools. Validate commands runs setup and checks in a temporary worktree; this executes repository code."}),e("div",{class:"onboarding-actions",children:[e("button",{class:"btn",disabled:!t||o||a,onClick:()=>k(!1),children:"Inspect readiness"}),e("button",{class:"btn",disabled:!t||o||a||!s.trim()&&!n.trim(),onClick:()=>k(!0),children:"Validate commands"})]}),o?e("p",{role:"status",children:"Checking repository readiness\u2026"}):null,f?e("p",{class:"msg err",role:"alert",children:f}):null,l?e("ul",{class:"readiness-results",children:l.items.map(b=>e("li",{children:[e("span",{class:`badge ${{passed:"ok",failed:"err",warning:"warn",skipped:""}[b.status]??""}`,children:b.status.charAt(0).toUpperCase()+b.status.slice(1)}),e("span",{children:[e("b",{children:b.label}),b.detail?e("span",{class:"help",children:b.detail}):null]})]},b.id))}):null]})]})}function vi(t){return structuredClone({pattern:t.id,roles:Vt(t),options:as(t),agentSettings:Be.value,roleSettings:rt.value[t.id]??{},trust:ut.value,limits:$e.value,approvePlan:un(t.id),toolApprovals:ae.get("interactiveApprovals")==="1",contextBudget:ts.value,check:Dt.value,setup:Gt.value,baseRef:Fe.value})}function bi(t,s){let n=ge.value.find(r=>r.id===t.pattern);if(!n)throw new Error("This workflow is no longer available.");St(t.pattern);for(let r of n.roles)At(n.id,r.id,t.roles[r.id]??[]);for(let r of n.options)pn(n,r.id,t.options[r.id]??r.default);Be.value={},ae.set("agentSettings","{}"),rt.value={...rt.value,[n.id]:{}},ae.set("roleModels",JSON.stringify(rt.value));for(let[r,a]of Object.entries(t.agentSettings))Fs(r,a);for(let[r,a]of Object.entries(t.roleSettings))for(let[c,i]of Object.entries(a))It(n.id,r,c,i);In(t.contextBudget,s),t.check!==void 0&&_a(t.check),t.setup!==void 0&&Va(t.setup),t.baseRef!==void 0&&(Fe.value=t.baseRef),Ln.value={...Ln.value,pattern:s,roles:s,models:s}}function Ex({p:t,onToolApprovalsChange:s,libraryKey:n="composerLibrary"}){let[r]=m(()=>{try{return{library:$s(ae.json(n,Cn),ge.value),error:""}}catch(D){return{library:structuredClone(Cn),error:`Saved library could not be loaded: ${D.message}. Import a valid backup to recover it.`}}}),[a,c]=m(r.library),i=Z(a);i.current=a;let[d,l]=m(r.error),[p,o]=m(""),[u,f]=m(""),[h,g]=m(""),[y,C]=m(""),[T,v]=m(""),[k,b]=m(null),S=Z(null),x=a.presets.find(D=>D.id===p),w=D=>{try{let I=$s(D,ge.value);return ae.set(n,JSON.stringify(I)),i.current=I,c(I),l(""),!0}catch(I){return l(I.message),!1}},j=()=>{let D=x,I=D?.id??crypto.randomUUID(),$={id:I,name:u.trim(),revision:(D?.revision??0)+1,updatedAt:Date.now(),config:vi(t),history:D?[...D.history,{revision:D.revision,updatedAt:D.updatedAt,config:D.config}].slice(-10):[]};w({...a,presets:[...a.presets.filter(E=>E.id!==I),$]})&&(o(I),g(""),J(`Saved ${$.name}, revision ${$.revision}`))},A=(D,I)=>{let $=Vr(D,I);D.config?bi(D.config,`Template ${D.name}`):St(D.pattern),jt.value=D.intent,Tt($.task),ms($.criteria),b(null)},P=()=>{let D=URL.createObjectURL(new Blob([JSON.stringify(a,null,2)],{type:"application/json"})),I=document.createElement("a");I.href=D,I.download="code-flow-library.json",I.click(),setTimeout(()=>URL.revokeObjectURL(D),1e3)};return e("details",{class:"settings composer-library",children:[e("summary",{children:[e("span",{class:"st",children:"Advanced library management"}),e("span",{class:"ss",children:[a.presets.length," teams \xB7 ",a.templates.length," templates"]})]}),e("div",{class:"settings-body",children:[e("p",{class:"help",children:"Saved in this browser for the selected library. Export a backup to share or move them. Saving captures the current run draft. Teams include permissions, models, workflow options and limits; saved workflow commands are restored when applied."}),e("div",{class:"settings-grid",children:[e("div",{children:[e("label",{class:"lbl",for:"saved-preset",children:"Saved workflow"}),e("select",{class:"field",id:"saved-preset",value:p,onChange:D=>{let I=a.presets.find($=>$.id===D.currentTarget.value);o(I?.id??""),f(I?.name??""),g("")},children:[e("option",{value:"",children:"New saved workflow\u2026"}),a.presets.map(D=>e("option",{value:D.id,children:[D.name," \xB7 r",D.revision]},D.id))]})]}),e("div",{children:[e("label",{class:"lbl",for:"preset-name",children:"Workflow name"}),e("input",{id:"preset-name",class:"field",maxLength:80,value:u,onInput:D=>f(D.currentTarget.value)})]})]}),x?e("div",{children:[e("label",{class:"lbl",for:"preset-revision",children:"Revision to apply"}),e("select",{id:"preset-revision",class:"field",value:h,onChange:D=>g(D.currentTarget.value),children:[e("option",{value:"",children:["Current \xB7 r",x.revision]}),[...x.history].reverse().map(D=>e("option",{value:D.revision,children:["r",D.revision," \xB7 ",new Date(D.updatedAt).toLocaleString()]},D.revision))]}),e("p",{class:"help",children:["Permissions: ",(h?x.history.find(D=>String(D.revision)===h)?.config:x.config)?.trust,". Up to 10 previous revisions are kept."]})]}):null,e("div",{class:"onboarding-actions",children:[e("button",{class:"btn",disabled:!u.trim(),onClick:j,children:x?"Save new revision":"Save current workflow"}),e("button",{class:"btn",disabled:!x||an.value||ys.value,onClick:()=>{if(x){let D=h?x.history.find(I=>String(I.revision)===h).config:x.config;bi(D,`Preset ${x.name} r${h||x.revision}`)}},children:"Apply workflow"}),x?e("button",{class:"btn ghost",onClick:()=>{w({...a,presets:a.presets.filter(D=>D.id!==p)})&&(o(""),f(""))},children:"Delete workflow"}):null]}),e("div",{class:"settings-grid",children:[e("div",{children:[e("label",{class:"lbl",for:"saved-template",children:"Task template"}),e("select",{class:"field",id:"saved-template",value:y,onChange:D=>{let I=a.templates.find($=>$.id===D.currentTarget.value);C(I?.id??""),v(I?.name??"")},children:[e("option",{value:"",children:"New task template\u2026"}),a.templates.map(D=>e("option",{value:D.id,children:D.name},D.id))]})]}),e("div",{children:[e("label",{class:"lbl",for:"template-name",children:"Template name"}),e("input",{class:"field",id:"template-name",maxLength:80,value:T,onInput:D=>v(D.currentTarget.value)})]})]}),e("p",{class:"help",children:["Save the current task, workflow and acceptance criteria. Write parameters such as ",e("code",{children:"{{component}}"})," or ",e("code",{children:"{{issue}}"})," in the task or criteria; you'll be asked to fill each one when applying."]}),e("div",{class:"onboarding-actions",children:[e("button",{class:"btn",disabled:!T.trim()||!Me.value.trim(),onClick:()=>{let D=y||crypto.randomUUID();w({...a,templates:[...a.templates.filter(I=>I.id!==D),{id:D,name:T,pattern:t.id,task:Me.value,intent:jt.value,criteria:Cs.value,config:vi(t)}]})&&C(D)},children:"Save current task as template"}),e("button",{class:"btn",disabled:!y||an.value||ys.value,onClick:()=>{let D=a.templates.find(I=>I.id===y);aa(D).length?b(D):A(D,{})},children:"Apply template"}),y?e("button",{class:"btn ghost",onClick:()=>{w({...a,templates:a.templates.filter(D=>D.id!==y)})&&(C(""),v(""))},children:"Delete template"}):null]}),e("div",{class:"onboarding-actions",children:[e("button",{class:"btn",onClick:P,children:"Export library"}),e("button",{class:"btn",onClick:()=>S.current?.click(),children:"Import library"})]}),e("input",{ref:S,type:"file",hidden:!0,accept:".json,application/json",onChange:async D=>{let I=D.currentTarget.files?.[0];if(D.currentTarget.value="",!!I)try{if(I.size>1024*1024)throw new Error("Library files must be under 1 MB.");let $=$s(JSON.parse(await I.text()),ge.value),E=i.current,L=(H,Q)=>[...H,...Q.map(le=>H.some(de=>de.id===le.id)?{...le,id:crypto.randomUUID()}:le)];w({schemaVersion:1,presets:L(E.presets,$.presets),templates:L(E.templates,$.templates)})&&J("Library imported. Existing entries were preserved.")}catch($){l($.message)}}}),d?e("p",{class:"msg err",role:"alert",children:d}):null]}),k?e(uh,{template:k,onClose:()=>b(null),onApply:D=>A(k,D)}):null]})}var dh=[{id:"starter-bug",intent:"bug",name:"Fix a bug",pattern:"pipeline",task:`Fix the following bug:
|
|
133
|
+
|
|
134
|
+
Expected behavior:
|
|
135
|
+
Actual behavior:
|
|
136
|
+
Steps to reproduce:`,criteria:[]},{id:"starter-feature",intent:"feature",name:"Build a feature",pattern:"pipeline",task:`Build the following feature:
|
|
137
|
+
|
|
138
|
+
Who it helps:
|
|
139
|
+
Expected behavior:
|
|
140
|
+
Acceptance criteria:`,criteria:[]},{id:"starter-review",intent:"review",name:"Review code",pattern:"council",task:`Review the code for correctness and regressions.
|
|
141
|
+
|
|
142
|
+
Scope or branch to review:
|
|
143
|
+
Areas of concern:`,criteria:[]},{id:"starter-explore",intent:"explore",name:"Explore an idea",pattern:"debate",task:`Explore approaches to the following idea without implementing changes:
|
|
144
|
+
|
|
145
|
+
Goal:
|
|
146
|
+
Constraints:
|
|
147
|
+
Trade-offs to consider:`,criteria:[]}];function hu({initialScope:t,onClose:s,onUsed:n,onConfigured:r}){let a=ye(!0,s),[c]=m(()=>ze.value.project),[i,d]=m(c&&t==="project"?"project":"personal"),[l,p]=m(""),[o,u]=m({}),[f,h]=m(null),g=Z(null),[y,C]=m(!1),[T,v]=m(""),[k,b]=m(()=>{let L=H=>{try{let Q=ae.get(H);return{...$s(Q===null?Cn:JSON.parse(Q),ge.value),error:""}}catch(Q){return{...Cn,error:`Could not load templates: ${Q.message}`}}};return{project:c?L(`composerLibrary:${c.id}`):{...Cn,error:""},personal:L("composerLibrary")}}),S=i==="project"?k.project:k.personal,x=dh.filter(L=>ge.value.some(H=>H.id===L.pattern)),w=l.startsWith("saved:")?S.templates.find(L=>`saved:${L.id}`===l):void 0,j=l.startsWith("workflow:")?S.presets.find(L=>`workflow:${L.id}`===l):void 0,A=w??(j?{id:j.id,name:j.name,pattern:j.config.pattern,task:Me.value.trim()||"{{task}}",criteria:[...Cs.value],config:j.config}:x.find(L=>L.id===l)),P=!!w;N(()=>{f&&g.current?.focus()},[f?.id]);let D=L=>{if(A)try{let H=i==="project"&&c?`composerLibrary:${c.id}`:"composerLibrary",Q=ae.get(H),le=$s(Q===null?Cn:JSON.parse(Q),ge.value),de=le.templates.find(te=>te.id===A.id);if(!de||JSON.stringify(de)!==JSON.stringify(A))throw new Error("This template changed elsewhere. Close and reopen the picker to load the latest version.");let ue=$s({...le,templates:L?le.templates.map(te=>te.id===A.id?L:te):le.templates.filter(te=>te.id!==A.id)},ge.value),q=JSON.stringify(ue);if(ae.set(H,q),ae.get(H)!==q)throw new Error("The change could not be saved. Check that browser storage is available.");b({...k,[i]:{...ue,error:""}}),h(null),C(!1),u({}),v(""),L||p(""),J(L?"Template updated.":"Template deleted.")}catch(H){v(H.message)}},I=A?aa(A):[],$;if(A)try{$=Vr(A,o)}catch{}let E=()=>{!A||!$||f||y||(A.config?bi(A.config,`Template ${A.name}`):St(A.pattern),A.id==="starter-explore"&&(At("debate","builder",[]),At("debate","reviewer",[])),jt.value=j?jt.value:A.intent,Tt($.task),ms($.criteria),r?.(A),n(i))};return e("dialog",{class:"picker",ref:a,"aria-labelledby":"use-task-template-title",children:e("form",{class:"picker-inner",onSubmit:L=>{L.preventDefault(),f?D({...f,name:f.name.trim(),criteria:f.criteria.map(H=>H.trim()).filter(Boolean)}):E()},children:[e("div",{class:"picker-head",children:e("h3",{id:"use-task-template-title",children:"Template library"})}),e("div",{class:"dialog-body",children:[e("label",{class:"lbl",for:"quick-use-library",children:"Library"}),e("select",{id:"quick-use-library",class:"field",disabled:!!f||y,value:i,onChange:L=>{d(L.currentTarget.value),p(""),u({}),v("")},children:[c?e("option",{value:"project",children:["This project \xB7 ",c.name]}):null,e("option",{value:"personal",children:"Personal library \xB7 all projects"})]}),S.error?e("p",{class:"msg err",role:"alert",children:S.error}):x.length||S.templates.length||S.presets.length?e(M,{children:[e("label",{class:"lbl",for:"quick-use-template",children:"Template"}),e("select",{id:"quick-use-template",class:"field",disabled:!!f||y,value:l,onChange:L=>{p(L.currentTarget.value),u({}),v("")},children:[e("option",{value:"",children:"Choose a template\u2026"}),e("optgroup",{label:"Built-in templates",children:x.map(L=>e("option",{value:L.id,children:L.name},L.id))}),e("optgroup",{label:"Saved templates",children:S.templates.map(L=>e("option",{value:`saved:${L.id}`,children:L.name},L.id))}),S.presets.length?e("optgroup",{label:"Saved workflows (keep your task)",children:S.presets.map(L=>e("option",{value:`workflow:${L.id}`,children:L.name},L.id))}):null]}),f?e(M,{children:[e("label",{class:"lbl",for:"edit-template-name",children:["Template name",e("input",{ref:g,id:"edit-template-name",class:"field",required:!0,maxLength:80,value:f.name,onInput:L=>h({...f,name:L.currentTarget.value})})]}),e("label",{class:"lbl",for:"edit-template-workflow",children:["Workflow",e("select",{id:"edit-template-workflow","aria-label":"Workflow",class:"field",value:f.pattern,onChange:L=>h({...f,pattern:L.currentTarget.value,config:L.currentTarget.value===f.pattern?f.config:void 0}),children:ge.value.map(L=>e("option",{value:L.id,children:L.name},L.id))})]}),e("label",{class:"lbl",for:"edit-template-task",children:["Template task",e("textarea",{id:"edit-template-task","aria-label":"Template task",class:"field",required:!0,rows:5,maxLength:1e5,value:f.task,onInput:L=>h({...f,task:L.currentTarget.value})})]}),e("label",{class:"lbl",for:"edit-template-criteria",children:["Acceptance criteria",e("textarea",{id:"edit-template-criteria","aria-label":"Acceptance criteria",class:"field",rows:3,value:f.criteria.join(`
|
|
148
|
+
`),onInput:L=>h({...f,criteria:L.currentTarget.value.split(`
|
|
149
|
+
`)})})]}),e("p",{class:"help",children:["One acceptance criterion per line. Keep placeholders such as ",e("code",{children:"{{component}}"})," for reusable prompts."]})]}):y&&A?e("div",{role:"group","aria-label":"Delete template confirmation",children:[e("p",{children:["Delete \u201C",A.name,"\u201D from ",i==="project"?"this project\u2019s library":"your personal library","?"]}),e("div",{class:"settings-actions",children:[e("button",{type:"button",class:"btn",onClick:()=>{C(!1),v("")},children:"Keep template"}),e("button",{type:"button",class:"btn danger",onClick:()=>D(null),children:"Delete template"})]})]}):e(M,{children:[A&&P?e("div",{class:"settings-actions",children:[e("button",{type:"button",class:"btn",onClick:()=>{h({...A,criteria:[...A.criteria]}),v("")},children:"Edit template"}),e("button",{type:"button",class:"btn danger",onClick:()=>{C(!0),v("")},children:"Delete template\u2026"})]}):null,I.map(L=>e("label",{class:"lbl",for:`quick-use-${L}`,children:[L,e("input",{class:"field",id:`quick-use-${L}`,required:!0,maxLength:4e3,value:o[L]??"",onInput:H=>u({...o,[L]:H.currentTarget.value})})]},L)),$?e("details",{children:[e("summary",{children:"Preview task"}),e("pre",{class:"template-preview",tabIndex:0,children:$a($.task,$.criteria)})]}):null,e("p",{class:"help",children:[A?.config?`Restores task, workflow, agents, models, checks and permissions (${A.config.trust}).`:"Replaces the task, workflow and acceptance criteria; current agent settings are retained."," Review the settings before choosing Start run."]})]})]}):e("p",{class:"help",role:"status",children:"No templates in this library yet. Choose \u201CSave as template\u2026\u201D from the chat box menu to create one."}),ee.value&&!f&&!y?e(gr,{only:"sources",onChoose:s}):null,T?e("p",{class:"msg err",role:"alert",children:T}):null]}),e("div",{class:"picker-foot",children:f?e(M,{children:[e("button",{type:"button",class:"btn",onClick:()=>{h(null),v("")},children:"Cancel editing"}),e("button",{type:"submit",class:"btn primary",disabled:!f.name.trim()||!f.task.trim(),children:"Save changes"})]}):e(M,{children:[e("button",{type:"button",class:"btn",onClick:s,children:"Cancel"}),e("button",{type:"submit",class:"btn primary",disabled:!$||y||an.value||ys.value,children:"Use template"})]})})]})})}function fu({p:t,initialScope:s,onClose:n,onSaved:r,runOptions:a}){let c=ye(!0,n),[i,d]=m(""),[l]=m(()=>ze.value.project),[p,o]=m(l&&s==="project"?"project":"personal"),[u]=m(()=>({task:Me.value,intent:jt.value,pattern:t.id,criteria:[...Cs.value],config:vi(t),...a?{runOptions:structuredClone(a)}:{}})),[f,h]=m(""),g=()=>{if(!(!i.trim()||!u.task.trim()))try{let y=p==="project"&&l?`composerLibrary:${l.id}`:"composerLibrary",C=ae.get(y),T=$s(C===null?Cn:JSON.parse(C),ge.value),v=$s({...T,templates:[...T.templates,{id:crypto.randomUUID(),name:i.trim(),...u}]},ge.value),k=JSON.stringify(v);if(ae.set(y,k),ae.get(y)!==k)throw new Error("The template could not be saved. Check that browser storage is available.");r(p),J(`Template \u201C${i.trim()}\u201D saved.`)}catch(y){h(y.message)}};return e("dialog",{class:"picker",ref:c,"aria-labelledby":"save-task-template-title",children:e("form",{class:"picker-inner",onSubmit:y=>{y.preventDefault(),g()},children:[e("div",{class:"picker-head",children:e("h3",{id:"save-task-template-title",children:"Save as template"})}),e("div",{class:"dialog-body",children:[e("label",{class:"lbl",for:"quick-template-name",children:"Template name"}),e("input",{id:"quick-template-name",class:"field",maxLength:80,required:!0,value:i,onInput:y=>d(y.currentTarget.value),placeholder:"e.g. Review a component"}),e("label",{class:"lbl",for:"quick-template-library",children:"Save to"}),e("select",{id:"quick-template-library",class:"field",value:p,onChange:y=>o(y.currentTarget.value),children:[l?e("option",{value:"project",children:["This project \xB7 ",l.name]}):null,e("option",{value:"personal",children:"Personal library \xB7 all projects"})]}),e("p",{class:"help",children:["Saves the task, acceptance criteria, workflow, agents, models, permissions, checks and run settings in this browser. Repository selection, remote worker assignments and attached files remain specific to each run. Use placeholders such as ",e("code",{children:"{{component}}"})," for reusable prompts."]}),f?e("p",{class:"msg err",role:"alert",children:f}):null]}),e("div",{class:"picker-foot",children:[e("button",{type:"button",class:"btn",onClick:n,children:"Cancel"}),e("button",{type:"submit",class:"btn primary",disabled:!i.trim()||!u.task.trim(),children:"Save template"})]})]})})}function uh({template:t,onClose:s,onApply:n}){let r=ye(!0,s),[a,c]=m({}),i=aa(t),d="";try{let l=Vr(t,a);d=$a(l.task,l.criteria)}catch{}return e("dialog",{class:"picker",ref:r,"aria-labelledby":"fill-template-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"fill-template-title",children:["Apply ",t.name]})}),e("div",{class:"dialog-body",children:[i.map(l=>e("div",{children:[e("label",{class:"lbl",for:`parameter-${l}`,children:l}),e("input",{class:"field",id:`parameter-${l}`,value:a[l]??"",maxLength:4e3,onInput:p=>c({...a,[l]:p.currentTarget.value})})]},l)),d?e("details",{children:[e("summary",{children:"Preview task"}),e("pre",{class:"template-preview",tabIndex:0,children:d})]}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps"}),e("button",{class:"btn",onClick:s,children:"Cancel"}),e("button",{class:"btn primary",disabled:!d,onClick:()=>n(a),children:"Use template"})]})]})})}function gu({p:t,verificationProfile:s,container:n}){let r=ee.value,a=ns.value?.config??{},c=r?ae.get(`check:${r}`):null,i=r?ae.get(`setup:${r}`):null,d=[["Repository",r||"Not chosen","Repository picker"],["Project",ze.value.project?.name??"Created from repository on start","Project selection / repository membership"],["Workflow",t.name,Ln.value.pattern??"Workflow default"],["Team",Object.entries(Vt(t)).map(([l,p])=>`${l}: ${p.join(", ")||"skipped"}`).join(" \xB7 "),Ln.value.roles??"Workflow defaults"],["Verification command",Dt.value||"No automated command",ma.value==="Override for this run."?"This run override":c!==null?"Project Settings (this browser)":a.check?".codeflow/config.json":ma.value||"Not configured"],["Worktree setup",Gt.value||"None",i!==null?"Repository preference (this browser)":a.setup?".codeflow/config.json":Gt.value?"Repository detection":"Not configured"],["Permissions",ut.value,ae.get("trust")!==null?"Explicit browser preference":a.trust?".codeflow/config.json":"Application default"],["Plan approval",un(t.id)?"Required":"Automatic","Per-workflow browser preference / workflow default"],["Tool permissions",ae.get("interactiveApprovals")==="1"?"Ask for supported native requests":"Decline requests requiring interaction",ae.get("interactiveApprovals")!==null?"Explicit browser preference / selected preset":"Application default"],["Verification gates",s?`${s.name}: ${s.checks.map(l=>`${l.id} (${l.required?"required":"optional"}) \xB7 ${l.command}`).join("; ")||"No runnable gates"}`:"Single configured check",s?`Detected profile${s.source?` from ${s.source}`:""}; selected for this run`:"Verification command above"],["Agent container",n?.enabled?`${n.image||"Image not configured"}${n.authVolume?` \xB7 authentication volume ${n.authVolume}`:" \xB7 no authentication volume"}`:"Host CLI execution",n?.enabled?`Explicit choice for this run; network ${n.network===!1?"disabled":"enabled"}`:"Application default"],["Start branch",Fe.value||"Current HEAD",Fe.value?"Selected branch (remembered)":"Repository HEAD"],["Limits",`${$e.value.maxMinutes} minutes \xB7 ${$e.value.maxSteps} steps${$e.value.maxTokens?` \xB7 ${$e.value.maxTokens.toLocaleString()} reported tokens`:""}${$e.value.maxCostUsd?` \xB7 $${$e.value.maxCostUsd} reported API equivalent`:""}`,ae.get("limits")?"Browser preferences / selected preset":"Application defaults"],["Explicit input context budget",ts.value?`${ts.value.maxPromptBytes??"No"} byte ceiling \xB7 ${ts.value.maxApproximateTokens??"no"} estimated token ceiling \xB7 ${ts.value.policy}`:"No configured ceiling",Bi.value]];for(let[l,p]of Object.entries(Vt(t)))for(let o of p){if(o==="auto"){d.push([`${l} model`,"Selected at dispatch from available providers","Auto selection"]);continue}let u=rt.value[t.id]?.[l]?.[o],f=Be.value[o],h=ps.value[o],g=u?.model||f?.model||(h&&!("error"in h)?h.defaultModel:void 0),y=u?.effort||f?.effort||(h&&!("error"in h)?h.models.find(C=>C.id===g)?.defaultEffort||h.defaultEffort:void 0);d.push([`${l} \xB7 ${o}`,`${g||"CLI default"} \xB7 ${y||"default effort"}`,u?.model||u?.effort?"Per-role override":f?.model||f?.effort?Ln.value.models??"Provider settings":"CLI defaults"])}return e("details",{class:"settings effective-settings",children:[e("summary",{children:[e("span",{class:"st",children:"Run details"}),e("span",{class:"ss",children:"Values and where they came from"})]}),e("div",{class:"settings-body",children:e("div",{class:"settings-table-scroll",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Setting"}),e("th",{children:"Value"}),e("th",{children:"Source"})]})}),e("tbody",{children:d.map(([l,p,o],u)=>e("tr",{children:[e("th",{scope:"row",children:l}),e("td",{children:p}),e("td",{children:o})]},`${l}-${u}`))})]})})})]})}function vu(){let t=[...bt.value.values()],s=Ge.value,[n,r]=m(null),[a,c]=m(!1),[i,d]=m(""),l=JSON.stringify([ee.value,Fe.value,t,s.map(({name:f,size:h})=>({name:f,size:h}))]),p=Z(l);p.current=l;let o=Z(0);N(()=>{++o.current,r(null),c(!1),d("")},[l]);let u=async()=>{let f=++o.current;c(!0),d("");try{let h=await O("/api/workspace/context",{repo:ee.value,baseRef:Fe.value||void 0,paths:t.map(g=>g.path),attachments:s.map(({name:g,size:y})=>({name:g,size:y}))});f===o.current&&l===p.current&&r(h)}catch(h){f===o.current&&l===p.current&&d(h.message)}finally{f===o.current&&l===p.current&&c(!1)}};return e("details",{class:"settings context-inspector",children:[e("summary",{children:[e("span",{class:"st",children:"Context inspector"}),e("span",{class:"ss",children:[t.length," repository paths \xB7 ",s.length," attachments"]})]}),e("div",{class:"settings-body",children:[e("p",{class:"help",children:"Preview selected files and expand folders from the chosen committed base. Explicit files show your current copy. Credential paths and symbolic selections are refused during actual context preparation; preview redaction does not remove secrets from other repository files."}),e("ul",{children:[t.map(f=>e("li",{children:[e("code",{children:[f.path,f.type==="dir"?"/":""]})," \xB7 selected repository path"]},f.path)),s.map((f,h)=>e("li",{children:[f.name," \xB7 ",f.size.toLocaleString()," bytes \xB7 uploaded file"]},h))]}),!t.length&&!s.length?e("p",{class:"help",children:"No explicit context selected. Agents can inspect their worktree."}):null,e("button",{class:"btn",disabled:!ee.value||!t.length&&!s.length||a,onClick:u,children:a?"Reading context\u2026":"Preview selected context"}),n?e("div",{class:"context-inspection-results",children:[e("p",{class:"help",children:[n.fileBytes.toLocaleString()," inspected text bytes \xB7 ",n.omittedBytes.toLocaleString()," known omitted-file bytes \xB7 ",n.attachmentBytes.toLocaleString()," attachment bytes \xB7 approximately ",n.approximateTokens.toLocaleString()," known text tokens. ",n.note]}),n.truncated?e("p",{class:"msg warn",children:"Inspection reached its file or byte limit. Narrow the selection to review the remaining context."}):null,n.files.map((f,h)=>e("details",{children:[e("summary",{children:[f.path," \xB7 ",f.source==="base-ref"?"committed base":"current copy",f.truncated?" \xB7 preview truncated":""]}),f.omitted?e("p",{class:"help",children:[f.bytes!==void 0?`${f.bytes.toLocaleString()} known bytes \xB7 `:"",f.omitted]}):e(M,{children:[e("p",{class:"help",children:[f.bytes?.toLocaleString()," bytes \xB7 approximately ",f.approximateTokens?.toLocaleString()," tokens",f.redacted?" \xB7 possible secret material redacted in this preview only":""]}),e("pre",{class:"template-preview",tabIndex:0,children:f.preview})]})]},`${f.path}-${h}`)),n.attachments.map((f,h)=>e("p",{class:"help",children:[f.name,": ",f.bytes.toLocaleString()," bytes \xB7 ",f.omitted??(f.approximateTokens===void 0?"token footprint unknown (image, binary or unrecognized format)":`approximately ${f.approximateTokens.toLocaleString()} text tokens from byte size`)]},h))]}):null,i?e("p",{class:"msg err",role:"alert",children:i}):null,e(uu,{})]})]})}var ki=qe(0);function bu(t){let s=ae.json(`runDefaults:${t}`,{})??{};return{verification:["lightweight","standard","thorough"].includes(s.verification??"")?s.verification:"",container:{enabled:s.container?.enabled===!0,image:s.container?.image??"",authVolume:s.container?.authVolume??""}}}function Lx(t,s){ae.set(`runDefaults:${t}`,JSON.stringify(s)),ki.value++}var wi="application/x-codeflow-path",ph=10*1024*1024,mh=25*1024*1024;function au(){let t=Ps.value?.repo===ee.value?Ps.value:null,s=Z(ca.value),[n,r]=m(s.current.taskTeam),[a,c]=m(s.current.remoteWorker),[i,d]=m(),[l,p]=m("");N(()=>{let R=!0;return d(void 0),p(""),a&&O(`/api/remote-workers/${encodeURIComponent(a.workerId)}/probe`,{repoMapping:a.repoMapping}).then(({capabilities:X})=>{R&&d(Re.value.map(se=>({...se,available:X.providers.some(Ce=>Ce.id===se.id&&Ce.available)})))},X=>{R&&p(X.message)}),()=>{R=!1}},[a?.workerId,a?.repoMapping,Re.value]);let[o,u]=m(s.current.container?.enabled??!1),[f,h]=m(s.current.container?.image??""),[g,y]=m(s.current.container?.authVolume??""),[C,T]=m(s.current.verificationProfile??null),[v,k]=m(s.current.verification??""),[b,S]=m(!1),x=Z(0),[w,j]=m(s.current.antigravityExecution==="native"),[A,P]=m(s.current.permissionRequirements??[]),[D,I]=m(s.current.toolApprovals??ae.get("interactiveApprovals")==="1"),$=vh(a?"Improve uses a local provider. Choose This computer to rewrite this task.":o?"Improve uses a local provider. Turn off Docker isolation to rewrite this task.":""),E=ln.value,L=E?.id==="solo";N(()=>{ut.value==="safe"?I(!1):s.current.toolApprovals===void 0&&ae.get("interactiveApprovals")===null&&I(L&&["claude","codex"].includes(Vt(E).agent?.[0]??""))},[L,Vt(E).agent?.[0],ut.value]);let[H,Q]=m(!1),[le,de]=m(()=>ae.get("composerAdvanced")==="1"),ue=async R=>{let X=++x.current,se=ee.value;if(te(!1),W(""),k(R),T(null),S(!!R),!!R)try{let Ce=await V(`/api/verification/profile?repo=${G(se)}&preset=${R}`);ee.value===se&&X===x.current&&T(Ce)}catch(Ce){X===x.current&&(W(Ce.message),te(!0))}finally{X===x.current&&S(!1)}},[q,te]=m(!1);We(()=>{let R=bu(ee.value),X=s.current.container??R.container;return u(X.enabled),h(X.image),y(X.authVolume),c(s.current.remoteWorker),I(s.current.toolApprovals??ae.get("interactiveApprovals")==="1"),te(!1),s.current.verification==="restored"?(++x.current,S(!1),k("restored"),T(s.current.verificationProfile??null)):ue(s.current.verification??R.verification),()=>{++x.current}},[ee.value,ki.value,t]),We(()=>{dt.value||(ca.value={taskTeam:n,remoteWorker:a,container:{enabled:o,image:f,authVolume:g},verification:v,verificationProfile:C,toolApprovals:D,antigravityExecution:w?"native":"isolated",permissionRequirements:A})},[n,a,o,f,g,v,C,D,w,A]);let[me,W]=m(""),[re,ne]=m(!1);N(()=>{let R=Pn("composer");R.length&&(Tt([Me.value.trim(),...R.map(X=>X.text)].filter(Boolean).join(`
|
|
150
|
+
|
|
151
|
+
`)),Ge.value=[...Ge.value,...R.flatMap(X=>X.images)])},[Ds.value]);let _=Vt(E),ie=_.agent?.[0],Te=ie&&ie!=="auto"?{...Be.value[ie],...rt.value[E.id]?.agent?.[ie]}:{},Ie=(E?.id==="auto-team"&&oa.value?.enabled===!1?"Team is disabled on this server. Choose Agent or a template in Advanced.":"")||(a?l||(i?fn(E,_,!0,i):"Checking remote worker\u2026"):fn(E,_))||(b?"Loading verification profile\u2026":q?"Verification profile unavailable. Choose another profile in Run options.":""),[et,z]=m(!1),[U,oe]=m(!1),[ke,we]=m(!1),[ce,tt]=m("project"),it=R=>({intent:Nt.value?.repo===ee.value?"bug":jt.value,journeyId:Nt.value?.repo===ee.value?Nt.value.id:void 0,repo:ee.value,project:vt.value||void 0,projectSelection:"explicit",parentRunId:t?.id,task:$a(Me.value,Cs.value),pattern:R.id,taskTeam:L&&!a&&!o?n:void 0,checkpointOnFinish:t?.checkpointOnFinish,templateRef:us.value?{id:us.value.template.id,version:us.value.template.version,inputs:us.value.inputs}:void 0,roles:_,options:as(R),baseRef:Fe.value,source:qi(Ye.value,t?.source),branchPrefix:cn.value.trim(),externalSourceId:yt.value?.id,context:{paths:[...bt.value.values()].map(X=>({path:X.path})),attachments:Ge.value.map(X=>({name:X.name,data:X.data}))},agentSettings:L&&ie&&ie!=="auto"?{...Be.value,[ie]:Te}:Be.value,approvals:{plan:!!Nn[R.id]&&un(R.id),tools:a?!1:D},trust:ut.value,permissionRequirements:A,antigravityExecution:w?"native":"isolated",roleSettings:rt.value[R.id]??{},loop:{...t?.loop,check:Dt.value.trim(),setup:Gt.value.trim(),maxMinutes:$e.value.maxMinutes,maxSteps:$e.value.maxSteps,maxTokens:$e.value.maxTokens,maxCostUsd:$e.value.maxCostUsd,contextBudget:ts.value,verification:C,remoteWorker:a,agentContainer:o&&!a?{...t?.loop.agentContainer,image:f.trim(),authVolume:g.trim()||void 0,network:t?.loop.agentContainer?.network??!0}:void 0,copy:a?[]:t?t.loop.copy??[]:ns.value?.config.copy}}),Xt=E?it(E):null;We(()=>{wr.value=Xt},[Xt]);let[Ue,B]=m(null),xe=async()=>{if(!(Ie||!E||re||b)){if(o&&!a&&!f.trim()){W("Choose a prebuilt agent image");return}$.stop(),ne(!0),W("");try{let{id:R,project:X}=await ku("/api/runs",{...it(E),remember:!0});Y.value={view:"run",id:R},F(),Promise.allSettled([po(),Fa(X),Un()])}catch(R){W(R.message)}finally{ne(!1)}}},F=()=>{Ps.value=null,ae.set("baseRef",Fe.value),Tt(""),Zi(),$e.value=ae.json("limits",$n),ms([]),cn.value="",Ye.value=null,yt.value=null,bt.value=new Map,Ge.value=[],Nt.value=void 0,jt.value=void 0};return!he.value.length&&!ee.value&&!Me.value.trim()?e("div",{class:"composer project-welcome",children:[e("div",{class:"eyebrow",children:"Your first project"}),e("h1",{children:"What would you like to work on?"}),e("p",{class:"lede",children:"Open a repository to start a project, describe a task, and review your agents\u2019 work."}),e("div",{class:"project-welcome-actions",children:[e("button",{class:"btn primary",onClick:()=>zs(),children:"Open repository"}),e("a",{class:"btn",href:"#/settings/connections/join",children:"Join shared project"})]}),e("p",{class:"help",children:["Computer: ",Yt()," \xB7 ",e("a",{href:"#/settings/connections/workspace",children:"On another computer"})]}),e(yi,{})]}):e("div",{class:`composer ${L?"composer-single":""}`,children:[e("div",{class:"eyebrow",children:"New run"}),e("h1",{children:L?"What would you like to work on?":"What should the agents build?"}),e("p",{class:"lede",children:L?"Choose a provider, describe your task, and start the conversation.":"Describe the task, add the files that matter, and pick how your agents work together."}),e("div",{class:"where",role:"group","aria-label":"Where the run works",children:[e(Ks,{composer:!0}),ze.value.project?.repos.length===1&&ze.value.project.repos[0]===ee.value?e("span",{class:"repo-btn",title:ee.value,children:[e(K,{name:"folder"}),e("span",{class:"name",children:be(ee.value)})]}):ze.value.project&&ze.value.project.repos.length>1?e("label",{class:"composer-repository",children:["Repository",e("select",{class:"field","aria-label":"Run repository",value:ee.value,onChange:R=>void Ga(R.currentTarget.value),children:[ze.value.project.repos.includes(ee.value)?null:e("option",{value:"",children:"Choose repository"}),ze.value.project.repos.map(R=>e("option",{value:R,children:[be(R)," \xB7 ",R]}))]})]}):e(gh,{}),e("button",{class:"btn small ghost",onClick:()=>zs(vt.value),children:"Open another repository"})]}),la.value?e("p",{class:"msg warn",role:"alert",children:[la.value," ",e("button",{class:"btn small",onClick:()=>void po(),children:"Retry saving"})]}):null,ee.value&&ze.value.problem?e("div",{class:"banner",children:[e("p",{children:ze.value.problem}),e("button",{class:"btn",onClick:()=>{ks.value={repository:ee.value,project:ze.value.project?.id}},children:"Choose destination"})]}):null,e(yi,{}),nn.value?null:e("div",{class:`banner ${Ls.value?"bad":""}`,children:[e("p",{children:Ls.value?/isn't a git repository$/.test(Ls.value)?`${Ls.value}. Pick the folder that contains your project's .git.`:Ls.value:"Choose the repository the agents should work in."}),e("button",{class:"btn primary",onClick:()=>ct.value=!0,children:"Choose repository"})]}),ns.value?.found?e("div",{class:`config-note ${ns.value.error?"bad":""}`,children:ns.value.error?e(M,{children:["\u26A0 ",ns.value.error]}):e(M,{children:[e(K,{name:"sliders"}),"Using ",e("code",{children:".codeflow/config.json"}),Sh(ns.value.config)]})}):null,yt.value?e("div",{class:"banner",children:[e("p",{children:["External context: ",yt.value.provider," ",yt.value.kind," ",yt.value.key," \xB7 ",yt.value.title]}),e("p",{class:"help",children:"This source remains untrusted. The run uses Safe permissions and isolated checks."}),e("button",{class:"btn small",onClick:()=>{yt.value=null},children:"Remove source"})]}):null,E?.id==="auto-team"?e(jo,{}):null,Nt.value?.repo===ee.value?e("p",{class:"help",children:["Recorded scenario: ",Nt.value.title," ",e("button",{class:"btn ghost small",onClick:()=>{Nt.value=void 0},children:"Detach scenario"})]}):null,e(kh,{onStart:xe,improve:$,controls:e(M,{children:[L?e(Lr,{config:n,lead:ie&&ie!=="auto"?ie:"claude",project:vt.value||void 0,toolApprovals:D,disabledReason:a||o?"Teams in this conversation require This computer without Docker isolation. Standalone workflows remain available in Advanced.":void 0,onChange:R=>{r(R),R.enabled&&(At(E.id,"agent",[R.coordinator]),It(E.id,"agent",R.coordinator,R.settings[R.coordinator]??{}))}}):e("button",{class:"btn ghost",onClick:()=>St("solo"),children:"Back to Agent conversation"}),L?n?.enabled&&!a&&!o?null:e(M,{children:ie&&ie!=="auto"?e(bs,{agent:ie,providers:i,onAgent:R=>At(E.id,"agent",[R]),settings:Te,onSettings:R=>It(E.id,"agent",ie,R),permissions:{trust:yt.value?"safe":ut.value,tools:!a&&!o&&!yt.value&&D},onPermissions:R=>{dn(R.trust),I(R.tools),ae.set("interactiveApprovals",R.tools?"1":"0")},restricted:!!yt.value,approvalsAvailable:!a&&!o}):e(Ve,{above:!0,label:"Provider",icon:"layers",class:"chat-choice",trigger:e(M,{children:[e("span",{children:ie==="auto"?"Auto provider":"Choose provider"}),e(K,{name:"chevron"})]}),children:R=>e(M,{children:(i??Re.value).map(X=>e(pe,{disabled:!X.available||!Zs(X.id),onClick:()=>{At(E.id,"agent",[X.id]),R()},children:X.displayName},X.id))})})}):e("span",{class:"help",children:us.value?`Template: ${us.value.template.name} v${us.value.template.version}`:E?.id==="auto-team"?"Plans and delegates dynamically":`Template: ${E?.name}`}),L?null:e(M,{children:[e("button",{type:"button",class:"btn ghost",onClick:()=>{Q(!0),de(!0),ae.set("composerAdvanced","1")},children:"Advanced"}),e(Lo,{permissions:{trust:yt.value?"safe":ut.value,tools:!a&&!o&&!yt.value&&D},onPermissions:R=>{dn(R.trust),I(R.tools),ae.set("interactiveApprovals",R.tools?"1":"0")},restricted:!!yt.value,approvalsAvailable:!a&&!o&&Object.values(_).flat().some(R=>R==="codex"||R.startsWith("acp:")),agent:Object.values(_).flat().find(R=>R.startsWith("acp:"))})]}),e("button",{class:"btn primary task-start",disabled:!!Ie||re,onClick:xe,title:Ie||"Start run (\u2318\u21B5)",children:[re?"Starting\u2026":L?"Send":"Start run",e(K,{name:"send"})]}),e(Ve,{above:!0,label:"Run actions",icon:"more",class:"chat-choice",children:R=>e(M,{children:[e(pe,{disabled:!E||!qs.value,onClick:()=>{R(),we(!0)},children:[e(K,{name:"files"}),"Use template\u2026"]}),e(pe,{disabled:!E||!qs.value||!Me.value.trim()||v==="restored",sub:v==="restored"?"Choose a verification preset before saving a template":void 0,onClick:()=>{R(),oe(!0)},children:[e(K,{name:"files"}),"Save as template\u2026"]}),e(pe,{disabled:!!Ie,onClick:()=>{R(),B(null),z(!0)},children:[e(K,{name:"clock"}),"Schedule\u2026"]})]})})]})}),e("div",{class:"composer-summary","aria-label":"Run configuration summary",children:[e("span",{children:[e("b",{children:"Computer"})," ",Yt(),a?` \xB7 Agent worker: ${a.workerId}`:""]}),e("span",{children:[e("b",{children:"Project"})," ",ze.value.project?.name??"Choose project"]}),e("span",{children:[e("b",{children:"Repository"})," ",ee.value?be(ee.value):"Choose repository"," \xB7 ",Fe.value||nn.value?.current||"HEAD"]}),e("span",{children:[e("b",{children:L?"Agent":E?.id==="auto-team"?"Team":"Template"})," ",E?ta(E,_):"Choose workflow"]}),e("span",{children:[e("b",{children:"Checks"})," ",b?"Detecting checks\u2026":C?C.checks.map(R=>R.command).join(" \xB7 ")||"No runnable gates":Dt.value.trim()||"Not configured"]}),e("span",{children:[e("b",{children:"Limit"})," ",t?.loop.maxInvocations??$e.value.maxSteps," calls \xB7 ",$e.value.maxMinutes," minutes"]}),Ie?e("span",{class:"composer-problem",role:"status",children:Ie}):null,ut.value==="full"?e("span",{class:"warn",children:"Full access \xB7 no provider sandbox"}):null,e("button",{class:"btn small ghost",onClick:()=>Q(!H),"aria-expanded":H,children:"Edit run options"})]}),e(ac,{repository:ee.value,intent:Nt.value?.repo===ee.value?"bug":jt.value}),on.value?e("div",{class:"msg err",children:on.value}):null,e("details",{class:"composer-options compact",open:H,onToggle:R=>Q(R.currentTarget.open),children:[e("summary",{children:["Run options ",e("span",{children:"Agents, context, checks and limits for this task"})]}),e(pu,{}),e("div",{class:"section",children:[E&&!L?e("p",{class:"pattern-why",children:ta(E,_)}):null,ut.value==="full"?e("p",{class:"full-warn",role:"alert",children:[e("b",{children:"Full access: no sandbox."})," Agents can run commands and change files outside their worktree with your credentials. Review permissions in Advanced agent settings."]}):null,E&&Nn[E.id]&&(E.id!=="debate"||_.builder?.length)?e("label",{class:"checkpoint",children:[e("input",{type:"checkbox",checked:un(E.id),onChange:R=>Wa(R.currentTarget.checked,E.id)}),e("span",{children:[e("b",{children:["Let me approve ",Nn[E.id]]})," before agents build."]})]}):null,e("div",{class:`donewhen ${E?.requiresCheck&&!Dt.value.trim()?"required":""}`,children:[e("label",{class:"lbl",for:"checkCmd",children:"Done when this passes"}),e("div",{class:"dw-row",children:[e("span",{class:"dw-prompt",children:"$"}),e("input",{class:"field",id:"checkCmd",disabled:ys.value,placeholder:"e.g. npm test",spellcheck:!1,autocomplete:"off",value:Dt.value,onInput:R=>{_a(R.currentTarget.value),ma.value="Override for this run."}})]}),e("div",{class:"help",children:"Override the project check for this run. A run without a passing automated check is unchecked."})]}),e("div",{class:"donewhen",children:[e("label",{class:"lbl",for:"setupCmd",children:"Worktree setup command"}),e("div",{class:"dw-row",children:[e("span",{class:"dw-prompt",children:"$"}),e("input",{class:"field",id:"setupCmd",disabled:ys.value,placeholder:"e.g. npm ci",spellcheck:!1,autocomplete:"off",value:Gt.value,onInput:R=>Va(R.currentTarget.value)})]}),e("div",{class:"help",children:"Runs once in each new worktree before agent work and checks. Override for this run; save reusable defaults in Settings \u2192 Projects."})]}),!a&&!o&&!C?e(mu,{pattern:E?.id,roles:_}):null]}),e("div",{class:"composer-more",children:[e("details",{class:"settings advanced-controls",open:le,onToggle:R=>{de(R.currentTarget.open),ae.set("composerAdvanced",R.currentTarget.open?"1":"0")},children:[e("summary",{children:[e("span",{class:"st",children:["Advanced",w?" \xB7 Unrestricted Antigravity":""]}),e("span",{class:"ss",children:"Templates, roles, models, permissions and limits"})]}),e("div",{class:"settings-body",children:[e("label",{class:"lbl",for:"workflow-select",children:"Built-in workflow templates"}),e("select",{class:"field",id:"workflow-select","aria-label":"Workflow",value:E?.id??"auto-team",onChange:R=>St(R.currentTarget.value),children:[e("option",{value:"auto-team",children:"Team \u2014 dynamic plan"}),e("option",{value:"solo",children:"Agent \u2014 one agent"}),ge.value.filter(R=>!["solo","auto-team"].includes(R.id)).map(R=>e("option",{value:R.id,children:R.name},R.id))]}),e(xr,{}),E?.id==="auto-team"?e(ru,{remote:!!a||o,nativeAntigravity:w}):null,e("fieldset",{class:"section",children:[e("legend",{children:"Antigravity execution"}),e("label",{class:"checkpoint",children:[e("input",{type:"checkbox",checked:w,onChange:R=>j(R.currentTarget.checked)}),e("span",{children:"Use unrestricted Antigravity with my existing login"})]}),e("p",{class:"help",children:"Opt-in for this run. Antigravity uses your normal profile without Code Flow's sandbox. Terminal, browser, MCP, hooks and native agents follow provider settings. Read-only requests are advisory and native child usage is outside the worker budget. Claude and Codex keep their run permissions. Requires a valid saved login, local attended execution, and no mandatory boundaries, Safe mode or tool approvals."})]}),e("fieldset",{class:"section",children:[e("legend",{children:"Required permission enforcement"}),[["workspace-writes","Require an agent workspace write boundary"],["no-command-network","Block network access from agent commands"],["no-external-tools","Disable external browser and MCP tools"]].map(([R,X])=>e("label",{class:"checkpoint",children:[e("input",{type:"checkbox",checked:A.includes(R),onChange:se=>P(se.currentTarget.checked?[...A,R]:A.filter(Ce=>Ce!==R))}),e("span",{children:X})]},R)),e("p",{class:"help",children:"Only providers that enforce these requirements can run. Command network restrictions do not cover provider inference or external tools. With none selected, the existing provider-specific permission profile applies."})]}),e("div",{class:"section",children:[e("button",{class:"btn",disabled:!E||!qs.value,onClick:()=>we(!0),children:"Browser task library"})," ",e("button",{class:"btn",disabled:!E||!Me.value.trim(),onClick:()=>oe(!0),children:"Save task preset"}),e("p",{class:"help",children:"Existing browser presets remain available. Applying a preset keeps this run's permissions and isolation."})]}),e(Yc,{value:a,onChange:R=>{$.stop(),c(R)},disabled:re}),a?e("p",{class:"help",children:"Provider availability comes from this worker. Checks and setup run on the application server. Copied workspace files and native interactive approvals are unavailable; use explicitly staged references."}):null,E&&!L?e(Th,{p:E,roles:_,providers:i,remote:!!a}):null,e("div",{class:"section",children:[e("label",{class:"lbl",for:"verification-profile",children:"Verification gates"}),e("select",{class:"field",id:"verification-profile",value:v,disabled:!ee.value,onChange:R=>void ue(R.currentTarget.value),children:[e("option",{value:"",children:"Single configured check"}),v==="restored"?e("option",{value:"restored",children:["From original run \xB7 ",C?.name]}):null,e("option",{value:"lightweight",children:"Lightweight profile"}),e("option",{value:"standard",children:"Standard profile"}),e("option",{value:"thorough",children:"Thorough profile"})]}),C?e("p",{class:"help",children:["Required gates: ",C.checks.map(R=>R.command).join(" \xB7 ")||"No runnable gates detected",". Each gate appears in the run's evidence."]}):null]}),E?e(Rh,{p:E,roles:_}):null]})]}),E?e(gu,{p:E,verificationProfile:C,container:{enabled:o,image:f,authVolume:g,network:t?.loop.agentContainer?.network}}):null,e(vu,{}),e("details",{class:"settings agent-isolation",children:[e("summary",{children:[e("span",{class:"st",children:"Agent isolation"}),e("span",{class:"ss",children:o&&!a?`Prebuilt Docker image${f.trim()?` \xB7 ${f.trim()}`:""}`:"Off \xB7 agents use this computer's CLIs"})]}),e("div",{class:"settings-body",children:[e("label",{class:"checkpoint",children:[e("input",{type:"checkbox",checked:o,disabled:!!a,onChange:R=>{$.stop(),u(R.currentTarget.checked)}}),e("span",{children:"Run agents in a prebuilt Docker image"})]}),o?e(M,{children:[e("label",{class:"iso-field",children:["Image",e("input",{class:"field mono",placeholder:"Your prepared image:tag",spellcheck:!1,value:f,onInput:R=>h(R.currentTarget.value)})]}),e("label",{class:"iso-field",children:["Authentication volume",e("input",{class:"field mono",spellcheck:!1,placeholder:"Optional explicitly named Docker volume",value:g,onInput:R=>y(R.currentTarget.value)})]}),e("p",{class:"help",children:["The image must contain compatible official CLIs and be authenticated inside the image or selected volume. Host credential folders are never mounted. Agents receive their worktree and read-only Git metadata; network access is ",t?.loop.agentContainer?.network===!1?"disabled by the original run":"enabled for inference",". Live team bridges use structured turn-boundary replies in containers."]})]}):null]})]})]})]}),me?e("div",{class:"msg err",children:me}):null,ke?e(hu,{initialScope:ce,onConfigured:R=>{R.runOptions?.verification&&ue(R.runOptions.verification)},onClose:()=>we(!1),onUsed:R=>{tt(R),we(!1)}}):null,U&&E?e(fu,{p:E,runOptions:{verification:v,container:{enabled:o,image:f,authVolume:g}},initialScope:ce,onClose:()=>oe(!1),onSaved:R=>{tt(R),oe(!1)}}):null,et&&E&&!Ue?e(hh,{onClose:()=>z(!1),onChoose:R=>{R==="backlog"||R==="missions"?(z(!1),Y.value={view:"automations",kind:R}):B(R)}}):null,et&&E&&Ue==="once"?e(fh,{body:it(E),onClose:()=>z(!1)}):null,et&&E&&Ue==="repeat"?e(Kl,{body:it(E),onClose:()=>z(!1)}):null]})}function hh({onClose:t,onChoose:s}){let n=ye(!0,t);return e("dialog",{ref:n,class:"picker","aria-labelledby":"schedule-choice-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"schedule-choice-title",children:"Schedule work"})}),e("div",{class:"dialog-body purpose-choices",children:ka.map(r=>e("button",{class:"settings-result",onClick:()=>s(r.id),children:e("span",{children:[e("strong",{children:r.label}),e("span",{children:r.description})]})}))}),e("div",{class:"picker-foot",children:e("button",{class:"btn",onClick:t,children:"Cancel"})})]})})}function fh({body:t,onClose:s}){let n=ye(!0,s);return e("dialog",{ref:n,class:"picker","aria-labelledby":"schedule-run-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:e("h3",{id:"schedule-run-title",children:"Start later"})}),e("div",{class:"dialog-body",children:e(fr,{runRequest:t,project:t.project,repo:t.repo})}),e("div",{class:"picker-foot",children:e("button",{class:"btn",onClick:s,children:"Close"})})]})})}function gh(){let t=nn.value;return e("button",{type:"button",class:`repo-btn ${t?"":"empty"} ${Ls.value?"bad":""}`,title:t?t.repo:"Choose repository",onClick:()=>ct.value=!0,children:[e(K,{name:"folder"}),e("span",{class:"name",children:t?be(t.repo):ys.value?"Checking\u2026":Ls.value||"Choose repository\u2026"}),e(K,{name:"chevron",class:"caret"})]})}async function ku(t,s){try{return await O(t,s)}catch(n){if(!(n instanceof st)||n.confirm!=="allowUntrusted")throw n;if(!await Ae(`${n.message}
|
|
152
|
+
|
|
153
|
+
Run its checks on this machine anyway?`,{title:"Run checks locally?",confirmLabel:"Run checks",danger:!0}))throw new Error("Not started: the source isn't trusted and Docker isn't available.");return O(t,{...s,allowUntrusted:!0})}}function pc({base:t,onClose:s,onStarted:n}){let r=ye(!0,s),a=ln.value?.id,[c,i]=m(new Set(a?[a]:[])),[d,l]=m(1),[p,o]=m(!1),[u,f]=m(""),h=ge.value.map(C=>{let T=Vt(C);return{p:C,roles:T,problem:fn(C,T)}}),g=c.size*d,y=async()=>{o(!0),f("");try{let C=h.filter(v=>c.has(v.p.id)).map(v=>({label:v.p.name,pattern:v.p.id,roles:v.roles,options:as(v.p),roleSettings:rt.value[v.p.id]??{}})),{group:T}=await ku("/api/compare",{run:t,variants:C,repeat:d});s(),n(T)}catch(C){f(C.message)}finally{o(!1)}};return e("dialog",{class:"picker",ref:r,"aria-labelledby":"compare-title",children:e("div",{class:"picker-inner",children:[e("div",{class:"picker-head",children:[e("h3",{id:"compare-title",children:"Compare setups"}),e("div",{class:"help",children:"Runs this task once per setup, at the same time, and shows the results side by side in Insights: did it pass, how long, how many steps and tokens, did it touch the tests. Each pattern uses the team you last picked for it \u2014 select a pattern in the composer to change its team."})]}),e("div",{class:"dialog-body",children:[h.map(({p:C,roles:T,problem:v})=>e("label",{class:`compare-choice ${v?"off":""}`,children:[e("input",{type:"checkbox",checked:c.has(C.id),disabled:!!v,onChange:k=>{let b=new Set(c);k.currentTarget.checked?b.add(C.id):b.delete(C.id),i(b)}}),e("span",{children:[e("b",{children:C.name}),e("span",{class:"help",children:v||ta(C,T)})]})]},C.id)),e("label",{class:"check",children:["Run each",e("select",{class:"field inline",value:d,onChange:C=>l(Number(C.currentTarget.value)),children:[e("option",{value:1,children:"once"}),e("option",{value:2,children:"twice"}),e("option",{value:3,children:"3 times"})]}),"(repeats show how consistent a setup is)"]}),u?e("div",{class:"msg err",children:u}):null]}),e("div",{class:"picker-foot",children:[e("span",{class:"ps",children:[g," run",g===1?"":"s",g>9?" \u2014 at most 9":"","; they share code-flow's agent slots, so some may wait their turn."]}),e("button",{class:"btn",onClick:s,children:"Cancel"}),e("button",{class:"btn primary",disabled:p||c.size<2||g>9,onClick:y,title:c.size<2?"Pick at least two setups":"",children:p?"Starting\u2026":`Start ${g} run${g===1?"":"s"}`})]})]})})}function fn(t,s,n=!0,r){if(t?.id==="auto-team"&&oa.value?.enabled===!1)return"New teams are disabled. Existing teams can still be resumed.";if(dt.value)return"Restoring project draft\u2026";if(ys.value)return"Checking repository\u2026";if(!ee.value)return"Choose a repository first";if(ze.value.problem)return ze.value.problem;if(an.value)return"Loading repository configuration\u2026";if(n&&!Me.value.trim())return"Describe the task to start";if(!t)return"Pick how the agents work together";let a=(t.id==="auto-team"?s.coordinator??[]:Object.values(s).flat()).find(d=>d!=="auto"&&!Zs(d));if(a)return`${a} cannot enforce managed run permissions yet. Choose Claude or Codex.`;for(let d of t.roles)if(!d.optional&&!s[d.id]?.length)return`Pick an agent for ${d.label}`;if(t.id==="race"&&Ia(t.id,"contestants",s.contestants??[])<2)return"A race needs at least two contestants";if(t.id==="debate"&&Ia(t.id,"debaters",s.debaters??[])<2)return"A debate needs at least two debaters";if(t.id==="auto-team"&&!s.pool?.some(Zs))return"Keep at least one compatible provider in the pool (Claude or Codex)";if(t.id==="auto-team"&&$e.value.maxSteps<4)return"A team needs at least 4 steps: planning, work, review and recovery";if(t.requiresCheck&&!Dt.value.trim())return`${t.name} needs a \u201CDone when\u201D command, e.g. npm test`;let c=new Set(t.id==="auto-team"?s.coordinator??[]:Object.values(s).flat());if(r){let d=new Set(r.filter(l=>l.available).map(l=>l.id));for(let l of c)if(l!=="auto"&&!d.has(l))return`${Se[l]} is unavailable on the selected remote worker`;return c.has("auto")&&!d.size?"No configured provider CLI is available on this remote worker":""}let i=Ts.value?.find(d=>c.has(d.id)&&d.installed&&d.signedIn===!1);return i?`${i.name} isn't signed in \u2014 open Settings \u2192 Agents & models`:""}function vh(t){let[s,n]=m(null),[r,a]=m(null),[c,i]=m(null),[d,l]=m(Rs.value.defaultMode),p=Z(t);p.current=t;let o=()=>[Me.value,ee.value,nn.value,_e.value,ze.value.project?.id,Fe.value,bt.value,Ge.value,Ye.value,yt.value,Cs.value,ts.value,p.current,Rs.value],u=(x,w)=>x.every((j,A)=>Object.is(j,w[A])),f=Z(o()),h=Z(0),g=Z(!0),y=Z(null),C=Z(null),T=()=>{let x=y.current;y.current=null,x?.stop.abort(),C.current=null,n(null),a(null),i(null)},v=()=>{let x=o();u(f.current,x)||(f.current=x,h.current++,T())};We(()=>{let x=$i(v);return()=>{g.current=!1,y.current?.stop.abort(),y.current=null,x()}},[]),We(v,[t]),N(()=>l(Rs.value.defaultMode),[Rs.value.defaultMode]);let k=async(x=d)=>{if(y.current){T();return}v();let w=Me.value;if(!g.current||p.current||!w.trim()||!ee.value)return;let j={stop:new AbortController,revision:h.current,snapshot:o()};y.current=j,C.current=null,n({mode:x}),i(null),a(null);let A=()=>g.current&&y.current===j&&!j.stop.signal.aborted&&h.current===j.revision&&u(j.snapshot,o());try{let P=await V("/api/improve-prompt",{method:"POST",signal:j.stop.signal,body:JSON.stringify({text:w,repo:ee.value,mode:x,execution:"local",settings:Rs.value,context:[...bt.value.values()].map($=>$.path).concat(Ge.value.map($=>$.name)),source:Ye.value?{kind:Ye.value.kind,number:Ye.value.number,title:Ye.value.title}:void 0})});if(!A())return;y.current=null,n(null),Tt(P.prompt);let D=Re.value.find($=>$.id===P.agent)?.displayName??P.agent,I={before:w,note:`${D}: ${P.summary}`,revision:h.current,snapshot:o()};C.current=I,a(I)}catch(P){A()&&i({message:P.message,revision:h.current,snapshot:o()})}finally{g.current&&y.current===j&&(y.current=null,n(null))}};return{busy:s,mode:d,run:k,pick:x=>{l(x),k(x)},undo:()=>{let x=C.current;if(!x||x.revision!==h.current||!u(x.snapshot,o())){T();return}T(),Tt(x.before)},stop:T,disabledReason:t,agentName:iu[Rs.value.agent],error:c&&c.revision===h.current&&u(c.snapshot,o())?c.message:"",done:r&&r.revision===h.current&&u(r.snapshot,o())?r:null}}function bh({improve:t,disabled:s}){let[n,r]=m(!1),a=Z(null),c=Z(null),i=Z(!1),d=(l=!1)=>{r(!1),l&&c.current?.focus()};return We(()=>{if(!n)return;let l=a.current?.querySelectorAll('[role="menuitemradio"]');l?.[i.current?l.length-1:0]?.focus()},[n]),N(()=>{if(!n)return;let l=p=>{a.current?.contains(p.target)||d()};return document.addEventListener("pointerdown",l),()=>document.removeEventListener("pointerdown",l)},[n]),We(()=>{s&&r(!1)},[s]),e("div",{class:"pop-wrap",ref:a,onBlur:l=>{l.currentTarget.contains(l.relatedTarget)||d()},onKeyDown:l=>{if(l.key==="Escape"&&n){l.preventDefault(),l.stopPropagation(),d(!0);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(l.key))return;if(l.preventDefault(),!n){s||(i.current=l.key==="ArrowUp"||l.key==="End",r(!0));return}let p=[...a.current?.querySelectorAll('[role="menuitemradio"]')??[]],o=p.findIndex(u=>u===document.activeElement);p[l.key==="Home"?0:l.key==="End"?p.length-1:(o+(l.key==="ArrowUp"?-1:1)+p.length)%p.length]?.focus()},children:[e("button",{ref:c,type:"button",class:`icon-btn ${n?"on":""}`,"aria-label":"How Improve works","aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?"improve-mode-menu":void 0,disabled:s,title:"How Improve works",onClick:()=>{i.current=!1,r(!n)},children:e(K,{name:"chevron"})}),n?e("div",{class:"pop-menu",role:"menu",id:"improve-mode-menu","aria-label":"Improve mode",children:[e(kt,{children:"Improve the task"}),[{mode:"quick",title:"Quick rewrite",description:"From your text alone, using your configured model"},{mode:"repo",title:"Use the repository",description:"Reads a committed repository snapshot. Skips local edits."}].map(l=>e("button",{type:"button",role:"menuitemradio",tabIndex:-1,"aria-checked":t.mode===l.mode,class:`pop-item ${t.mode===l.mode?"on":""}`,onClick:()=>{d(),t.pick(l.mode),a.current?.previousElementSibling?.focus()},children:[e("span",{class:"pi-main",children:l.title}),e("span",{class:"pi-sub",children:l.description})]},l.mode))]}):null]})}function yh(){let t=nn.value,s=Ye.value?.kind==="pr"?Ye.value:null;if(!t)return null;let n=s?"__pr":Fe.value;return e("div",{class:"task-branch",children:[e("span",{children:"Start from branch"}),e(xs,{label:"Start from branch",title:"Choose a branch",kind:"branch",value:n,disabled:!!s,onChange:r=>{Fe.value=r},options:s?[{id:"__pr",label:`PR #${s.number} \xB7 ${s.headRefName}`}]:[{id:"",label:t.current?`Current branch \xB7 ${t.current}`:"Current HEAD",description:"Use the current checkout"},...Fe.value&&!t.branches.some(r=>r.name===Fe.value)?[{id:Fe.value,label:Fe.value}]:[],...t.branches.map(r=>({id:r.name,label:r.name,description:r.kind==="local"?"Local branch":r.kind==="remote"?"Remote branch":"Previous task branch"}))]}),e("span",{class:"help",children:"New worktree"})]})}function kh({onStart:t,improve:s,controls:n}){let[r,a]=m(!1),c=Z(null),i=Z(null),d=!!Me.value.trim()&&!!ee.value&&!s.disabledReason;N(()=>{let h=c.current;h&&(h.style.height="auto",h.style.height=`${Math.min(420,Math.max(120,h.scrollHeight))}px`)},[Me.value]),N(()=>{let h=g=>{!g.target?.closest?.(".taskbox")&&g.dataTransfer?.types.includes("Files")&&g.preventDefault()};return window.addEventListener("dragover",h),window.addEventListener("drop",h),()=>{window.removeEventListener("dragover",h),window.removeEventListener("drop",h)}},[]);let p=bt.value.size+Ge.value.length,o=`${p} item${p===1?"":"s"} of context`,u=p?`${o} \u2014 agents read these first`:"Drag files here to give the agents context",f=p?`${o} \u2014 agents read these before starting`:"Drag files here from the file list or Finder to give the agents context";return e("div",{class:`taskbox ${r?"over":""}`,onDragOver:h=>{let g=[...h.dataTransfer?.types??[]];!g.includes(wi)&&!g.includes("Files")||(h.preventDefault(),h.dataTransfer.dropEffect="copy",a(!0))},onDragLeave:h=>{h.currentTarget.contains(h.relatedTarget)||a(!1)},onDrop:h=>{a(!1);let g=h.dataTransfer?.getData(wi);if(g){h.preventDefault(),wu(JSON.parse(g));return}if(!h.dataTransfer?.files.length)return;h.preventDefault();let y=[...h.dataTransfer.items].filter(v=>v.kind==="file"),C=[],T=[];[...h.dataTransfer.files].forEach((v,k)=>{y[k]?.webkitGetAsEntry?.()?.isDirectory?T.push(v.name):C.push(v)}),yu(C,T)},children:[e(yh,{}),e("textarea",{ref:c,"aria-label":"Task",placeholder:"e.g. Add rate limiting to the /login endpoint, with tests\u2026",value:Me.value,"aria-busy":!!s.busy,onInput:h=>Tt(h.currentTarget.value),onKeyDown:h=>{h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),t())}}),e(wh,{}),e("div",{class:"bar",children:[e("button",{class:"btn ghost small",title:"Attach files from your computer",onClick:()=>i.current?.click(),children:[e(K,{name:"attach"})," Attach"]}),e("button",{class:"btn ghost small",title:"Start from a GitHub issue or pull request",onClick:()=>Ws.value={kind:Ye.value?.kind==="pr"?"pr":"issue"},children:[e(K,{name:"pull"})," GitHub"]}),e("button",{class:"btn ghost small",title:"Show the repository's files in the side panel",onClick:()=>$t("files"),children:[e(K,{name:"files"})," Files"]}),s.busy?e("span",{class:"hint status",role:"status",children:s.busy.mode==="repo"?"Reading the committed repository snapshot and rewriting the task\u2026":"Rewriting the task\u2026"}):s.error?e("span",{class:"hint status bad",role:"alert",title:s.error,children:s.error}):s.done?e("span",{class:"hint status",role:"status",title:s.done.note,children:s.done.note}):s.disabledReason?e("span",{class:"hint status",id:"improve-execution-note",children:s.disabledReason}):e("span",{class:"hint",title:f,children:u}),s.done?e("button",{class:"btn ghost small improve-undo",title:"Put back the task as you wrote it",onClick:s.undo,children:"Undo"}):null,e("div",{class:"improve",children:[e("button",{class:"btn ghost small",disabled:!s.busy&&!d,"aria-label":s.busy?"Stop":"Improve","aria-description":`Prompt improvement agent: ${s.agentName}. Mode: ${s.mode}. Configure in Settings, Agents & models.`,"aria-describedby":s.disabledReason?"improve-execution-note":void 0,title:s.busy?"Stop rewriting":s.disabledReason||(ee.value?s.mode==="repo"?"Rewrite the task using a committed repository snapshot":"Rewrite the task so agents can act on it":"Choose a repository first"),onClick:()=>void s.run(),children:[s.busy?e("span",{class:"spin"}):e(K,{name:"sparkle"})," ",s.busy?"Stop":e(M,{children:["Improve ",e("span",{class:"improve-agent","aria-hidden":"true",children:["\xB7 ",s.agentName]})]})]}),e(bh,{improve:s,disabled:!!s.busy||!d})]})]}),n?e("div",{class:"task-controls",children:n}):null,e("div",{class:"overlay",children:"Drop to add as context"}),e("input",{ref:i,type:"file",multiple:!0,hidden:!0,onChange:h=>{yu([...h.currentTarget.files??[]]),h.currentTarget.value=""}})]})}function wh(){let t=s=>{let n=new Map(bt.value);n.delete(s),bt.value=n};return e("div",{class:"chips",children:[e(Yl,{}),[...bt.value.values()].map(s=>e("span",{class:"chip-ctx",title:s.path,children:[e(K,{name:s.type==="dir"?"folder":"note"}),e("span",{class:"n",children:[s.path,s.type==="dir"?"/":""]}),e("button",{type:"button",title:"Remove","aria-label":`Remove ${s.path}`,onClick:()=>t(s.path),children:"\xD7"})]},s.path)),Ge.value.map((s,n)=>e("span",{class:"chip-ctx",title:s.name,children:[e(K,{name:"attach"}),e("span",{class:"n",children:[s.name," \xB7 ",Zt(s.size)]}),e("button",{type:"button",title:"Remove","aria-label":`Remove ${s.name}`,onClick:()=>Ge.value=Ge.value.filter(r=>r!==s),children:"\xD7"})]},`a${n}`))]})}function wu(t){let s=new Map(bt.value);s.set(t.path,{path:t.path,type:t.type}),bt.value=s}function Ch(t){let s=new Map(bt.value);s.has(t.path)?s.delete(t.path):s.set(t.path,{path:t.path,type:t.type}),bt.value=s}async function yu(t,s=[]){on.value=s.length?`${s.join(", ")} ${s.length===1?"is a folder":"are folders"}. From outside the repo, add individual files.`:"";let n=Ge.value.reduce((a,c)=>a+c.size,0),r=[];for(let a of t){if(a.size>ph){on.value=`"${a.name}" is over 10 MB.`;continue}if(n+a.size>mh){on.value="Attached files must total under 25 MB.";break}try{r.push({name:a.name,size:a.size,data:await Di(a)}),n+=a.size}catch{on.value=`Couldn't read "${a.name}".`}}Ge.value=[...Ge.value,...r]}function Ia(t,s,n){return n.reduce((r,a)=>r+1+(a==="auto"?0:rt.value[t]?.[s]?.[a]?.variants?.length??0),0)}function Th({p:t,roles:s,providers:n,remote:r}){return e("div",{class:"team",children:[t.roles.map(a=>{let c=s[a.id]??[],i=a.multiple,d=r?[]:(n??Re.value).filter(l=>l.available&&Zs(l.id)).flatMap(l=>{let p=t.id==="auto-team"?Ra.value[l.id]:ps.value[l.id],o=p&&!("error"in p)?p.models.filter(vn):[];return o.length?[{agent:l.id,models:o}]:[]});return e("div",{class:"role",children:[e("div",{class:"role-heading",children:[e("div",{class:"role-description",children:[e("div",{class:"rl",children:[a.label,e("span",{class:"role-count",children:[Ia(t.id,a.id,c)," ",t.id==="auto-team"&&a.id==="pool"?"choices":"selected"]})]}),e("div",{class:"rd",children:a.description})]}),d.length?e("button",{type:"button",class:"btn small role-free-action",onClick:()=>{let l=i?d:[d.find(p=>c.includes(p.agent))??d[0]];for(let p of l)It(t.id,a.id,p.agent,{model:p.models[0].id,effort:"",variants:i?p.models.slice(1).map(o=>({model:o.id})):[]});At(t.id,a.id,l.map(p=>p.agent))},children:i?"Select all free":"Use free model"}):null]}),e("div",{class:"role-pick",children:[e("div",{class:"pills",role:"group","aria-label":`${a.label} providers`,children:[(n??Re.value).map(l=>{let p=c.includes(l.id);return e("button",{type:"button",class:"pill","aria-pressed":p,disabled:(!l.available||!Zs(l.id))&&!p,title:Zs(l.id)?l.available?`${a.multiple?"Toggle":"Choose"} ${l.displayName}`:`${l.displayName} isn't installed`:"Managed run permissions are not supported by this adapter yet",onClick:()=>At(t.id,a.id,a.multiple?p?c.filter(o=>o!==l.id):[...c,l.id]:[l.id]),children:[e("span",{class:"provider-check","aria-hidden":"true",children:p?"\u2713":"+"}),e("span",{children:l.displayName})]},l.id)}),t.id!=="auto-team"||a.id!=="pool"?e("button",{type:"button",class:"pill auto","aria-pressed":c.includes("auto"),title:"code-flow picks an installed agent when the run starts, skipping plans that are near their usage limit",onClick:()=>{let l=c.includes("auto");At(t.id,a.id,a.multiple?l?c.filter(p=>p!=="auto"):[...c,"auto"]:["auto"])},children:"Auto"}):null,a.optional?e("button",{type:"button",class:"pill none","aria-pressed":!c.length,onClick:()=>At(t.id,a.id,[]),children:"Skip"}):null]}),i&&Ia(t.id,a.id,c)>c.length?e("span",{class:"help",children:[Ia(t.id,a.id,c)," ",t.id==="auto-team"?"model choices \xB7 coordinator selects within the member limit":"agents \xB7 each model runs separately"]}):null,c.some(l=>l!=="auto")?e(xh,{p:t,roleId:a.id,roleLabel:a.label.toLowerCase(),agents:c.filter(l=>l!=="auto"),remote:r}):null]})]},a.id)}),e("div",{class:"team-summary",children:[e(K,{name:"chevron"}),e("span",{children:ta(t,s)})]})]})}var xa={safe:{label:"Safe",help:"Edit files only. Claude can't run commands; Codex stays sandboxed."},standard:{label:"Standard",help:"Edit files and run common build/test commands (npm, node, pytest, uv, poetry, cargo, go, make\u2026)."},trusted:{label:"Trusted",help:"Any command for Claude; network access inside Codex's sandbox. Use on repos you trust."},full:{label:"Full access",help:"Every agent can run any command, use the network and change files outside its worktree, with your credentials. Only for repos and tasks you trust completely."}};function ta(t,s,n=!0){let r=l=>s[l]?.[0]?Se[s[l][0]]:"\u2014",a=l=>{let p=(s[l]??[]).map(o=>{let u=o==="auto"?1:1+(rt.value[t.id]?.[l]?.[o]?.variants?.length??0);return`${Se[o]}${u>1?` \xD7 ${u}`:""}`});return p.length?p.length===1?p[0]:`${p.slice(0,-1).join(", ")} and ${p.at(-1)}`:"\u2014"},c=as(t),i=Dt.value.trim(),d=(i?` \xB7 done when \u201C${i}\u201D passes`:"")+(n&&Nn[t.id]&&un(t.id)&&(t.id!=="debate"||s.builder?.length)?` \xB7 you approve ${Nn[t.id]} first`:"");switch(t.id){case"auto-team":return`${r("coordinator")} assembles up to ${c.maxMembers??4} members from ${a("pool")} \u2192 the team works through dependencies \u2192 an independent member verifies the result${d}`;case"pipeline":return`${r("planner")} plans \u2192 ${r("builder")} builds \u2192 ${r("reviewer")} reviews (up to ${c.maxRounds} rounds of fixes)${d}`;case"race":return`${a("contestants")} each solve it separately \u2192 ${a("judge")} ${(s.judge?.length??0)>1?"vote":"picks"} the best, blind${d}`;case"debate":return`${a("debaters")} propose and debate \u2192 ${r("synthesizer")} writes the final plan${s.builder?.length?` \u2192 ${r("builder")} builds it${s.reviewer?.length?` \u2192 ${r("reviewer")} reviews it`:""}`:" (design only)"}${d}`;case"supervisor":return`${r("supervisor")} splits the work and sets the contracts \u2192 ${a("workers")} build the parts in parallel \u2192 ${r("supervisor")} merges${s.reviewer?.length?` \u2192 ${r("reviewer")} reviews`:" and reviews its own work"}${d}`;case"tdd":return`${r("tester")} writes tests \u2192 ${r("builder")} makes them pass \u2192 ${r("tester")} tries to break it${d}`;case"council":return`${a("reviewers")} review on their own, read-only \u2192 ${r("chair")} merges what they found \xB7 nothing is changed or posted without you`;case"solo":return`${r("agent")} works on it in its own branch; reply to keep going, like a chat${i?` \xB7 code-flow runs \u201C${i}\u201D after every turn`:""}`;case"loop":{let l=s.workers??[],p=l.length>1?`, handing over to ${l.slice(1).map(o=>Se[o]).join(", then ")} if stuck`:"";return`${l.length?Se[l[0]]:"\u2014"} fixes and code-flow re-runs \u201C${i||"your check"}\u201D until it passes${p} (max ${c.maxRounds} rounds)`}default:return t.summary}}function Sh(t){let s=[t.check&&`check \u201C${t.check}\u201D`,t.setup&&`setup \u201C${t.setup}\u201D`,t.copy?.length&&`copies ${t.copy.join(", ")}`,t.run?.command&&`runs the app with \u201C${t.run.command}\u201D`,t.trust&&`${t.trust} permissions`].filter(Boolean);return s.length?`: ${s.join(" \xB7 ")}`:""}function xh({p:t,roleId:s,roleLabel:n,agents:r,remote:a}){let c=rt.value[t.id]?.[s]??{};return e("div",{class:"role-models",children:r.map(i=>{let d=c[i]??{},l=t.id==="auto-team"?Ra.value[i]:ps.value[i];if(a)return e("div",{class:"provider-models",children:[e("div",{class:"provider-model-heading",children:e(Ee,{id:i})}),e("div",{class:"team-model-row",children:[e("label",{children:["Model",e("input",{class:"field","aria-label":`${Se[i]} model for the ${n}`,placeholder:"Worker CLI default model",value:d.model??"",onChange:y=>It(t.id,s,i,{model:y.currentTarget.value})})]}),e("label",{children:["Effort",e("input",{class:"field","aria-label":`${Se[i]} effort for the ${n}`,placeholder:"Default effort",value:d.effort??"",onChange:y=>It(t.id,s,i,{effort:y.currentTarget.value})})]})]})]},i);if(!l||"error"in l)return e("div",{class:"provider-models",children:e("div",{class:"provider-model-heading",children:[e(Ee,{id:i}),e("span",{class:"help",children:l?"Using CLI defaults \xB7 model list unavailable":"Loading models\u2026"})]})},i);let p=l,o=t.id==="auto-team"&&s==="pool"?{}:Be.value[i]??{},u=o.model||p.defaultModel,f=t.roles.find(y=>y.id===s)?.multiple,h=[{model:d.model??"",effort:d.effort??""},...f?d.variants??[]:[]],g=Yn(p.models).filter(y=>y.id!==(d.model||u)&&!d.variants?.some(C=>C.model===y.id));return e("div",{class:"provider-models",children:[e("div",{class:"provider-model-heading",children:[e("div",{class:"provider-model-name",children:[e(Ee,{id:i}),h.length>1?e("span",{class:"role-count",children:[h.length," models"]}):null]}),f?e(xs,{class:"add-model",label:`Add ${Se[i]} model for the ${n}`,value:"",placeholder:"+ Add model",options:g,disabled:!g.length||h.length>=129,onChange:y=>It(t.id,s,i,{variants:[...d.variants??[],{model:y}]})}):null]}),h.map((y,C)=>{let T=C===0,v=p.models.find(w=>w.id===(y.model||u)),k=v?.efforts??p.efforts,b=T?o.effort||v?.defaultEffort||p.defaultEffort:v?.defaultEffort||p.defaultEffort,S=w=>T?`${Se[i]} ${w} for the ${n}`:`${Se[i]} additional ${w} ${C} for the ${n}`,x=Yn(p.models).filter(w=>T||w.id===y.model||w.id!==(d.model||u)&&!d.variants?.some(j=>j.model===w.id));return e("div",{class:`team-model-row ${T?"primary":"additional"}`,children:[e("div",{class:"model-field",children:[e("span",{children:["Model",h.length>1?` ${C+1}`:""]}),e(xs,{label:S("model"),value:y.model,options:[...T?[{id:"",label:t.id==="auto-team"&&s==="pool"?"Automatic \xB7 coordinator chooses":u?`Default \xB7 ${p.models.find(w=>w.id===u)?.label??u}`:"Default model"}]:[],...x,...y.model&&!p.models.some(w=>w.id===y.model)?[{id:y.model,label:y.model}]:[]],onChange:w=>{if(T){let A=p.models.find(P=>P.id===(w||u))?.efforts??p.efforts;It(t.id,s,i,{model:w,effort:y.effort&&A.includes(y.effort)?y.effort:"",variants:d.variants?.filter(P=>P.model!==(w||u))})}else It(t.id,s,i,{variants:d.variants.map((j,A)=>A===C-1?{model:w}:j)})}})]}),e("label",{children:["Effort",e("select",{class:"field","aria-label":S("effort"),value:y.effort??"",onChange:w=>{let j=w.currentTarget.value;T?It(t.id,s,i,{effort:j}):It(t.id,s,i,{variants:d.variants.map((A,P)=>P===C-1?{...A,effort:j}:A)})},children:[e("option",{value:"",children:b?`Default \xB7 ${b}`:"Default effort"}),k.map(w=>e("option",{value:w,children:w},w))]})]}),T?e("span",{class:"model-remove-space","aria-hidden":"true"}):e("button",{type:"button",class:"icon-btn remove-model",title:"Remove model","aria-label":`Remove ${Se[i]} model ${y.model}`,onClick:()=>It(t.id,s,i,{variants:d.variants.filter((w,j)=>j!==C-1)}),children:e(K,{name:"close"})})]},C)})]},i)})})}function Rh({p:t,roles:s}){let n=nn.value,a=[...new Set(Object.values(s).flat().filter(p=>p!=="auto"))].map(p=>{let o=Be.value[p];return o?.model||o?.effort?`${Se[p]}: ${[o.model,o.effort].filter(Boolean).join(" ")}`:null}).filter(Boolean),c=Ye.value?.kind==="pr"?Ye.value:null,i=c?`PR #${c.number}'s branch`:Fe.value||(n?.current?`HEAD (${n.current})`:"HEAD"),d=as(t),l=p=>{$e.value={...$e.value,...p}};return e("details",{class:"settings",children:[e("summary",{children:[e("span",{class:"st",children:"Branches and limits"}),e("span",{class:"ss",children:["from ",i," \xB7 ",a.length?a.join(", "):"default models"," \xB7 stops after ",$e.value.maxMinutes," min or ",$e.value.maxSteps," steps",ut.value==="full"?e("span",{class:"full-access",children:" \xB7 \u26A0 full access"}):null]})]}),e("div",{class:"settings-body",children:[e("div",{class:"settings-grid",children:[e("div",{children:[e("label",{class:"lbl",for:"branchPrefix",children:"Result branch name"}),e("input",{class:"field",id:"branchPrefix",placeholder:"codeflow/<run-id>",spellcheck:!1,autocomplete:"off",value:cn.value,onInput:p=>cn.value=p.currentTarget.value}),e("div",{class:"help",children:["Results land on ",e("code",{children:"name/build"}),", ",e("code",{children:"name/candidate-a"}),"\u2026"]})]}),t.options.map(p=>e("div",{children:[e("label",{class:"lbl",for:`opt-${p.id}`,children:p.label}),p.type==="boolean"?e("input",{type:"checkbox",id:`opt-${p.id}`,checked:!!d[p.id],onChange:o=>pn(t,p.id,o.currentTarget.checked)}):e("input",{class:"field",type:"number",id:`opt-${p.id}`,min:p.min,max:p.max,value:String(d[p.id]),onInput:o=>pn(t,p.id,Number(o.currentTarget.value))})]},p.id))]}),e("div",{children:[e("span",{class:"lbl",children:"Limits \u2014 the run stops when it reaches either"}),e("div",{class:"settings-grid",children:[e("div",{children:[e("label",{class:"lbl",for:"maxMinutes",children:"Minutes"}),e("input",{class:"field",type:"number",id:"maxMinutes",min:1,max:720,value:String($e.value.maxMinutes),onInput:p=>l({maxMinutes:Number(p.currentTarget.value)||$n.maxMinutes})})]}),e("div",{children:[e("label",{class:"lbl",for:"maxSteps",children:"Agent steps"}),e("input",{class:"field",type:"number",id:"maxSteps",min:1,max:200,value:String($e.value.maxSteps),onInput:p=>l({maxSteps:Number(p.currentTarget.value)||$n.maxSteps})})]}),e("div",{children:[e("label",{class:"lbl",for:"maxTokens",children:"Reported token ceiling"}),e("input",{class:"field",id:"maxTokens",type:"number",min:1,placeholder:"Optional",value:$e.value.maxTokens??"",onInput:p=>l({maxTokens:Number(p.currentTarget.value)||void 0})})]}),e("div",{children:[e("label",{class:"lbl",for:"maxCostUsd",children:"Reported API-equivalent ceiling ($)"}),e("input",{class:"field",id:"maxCostUsd",type:"number",min:.001,step:.01,placeholder:"Optional",value:$e.value.maxCostUsd??"",onInput:p=>l({maxCostUsd:Number(p.currentTarget.value)||void 0})})]})]}),e("div",{class:"help",children:"Ceilings use reported usage; they cannot count missing provider data and are checked between operations. API-equivalent cost is not your subscription bill. Work done before a limit is kept on its branch."}),Ps.value?.loop.maxInvocations!==void 0?e("p",{class:"help",children:["Original invocation ceiling: ",Ps.value.loop.maxInvocations," CLI calls. This ceiling is retained separately from the agent-step limit."]}):null]}),n?e("div",{class:"help",children:["Each run works in git worktrees under ",n.worktreeRoot,"/ \u2014 your checkout is never touched."]}):null]})]})}function hn({agent:t,used:s,settings:n,onChange:r}){let a=ps.value[t.id],c=n??Be.value[t.id]??{},i=y=>r?r(y):Fs(t.id,y),[d,l]=m(null);if(!a||"error"in a)return e("div",{class:`model-row ${s?"":"unused"}`,children:[e(Ee,{id:t.id}),e("div",{class:"err",children:"Uses the CLI's defaults (couldn't list models)"})]});let p=a,o=p.models.some(y=>y.id===c.model),u=d??(!!c.model&&!o),f=p.models.find(y=>y.id===c.model),h=f?.efforts?.length?f.efforts:p.efforts,g=f?.defaultEffort||p.defaultEffort;return e("div",{class:`model-row ${s?"":"unused"}`,title:s?"":"Not used by this team",children:[e(Ee,{id:t.id}),e(xs,{label:`${t.displayName} model`,value:u?"__custom":c.model??"",options:[{id:"",label:p.defaultModel?`Default (${p.defaultModel})`:"Default model"},...Yn(p.models),...p.allowCustom?[{id:"__custom",label:"Other\u2026"}]:[]],onChange:y=>{l(y==="__custom");let C=y==="__custom"?"":y,T=p.models.find(k=>k.id===C),v=T?.efforts?.length?T.efforts:p.efforts;i({model:C,effort:c.effort&&v.includes(c.effort)?c.effort:""})}}),e("select",{class:"field","aria-label":`${t.displayName} effort`,value:c.effort??"",onChange:y=>i({effort:y.currentTarget.value}),children:[e("option",{value:"",children:g?`Default (${g})`:"Default effort"}),h.map(y=>e("option",{value:y,children:y},y))]}),u?e("input",{class:"field custom",type:"text",placeholder:"model id or alias","aria-label":`${t.displayName} custom model`,value:c.model??"",onInput:y=>i({model:y.currentTarget.value.trim()})}):null]})}function kR({root:t,onOpen:s}){let[n,r]=m(null),[a,c]=m(!1),[i,d]=m(""),[l,p]=m(""),[o,u]=m(null),f=xn(),h=xn();N(()=>{let y=f();if(p(""),u(null),!t){r(null),d("Choose a repository to see its files.");return}d("Loading\u2026"),V(`/api/tree?repo=${G(t)}&path=`).then(C=>{y()&&(r(C.entries),c(C.truncated),d(""))}).catch(C=>y()&&d(C.message))},[t]),N(()=>{let y=h(),C=l.trim();if(!C||!t)return u(null);let T=setTimeout(async()=>{try{let v=await V(`/api/search?repo=${G(t)}&q=${G(C)}`);y()&&u(v)}catch(v){y()&&d(v.message)}},180);return()=>clearTimeout(T)},[l,t]);let g=Y.value.view==="composer"&&t===ee.value;return e(M,{children:[e("input",{type:"search",class:"field files-search",placeholder:"Search files\u2026","aria-label":"Search files",autocomplete:"off",spellcheck:!1,value:l,onInput:y=>p(y.currentTarget.value)}),e("div",{class:"tree",children:[i?e("div",{class:"tree-empty",children:i}):null,(o??n)?.length?e("div",{role:"tree","aria-label":o?"Matching files":"Files",children:o?o.map(y=>e(Ci,{entry:y,depth:0,sub:y.path.includes("/")?y.path.slice(0,y.path.lastIndexOf("/")):"",root:t,onOpen:s,context:g},`s:${y.path}`)):n?.map(y=>e(Ci,{entry:y,depth:0,root:t,onOpen:s,context:g},y.path))}):null,o&&!o.length?e("div",{class:"tree-empty",children:"No matching files"}):null,!o&&a?e("div",{class:"tree-empty",children:"Showing the first 1000 \u2014 use search"}):null]}),g?e("div",{class:"files-foot",children:["Click a file to read it; ",e("b",{children:"+"})," or drag adds it to the task. ",e("b",{class:"mark-m",children:"M"})," changed \xB7 ",e("b",{class:"mark-u",children:"U"})," new"]}):null]})}function Ci({entry:t,depth:s,sub:n,root:r,onOpen:a,context:c}){let[i,d]=m(null),[l,p]=m(!1),[o,u]=m(""),f=xn(),h=c&&bt.value.has(t.path),g=t.status?{M:"changed",U:"new, not committed",A:"added"}[t.status]:"",y=t.type==="dir",C=async()=>{if(p(!0),i)return;let k=f();u("Loading\u2026");try{let b=await V(`/api/tree?repo=${G(r)}&path=${G(t.path)}`);if(!k())return;d(b.entries),u(b.entries.length?"":"Empty folder")}catch(b){k()&&u(b.message)}},T=()=>{if(!y)return a(t.path);if(l)return p(!1);C()},v=k=>{if(k.target!==k.currentTarget)return;let b=k.currentTarget;if(k.key==="Enter"||k.key===" ")T();else if(k.key==="ArrowRight"&&y&&!l)C();else if(k.key==="ArrowLeft"&&y&&l)p(!1);else if(k.key==="ArrowDown"||k.key==="ArrowUp"){let S=[...b.closest('[role="tree"]')?.querySelectorAll('[role="treeitem"]')??[]];S[S.indexOf(b)+(k.key==="ArrowDown"?1:-1)]?.focus()}else return;k.preventDefault()};return e("div",{children:[e("div",{class:`node ${h?"added":""}`,role:"treeitem",tabIndex:0,"aria-level":s+1,"aria-expanded":y?l:void 0,"aria-label":`${t.name}${n?`, in ${n}`:""}${g?`, ${g}`:""}`,draggable:c,title:`${t.path}${g?` \u2014 ${g}`:""}${c?`
|
|
154
|
+
Drag into the task, or click +`:""}`,style:`padding-left:${2+s*14}px`,onClick:T,onKeyDown:v,onDblClick:()=>c&&t.type==="file"&&wu(t),onDragStart:k=>{k.dataTransfer.setData(wi,JSON.stringify({path:t.path,type:t.type})),k.dataTransfer.setData("text/plain",t.path),k.dataTransfer.effectAllowed="copy",k.currentTarget.classList.add("dragging")},onDragEnd:k=>k.currentTarget.classList.remove("dragging"),children:[e("span",{class:"tw",children:t.type==="dir"?e(K,{name:"chevron",class:l?"":"shut"}):null}),e("span",{class:`lb ${t.type}`,children:[e(K,{name:t.type==="dir"?"folder":"file",class:"fi"})," ",t.name]}),n?e("span",{class:"sub",children:n}):null,e("span",{class:`st ${t.status??""}`,children:t.status??""}),c?e("button",{type:"button",class:"add",title:`Add ${t.path} to the task`,"aria-label":`Add ${t.path} to the task`,onClick:k=>{k.stopPropagation(),Ch(t)},children:"+"}):null]}),l?e("div",{role:"group",children:[o?e("div",{class:"tree-empty",style:`padding-left:${22+s*14}px`,children:o}):null,i?.map(k=>e(Ci,{entry:k,depth:s+1,root:r,onOpen:a,context:c},k.path))]}):null]})}export{vo as a,Pl as b,Ah as c,Su as d,bo as e,Eh as f,Xe as g,qh as h,Uh as i,Bh as j,Qt as k,Cg as l,Tg as m,ou as n,iu as o,ax as p,rx as q,Rs as r,dx as s,mu as t,Ex as u,Iy as v,bu as w,Lx as x,wu as y,xa as z,hn as A,kR as B,So as C,vr as D,mc as E,Ed as F,Do as G,Sr as H,kc as I,Pc as J,Or as K,ni as L,jd as M,mm as N,oi as O,hm as P,fm as Q,gm as R,LC as S,Vd as T,NC as U,ZC as V,eT as W,BT as X,BS as Y,FS as Z};
|