@visulima/vis 6.1.3 → 6.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE.md +0 -29
  3. package/dashboard/dist/index.html +10 -10
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/config/index.d.ts +16 -10
  7. package/dist/generate/index.d.ts +25 -0
  8. package/dist/packem_chunks/CONFIG_FILES.js +6 -7
  9. package/dist/packem_chunks/bloom-status.js +1 -1
  10. package/dist/packem_chunks/bloom-sync.js +1 -1
  11. package/dist/packem_chunks/catalog2.js +7 -7
  12. package/dist/packem_chunks/cli-exec.js +1 -1
  13. package/dist/packem_chunks/cli-main.js +129 -129
  14. package/dist/packem_chunks/dispatch.js +1 -1
  15. package/dist/packem_chunks/fix.js +1 -1
  16. package/dist/packem_chunks/handler.js +1 -1
  17. package/dist/packem_chunks/handler10.js +5 -5
  18. package/dist/packem_chunks/handler11.js +1 -1
  19. package/dist/packem_chunks/handler12.js +1 -1
  20. package/dist/packem_chunks/handler13.js +1 -1
  21. package/dist/packem_chunks/handler14.js +1 -1
  22. package/dist/packem_chunks/handler15.js +1 -1
  23. package/dist/packem_chunks/handler16.js +1 -1
  24. package/dist/packem_chunks/handler17.js +1 -1
  25. package/dist/packem_chunks/handler18.js +1 -1
  26. package/dist/packem_chunks/handler19.js +1 -1
  27. package/dist/packem_chunks/handler2.js +1 -1
  28. package/dist/packem_chunks/handler20.js +1 -1
  29. package/dist/packem_chunks/handler21.js +1 -1
  30. package/dist/packem_chunks/handler22.js +1 -1
  31. package/dist/packem_chunks/handler23.js +1 -1
  32. package/dist/packem_chunks/handler24.js +1 -1
  33. package/dist/packem_chunks/handler25.js +1 -1
  34. package/dist/packem_chunks/handler26.js +1 -1
  35. package/dist/packem_chunks/handler27.js +1 -1
  36. package/dist/packem_chunks/handler28.js +1 -1
  37. package/dist/packem_chunks/handler29.js +1 -1
  38. package/dist/packem_chunks/handler3.js +2 -2
  39. package/dist/packem_chunks/handler30.js +1 -1
  40. package/dist/packem_chunks/handler4.js +1 -1
  41. package/dist/packem_chunks/handler40.js +1 -1
  42. package/dist/packem_chunks/handler5.js +1 -1
  43. package/dist/packem_chunks/handler50.js +2 -2
  44. package/dist/packem_chunks/handler51.js +1 -1
  45. package/dist/packem_chunks/handler52.js +1 -1
  46. package/dist/packem_chunks/handler53.js +1 -1
  47. package/dist/packem_chunks/handler54.js +2 -2
  48. package/dist/packem_chunks/handler55.js +1 -1
  49. package/dist/packem_chunks/handler56.js +1 -1
  50. package/dist/packem_chunks/handler58.js +1 -1
  51. package/dist/packem_chunks/handler59.js +1 -1
  52. package/dist/packem_chunks/handler6.js +1 -1
  53. package/dist/packem_chunks/handler60.js +4 -4
  54. package/dist/packem_chunks/handler61.js +2 -2
  55. package/dist/packem_chunks/handler62.js +1 -1
  56. package/dist/packem_chunks/handler63.js +2 -61
  57. package/dist/packem_chunks/handler64.js +61 -6
  58. package/dist/packem_chunks/handler65.js +6 -8
  59. package/dist/packem_chunks/handler66.js +8 -2
  60. package/dist/packem_chunks/handler67.js +2 -28
  61. package/dist/packem_chunks/handler68.js +28 -12
  62. package/dist/packem_chunks/handler69.js +12 -25
  63. package/dist/packem_chunks/handler7.js +1 -1
  64. package/dist/packem_chunks/handler70.js +25 -22
  65. package/dist/packem_chunks/handler71.js +22 -10
  66. package/dist/packem_chunks/handler72.js +10 -133
  67. package/dist/packem_chunks/handler73.js +133 -23
  68. package/dist/packem_chunks/handler74.js +23 -323
  69. package/dist/packem_chunks/handler75.js +274 -659
  70. package/dist/packem_chunks/handler76.js +13 -13
  71. package/dist/packem_chunks/handler77.js +12 -12
  72. package/dist/packem_chunks/handler78.js +1 -1
  73. package/dist/packem_chunks/handler79.js +69 -67
  74. package/dist/packem_chunks/handler8.js +1 -1
  75. package/dist/packem_chunks/handler9.js +1 -1
  76. package/dist/packem_chunks/heal-accept.js +1 -1
  77. package/dist/packem_chunks/heal.js +1 -1
  78. package/dist/packem_chunks/help-command.js +1 -1
  79. package/dist/packem_chunks/html.js +707 -0
  80. package/dist/packem_chunks/index4.js +1 -1
  81. package/dist/packem_chunks/index6.js +57 -51
  82. package/dist/packem_chunks/index7.js +2 -2
  83. package/dist/packem_chunks/keys-refresh.js +1 -1
  84. package/dist/packem_chunks/lean.js +1 -1
  85. package/dist/packem_chunks/list.js +1 -1
  86. package/dist/packem_chunks/loader.js +1 -1
  87. package/dist/packem_chunks/prune.js +1 -1
  88. package/dist/packem_chunks/run.js +1 -1
  89. package/dist/packem_chunks/status.js +1 -1
  90. package/dist/packem_chunks/sync.js +1 -1
  91. package/dist/packem_chunks/sync2.js +1 -1
  92. package/dist/packem_chunks/tripwire.js +1 -1
  93. package/dist/packem_chunks/ts-loader.js +1 -1
  94. package/dist/packem_chunks/verify-lockfile.js +1 -1
  95. package/dist/packem_shared/advisories-DHGJ6XhP.js +1 -0
  96. package/dist/packem_shared/affected-selection-DCT4CLex.js +1 -0
  97. package/dist/packem_shared/{affected-shas-B_kfSKss.js → affected-shas-CycHU3nr.js} +1 -1
  98. package/dist/packem_shared/{ai-analysis-qdksWsn1.js → ai-analysis-CO4rT3Nd.js} +1 -1
  99. package/dist/packem_shared/ai-cache-Dkb6me20.js +1 -0
  100. package/dist/packem_shared/{ai-fix-DEwd0QKC.js → ai-fix-C0OBhGDq.js} +1 -1
  101. package/dist/packem_shared/{augment-B9kSZuvW.js → augment-BSeqaai8.js} +1 -1
  102. package/dist/packem_shared/{bin-BND-N6AL.js → bin-DwACrJUJ.js} +1 -1
  103. package/dist/packem_shared/build-scripts-BeMIA-_q.js +1 -0
  104. package/dist/packem_shared/{command-runtime-HSsYGCQd.js → command-runtime-DG49t2MT.js} +1 -1
  105. package/dist/packem_shared/{dependency-scan-B1CU6P9M.js → dependency-scan-D8e370_h.js} +1 -1
  106. package/dist/packem_shared/detect-C-9o_BPB.js +1 -0
  107. package/dist/packem_shared/{docker-DXqV-07f.js → docker-vRDm2lHX.js} +1 -1
  108. package/dist/packem_shared/{ecosystem-gate-InIAzSPA.js → ecosystem-gate-DpO43yAS.js} +1 -1
  109. package/dist/packem_shared/env-BymuoTL8.js +4 -0
  110. package/dist/packem_shared/env-consistency-BDfAa56d.js +1 -0
  111. package/dist/packem_shared/{failure-log-DIsKBKaI.js → failure-log-BslhfaEO.js} +1 -1
  112. package/dist/packem_shared/glob-Cyk1H9ZL-6yDyaJwk.js +1 -0
  113. package/dist/packem_shared/{index-BzhrR_iC.js → index-0dnGN3GP.js} +1 -1
  114. package/dist/packem_shared/index-CIdjkZgt.js +1 -0
  115. package/dist/packem_shared/{index-BtVOr8mn.js → index-Cwxbl_pY.js} +1 -1
  116. package/dist/packem_shared/index-Doab17tq.js +1 -0
  117. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-C-_5cgwu.js → isAccessibleSync-DYKTrrvc-CBsMZhj-.js} +1 -1
  118. package/dist/packem_shared/{lifecycle-CQjeMPY0.js → lifecycle-Gy7mqMGg.js} +2 -2
  119. package/dist/packem_shared/{lockfile-CiUtEbnt.js → lockfile-DEWjBrlY.js} +1 -1
  120. package/dist/packem_shared/manifests-kE5OweNT.js +1 -0
  121. package/dist/packem_shared/{min-release-age-JViyQuBM.js → min-release-age-yvuPbJ8G.js} +1 -1
  122. package/dist/packem_shared/missing-package-json-CEEPXqYi.js +1 -0
  123. package/dist/packem_shared/{multi-eco-lockfiles-h_HBOpPX.js → multi-eco-lockfiles-D5tM7pkg.js} +1 -1
  124. package/dist/packem_shared/{native-config-sync-TdTWjVgI.js → native-config-sync-DDGt3vvd.js} +1 -1
  125. package/dist/packem_shared/{npmrc-CHsOyMvA.js → npmrc-CIvOb61L.js} +1 -1
  126. package/dist/packem_shared/{osv-BLj4LauP.js → osv-4kFhXIoW.js} +1 -1
  127. package/dist/packem_shared/osv-bloom-DU6avR2k.js +2 -0
  128. package/dist/packem_shared/package-version-x7sPg2TM.js +4 -0
  129. package/dist/packem_shared/packument-Dg8cIDYR.js +1 -0
  130. package/dist/packem_shared/{pm-runner-RM72mDZg.js → pm-runner-Dboj-wZG.js} +1 -1
  131. package/dist/packem_shared/{project-name-filter-C6ObyhZ4.js → project-name-filter-B3tKt-Pf.js} +1 -1
  132. package/dist/packem_shared/{provenance-SX1MxPUZ.js → provenance-BG5mu0H_.js} +1 -1
  133. package/dist/packem_shared/registry-CndByNx9.js +85 -0
  134. package/dist/packem_shared/registry-keys-CE-RZlp_.js +1 -0
  135. package/dist/packem_shared/{removeSync-g1D5kONg-LbjATA8v.js → removeSync-g1D5kONg-jOsRSIIv.js} +1 -1
  136. package/dist/packem_shared/{renderToString-DR0zDUjh-5WQEQBtg.js → renderToString-DR0zDUjh-DeiCwydO.js} +1 -1
  137. package/dist/packem_shared/{resolve-explicit-D9kdTNvl.js → resolve-explicit-Cge6eKPt.js} +1 -1
  138. package/dist/packem_shared/{resolve-runtime-DNukUjIr.js → resolve-runtime-D8rxuo3J.js} +1 -1
  139. package/dist/packem_shared/run-CKL4VGzQ.js +10 -0
  140. package/dist/packem_shared/{run-file-UBukWaha.js → run-file-D1mlOnd8.js} +1 -1
  141. package/dist/packem_shared/{run-summary-utils-CMeURYtS.js → run-summary-utils-DbyeUM6f.js} +1 -1
  142. package/dist/packem_shared/runtime-check-Dw0q3X67.js +1 -0
  143. package/dist/packem_shared/s1ngularity-BOl0c716.js +1 -0
  144. package/dist/packem_shared/{scaffold-files-02tUvEKC.js → scaffold-files-B8zMyMvq.js} +1 -1
  145. package/dist/packem_shared/{scan-progress-D_POj2sy.js → scan-progress-CY3XIDOY.js} +1 -1
  146. package/dist/packem_shared/selectors-BB0yaWyK.js +3 -0
  147. package/dist/packem_shared/{signatures-CeL0bOEo.js → signatures-r1SeDHLL.js} +1 -1
  148. package/dist/packem_shared/spinner-B_rRdoro.js +1 -0
  149. package/dist/packem_shared/{table-bf3rvDd-.js → table-bu4cV-it.js} +1 -1
  150. package/dist/packem_shared/{tabs-CvrVM8BU.js → tabs-A2EUpTHt.js} +1 -1
  151. package/dist/packem_shared/target-merge-ya19LiWB.js +1 -0
  152. package/dist/packem_shared/{target-options-DsHFmRZH.js → target-options-rIthWS4M.js} +1 -1
  153. package/dist/packem_shared/{task-env-C2lmxvzA.js → task-env-Cl4jNMCR.js} +1 -1
  154. package/dist/packem_shared/toolchain-Bt93i37e.js +5 -0
  155. package/dist/packem_shared/typosquats-BbebOgKM.js +1 -0
  156. package/dist/packem_shared/{use-measured-height-CQ-qYCmz.js → use-measured-height-CwhybDI9.js} +1 -1
  157. package/dist/packem_shared/{verify-B_MblU_Q.js → verify-3WE9U_Bv.js} +1 -1
  158. package/dist/packem_shared/{vis-update-app-a93HLRLX.js → vis-update-app-PjJWvxqF.js} +1 -1
  159. package/dist/packem_shared/{vis-user-error-Cpb0P6VA.js → vis-user-error-BivZDkQD.js} +2 -2
  160. package/dist/packem_shared/{watch-CcTketln.js → watch-C-9-PD2m.js} +1 -1
  161. package/dist/packem_shared/{watch-loop-CGPe21AK.js → watch-loop-dWYGUQwi.js} +1 -1
  162. package/dist/release/plugin-sdk.d.ts +32 -0
  163. package/dist/release/presets.d.ts +38 -0
  164. package/dist/runtime/preload.js +1 -1
  165. package/index.js +26 -26
  166. package/package.json +19 -15
  167. package/schemas/vis-config.schema.json +12 -0
  168. package/dist/packem_shared/advisories-BKsh48bi.js +0 -1
  169. package/dist/packem_shared/affected-selection-C7rvg_xC.js +0 -1
  170. package/dist/packem_shared/ai-cache-iSIyY3So.js +0 -1
  171. package/dist/packem_shared/build-scripts-CEDx_nJp.js +0 -1
  172. package/dist/packem_shared/detect-CbMRSXkM.js +0 -1
  173. package/dist/packem_shared/env-BSXG3QKH.js +0 -4
  174. package/dist/packem_shared/env-consistency-B4rU4MQb.js +0 -1
  175. package/dist/packem_shared/glob-Cyk1H9ZL-DlsGNNhY.js +0 -1
  176. package/dist/packem_shared/index-BS3mFsh-.js +0 -1
  177. package/dist/packem_shared/manifests-Du4yKlf_.js +0 -1
  178. package/dist/packem_shared/missing-package-json-DDVQ_scH.js +0 -1
  179. package/dist/packem_shared/osv-bloom-BCAX5ARR.js +0 -2
  180. package/dist/packem_shared/package-version-D0b8b41D.js +0 -4
  181. package/dist/packem_shared/packument-CbTmbHU4.js +0 -1
  182. package/dist/packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js +0 -1
  183. package/dist/packem_shared/registry-B6LWRK9T.js +0 -81
  184. package/dist/packem_shared/registry-keys-z038Ecb4.js +0 -1
  185. package/dist/packem_shared/run-DLvd3RIZ.js +0 -10
  186. package/dist/packem_shared/runtime-check-D3cRDuoi.js +0 -1
  187. package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +0 -1
  188. package/dist/packem_shared/selectors-edwcgNl3.js +0 -3
  189. package/dist/packem_shared/spinner-8fJUI_wl.js +0 -1
  190. package/dist/packem_shared/target-merge-DVJl-7Qz.js +0 -4
  191. package/dist/packem_shared/toolchain-CP79HNVy.js +0 -5
  192. package/dist/packem_shared/typosquats-BFKus_aM.js +0 -1
  193. package/dist/packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js +0 -1
@@ -1,67 +1,69 @@
1
- import{createRequire as ss}from"node:module";import{readLastRunSummary as is,getLastRunSummaryPath as os,runConcurrently as $e,TerminalBuffer as We,CompositeLifeCycle as jt,defaultTaskRunner as St,resolveTurboEnvCompat as cs,pickChildParentEnv as as,generateRunSummary as kt,writeChromeTrace as ls,expandAffected as ds,getChangedFiles as us,enforceProjectConstraints as fs,buildEnhancedPath as hs,createLogReporter as ps,writeRunSummary as ms,reverseTaskGraph as gs,splitCompoundTasks as ws,createTaskGraph as vs,expandTokensInString as bt,parsePartition as ys,TaskScheduler as xs}from"@visulima/task-runner";import{r as U,j as c,X as v,O as u,R as K,o as js,d as Ss,b as ks}from"../packem_shared/registry-B6LWRK9T.js";import{r as bs}from"../packem_shared/command-runtime-HSsYGCQd.js";import{d as Ce,S as Ts}from"../packem_shared/env-BSXG3QKH.js";import{f as $s,d as Cs,e as Is,H as Es,i as Rs,r as Ps,s as Ms,a as Fs,b as Os,c as As}from"../packem_shared/lifecycle-CQjeMPY0.js";import{z as Ls,e as ne,m as Tt,$ as Ds,a as Bs}from"../packem_shared/index-BzhrR_iC.js";import{a as $t,d as Ct,r as He,s as _s,m as Ns,l as Gs}from"../packem_shared/target-options-DsHFmRZH.js";import{g as je,r as ke,b as Ws,e as Hs,A as qs,T as Vs,d as Us}from"../packem_shared/task-env-C2lmxvzA.js";import{f as zs}from"../packem_shared/removeSync-g1D5kONg-LbjATA8v.js";import{K as It,M as Ys,J as Ks,C as Je,N as Xs,Q as Js,q as Qs,P as Zs,Z as er,h as tr,aj as sr,ak as rr,al as nr,am as ir}from"./cli-main.js";import{O as ce}from"../packem_shared/renderToString-DR0zDUjh-5WQEQBtg.js";import{T as Et,C as Rt,D as Fe,E as Pt}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as mr,j as gr,X as Ae,F as et}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as wr,codeFrame as vr}from"@visulima/error";import{originalPositionFor as yr,sourceContentFor as xr,loadSourceMap as jr}from"@visulima/source-map";import{l as Mt}from"../packem_shared/spinner-8fJUI_wl.js";import{i as Se}from"../packem_shared/index-BjdW45xX.js";import{d as kr,r as br}from"../packem_shared/lockfile-CiUtEbnt.js";import{y as Ft}from"../packem_shared/index-BisalDCf.js";import{r as Cr}from"../packem_shared/toolchain-CP79HNVy.js";import{F as Ir}from"../packem_shared/failure-log-DIsKBKaI.js";import{V as pe}from"../packem_shared/vis-user-error-Cpb0P6VA.js";import{s as Er}from"../packem_shared/affected-selection-C7rvg_xC.js";import{c as Ot,s as Rr,p as Pr,a as Mr,b as Fr,r as Or,f as Ar}from"../packem_shared/project-name-filter-C6ObyhZ4.js";import{r as Lr,f as Dr,a as Br,p as _r}from"../packem_shared/selectors-edwcgNl3.js";import Be from"./index.js";import{U as At}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{c as tt,a as qr,s as st}from"../packem_shared/watch-CcTketln.js";let rs;const ns=t=>(rs??=ss(import.meta.url))(t),ye=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fe=t=>{if(typeof ye<"u"&&ye.versions&&ye.versions.node){const[e,s]=ye.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ye.getBuiltinModule(t)}return ns(t)},{existsSync:he,readFileSync:we,mkdirSync:or,writeFileSync:qe,openSync:cr,statSync:Qe,readSync:ar,closeSync:lr,mkdtempSync:dr}=fe("node:fs"),{isAbsolute:ur,resolve:Ze,dirname:fr,relative:hr}=fe("node:path"),{fileURLToPath:pr}=fe("node:url"),{createHash:Sr}=fe("node:crypto"),{createInterface:Tr,emitKeypressEvents:$r}=fe("node:readline"),{mkdir:Nr,appendFile:Oe}=fe("node:fs/promises"),{platform:Gr,homedir:Ve,tmpdir:Wr}=fe("node:os"),{spawn:Hr}=fe("node:child_process"),Vr=(t,e,s,r,i,o,n,l,d,h,f,p,a,m)=>{const w={d:r,h:i,m:o,mo:e,ms:l,s:n,w:s,y:t};return w.future=d,w.past=h,w.decimal=f,p!==void 0&&(w.unitMap=p),w.groupSeparator=a,w.placeholderSeparator=m,w},Ur={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},zr=Vr(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",Ur,",","_"),rt=new WeakSet,Yr=t=>{if(rt.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(t,r))throw new TypeError(`Missing required property: ${r}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const r of s)if(typeof t[r]!="string"&&typeof t[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");rt.add(t)},Lt=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,r=Number((t*s).toPrecision(15));return Math.trunc(r)/s},nt=({unitCount:t,unitName:e},s,r)=>{let{spacer:i}=r;const{maxDecimalPoints:o}=r;let n=".";r.decimal!==void 0?n=r.decimal:s.decimal!==void 0&&(n=s.decimal);let l;"digitReplacements"in r?l=r.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Lt(t,o));const f=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of f)d+=m==="."?n:l[m]}else d=f.replace(".",n);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(i=""),s._numberFirst?a+i+d:d+i+a},Kr=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:r}=e,i=e.largest??Number.POSITIVE_INFINITY,o={};let n,l,d,h=t;for(l=0;l<s.length;l++){n=s[l];const p=r[n];d=l===s.length-1?h/p:Math.floor(h/p),o[n]=d,h-=d*p}if(e.round){let p=i;for(l=0;l<s.length;l++)if(n=s[l],d=o[n],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],w=o[m];o[n]=(o[n]??0)+w*r[m]/r[n],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(n=s[l],d=o[n],d===0)continue;const a=Math.round(d);if(o[n]=a,l===0)break;const m=s[l-1],w=r[m],j=Math.floor(a*r[n]/w);if(j)o[m]=(o[m]??0)+j,o[n]=0;else break}}const f=[];for(l=0;l<s.length&&f.length<i;l++){if(n=s[l],d=o[n],d&&!e.round&&f.length===i-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[n])}d+=a,e.maxDecimalPoints!==void 0&&(d=Lt(d,e.maxDecimalPoints))}d&&f.push({unitCount:d,unitName:n})}return f},Xr=(t,e,s)=>{const{language:r,units:i}=e;if(t.length===0){const p=i.at(-1);return nt({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:n}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:r.delimiter!==void 0&&(l=r.delimiter);let d="";e.timeAdverb&&s!==0&&(d=r.future??"",s<0&&(d=r.past??""));const h=t.map(p=>nt(p,r,e));let f;return!o||t.length===1?f=h.join(l):t.length===2?f=h.join(o):f=h.slice(0,-1).join(l)+(n?",":"")+o+(h.at(-1)??""),d&&(f=d.replace("%s",f)),f},Jr=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:zr,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Yr(s.language);const r=Math.abs(t),i=Kr(r,s);return Xr(i,s,t)},Ie=256*1024;class Qr{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
2
- ${this.#r}`:this.#r}}const Zr=t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},en=async(t,e)=>{const s=await is(t,{dataDirectory:Ce(t)});if(!s){e.warn(`No previous run recorded yet. Run a task at least once to populate ${os(t,{dataDirectory:Ce(t)})}.`);return}const r=(s.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${s.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(s.stats.total)}`),e.info(` Succeeded: ${String(s.stats.succeeded)}`),e.info(` Cached: ${String(s.stats.cached)}`),e.info(` Failed: ${String(s.stats.failed)}`),e.info(` Skipped: ${String(s.stats.skipped)}`),e.info(""),s.stats.failed>0){const o=s.tasks.filter(n=>n.exitCode!==void 0&&n.exitCode!==0);e.info("Failed tasks:");for(const n of o){const l=n.duration??0;e.info(` × ${n.taskId} (exit ${String(n.exitCode??-1)}, ${l}ms)`)}e.info("")}const i=[...s.tasks].filter(o=>typeof o.duration=="number").sort((o,n)=>(n.duration??0)-(o.duration??0)).slice(0,5);if(i.length>0){e.info("Slowest tasks:");for(const o of i)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},tn=t=>{if(!(t===void 0||t==="")){if(t!=="read"&&t!=="write"&&t!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${t}")`);return t}},sn=t=>{if(!(t===void 0||t==="")){if(t!=="http"&&t!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${t}")`);return t}},rn=t=>{if(!(t===void 0||t==="")){if(t!=="declared"&&t!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${t}")`);return t}},nn=({interactive:t,taskPty:e,workspacePty:s})=>e===!0?!0:e===!1?!1:t&&s!==!1,on=t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,Ue=t=>process.platform==="win32"?t.length>0&&!/[\s"&|<>^()%!]/.test(t)?t:`"${t.replaceAll('"','""')}"`:on(t),cn=(t,e,s)=>{if(!e||e.length===0||s===!1||s===void 0)return t;if(s==="args"||s==="both"){const r=e.map(i=>Ue(i)).join(" ");return`${t} ${r}`}return t},Dt="visForwardedArgs",an=(t,e)=>{const s=e.overrides[Dt];if(!Array.isArray(s)||s.length===0)return t;const r=s.map(i=>Ue(i)).join(" ");return`${t} ${r}`},ze=(t,e,s)=>{const r=t.overrides.command;if(!r)return;const i=je(t),o=t.segment!==void 0&&t.segment.index<t.segment.count,n=o?r:an(r,t),l=o?n:cn(n,e,i?.affectedFiles),d=$t(i,s),h=i?.shellArgs,f=h&&h.length>0?h.join(" "):"-c";return d?`${d} ${f} ${Ue(l)}`:l},ln=2e3,Bt=async(t,e,s)=>{const{workspaceRoot:r}=e,i=t.map(g=>{const k=ze(g,e.affectedFiles,Ct());if(!k)return;const P=g.overrides.visOptions,C=He(r,g.projectRoot,!!P?.runFromWorkspaceRoot),y=nn({interactive:!!s,taskPty:g.pty,workspacePty:P?.pty}),E=ke(e,g);return{command:k,cwd:C,env:E.env,inheritEnv:E.inheritEnv,name:g.id,...y?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(g=>g!==void 0);if(i.length===0)return;if(!s){await $e(i,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:n,stdinRegistry:l,store:d}=s,h=i.map(g=>t.find(k=>k.id===g.name)).filter(Boolean),f=g=>i[g]?.stdin==="pty",p=new Map,a=g=>{if(!f(g))return;let k=p.get(g);return k||(k=new We(Ie),p.set(g,k)),k};d.unmarkDone(),n.startTasks?.(h);const m=new Map,w=new Map;let j;const M=()=>{for(const g of w.values())try{g("SIGTERM")}catch{}j||(j=setTimeout(()=>{for(const g of w.values())try{g("SIGKILL")}catch{}w.clear()},2e3),j.unref?.())};let x;o&&(x=()=>{M()},o.then(()=>{x?.()}).catch(()=>{x?.()}));try{await $e(i,{killOthers:["failure"],onEvent:g=>{const k=h[g.index];if(k)switch(g.kind){case"close":{const P=m.get(k.id)??Date.now(),C=g.killed||g.exitCode===0?"success":"failure";n.endTasks?.([{code:g.exitCode??0,endTime:Date.now(),startTime:P,status:C,task:k,terminalOutput:d.getSnapshot().outputs.get(k.id)??""}]),w.delete(g.index),l?.delete(k.id);break}case"error":{if(g.message){const P=a(g.index);P?(P.write(`${g.message}
3
- `),d.setOutput(k.id,P.toString())):d.addOutput(k.id,`${g.message}
4
- `)}break}case"started":{m.set(k.id,Date.now()),g.kill&&w.set(g.index,g.kill),g.write&&l&&l.set(k.id,{kill:g.kill,resize:g.resize,write:g.write});break}case"stderr":case"stdout":{if(g.text){const P=a(g.index);P?(P.write(g.text),d.setOutput(k.id,P.toString())):d.addOutput(k.id,`${g.text}
5
- `)}break}default:}}})}finally{j&&(clearTimeout(j),j=void 0),d.markDone()}},it=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},dn=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},un=t=>{const{extraPids:e=[],pidFiles:s,runDir:r}=t,i=[],o=n=>{try{process.kill(-n,"SIGTERM")}catch{try{process.kill(n,"SIGTERM")}catch{}}};for(const n of s){let l;try{const d=Ls(n),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(i.push(l),o(l))}for(const n of e)!Number.isFinite(n)||n<=0||(i.push(n),o(n));if(i.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const f of i)if(it(f)){h=!1;break}if(h)break;dn(100)}for(const h of i)if(it(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&zs(r)},fn=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:r,serviceRunDir:i,stopServicesOnExit:o,workspaceRoot:n})=>{let l=!1;const d=()=>{if(l)return;l=!0,r&&r.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;un({extraPids:p,pidFiles:t,runDir:i})},h=()=>{d()},f=t.length>0||i!==void 0||o&&e.length>0;return{finish:async()=>{d(),f&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await $s(n,p)}catch{}}))},install:()=>{f&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},hn=({config:t,logger:e,persistentTasks:s,taskGraph:r})=>{const i=Object.keys(r.tasks).length,o=r.roots.length;e.info(`Execution plan (${String(i)} task(s), ${String(o)} root(s)):`),e.info("");const n=new Set,l=(d,h)=>{if(n.has(d))return;n.add(d);for(const j of r.dependencies[d]??[])l(j,h+1);const f=r.tasks[d],p=" ".repeat(h+1),a=f?.segment?` (segment ${String(f.segment.index)}/${String(f.segment.count)}: ${String(f.overrides.command)})`:"",m=f?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,w=`${f?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${w}`)};for(const d of r.roots)l(d,0);for(const d of Object.keys(r.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},pn=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,r]of t.entries())if(!Object.is(r,e[s]))return!1;return!0},ot=({children:t,deps:e,onRender:s,style:r,width:i})=>{const o=U.useRef(null),n=U.useRef(!1),l=U.useRef(e),d=U.useRef(t),h=U.useRef(s);h.current=s;let f=!1;e!==void 0?pn(l.current,e)||(f=!0,l.current=e):t!==d.current&&(f=!0,d.current=t),f&&(n.current=!1,o.current&&(o.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{n.current=!0,h.current?.(a)})}),U.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=U.useMemo(()=>({...r,width:i}),[r,i]);return c.jsx("ink-static-render",{ref:o,style:p,children:n.current?null:t()})},mn=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),gn=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${mn(s)}`,Ye=(t,e,s)=>{const r=new Set(new Set(s.map(a=>a.target.target))),i=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),n=t.filter(a=>i.has(a)),l=s.length-n.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),f=n.length===1?`project ${n[0]}`:`${n.length} projects`;let p=`${d} ${h} for ${f}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},wn={error:"red",info:"white",success:"green"},_e=({children:t,title:e,variant:s})=>{const r=wn[s];return c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{bold:!0,color:r,children:"•"}),c.jsx(u,{children:e})]}),t]})},_t=({cached:t,failed:e,failedIds:s,projectNames:r,retriedIds:i,skippedIds:o,succeeded:n,targets:l,tasks:d,took:h})=>{const f=Ye(r,l,d),p=i??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Successfully ran ${f}`,variant:"success",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(u,{children:[c.jsx(u,{color:"green",children:Et})," ",n+t," tasks completed",a?c.jsx(u,{dimColor:!0,children:a}):null,c.jsx(u,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",marginTop:1,children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:"↻"})," ",c.jsx(u,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Ran ${f}`,variant:"error",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(u,{dimColor:!0,children:[" - ",a]},a)),c.jsx(u,{})]}),e>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"red",children:Rt})," ",a]},a)),c.jsx(u,{})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(u,{})]}),c.jsx(u,{dimColor:!0,children:` Took ${h}`})]})})})};class Ee{#e;#r=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const r of e){const i=s.findIndex(o=>o.taskId===r.id);i!==-1&&(s[i]={...s[i],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:r,completed:i,failed:o,succeeded:n}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),i++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{n++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:i,failed:o,outputs:l,retriedIds:d,rows:s,running:f,selectedIndex:h,succeeded:n})}static#n=256*1024;addOutput(e,s){if(!s.trim())return;let r=(this.#e.outputs.get(e)??"")+s;r.length>Ee.#n&&(r=r.slice(-Ee.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let r=0;r<s.length;r++){const i=s[r];if(i.status==="running"){const o=this.#s.get(i.taskId);if(o){const n=process.hrtime(o),l=n[0]*1e3+n[1]/1e6;s[r]={...i,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const r=[...this.#e.pinnedTaskIds];r[e]=s,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],r=s.findIndex(l=>l.taskId===e);let{completed:i,failed:o,succeeded:n}=this.#e;if(r!==-1){const l=s[r].status;l==="failure"?(o=Math.max(0,o-1),i=Math.max(0,i-1)):l==="success"&&(n=Math.max(0,n-1),i=Math.max(0,i-1)),s[r]={...s[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:i,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:n})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#r)try{s()}catch{}}}const vn=27,yn={95:"apc",80:"dcs",94:"pm",88:"sos"},xn={159:"apc",144:"dcs",158:"pm",152:"sos"},Nt=t=>t===155||t===157||t===144||t===152||t===158||t===159,Gt=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Re=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const i=t.codePointAt(r);if(i===156||s&&i===7)return r;if(i===27&&t.codePointAt(r+1)===92)return r+1}return-1},jn=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=Gt(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Re(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Re(t,e+2,!1),i=yn[s];return r===-1?void 0:{end:r,kind:i}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Sn=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=Gt(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Re(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Re(t,e+1,!1),i=xn[s];return r===-1?void 0:{end:r,kind:i}}},kn=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Nt(t.codePointAt(e)))return!0;return!1},bn=t=>{if(!kn(t))return t;let e="",s=0,r=0;const{length:i}=t;for(;r<i;){const o=t.codePointAt(r);let n;if(o===vn)n=jn(t,r);else if(Nt(o))n=Sn(t,r);else{r+=1;continue}const l=n===void 0?i-1:n.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},Tn=t=>bn(t),$n=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Cn=/^\s*at\s+/,In=t=>{const e=t.split(`
6
- `);let s;for(let r=0;r<e.length;r++){const i=$n.exec(e[r].trim());if(!i)continue;const o=[];for(let n=r+1;n<e.length&&n<=r+200;n++){const l=e[n];if(Cn.test(l))o.push(l.trim());else{if(o.length>0)break;if(l.trim()!=="")break}}if(o.length>0){const n=i.groups?.name??"Error",l=i.groups?.message??"";s={message:l,name:n,stack:`${n}: ${l}
1
+ import{createRequire as ns}from"node:module";import{readLastRunSummary as cs,getLastRunSummaryPath as as,runConcurrently as Ce,TerminalBuffer as He,CompositeLifeCycle as kt,defaultTaskRunner as bt,resolveTurboEnvCompat as ls,pickChildParentEnv as ds,generateRunSummary as Tt,writeChromeTrace as us,expandAffected as fs,getChangedFiles as hs,enforceProjectConstraints as ps,buildEnhancedPath as ms,createLogReporter as gs,writeRunSummary as ws,reverseTaskGraph as vs,splitCompoundTasks as ys,createTaskGraph as xs,expandTokensInString as $t,parsePartition as js,TaskScheduler as Ss}from"@visulima/task-runner";import{L as Ct,N as ks,K as bs,C as Qe,P as Ts,Q as $s,q as Cs,j as Is,ak as Es,al as Rs,am as Ps,an as Ms,r as Fs}from"./cli-main.js";import{r as U,j as c,X as x,O as f,R as X,o as Os,d as As,b as Ls}from"../packem_shared/registry-CndByNx9.js";import{r as Ds}from"../packem_shared/command-runtime-DG49t2MT.js";import{s as Bs,p as _s,i as Ns}from"../packem_shared/affected-selection-DCT4CLex.js";import{d as Ie,U as It,a1 as Ws}from"../packem_shared/env-BymuoTL8.js";import{f as Gs,d as Hs,e as qs,H as Us,i as Vs,r as zs,s as Ys,a as Ks,b as Xs,c as Js}from"../packem_shared/lifecycle-Gy7mqMGg.js";import{z as Qs,e as ie,m as Et,$ as Zs,a as er}from"../packem_shared/index-0dnGN3GP.js";import{a as Rt,d as Pt,r as qe,s as tr,m as sr,l as rr}from"../packem_shared/target-options-rIthWS4M.js";import{g as ke,r as Te,b as nr,e as ir,A as or,T as cr,d as ar}from"../packem_shared/task-env-Cl4jNMCR.js";import{f as lr}from"../packem_shared/removeSync-g1D5kONg-jOsRSIIv.js";import{O as le}from"../packem_shared/renderToString-DR0zDUjh-DeiCwydO.js";import{T as Mt,C as Ft,D as Oe,E as Ot}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as yr,j as xr,X as Le,F as tt}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as jr,codeFrame as Sr}from"@visulima/error";import{originalPositionFor as kr,sourceContentFor as br,loadSourceMap as Tr}from"@visulima/source-map";import{l as At}from"../packem_shared/spinner-B_rRdoro.js";import{i as be}from"../packem_shared/index-BjdW45xX.js";import{d as Cr,r as Ir}from"../packem_shared/lockfile-DEWjBrlY.js";import{y as Lt}from"../packem_shared/index-BisalDCf.js";import{r as Pr}from"../packem_shared/toolchain-Bt93i37e.js";import{F as Mr}from"../packem_shared/failure-log-BslhfaEO.js";import{V as ge}from"../packem_shared/vis-user-error-BivZDkQD.js";import{c as Dt,s as Fr,p as Or,a as Ar,b as Lr,r as Dr,f as Br}from"../packem_shared/project-name-filter-B3tKt-Pf.js";import{r as _r,f as Nr,a as Wr,p as Gr}from"../packem_shared/selectors-BB0yaWyK.js";import _e from"./index.js";import{c as st,a as zr,s as rt}from"../packem_shared/watch-C-9-PD2m.js";let is;const os=t=>(is??=ns(import.meta.url))(t),je=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=t=>{if(typeof je<"u"&&je.versions&&je.versions.node){const[e,s]=je.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return je.getBuiltinModule(t)}return os(t)},{existsSync:me,readFileSync:ye,mkdirSync:dr,writeFileSync:Ue,openSync:ur,statSync:Ze,readSync:fr,closeSync:hr,mkdtempSync:pr}=pe("node:fs"),{isAbsolute:mr,resolve:et,dirname:gr,relative:wr}=pe("node:path"),{fileURLToPath:vr}=pe("node:url"),{createHash:$r}=pe("node:crypto"),{createInterface:Er,emitKeypressEvents:Rr}=pe("node:readline"),{mkdir:Hr,appendFile:Ae}=pe("node:fs/promises"),{platform:qr,homedir:Ve,tmpdir:Ur}=pe("node:os"),{spawn:Vr}=pe("node:child_process"),Yr=27,Kr={95:"apc",80:"dcs",94:"pm",88:"sos"},Xr={159:"apc",144:"dcs",158:"pm",152:"sos"},Bt=t=>t===155||t===157||t===144||t===152||t===158||t===159,_t=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Ee=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const n=t.codePointAt(r);if(n===156||s&&n===7)return r;if(n===27&&t.codePointAt(r+1)===92)return r+1}return-1},Jr=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=_t(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Ee(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Ee(t,e+2,!1),n=Kr[s];return r===-1?void 0:{end:r,kind:n}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Qr=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=_t(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Ee(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Ee(t,e+1,!1),n=Xr[s];return r===-1?void 0:{end:r,kind:n}}},Zr=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Bt(t.codePointAt(e)))return!0;return!1},en=t=>{if(!Zr(t))return t;let e="",s=0,r=0;const{length:n}=t;for(;r<n;){const o=t.codePointAt(r);let i;if(o===Yr)i=Jr(t,r);else if(Bt(o))i=Qr(t,r);else{r+=1;continue}const l=i===void 0?n-1:i.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},tn=(t,e,s,r,n,o,i,l,d,h,u,p,a,m)=>{const w={d:r,h:n,m:o,mo:e,ms:l,s:i,w:s,y:t};return w.future=d,w.past=h,w.decimal=u,p!==void 0&&(w.unitMap=p),w.groupSeparator=a,w.placeholderSeparator=m,w},sn={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},rn=tn(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",sn,",","_"),nt=new WeakSet,nn=t=>{if(nt.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(t,r))throw new TypeError(`Missing required property: ${r}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const r of s)if(typeof t[r]!="string"&&typeof t[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");nt.add(t)},Nt=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,r=Number((t*s).toPrecision(15));return Math.trunc(r)/s},it=({unitCount:t,unitName:e},s,r)=>{let{spacer:n}=r;const{maxDecimalPoints:o}=r;let i=".";r.decimal!==void 0?i=r.decimal:s.decimal!==void 0&&(i=s.decimal);let l;"digitReplacements"in r?l=r.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Nt(t,o));const u=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of u)d+=m==="."?i:l[m]}else d=u.replace(".",i);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(n=""),s._numberFirst?a+n+d:d+n+a},on=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:r}=e,n=e.largest??Number.POSITIVE_INFINITY,o={};let i,l,d,h=t;for(l=0;l<s.length;l++){i=s[l];const p=r[i];d=l===s.length-1?h/p:Math.floor(h/p),o[i]=d,h-=d*p}if(e.round){let p=n;for(l=0;l<s.length;l++)if(i=s[l],d=o[i],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],w=o[m];o[i]=(o[i]??0)+w*r[m]/r[i],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(i=s[l],d=o[i],d===0)continue;const a=Math.round(d);if(o[i]=a,l===0)break;const m=s[l-1],w=r[m],j=Math.floor(a*r[i]/w);if(j)o[m]=(o[m]??0)+j,o[i]=0;else break}}const u=[];for(l=0;l<s.length&&u.length<n;l++){if(i=s[l],d=o[i],d&&!e.round&&u.length===n-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[i])}d+=a,e.maxDecimalPoints!==void 0&&(d=Nt(d,e.maxDecimalPoints))}d&&u.push({unitCount:d,unitName:i})}return u},cn=(t,e,s)=>{const{language:r,units:n}=e;if(t.length===0){const p=n.at(-1);return it({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:i}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:r.delimiter!==void 0&&(l=r.delimiter);let d="";e.timeAdverb&&s!==0&&(d=r.future??"",s<0&&(d=r.past??""));const h=t.map(p=>it(p,r,e));let u;return!o||t.length===1?u=h.join(l):t.length===2?u=h.join(o):u=h.slice(0,-1).join(l)+(i?",":"")+o+(h.at(-1)??""),d&&(u=d.replace("%s",u)),u},an=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:rn,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};nn(s.language);const r=Math.abs(t),n=on(r,s);return cn(n,s,t)},Re=256*1024;class ln{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
2
+ ${this.#r}`:this.#r}}const dn=t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},un=async(t,e)=>{const s=await cs(t,{dataDirectory:Ie(t)});if(!s){e.warn(`No previous run recorded yet. Run a task at least once to populate ${as(t,{dataDirectory:Ie(t)})}.`);return}const r=(s.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${s.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(s.stats.total)}`),e.info(` Succeeded: ${String(s.stats.succeeded)}`),e.info(` Cached: ${String(s.stats.cached)}`),e.info(` Failed: ${String(s.stats.failed)}`),e.info(` Skipped: ${String(s.stats.skipped)}`),e.info(""),s.stats.failed>0){const o=s.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const l=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${l}ms)`)}e.info("")}const n=[...s.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(n.length>0){e.info("Slowest tasks:");for(const o of n)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},fn=t=>{if(!(t===void 0||t==="")){if(t!=="read"&&t!=="write"&&t!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${t}")`);return t}},hn=t=>{if(!(t===void 0||t==="")){if(t!=="http"&&t!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${t}")`);return t}},pn=t=>{if(!(t===void 0||t==="")){if(t!=="declared"&&t!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${t}")`);return t}},mn=({interactive:t,taskPty:e,workspacePty:s})=>e===!0?!0:e===!1?!1:t&&s!==!1,gn=t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,ze=t=>process.platform==="win32"?t.length>0&&!/[\s"&|<>^()%!]/.test(t)?t:`"${t.replaceAll('"','""')}"`:gn(t),wn=(t,e,s)=>{if(!e||e.length===0||s===!1||s===void 0)return t;if(s==="args"||s==="both"){const r=e.map(n=>ze(n)).join(" ");return`${t} ${r}`}return t},Wt="visForwardedArgs",vn=(t,e)=>{const s=e.overrides[Wt];if(!Array.isArray(s)||s.length===0)return t;const r=s.map(n=>ze(n)).join(" ");return`${t} ${r}`},Ye=(t,e,s)=>{const r=t.overrides.command;if(!r)return;const n=ke(t),o=t.segment!==void 0&&t.segment.index<t.segment.count,i=o?r:vn(r,t),l=o?i:wn(i,e,n?.affectedFiles),d=Rt(n,s),h=n?.shellArgs,u=h&&h.length>0?h.join(" "):"-c";return d?`${d} ${u} ${ze(l)}`:l},yn=2e3,Gt=async(t,e,s)=>{const{workspaceRoot:r}=e,n=t.map(g=>{const S=Ye(g,e.affectedFiles,Pt());if(!S)return;const F=g.overrides.visOptions,C=qe(r,g.projectRoot,!!F?.runFromWorkspaceRoot),v=mn({interactive:!!s,taskPty:g.pty,workspacePty:F?.pty}),L=Te(e,g);return{command:S,cwd:C,env:L.env,inheritEnv:L.inheritEnv,name:g.id,...v?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(g=>g!==void 0);if(n.length===0)return;if(!s){await Ce(n,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:i,stdinRegistry:l,store:d}=s,h=n.map(g=>t.find(S=>S.id===g.name)).filter(Boolean),u=g=>n[g]?.stdin==="pty",p=new Map,a=g=>{if(!u(g))return;let S=p.get(g);return S||(S=new He(Re),p.set(g,S)),S};d.unmarkDone(),i.startTasks?.(h);const m=new Map,w=new Map;let j;const E=()=>{for(const g of w.values())try{g("SIGTERM")}catch{}j||(j=setTimeout(()=>{for(const g of w.values())try{g("SIGKILL")}catch{}w.clear()},2e3),j.unref?.())};let y;o&&(y=()=>{E()},o.then(()=>{y?.()}).catch(()=>{y?.()}));try{await Ce(n,{killOthers:["failure"],onEvent:g=>{const S=h[g.index];if(S)switch(g.kind){case"close":{const F=m.get(S.id)??Date.now(),C=g.killed||g.exitCode===0?"success":"failure";i.endTasks?.([{code:g.exitCode??0,endTime:Date.now(),startTime:F,status:C,task:S,terminalOutput:d.getSnapshot().outputs.get(S.id)??""}]),w.delete(g.index),l?.delete(S.id);break}case"error":{if(g.message){const F=a(g.index);F?(F.write(`${g.message}
3
+ `),d.setOutput(S.id,F.toString())):d.addOutput(S.id,`${g.message}
4
+ `)}break}case"started":{m.set(S.id,Date.now()),g.kill&&w.set(g.index,g.kill),g.write&&l&&l.set(S.id,{kill:g.kill,resize:g.resize,write:g.write});break}case"stderr":case"stdout":{if(g.text){const F=a(g.index);F?(F.write(g.text),d.setOutput(S.id,F.toString())):d.addOutput(S.id,`${g.text}
5
+ `)}break}default:}}})}finally{j&&(clearTimeout(j),j=void 0),d.markDone()}},ot=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},xn=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},jn=t=>{const{extraPids:e=[],pidFiles:s,runDir:r}=t,n=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of s){let l;try{const d=Qs(i),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(n.push(l),o(l))}for(const i of e)!Number.isFinite(i)||i<=0||(n.push(i),o(i));if(n.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const u of n)if(ot(u)){h=!1;break}if(h)break;xn(100)}for(const h of n)if(ot(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&lr(r)},Sn=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:r,serviceRunDir:n,stopServicesOnExit:o,workspaceRoot:i})=>{let l=!1;const d=()=>{if(l)return;l=!0,r&&r.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;jn({extraPids:p,pidFiles:t,runDir:n})},h=()=>{d()},u=t.length>0||n!==void 0||o&&e.length>0;return{finish:async()=>{d(),u&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await Gs(i,p)}catch{}}))},install:()=>{u&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},kn=({config:t,logger:e,persistentTasks:s,taskGraph:r})=>{const n=Object.keys(r.tasks).length,o=r.roots.length;e.info(`Execution plan (${String(n)} task(s), ${String(o)} root(s)):`),e.info("");const i=new Set,l=(d,h)=>{if(i.has(d))return;i.add(d);for(const j of r.dependencies[d]??[])l(j,h+1);const u=r.tasks[d],p=" ".repeat(h+1),a=u?.segment?` (segment ${String(u.segment.index)}/${String(u.segment.count)}: ${String(u.overrides.command)})`:"",m=u?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,w=`${u?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${w}`)};for(const d of r.roots)l(d,0);for(const d of Object.keys(r.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},bn=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,r]of t.entries())if(!Object.is(r,e[s]))return!1;return!0},ct=({children:t,deps:e,onRender:s,style:r,width:n})=>{const o=U.useRef(null),i=U.useRef(!1),l=U.useRef(e),d=U.useRef(t),h=U.useRef(s);h.current=s;let u=!1;e!==void 0?bn(l.current,e)||(u=!0,l.current=e):t!==d.current&&(u=!0,d.current=t),u&&(i.current=!1,o.current&&(o.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{i.current=!0,h.current?.(a)})}),U.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=U.useMemo(()=>({...r,width:n}),[r,n]);return c.jsx("ink-static-render",{ref:o,style:p,children:i.current?null:t()})},Tn=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),$n=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${Tn(s)}`,Ke=(t,e,s)=>{const r=new Set(new Set(s.map(a=>a.target.target))),n=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),i=t.filter(a=>n.has(a)),l=s.length-i.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),u=i.length===1?`project ${i[0]}`:`${i.length} projects`;let p=`${d} ${h} for ${u}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},Cn={error:"red",info:"white",success:"green"},Ne=({children:t,title:e,variant:s})=>{const r=Cn[s];return c.jsxs(x,{flexDirection:"column",children:[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(f,{bold:!0,color:r,children:"•"}),c.jsx(f,{children:e})]}),t]})},Ht=({cached:t,failed:e,failedIds:s,projectNames:r,retriedIds:n,skippedIds:o,succeeded:i,targets:l,tasks:d,took:h})=>{const u=Ke(r,l,d),p=n??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(ct,{children:()=>c.jsx(Ne,{title:`Successfully ran ${u}`,variant:"success",children:c.jsxs(x,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(f,{children:[c.jsx(f,{color:"green",children:Mt})," ",i+t," tasks completed",a?c.jsx(f,{dimColor:!0,children:a}):null,c.jsx(f,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(x,{flexDirection:"column",marginTop:1,children:[c.jsxs(f,{children:[c.jsx(f,{color:"yellow",children:"↻"})," ",c.jsx(f,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(ct,{children:()=>c.jsx(Ne,{title:`Ran ${u}`,variant:"error",children:c.jsxs(x,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(x,{flexDirection:"column",children:[c.jsxs(f,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(f,{dimColor:!0,children:[" - ",a]},a)),c.jsx(f,{})]}),e>0&&c.jsxs(x,{flexDirection:"column",children:[c.jsxs(f,{children:[c.jsx(f,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"red",children:Ft})," ",a]},a)),c.jsx(f,{})]}),p.length>0&&c.jsxs(x,{flexDirection:"column",children:[c.jsxs(f,{children:[c.jsx(f,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(f,{})]}),c.jsx(f,{dimColor:!0,children:` Took ${h}`})]})})})};class Pe{#e;#r=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const r of e){const n=s.findIndex(o=>o.taskId===r.id);n!==-1&&(s[n]={...s[n],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:r,completed:n,failed:o,succeeded:i}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),n++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const u=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:n,failed:o,outputs:l,retriedIds:d,rows:s,running:u,selectedIndex:h,succeeded:i})}static#n=256*1024;addOutput(e,s){if(!s.trim())return;let r=(this.#e.outputs.get(e)??"")+s;r.length>Pe.#n&&(r=r.slice(-Pe.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let r=0;r<s.length;r++){const n=s[r];if(n.status==="running"){const o=this.#s.get(n.taskId);if(o){const i=process.hrtime(o),l=i[0]*1e3+i[1]/1e6;s[r]={...n,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const r=[...this.#e.pinnedTaskIds];r[e]=s,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],r=s.findIndex(l=>l.taskId===e);let{completed:n,failed:o,succeeded:i}=this.#e;if(r!==-1){const l=s[r].status;l==="failure"?(o=Math.max(0,o-1),n=Math.max(0,n-1)):l==="success"&&(i=Math.max(0,i-1),n=Math.max(0,n-1)),s[r]={...s[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:n,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#r)try{s()}catch{}}}const In=t=>en(t),En=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Rn=/^\s*at\s+/,Pn=t=>{const e=t.split(`
6
+ `);let s;for(let r=0;r<e.length;r++){const n=En.exec(e[r].trim());if(!n)continue;const o=[];for(let i=r+1;i<e.length&&i<=r+200;i++){const l=e[i];if(Rn.test(l))o.push(l.trim());else{if(o.length>0)break;if(l.trim()!=="")break}}if(o.length>0){const i=n.groups?.name??"Error",l=n.groups?.message??"";s={message:l,name:i,stack:`${i}: ${l}
7
7
  ${o.map(d=>` ${d}`).join(`
8
- `)}`}}}return s},Wt=t=>{if(t.startsWith("file://"))try{return pr(t)}catch{return t}return t},En=t=>!t.includes("node_modules")&&!t.startsWith("node:")&&!t.startsWith("internal/"),Rn=t=>{try{return jr(t)}catch{return}},Pn=(t,e)=>{if(!t.file||t.line===void 0)return;const s=Wt(t.file),r=ur(s)?s:Ze(e,s);if(!En(r)||!he(r))return;const i=Rn(r);if(i){const o=yr(i,{column:t.column===void 0?0:Math.max(0,t.column-1),line:t.line});if(o.source&&o.line!=null){const n=Ze(fr(r),o.source),d=xr(i,o.source)??(he(n)?we(n,"utf8"):void 0);if(d!==void 0)return{column:o.column==null?void 0:o.column+1,file:n,line:o.line,source:d}}}return{column:t.column,file:r,line:t.line,source:we(r,"utf8")}},ct=(t,e)=>{const s=hr(e,t);return s&&!s.startsWith("..")?s:t},Ht=(t,e)=>{if(!t?.trim())return t;try{const s=In(Tn(t));if(!s)return t;const r=new Error(s.message);r.name=s.name,r.stack=s.stack;const i=wr(r);if(i.length===0)return t;const o=e.color,n={dim:a=>o?et(a):a,head:a=>o?gr(Ae(a)):a,loc:a=>o?mr(a):a};let l,d;for(const a of i){const m=Pn(a,e.cwd);if(m){l=m,d=a;break}}const h=[n.head(`✖ ${s.name}${s.message?`: ${s.message}`:""}`)];if(l){const a=`${ct(l.file,e.cwd)}:${l.line}${l.column?`:${l.column}`:""}`;h.push(` ${n.loc(a)}`,""),h.push(vr(l.source,{start:{column:l.column,line:l.line}},{color:o?{gutter:et,marker:Ae,message:Ae}:void 0,linesAbove:2,linesBelow:3}))}const f=i.filter(a=>a!==d).slice(0,8).map(a=>{const m=a.methodName??"<anonymous>",w=a.file?`${ct(Wt(a.file),e.cwd)}${a.line?`:${a.line}`:""}`:"";return n.dim(` at ${m}${w?` (${w})`:""}`)});f.length>0&&h.push("",...f);const p=n.dim("─".repeat(40));return`${h.join(`
8
+ `)}`}}}return s},qt=t=>{if(t.startsWith("file://"))try{return vr(t)}catch{return t}return t},Mn=t=>!t.includes("node_modules")&&!t.startsWith("node:")&&!t.startsWith("internal/"),Fn=t=>{try{return Tr(t)}catch{return}},On=(t,e)=>{if(!t.file||t.line===void 0)return;const s=qt(t.file),r=mr(s)?s:et(e,s);if(!Mn(r)||!me(r))return;const n=Fn(r);if(n){const o=kr(n,{column:t.column===void 0?0:Math.max(0,t.column-1),line:t.line});if(o.source&&o.line!=null){const i=et(gr(r),o.source),d=br(n,o.source)??(me(i)?ye(i,"utf8"):void 0);if(d!==void 0)return{column:o.column==null?void 0:o.column+1,file:i,line:o.line,source:d}}}return{column:t.column,file:r,line:t.line,source:ye(r,"utf8")}},at=(t,e)=>{const s=wr(e,t);return s&&!s.startsWith("..")?s:t},Ut=(t,e)=>{if(!t?.trim())return t;try{const s=Pn(In(t));if(!s)return t;const r=new Error(s.message);r.name=s.name,r.stack=s.stack;const n=jr(r);if(n.length===0)return t;const o=e.color,i={dim:a=>o?tt(a):a,head:a=>o?xr(Le(a)):a,loc:a=>o?yr(a):a};let l,d;for(const a of n){const m=On(a,e.cwd);if(m){l=m,d=a;break}}const h=[i.head(`✖ ${s.name}${s.message?`: ${s.message}`:""}`)];if(l){const a=`${at(l.file,e.cwd)}:${l.line}${l.column?`:${l.column}`:""}`;h.push(` ${i.loc(a)}`,""),h.push(Sr(l.source,{start:{column:l.column,line:l.line}},{color:o?{gutter:tt,marker:Le,message:Le}:void 0,linesAbove:2,linesBelow:3}))}const u=n.filter(a=>a!==d).slice(0,8).map(a=>{const m=a.methodName??"<anonymous>",w=a.file?`${at(qt(a.file),e.cwd)}${a.line?`:${a.line}`:""}`:"";return i.dim(` at ${m}${w?` (${w})`:""}`)});u.length>0&&h.push("",...u);const p=i.dim("─".repeat(40));return`${h.join(`
9
9
  `)}
10
10
  ${p}
11
- ${t}`}catch{return t}},Mn={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},me=t=>Jr(t,Mn),ge=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",ve=t=>{switch(t){case"failure":return{color:"red",icon:Rt};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Et};case"skipped":return{color:"gray",icon:Fe};default:return{color:"gray",icon:"?"}}},xe=t=>{const{color:e,icon:s}=ve(t);return ce(K.createElement(u,{color:e},s),{columns:10}).trim()},Fn=t=>{const{color:e,icon:s}=ve(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return ce(K.createElement(u,null,K.createElement(u,{color:e},s)," ",K.createElement(u,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return ce(K.createElement(u,null,K.createElement(u,{dimColor:!0},s)," ",K.createElement(u,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return ce(K.createElement(u,{color:e},s),{columns:10}).trim()}},On=t=>t==="azure"||t==="buildkite"||t==="github"||t==="gitlab"||t==="off"?t:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",An=t=>{const e=t.replaceAll(/\W+/g,"_"),s=Sr("sha256").update(t).digest("hex").slice(0,6);return`${e}_${s}`},Ln=(t,e,s,r="auto")=>{const i=s.trim();if(!i)return;const o=`
12
- `,n=On(r);if(n==="github"){process.stdout.write(`::group::${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`::endgroup::${o}`);return}if(n==="gitlab"){const p=Math.floor(Date.now()/1e3),a=An(t),m=e==="failure"?"":"[collapsed=true]",w="\x1B[0K";process.stdout.write(`${w}section_start:${String(p)}:${a}${m}\r${w}${xe(e)} ${t}${o}`),process.stdout.write(i+o);const j=Math.floor(Date.now()/1e3);process.stdout.write(`${w}section_end:${String(j)}:${a}\r${w}${o}`);return}if(n==="buildkite"){const p=e==="failure"?"+++":"---";process.stdout.write(`${p} ${xe(e)} ${t}${o}`),process.stdout.write(i+o);return}if(n==="azure"){process.stdout.write(`##[group]${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`##[endgroup]${o}`);return}const l=process.stdout.columns||80,d=ce(K.createElement(u,{dimColor:!0},Fe.repeat(l)),{columns:l}).trim(),h=Fn(e),f=ce(K.createElement(u,{bold:!0},t),{columns:l}).trim();process.stdout.write(`${d}${o}`),process.stdout.write(`${h} ${f}${o}`),process.stdout.write(i+o),process.stdout.write(`${d}${o}`)},Dn=t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:ve(t),Bn=({autoScroll:t,focused:e,interactiveMode:s,showFullscreenHint:r,statusValue:i,supportsInteractive:o,taskId:n})=>{if(!n)return;if(s)return"Esc cancel | Enter send";const l=t?"":" PAUSED (f resume)",d=o?" i INPUT":"";return e&&i==="running"&&r?`⏎ FULLSCREEN${d} f FOLLOW${l}`:e&&i==="running"?`f FOLLOW${d}${l}`:e&&r?`<enter> full screen${l}`:e?l||void 0:"<tab> or <enter> to focus"},at=({autoScroll:t=!0,duration:e,focused:s,interactiveMode:r,output:i,scrollRef:o,showFullscreenHint:n,status:l,supportsInteractive:d=!0,taskId:h})=>{const f=l??"pending",{icon:p}=Dn(f),a=s?"bold":"single",m=f==="failure"?"red":f==="success"||ge(f)?s?"green":"gray":f==="running"?s?"white":"cyan":s?"white":"gray",w=h?`${p} ${h}`:void 0,j=e===void 0?void 0:me(e),M=Bn({autoScroll:t,focused:s,interactiveMode:r??!1,showFullscreenHint:n??!1,statusValue:f,supportsInteractive:d,taskId:h});if(!h)return c.jsxs(v,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c.jsx(u,{dimColor:!0,children:"Select a task to view output"}),c.jsx(u,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const x=[];if(i)for(const g of i.split(`
13
- `))x.push(g.endsWith("\r")?g.slice(0,-1):g);return!i&&(f==="running"||f==="pending")?c.jsx(v,{borderBottomTitle:M,borderColor:m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c.jsx(v,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c.jsx(u,{dimColor:!0,children:"Waiting for task output…"})})}):c.jsxs(v,{borderBottomTitle:M,borderColor:r?"yellow":m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,children:[c.jsx(v,{flexGrow:1,flexShrink:1,paddingY:1,children:c.jsx(It,{flexGrow:1,followOutput:t,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:c.jsx(u,{children:x.join(`
14
- `)})})}),r&&c.jsx(v,{flexShrink:0,justifyContent:"center",paddingX:1,children:c.jsx(u,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},_n={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},qt=t=>t==="ready"?"green":t==="crashed"||t==="failed"?"red":t==="starting"?"cyan":"gray",Nn=({status:t})=>t==="starting"?c.jsx(u,{color:"cyan",children:c.jsx(Mt,{type:"dots"})}):c.jsx(u,{bold:!0,color:qt(t),children:_n[t]}),Gn=({active:t,focused:e,state:s})=>{const r=e&&t,i=r?">":" ",o=s.status==="ready"?s.port?`running, port ${String(s.port)}`:"running":s.status==="failed"||s.status==="crashed"?s.errorMessage??"exited":s.lastLine??"booting…";return c.jsxs(v,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c.jsx(u,{children:i}),c.jsx(u,{children:" "}),c.jsx(v,{flexShrink:0,width:3,children:c.jsx(Nn,{status:s.status})}),c.jsx(v,{flexGrow:0,flexShrink:0,width:28,children:c.jsx(u,{bold:r,inverse:r,children:s.id})}),c.jsx(v,{flexGrow:1,flexShrink:1,overflow:"hidden",children:c.jsxs(u,{color:qt(s.status),dimColor:s.status!=="crashed"&&s.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Wn=({states:t})=>{const e=[];for(const r of t)r.status==="ready"&&e.push(r.id);const s=e.join(", ");return c.jsxs(v,{paddingX:1,children:[c.jsxs(u,{bold:!0,color:"green",children:["● ","Services"]}),c.jsxs(u,{children:[" ",String(e.length)," / ",String(t.length)," running"]}),s.length>0&&c.jsxs(u,{dimColor:!0,children:[" ",s]}),c.jsx(u,{dimColor:!0,children:" [Tab ↓]"})]})},Hn=({states:t})=>{const e=t.find(s=>s.status==="crashed"||s.status==="failed");return e?c.jsxs(v,{flexDirection:"column",paddingX:1,children:[c.jsxs(u,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((s,r)=>c.jsxs(u,{color:"red",dimColor:!0,children:[" ",s]},`crash-${String(r)}`))]}):c.jsx(c.Fragment,{})},qn=({activeIndex:t,focused:e,store:s})=>{const r=U.useSyncExternalStore(s.subscribe,s.getSnapshot),i=s.getIds();if(i.length===0)return c.jsx(c.Fragment,{});const o=i.map(f=>r.get(f)).filter(f=>f!==void 0),n=s.getDockState(),l=n==="crash"?"red":n==="ready"?"gray":e?"white":"cyan",d=n==="crash"?"Services (crashed)":n==="ready"?"Services":"Services (starting)",h=e?n==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return n==="ready"&&!e?c.jsx(v,{borderColor:l,borderStyle:"single",flexDirection:"row",flexShrink:0,children:c.jsx(Wn,{states:o})}):c.jsxs(v,{borderBottomTitle:h,borderColor:l,borderStyle:e?"bold":"single",borderTopTitle:d,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[n==="crash"&&c.jsx(Hn,{states:o}),o.map((f,p)=>c.jsx(Gn,{active:p===t,focused:e,state:f},f.id))]})},Vt=6,Ut=8,zt=12,Vn=t=>t==="running"||t==="pending"?Pt:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":Fe,lt=(t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"",dt=({compact:t,focused:e,isSelected:s,pinLabel:r,row:i})=>{const{persistent:o,status:n,taskId:l}=i,d=e&&s,h=d?">":" ",f=n==="running"&&o===!0;let p;if(f)p=c.jsx(u,{bold:!0,color:"green",children:" ● "});else if(n==="running")p=c.jsxs(u,{bold:!0,color:"white",children:[" ",c.jsx(Mt,{type:"dots"})," "]});else if(n==="pending")p=c.jsx(u,{bold:!0,color:"gray",children:" · "});else{const{color:m,icon:w}=ve(n);p=c.jsxs(u,{bold:!0,color:m,children:[" ",w," "]})}let a=Pt;return f?a="running":n!=="running"&&n!=="pending"?a=i.duration===void 0?Fe:me(i.duration):n==="running"&&i.elapsed!==void 0&&(a=me(i.elapsed)),c.jsxs(v,{children:[c.jsx(u,{children:h}),c.jsx(v,{width:Vt,children:p}),c.jsxs(v,{flexGrow:1,children:[c.jsx(u,{bold:d,inverse:d,children:l}),r?c.jsx(u,{dimColor:!0,children:` ${r}`}):null]}),!t&&c.jsx(v,{justifyContent:"flex-end",width:Ut,children:c.jsx(u,{dimColor:!ge(n),children:Vn(n)})}),!t&&c.jsx(v,{justifyContent:"flex-end",width:zt,children:c.jsx(u,{color:f?"green":void 0,dimColor:n==="pending"||f,children:a})})]})},ut=({compact:t,filterActive:e,filterText:s,focused:r,headerStatus:i,parallelSlots:o=3,pinnedTaskIds:n,rows:l,scrollRef:d,selectedIndex:h,title:f})=>{const p=i==="error"?"red":i==="success"?"green":r?"white":"gray",a=l[h]?.taskId,m=[];let w=0;for(const g of l)g.status==="running"?m.push(g):g.status==="pending"&&(w+=1);const j=Math.min(o,m.length+w),M=j>1,x=[];if(M)for(let g=0;g<j;g++){const k=m[g];k?x.push(c.jsx(dt,{compact:t,focused:r,isSelected:k.taskId===a,pinLabel:lt(k.taskId,n),row:k},`par-${k.taskId}`)):x.push(c.jsxs(v,{children:[c.jsx(u,{children:" "}),c.jsx(v,{width:Vt,children:c.jsx(u,{bold:!0,color:"gray",children:" · "})}),c.jsx(u,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(g)}`))}return c.jsxs(v,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c.jsxs(v,{flexShrink:0,paddingX:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{children:` ${f}`}),!t&&c.jsxs(v,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c.jsx(v,{justifyContent:"flex-end",width:Ut,children:c.jsx(u,{dimColor:!0,children:"Cache"})}),c.jsx(v,{justifyContent:"flex-end",width:zt,children:c.jsx(u,{dimColor:!0,children:"Duration"})})]})]}),c.jsx(It,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(g=>c.jsx(dt,{compact:t,focused:r,isSelected:g.taskId===a,pinLabel:lt(g.taskId,n),row:g},g.taskId))}),M&&c.jsx(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:x}),e&&c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/ "}),c.jsx(u,{children:s}),c.jsx(u,{inverse:!0,children:" "})]})]})},ft=40,ht=10,pt=100,Un=Object.freeze([]),zn=({autoExitSeconds:t,onRetryService:e,parallelSlots:s,projectNames:r,serviceDockStore:i,stdinRegistry:o,store:n,targets:l,tasks:d})=>{const{exit:h}=Ys(),{columns:f,rows:p}=Ks(),a=U.useSyncExternalStore(n.subscribe,n.getSnapshot),m=U.useCallback(I=>i?i.subscribe(I):()=>{},[i]);U.useSyncExternalStore(m,()=>i?i.getDockState():"ready");const w=i?i.getIds():Un,j=w.length>0,[M,x]=U.useState(0),[g,k]=U.useState(null),P=U.useSyncExternalStore(m,()=>g&&i?i.getState(g):void 0),[C,y]=U.useState(!1),E=U.useRef(null),R=U.useRef(null),$=U.useRef(null),[O,T]=U.useState(!1),[b,B]=U.useState(!0),D=U.useRef({list:0,splitList:0,splitOutput:0}),N=U.useCallback(()=>{a.viewMode==="list"?D.current.list=R.current?.getScrollOffset()??0:a.viewMode==="split"&&(D.current.splitList=R.current?.getScrollOffset()??0,D.current.splitOutput=$.current?.getScrollOffset()??0)},[a.viewMode]),A=U.useCallback(I=>{setTimeout(()=>{if(I==="list"){const S=D.current.list;R.current?.scrollTo(S)}else if(I==="split"){const S=D.current.splitList;S>0?R.current?.scrollTo(S):R.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),$.current?.scrollTo(D.current.splitOutput)}},0)},[n]),L=U.useRef(!1);U.useEffect(()=>{a.done&&!L.current&&(L.current=!0,t>0&&a.failed===0&&T(!0)),!a.done&&L.current&&(L.current=!1,T(!1))},[a.done,a.failed,t]);const G=U.useMemo(()=>{const I=w.length>0?new Set(w):null,S=a.filterText?a.filterText.toLowerCase():null,F=[];for(const ee of a.rows)I?.has(ee.taskId)||a.statusFilter==="failed"&&ee.status!=="failure"||a.statusFilter==="running"&&ee.status!=="running"&&ee.status!=="pending"||a.statusFilter==="passed"&&ee.status!=="success"&&!ge(ee.status)||S&&!ee.taskId.toLowerCase().includes(S)||F.push(ee);return F},[a.rows,a.filterText,a.statusFilter,w]),W=(G[a.selectedIndex]??null)?.taskId??null,X=g?null:a.pinnedTaskIds[0]??W,H=X?a.rows.find(I=>I.taskId===X):null,Q=P??null,J=g?(Q?.tailLines??[]).join(`
15
- `):X?a.outputs.get(X)??"":"",te=U.useMemo(()=>H?.status==="failure"&&J?Ht(J,{color:!process.env.NO_COLOR,cwd:process.cwd()}):J,[H?.status,J]),re=g??X,_=g?Q?.status==="crashed"||Q?.status==="failed"?"failure":"running":H?.status,z=Ye(r,l,d),q=a.done?`Completed ${z} (${me((a.endTime??Date.now())-a.startTime)})`:`Running ${z}...`,oe=a.done?a.failed>0?"error":"success":"running",ae=U.useCallback(I=>{R.current?.scrollTo(Math.max(0,I-2))},[]);if(U.useEffect(()=>{a.interactiveMode&&H?.status!=="running"&&n.setInteractiveMode(!1)},[a.interactiveMode,H?.status,n]),U.useEffect(()=>{if(!X)return;let I=f;a.viewMode==="split"&&f>=pt?I=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(I=f-2);const S=Math.max(1,p-4);o.get(X)?.resize?.(I,S)},[f,p,a.viewMode,X]),Je((I,S)=>{if(S.escape){n.setInteractiveMode(!1);return}if(!X)return;const F=o.get(X);if(!F){n.setInteractiveMode(!1);return}if(S.return)F.write("\r");else if(S.upArrow)F.write("\x1B[A");else if(S.downArrow)F.write("\x1B[B");else if(S.rightArrow)F.write("\x1B[C");else if(S.leftArrow)F.write("\x1B[D");else if(S.backspace)F.write("");else if(S.delete)F.write("\x1B[3~");else if(S.tab)F.write(" ");else if(S.home)F.write("\x1B[H");else if(S.end)F.write("\x1B[F");else if(S.pageUp)F.write("\x1B[5~");else if(S.pageDown)F.write("\x1B[6~");else if(S.ctrl&&I){const ee=I.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&F.write(String.fromCodePoint(ee-64))}else I&&F.write(I)},{isActive:a.interactiveMode}),Je((I,S)=>{if(I==="c"&&S.ctrl){h();return}if(!O){if(C){S.escape||I==="?"?y(!1):I==="q"?(y(!1),T(!0)):S.downArrow||I==="j"?E.current?.scrollBy(1):S.upArrow||I==="k"?E.current?.scrollBy(-1):S.pageDown?E.current?.scrollBy(5):S.pageUp?E.current?.scrollBy(-5):S.home?E.current?.scrollToTop():S.end&&E.current?.scrollToBottom();return}if(I==="?"){y(!0);return}if(I==="q"){T(!0);return}if(I==="r"&&a.done){n.requestRerun();return}if(I==="R"&&a.done){const F=G[a.selectedIndex];F?.status==="failure"&&n.requestRetry(F.taskId);return}if(I==="F"&&!a.filterActive){const F=["all","failed","running","passed"],ee=F.indexOf(a.statusFilter);n.setStatusFilter(F[(ee+1)%F.length]);return}if(a.filterActive){if(S.escape){n.setFilterActive(!1);return}if(S.return){n.setFilterActive(!1);return}if(S.backspace){n.setFilter(a.filterText.slice(0,-1));return}if(I&&!S.ctrl&&!S.meta){n.setFilter(a.filterText+I);return}return}if(I==="i"&&H?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(S.escape){n.setViewMode("split"),A("split");return}if(I==="f"){const F=!b;B(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){B(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){B(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){B(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){B(!1),$.current?.scrollBy(-12);return}if(S.home){B(!1),$.current?.scrollToTop();return}if(S.end){B(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&j&&i){if(S.tab){k(null),n.setFocusedPanel("tasks");return}if(S.escape){n.setFocusedPanel("tasks"),k(null),a.viewMode==="split"&&(n.setViewMode("list"),A("list"));return}if(S.downArrow||I==="j"){x(F=>Math.min(F+1,w.length-1));return}if(S.upArrow||I==="k"){x(F=>Math.max(F-1,0));return}if(S.return){const F=w[M];F&&(k(F),B(!0),N(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split"));return}if((I==="r"||I==="R")&&e){const F=w[M],ee=F?i.getState(F)?.status:void 0;if(F&&(ee==="crashed"||ee==="failed")){const be=e(F);be instanceof Promise&&be.catch(()=>{})}return}return}if(a.viewMode==="split"){if(S.tab){a.focusedPanel==="tasks"?n.setFocusedPanel("output"):j?n.setFocusedPanel("dock"):(k(null),n.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(S.escape){if(g&&j){k(null),n.setViewMode("list"),n.setFocusedPanel("dock"),A("list");return}k(null),n.setFocusedPanel("tasks");return}if(S.return){N(),n.setViewMode("fullscreen");return}if(I==="f"){const F=!b;B(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){B(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){B(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){B(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){B(!1),$.current?.scrollBy(-12);return}if(S.home){B(!1),$.current?.scrollToTop();return}if(S.end){B(!0),$.current?.scrollToBottom();return}return}if(S.escape){n.setViewMode("list"),A("list");return}if(S.return){n.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(S.tab&&a.viewMode==="list"&&j){n.setFocusedPanel("dock");return}if(S.downArrow||I==="j"){const F=Math.min(a.selectedIndex+1,Math.max(0,G.length-1));n.setSelectedIndex(F),ae(F);return}if(S.upArrow||I==="k"){const F=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(F),ae(F);return}if(S.return&&a.viewMode==="list"){B(!0),N(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split");return}if(I==="/"){n.setFilterActive(!0);return}if(I==="1"&&W){n.pinTask(0,W);return}if(I==="2"&&W){n.pinTask(1,W);return}if(I==="0"){n.clearPins();return}S.escape&&a.filterText&&n.setFilter("")}}},{isActive:!a.interactiveMode}),f<ft||p<ht)return c.jsx(v,{alignItems:"center",height:p,justifyContent:"center",width:f,children:c.jsxs(u,{color:"yellow",children:["Terminal too small (",f,"x",p,"). Minimum:"," ",ft,"x",ht]})});const de=c.jsxs(v,{gap:1,children:[a.succeeded>0&&c.jsxs(u,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(u,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(u,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(u,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(u,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(u,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let Y;if(a.viewMode==="fullscreen")Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(u,{dimColor:!0,children:"PAGE"})]},"page"),...H?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const I=G[a.selectedIndex]?.status==="failure";Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"r"}),c.jsx(u,{dimColor:!0,children:"RERUN"})]},"r"),...I?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"R"}),c.jsx(u,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),...H?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?")]:Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Z=c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(v,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:Y}),c.jsx(v,{flexShrink:0,paddingX:1,children:de})]}),se=c.jsxs(Xs,{backgroundColor:"#1e1e1e",footer:c.jsxs(u,{dimColor:!0,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(u,{bold:!0,color:"white",children:"?"}),"/",c.jsx(u,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:E,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Move up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(u,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(u,{dimColor:!0,children:" Back / close"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(u,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(u,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(u,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(u,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(u,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(u,{dimColor:!0,children:"/"}),c.jsx(u,{bold:!0,color:"white",children:"2"}),c.jsx(u,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(u,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(u,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(u,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(u,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(u,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(u,{dimColor:!0,children:" Page up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(u,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(u,{dimColor:!0,children:" Top"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(u,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(u,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(u,{dimColor:!0,children:" Quit"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(u,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ie=c.jsx(Js,{autoExitSeconds:t>0?t:3,onCancel:()=>{T(!1)},visible:O}),ue=j&&i?c.jsx(qn,{activeIndex:M,focused:a.focusedPanel==="dock",store:i}):null;if(a.viewMode==="fullscreen")return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(at,{autoScroll:b,duration:H?.duration??H?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:te,scrollRef:$,status:_,supportsInteractive:!g,taskId:re})}),ue,Z,ie,se]});if(a.viewMode==="split"){const I=f>=pt,S=c.jsx(ut,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:G,scrollRef:R,selectedIndex:a.selectedIndex,title:q}),F=c.jsx(at,{autoScroll:b,duration:H?.duration??H?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:te,scrollRef:$,showFullscreenHint:!0,status:_,supportsInteractive:!g,taskId:re});if(I){const be=Math.floor(f*.4);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsxs(v,{flexDirection:"row",flexGrow:1,children:[c.jsx(v,{width:be,children:S}),c.jsx(v,{flexGrow:1,children:F})]}),ue,Z,ie,se]})}const ee=Math.floor(p*.45);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{height:ee,children:S}),c.jsx(v,{flexGrow:1,children:F}),ue,Z,ie,se]})}return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(ut,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:G,scrollRef:R,selectedIndex:a.selectedIndex,title:q})}),ue,Z,ie,se]})},Yn=t=>t==="quiet"?"quiet":"normal",Kn=(t,e)=>typeof t=="string"?Yn(t.toLowerCase()):e===!0?"quiet":"normal",Ne=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Yt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class Xn{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Ye(this.#e,this.#r,this.#s)}`,r=ce(K.createElement(_e,{title:s,variant:"info"}),{columns:e});process.stdout.write(r);const i=this.#s[0],o=i?.overrides?Object.entries(i.overrides).filter(([n])=>n!=="command"):[];if(o.length>0){process.stdout.write(`
11
+ ${t}`}catch{return t}},An={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},we=t=>an(t,An),Ln={chunkCodeUnits:32*1024,now:Date.now,stallDropMs:3e4,stallRerouteMs:3e4,stallWarnMs:1e4},Dn=(t,e)=>{if(t.length<=e)return[t];const s=[];let r=0;for(;r<t.length;){let n=Math.min(r+e,t.length);if(n<t.length){const o=t.lastIndexOf(`
12
+ `,n-1);o>=r&&(n=o+1),n>r&&(t.codePointAt(n-1)??0)>65535&&(n-=1)}s.push(t.slice(r,n)),r=n}return s},Bn=(t,e,s={})=>{const r={...Ln,...s},n=Math.min(250,Math.max(10,Math.floor(r.stallWarnMs/4))),o=[],i=[],l=new Set;let d="stdout",h=!1,u=!1,p=!1,a=0,m,w;const j=()=>o.length>0||u,E=k=>{try{e.write(`${k}
13
+ `)}catch{}},y=()=>{const k=i.splice(0);for(const O of k)O()},g=()=>{if(d==="dropped"||!j()){m&&(clearTimeout(m),m=void 0);return}m||(m=setTimeout($,n),m.unref?.())},S=k=>{p=!0,E(`vis: stdout stalled for ${Math.round(k/1e3)}s — dropping the wedged stdout write and rerouting the remaining output to stderr so the run can still finish; at most one ${r.chunkCodeUnits}-unit chunk of stdout output is lost.`);try{t.destroy?.()}catch{}d="stderr",a=r.now(),w?.()},F=()=>{try{e.destroy?.()}catch{}d="dropped",o.length=0,a=r.now(),w?.(),y(),g()},C=(k,O)=>{if(k===t&&d==="stdout"){p=!0;const B=O?.code;E(`vis: stdout writes failed (${B??O?.message??"stream closed or errored"}) — rerouting the remaining output to stderr.`),d="stderr",a=r.now(),w?.();return}k===e&&d==="stderr"&&F()},v=()=>{l.has(t)||(t.on("error",k=>{C(t,k)}),t.on("close",()=>{C(t)}),l.add(t)),l.has(e)||(e.on("error",k=>{C(e,k)}),e.on("close",()=>{C(e)}),l.add(e))},L=k=>new Promise(O=>{const B=G=>{k.off("drain",D),k.off("error",_),k.off("close",W),w===q&&(w=void 0),u=!1,O(G)},D=()=>{B("drain")},_=()=>{B("error")},W=()=>{B("close")},q=()=>{B("abandoned")};u=!0,w=q,k.once("drain",D),k.once("error",_),k.once("close",W)}),P=async()=>{if(!h){h=!0;try{for(;d!=="dropped"&&o.length>0;){const k=d==="stderr"?e:t,O=o[0],B=k.write(O.text);if(o.shift(),B){a=r.now(),p=!1;continue}await L(k)==="drain"&&(a=r.now(),p=!1)}}catch(k){C(d==="stderr"?e:t,k instanceof Error?k:void 0)}finally{h=!1,g(),y()}}},$=()=>{if(m=void 0,d==="dropped"||!j()){y();return}const k=r.now()-a;if(d==="stdout"){if(k>=r.stallRerouteMs)S(k);else if(k>=r.stallWarnMs&&!p){p=!0;const{pendingChunks:O,pendingCodeUnits:B}=M(),D=o.at(0)?.label;E(`vis: stdout writes stalled for ${Math.round(k/1e3)}s (${O} chunk(s), ~${Math.round(B/1024)} KB pending${D?` for "${D}"`:""}); waiting for the log reader to drain.`)}}else k>=r.stallDropMs&&F();g(),o.length>0&&P()},M=()=>({channel:d,pendingChunks:o.length,pendingCodeUnits:o.reduce((k,O)=>k+O.text.length,0)});return{flush:()=>new Promise(k=>{if(d==="dropped"||!j()){k();return}i.push(k),g()}),status:M,write:(k,O)=>{if(!(d==="dropped"||k.length===0)){j()||(a=r.now());for(const B of Dn(k,r.chunkCodeUnits))o.push({label:O,text:B});v(),P(),g()}}}};let lt;const _n=()=>(lt??=Bn(process.stdout,process.stderr),lt),se=(t,e)=>{_n().write(t,e)},ve=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",xe=t=>{switch(t){case"failure":return{color:"red",icon:Ft};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Mt};case"skipped":return{color:"gray",icon:Oe};default:return{color:"gray",icon:"?"}}},Se=t=>{const{color:e,icon:s}=xe(t);return le(X.createElement(f,{color:e},s),{columns:10}).trim()},Nn=t=>{const{color:e,icon:s}=xe(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return le(X.createElement(f,null,X.createElement(f,{color:e},s)," ",X.createElement(f,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return le(X.createElement(f,null,X.createElement(f,{dimColor:!0},s)," ",X.createElement(f,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return le(X.createElement(f,{color:e},s),{columns:10}).trim()}},Wn=t=>t==="azure"||t==="buildkite"||t==="github"||t==="gitlab"||t==="off"?t:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",Gn=t=>{const e=t.replaceAll(/\W+/g,"_"),s=$r("sha256").update(t).digest("hex").slice(0,6);return`${e}_${s}`},Hn=(t,e,s,r="auto")=>{const n=s.trim();if(!n)return;const o=`
14
+ `,i=Wn(r);if(i==="github"){se(`::group::${Se(e)} ${t}${o}`,t),se(n+o,t),se(`::endgroup::${o}`,t);return}if(i==="gitlab"){const p=Math.floor(Date.now()/1e3),a=Gn(t),m=e==="failure"?"":"[collapsed=true]",w="\x1B[0K";se(`${w}section_start:${String(p)}:${a}${m}\r${w}${Se(e)} ${t}${o}`,t),se(n+o,t);const j=Math.floor(Date.now()/1e3);se(`${w}section_end:${String(j)}:${a}\r${w}${o}`,t);return}if(i==="buildkite"){se(`${e==="failure"?"+++":"---"} ${Se(e)} ${t}${o}`,t),se(n+o,t);return}if(i==="azure"){se(`##[group]${Se(e)} ${t}${o}`,t),se(n+o,t),se(`##[endgroup]${o}`,t);return}const l=process.stdout.columns||80,d=le(X.createElement(f,{dimColor:!0},Oe.repeat(l)),{columns:l}).trim(),h=Nn(e),u=le(X.createElement(f,{bold:!0},t),{columns:l}).trim();se(`${d}${o}`,t),se(`${h} ${u}${o}`,t),se(n+o,t),se(`${d}${o}`,t)},qn=t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:xe(t),Un=({autoScroll:t,focused:e,interactiveMode:s,showFullscreenHint:r,statusValue:n,supportsInteractive:o,taskId:i})=>{if(!i)return;if(s)return"Esc cancel | Enter send";const l=t?"":" PAUSED (f resume)",d=o?" i INPUT":"";return e&&n==="running"&&r?`⏎ FULLSCREEN${d} f FOLLOW${l}`:e&&n==="running"?`f FOLLOW${d}${l}`:e&&r?`<enter> full screen${l}`:e?l||void 0:"<tab> or <enter> to focus"},dt=({autoScroll:t=!0,duration:e,focused:s,interactiveMode:r,output:n,scrollRef:o,showFullscreenHint:i,status:l,supportsInteractive:d=!0,taskId:h})=>{const u=l??"pending",{icon:p}=qn(u),a=s?"bold":"single",m=u==="failure"?"red":u==="success"||ve(u)?s?"green":"gray":u==="running"?s?"white":"cyan":s?"white":"gray",w=h?`${p} ${h}`:void 0,j=e===void 0?void 0:we(e),E=Un({autoScroll:t,focused:s,interactiveMode:r??!1,showFullscreenHint:i??!1,statusValue:u,supportsInteractive:d,taskId:h});if(!h)return c.jsxs(x,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c.jsx(f,{dimColor:!0,children:"Select a task to view output"}),c.jsx(f,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const y=[];if(n)for(const g of n.split(`
15
+ `))y.push(g.endsWith("\r")?g.slice(0,-1):g);return!n&&(u==="running"||u==="pending")?c.jsx(x,{borderBottomTitle:E,borderColor:m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c.jsx(x,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c.jsx(f,{dimColor:!0,children:"Waiting for task output…"})})}):c.jsxs(x,{borderBottomTitle:E,borderColor:r?"yellow":m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,children:[c.jsx(x,{flexGrow:1,flexShrink:1,paddingY:1,children:c.jsx(Ct,{flexGrow:1,followOutput:t,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:c.jsx(f,{children:y.join(`
16
+ `)})})}),r&&c.jsx(x,{flexShrink:0,justifyContent:"center",paddingX:1,children:c.jsx(f,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},Vn={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Vt=t=>t==="ready"?"green":t==="crashed"||t==="failed"?"red":t==="starting"?"cyan":"gray",zn=({status:t})=>t==="starting"?c.jsx(f,{color:"cyan",children:c.jsx(At,{type:"dots"})}):c.jsx(f,{bold:!0,color:Vt(t),children:Vn[t]}),Yn=({active:t,focused:e,state:s})=>{const r=e&&t,n=r?">":" ",o=s.status==="ready"?s.port?`running, port ${String(s.port)}`:"running":s.status==="failed"||s.status==="crashed"?s.errorMessage??"exited":s.lastLine??"booting…";return c.jsxs(x,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c.jsx(f,{children:n}),c.jsx(f,{children:" "}),c.jsx(x,{flexShrink:0,width:3,children:c.jsx(zn,{status:s.status})}),c.jsx(x,{flexGrow:0,flexShrink:0,width:28,children:c.jsx(f,{bold:r,inverse:r,children:s.id})}),c.jsx(x,{flexGrow:1,flexShrink:1,overflow:"hidden",children:c.jsxs(f,{color:Vt(s.status),dimColor:s.status!=="crashed"&&s.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Kn=({states:t})=>{const e=[];for(const r of t)r.status==="ready"&&e.push(r.id);const s=e.join(", ");return c.jsxs(x,{paddingX:1,children:[c.jsxs(f,{bold:!0,color:"green",children:["● ","Services"]}),c.jsxs(f,{children:[" ",String(e.length)," / ",String(t.length)," running"]}),s.length>0&&c.jsxs(f,{dimColor:!0,children:[" ",s]}),c.jsx(f,{dimColor:!0,children:" [Tab ↓]"})]})},Xn=({states:t})=>{const e=t.find(s=>s.status==="crashed"||s.status==="failed");return e?c.jsxs(x,{flexDirection:"column",paddingX:1,children:[c.jsxs(f,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((s,r)=>c.jsxs(f,{color:"red",dimColor:!0,children:[" ",s]},`crash-${String(r)}`))]}):c.jsx(c.Fragment,{})},Jn=({activeIndex:t,focused:e,store:s})=>{const r=U.useSyncExternalStore(s.subscribe,s.getSnapshot),n=s.getIds();if(n.length===0)return c.jsx(c.Fragment,{});const o=n.map(u=>r.get(u)).filter(u=>u!==void 0),i=s.getDockState(),l=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",d=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",h=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?c.jsx(x,{borderColor:l,borderStyle:"single",flexDirection:"row",flexShrink:0,children:c.jsx(Kn,{states:o})}):c.jsxs(x,{borderBottomTitle:h,borderColor:l,borderStyle:e?"bold":"single",borderTopTitle:d,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&c.jsx(Xn,{states:o}),o.map((u,p)=>c.jsx(Yn,{active:p===t,focused:e,state:u},u.id))]})},zt=6,Yt=8,Kt=12,Qn=t=>t==="running"||t==="pending"?Ot:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":Oe,ut=(t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"",ft=({compact:t,focused:e,isSelected:s,pinLabel:r,row:n})=>{const{persistent:o,status:i,taskId:l}=n,d=e&&s,h=d?">":" ",u=i==="running"&&o===!0;let p;if(u)p=c.jsx(f,{bold:!0,color:"green",children:" ● "});else if(i==="running")p=c.jsxs(f,{bold:!0,color:"white",children:[" ",c.jsx(At,{type:"dots"})," "]});else if(i==="pending")p=c.jsx(f,{bold:!0,color:"gray",children:" · "});else{const{color:m,icon:w}=xe(i);p=c.jsxs(f,{bold:!0,color:m,children:[" ",w," "]})}let a=Ot;return u?a="running":i!=="running"&&i!=="pending"?a=n.duration===void 0?Oe:we(n.duration):i==="running"&&n.elapsed!==void 0&&(a=we(n.elapsed)),c.jsxs(x,{children:[c.jsx(f,{children:h}),c.jsx(x,{width:zt,children:p}),c.jsxs(x,{flexGrow:1,children:[c.jsx(f,{bold:d,inverse:d,children:l}),r?c.jsx(f,{dimColor:!0,children:` ${r}`}):null]}),!t&&c.jsx(x,{justifyContent:"flex-end",width:Yt,children:c.jsx(f,{dimColor:!ve(i),children:Qn(i)})}),!t&&c.jsx(x,{justifyContent:"flex-end",width:Kt,children:c.jsx(f,{color:u?"green":void 0,dimColor:i==="pending"||u,children:a})})]})},ht=({compact:t,filterActive:e,filterText:s,focused:r,headerStatus:n,parallelSlots:o=3,pinnedTaskIds:i,rows:l,scrollRef:d,selectedIndex:h,title:u})=>{const p=n==="error"?"red":n==="success"?"green":r?"white":"gray",a=l[h]?.taskId,m=[];let w=0;for(const g of l)g.status==="running"?m.push(g):g.status==="pending"&&(w+=1);const j=Math.min(o,m.length+w),E=j>1,y=[];if(E)for(let g=0;g<j;g++){const S=m[g];S?y.push(c.jsx(ft,{compact:t,focused:r,isSelected:S.taskId===a,pinLabel:ut(S.taskId,i),row:S},`par-${S.taskId}`)):y.push(c.jsxs(x,{children:[c.jsx(f,{children:" "}),c.jsx(x,{width:zt,children:c.jsx(f,{bold:!0,color:"gray",children:" · "})}),c.jsx(f,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(g)}`))}return c.jsxs(x,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c.jsxs(x,{flexShrink:0,paddingX:1,children:[c.jsx(f,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(f,{children:` ${u}`}),!t&&c.jsxs(x,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c.jsx(x,{justifyContent:"flex-end",width:Yt,children:c.jsx(f,{dimColor:!0,children:"Cache"})}),c.jsx(x,{justifyContent:"flex-end",width:Kt,children:c.jsx(f,{dimColor:!0,children:"Duration"})})]})]}),c.jsx(Ct,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(g=>c.jsx(ft,{compact:t,focused:r,isSelected:g.taskId===a,pinLabel:ut(g.taskId,i),row:g},g.taskId))}),E&&c.jsx(x,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:y}),e&&c.jsxs(x,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c.jsx(f,{bold:!0,color:"white",children:"/ "}),c.jsx(f,{children:s}),c.jsx(f,{inverse:!0,children:" "})]})]})},pt=40,mt=10,gt=100,Zn=Object.freeze([]),ei=({autoExitSeconds:t,onRetryService:e,parallelSlots:s,projectNames:r,serviceDockStore:n,stdinRegistry:o,store:i,targets:l,tasks:d})=>{const{exit:h}=ks(),{columns:u,rows:p}=bs(),a=U.useSyncExternalStore(i.subscribe,i.getSnapshot),m=U.useCallback(R=>n?n.subscribe(R):()=>{},[n]);U.useSyncExternalStore(m,()=>n?n.getDockState():"ready");const w=n?n.getIds():Zn,j=w.length>0,[E,y]=U.useState(0),[g,S]=U.useState(null),F=U.useSyncExternalStore(m,()=>g&&n?n.getState(g):void 0),[C,v]=U.useState(!1),L=U.useRef(null),P=U.useRef(null),$=U.useRef(null),[M,T]=U.useState(!1),[I,k]=U.useState(!0),O=U.useRef({list:0,splitList:0,splitOutput:0}),B=U.useCallback(()=>{a.viewMode==="list"?O.current.list=P.current?.getScrollOffset()??0:a.viewMode==="split"&&(O.current.splitList=P.current?.getScrollOffset()??0,O.current.splitOutput=$.current?.getScrollOffset()??0)},[a.viewMode]),D=U.useCallback(R=>{setTimeout(()=>{if(R==="list"){const b=O.current.list;P.current?.scrollTo(b)}else if(R==="split"){const b=O.current.splitList;b>0?P.current?.scrollTo(b):P.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),$.current?.scrollTo(O.current.splitOutput)}},0)},[i]),_=U.useRef(!1);U.useEffect(()=>{a.done&&!_.current&&(_.current=!0,t>0&&a.failed===0&&T(!0)),!a.done&&_.current&&(_.current=!1,T(!1))},[a.done,a.failed,t]);const W=U.useMemo(()=>{const R=w.length>0?new Set(w):null,b=a.filterText?a.filterText.toLowerCase():null,A=[];for(const Q of a.rows)R?.has(Q.taskId)||a.statusFilter==="failed"&&Q.status!=="failure"||a.statusFilter==="running"&&Q.status!=="running"&&Q.status!=="pending"||a.statusFilter==="passed"&&Q.status!=="success"&&!ve(Q.status)||b&&!Q.taskId.toLowerCase().includes(b)||A.push(Q);return A},[a.rows,a.filterText,a.statusFilter,w]),G=(W[a.selectedIndex]??null)?.taskId??null,J=g?null:a.pinnedTaskIds[0]??G,z=J?a.rows.find(R=>R.taskId===J):null,Z=F??null,te=g?(Z?.tailLines??[]).join(`
17
+ `):J?a.outputs.get(J)??"":"",K=U.useMemo(()=>z?.status==="failure"&&te?Ut(te,{color:!process.env.NO_COLOR,cwd:process.cwd()}):te,[z?.status,te]),N=g??J,H=g?Z?.status==="crashed"||Z?.status==="failed"?"failure":"running":z?.status,V=Ke(r,l,d),re=a.done?`Completed ${V} (${we((a.endTime??Date.now())-a.startTime)})`:`Running ${V}...`,oe=a.done?a.failed>0?"error":"success":"running",fe=U.useCallback(R=>{P.current?.scrollTo(Math.max(0,R-2))},[]);if(U.useEffect(()=>{a.interactiveMode&&z?.status!=="running"&&i.setInteractiveMode(!1)},[a.interactiveMode,z?.status,i]),U.useEffect(()=>{if(!J)return;let R=u;a.viewMode==="split"&&u>=gt?R=u-Math.floor(u*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(R=u-2);const b=Math.max(1,p-4);o.get(J)?.resize?.(R,b)},[u,p,a.viewMode,J]),Qe((R,b)=>{if(b.escape){i.setInteractiveMode(!1);return}if(!J)return;const A=o.get(J);if(!A){i.setInteractiveMode(!1);return}if(b.return)A.write("\r");else if(b.upArrow)A.write("\x1B[A");else if(b.downArrow)A.write("\x1B[B");else if(b.rightArrow)A.write("\x1B[C");else if(b.leftArrow)A.write("\x1B[D");else if(b.backspace)A.write("");else if(b.delete)A.write("\x1B[3~");else if(b.tab)A.write(" ");else if(b.home)A.write("\x1B[H");else if(b.end)A.write("\x1B[F");else if(b.pageUp)A.write("\x1B[5~");else if(b.pageDown)A.write("\x1B[6~");else if(b.ctrl&&R){const Q=R.toUpperCase().codePointAt(0);Q!==void 0&&Q>=65&&Q<=90&&A.write(String.fromCodePoint(Q-64))}else R&&A.write(R)},{isActive:a.interactiveMode}),Qe((R,b)=>{if(R==="c"&&b.ctrl){h();return}if(!M){if(C){b.escape||R==="?"?v(!1):R==="q"?(v(!1),T(!0)):b.downArrow||R==="j"?L.current?.scrollBy(1):b.upArrow||R==="k"?L.current?.scrollBy(-1):b.pageDown?L.current?.scrollBy(5):b.pageUp?L.current?.scrollBy(-5):b.home?L.current?.scrollToTop():b.end&&L.current?.scrollToBottom();return}if(R==="?"){v(!0);return}if(R==="q"){T(!0);return}if(R==="r"&&a.done){i.requestRerun();return}if(R==="R"&&a.done){const A=W[a.selectedIndex];A?.status==="failure"&&i.requestRetry(A.taskId);return}if(R==="F"&&!a.filterActive){const A=["all","failed","running","passed"],Q=A.indexOf(a.statusFilter);i.setStatusFilter(A[(Q+1)%A.length]);return}if(a.filterActive){if(b.escape){i.setFilterActive(!1);return}if(b.return){i.setFilterActive(!1);return}if(b.backspace){i.setFilter(a.filterText.slice(0,-1));return}if(R&&!b.ctrl&&!b.meta){i.setFilter(a.filterText+R);return}return}if(R==="i"&&z?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(b.escape){i.setViewMode("split"),D("split");return}if(R==="f"){const A=!I;k(A),A&&$.current?.scrollToBottom();return}if(b.downArrow||R==="j"){k(!1),$.current?.scrollBy(1);return}if(b.upArrow||R==="k"){k(!1),$.current?.scrollBy(-1);return}if(b.pageDown||b.ctrl&&R==="d"){k(!1),$.current?.scrollBy(12);return}if(b.pageUp||b.ctrl&&R==="u"){k(!1),$.current?.scrollBy(-12);return}if(b.home){k(!1),$.current?.scrollToTop();return}if(b.end){k(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&j&&n){if(b.tab){S(null),i.setFocusedPanel("tasks");return}if(b.escape){i.setFocusedPanel("tasks"),S(null),a.viewMode==="split"&&(i.setViewMode("list"),D("list"));return}if(b.downArrow||R==="j"){y(A=>Math.min(A+1,w.length-1));return}if(b.upArrow||R==="k"){y(A=>Math.max(A-1,0));return}if(b.return){const A=w[E];A&&(S(A),k(!0),B(),O.current.splitList=0,O.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),D("split"));return}if((R==="r"||R==="R")&&e){const A=w[E],Q=A?n.getState(A)?.status:void 0;if(A&&(Q==="crashed"||Q==="failed")){const ae=e(A);ae instanceof Promise&&ae.catch(()=>{})}return}return}if(a.viewMode==="split"){if(b.tab){a.focusedPanel==="tasks"?i.setFocusedPanel("output"):j?i.setFocusedPanel("dock"):(S(null),i.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(b.escape){if(g&&j){S(null),i.setViewMode("list"),i.setFocusedPanel("dock"),D("list");return}S(null),i.setFocusedPanel("tasks");return}if(b.return){B(),i.setViewMode("fullscreen");return}if(R==="f"){const A=!I;k(A),A&&$.current?.scrollToBottom();return}if(b.downArrow||R==="j"){k(!1),$.current?.scrollBy(1);return}if(b.upArrow||R==="k"){k(!1),$.current?.scrollBy(-1);return}if(b.pageDown||b.ctrl&&R==="d"){k(!1),$.current?.scrollBy(12);return}if(b.pageUp||b.ctrl&&R==="u"){k(!1),$.current?.scrollBy(-12);return}if(b.home){k(!1),$.current?.scrollToTop();return}if(b.end){k(!0),$.current?.scrollToBottom();return}return}if(b.escape){i.setViewMode("list"),D("list");return}if(b.return){i.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(b.tab&&a.viewMode==="list"&&j){i.setFocusedPanel("dock");return}if(b.downArrow||R==="j"){const A=Math.min(a.selectedIndex+1,Math.max(0,W.length-1));i.setSelectedIndex(A),fe(A);return}if(b.upArrow||R==="k"){const A=Math.max(a.selectedIndex-1,0);i.setSelectedIndex(A),fe(A);return}if(b.return&&a.viewMode==="list"){k(!0),B(),O.current.splitList=0,O.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),D("split");return}if(R==="/"){i.setFilterActive(!0);return}if(R==="1"&&G){i.pinTask(0,G);return}if(R==="2"&&G){i.pinTask(1,G);return}if(R==="0"){i.clearPins();return}b.escape&&a.filterText&&i.setFilter("")}}},{isActive:!a.interactiveMode}),u<pt||p<mt)return c.jsx(x,{alignItems:"center",height:p,justifyContent:"center",width:u,children:c.jsxs(f,{color:"yellow",children:["Terminal too small (",u,"x",p,"). Minimum:"," ",pt,"x",mt]})});const de=c.jsxs(x,{gap:1,children:[a.succeeded>0&&c.jsxs(f,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(f,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(f,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(f,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(f,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(f,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let ce;if(a.viewMode==="fullscreen")ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Esc"}),c.jsx(f,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(f,{dimColor:!0,children:"PAGE"})]},"page"),...z?.status==="running"?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"i"}),c.jsx(f,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const R=W[a.selectedIndex]?.status==="failure";ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"r"}),c.jsx(f,{dimColor:!0,children:"RERUN"})]},"r"),...R?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"R"}),c.jsx(f,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"F"}),c.jsx(f,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Esc"}),c.jsx(f,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"SCROLL"})]},"scroll"),...z?.status==="running"?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"i"}),c.jsx(f,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Tab"}),c.jsx(f,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?")]:ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"/"}),c.jsx(f,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"F"}),c.jsx(f,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Tab"}),c.jsx(f,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const ee=c.jsxs(x,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(x,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ce}),c.jsx(x,{flexShrink:0,paddingX:1,children:de})]}),ne=c.jsxs(Ts,{backgroundColor:"#1e1e1e",footer:c.jsxs(f,{dimColor:!0,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(f,{bold:!0,color:"white",children:"?"}),"/",c.jsx(f,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:L,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(f,{dimColor:!0,children:" Move up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(f,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(f,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(f,{dimColor:!0,children:" Back / close"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(f,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(f,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(f,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(f,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(f,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(f,{dimColor:!0,children:"/"}),c.jsx(f,{bold:!0,color:"white",children:"2"}),c.jsx(f,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(f,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(f,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(f,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(f,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(f,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(f,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(f,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(f,{dimColor:!0,children:" Page up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(f,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(f,{dimColor:!0,children:" Top"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(f,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(f,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(x,{flexDirection:"column",children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(f,{dimColor:!0,children:" Quit"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(f,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Y=c.jsx($s,{autoExitSeconds:t>0?t:3,onCancel:()=>{T(!1)},visible:M}),he=j&&n?c.jsx(Jn,{activeIndex:E,focused:a.focusedPanel==="dock",store:n}):null;if(a.viewMode==="fullscreen")return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsx(x,{flexGrow:1,children:c.jsx(dt,{autoScroll:I,duration:z?.duration??z?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:K,scrollRef:$,status:H,supportsInteractive:!g,taskId:N})}),he,ee,Y,ne]});if(a.viewMode==="split"){const R=u>=gt,b=c.jsx(ht,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:P,selectedIndex:a.selectedIndex,title:re}),A=c.jsx(dt,{autoScroll:I,duration:z?.duration??z?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:K,scrollRef:$,showFullscreenHint:!0,status:H,supportsInteractive:!g,taskId:N});if(R){const ae=Math.floor(u*.4);return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsxs(x,{flexDirection:"row",flexGrow:1,children:[c.jsx(x,{width:ae,children:b}),c.jsx(x,{flexGrow:1,children:A})]}),he,ee,Y,ne]})}const Q=Math.floor(p*.45);return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsx(x,{height:Q,children:b}),c.jsx(x,{flexGrow:1,children:A}),he,ee,Y,ne]})}return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsx(x,{flexGrow:1,children:c.jsx(ht,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:P,selectedIndex:a.selectedIndex,title:re})}),he,ee,Y,ne]})},ti=t=>t==="quiet"?"quiet":"normal",si=(t,e)=>typeof t=="string"?ti(t.toLowerCase()):e===!0?"quiet":"normal",We=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Xt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class ri{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Ke(this.#e,this.#r,this.#s)}`,r=le(X.createElement(Ne,{title:s,variant:"info"}),{columns:e});se(r,"run header");const n=this.#s[0],o=n?.overrides?Object.entries(n.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){se(`
16
18
  With additional flags:
17
- `);for(const[n,l]of o)process.stdout.write(`${gn(" ",n,l)}
19
+ `,"run header");for(const[i,l]of o)se(`${$n(" ",i,l)}
20
+ `,"run header")}se(`
21
+ `,"run header")}startTasks(e){const s=process.stdout.columns||80;for(const r of e){const n=le(X.createElement(f,null,X.createElement(f,{dimColor:!0},">"),` ${r.id}`),{columns:s});se(`${n}
22
+ `,r.id)}}endTasks(e){const s=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):ve(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const n=Se(r.status),o=r.startTime&&r.endTime?` (${we(r.endTime-r.startTime)})`:"",i=ve(r.status)?" [cache]":"",l=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",d=le(X.createElement(f,null,n,` ${r.task.id}`,i?X.createElement(f,{color:"cyan"},i):null,l?X.createElement(f,{color:"yellow"},l):null,o?X.createElement(f,{dimColor:!0},o):null),{columns:s});se(`${d}
23
+ `,r.task.id)}}#l(e){const s=process.stdout.columns||80,r=le(X.createElement(f,{dimColor:!0},` ⓘ ${e}`),{columns:s});se(`${r}
24
+ `,"cache notice")}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,s){this.#l(`${e.id}: caching skipped — task modified its own input${s.length===1?"":"s"} (${s.join(", ")})`)}printDeclaredFallback(e){We(e,this.#a)!=="quiet"&&this.#l(Xt(e))}printEmptyFingerprintWarning(e,s){this.#l(`${e.id}: caching skipped — ${s}`)}printTaskTerminalOutput(e,s,r){if(We(e,this.#a)==="quiet"&&(s==="success"||ve(s)))return;const n=s==="failure"?Ut(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,s,n);return}Hn(e.id,s,n,this.#d)}endCommand(){const e=we(Date.now()-this.#u),s=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);se(`
25
+ `,"run summary");const r=process.stdout.columns||80,n=le(X.createElement(Ht,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:s.length>0?s:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});se(`${n}
26
+ `,"run summary")}}const ni=t=>{const{args:e,autoExit:s=!1,onRetryService:r,outputStyle:n="normal",projectNames:o,serviceDockStore:i,stdinRegistry:l,tasks:d,totalTaskCount:h}=t,u=new Pe(d,h),p=typeof e.parallel=="number"?e.parallel:3,a=s===!0?3:typeof s=="number"?s:0,m=new Map,w=(T,I)=>{const k=m.get(T);k?k.push(I):m.set(T,[I])};let j,E;const y=new Promise(T=>{E=T});let g;const S=()=>{g&&(clearInterval(g),g=void 0)},F=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},C=()=>{if(l){for(const T of l.values())T.kill?.();l.clear()}},v=()=>{S(),$(),C(),F(),process.stdout.write("\x1B[?1049l\x1B[?25h"),j?.cleanup(),process.exit(1)},L=()=>{const T=u.getSnapshot(),I=we(Date.now()-T.startTime),k=T.rows.filter(D=>D.status==="failure").map(D=>D.taskId),O=process.stdout.columns||80;process.stdout.write(`
27
+ `);for(const D of T.rows){const{persistent:_,status:W,taskId:q}=D,G=W==="running"||W==="pending",J=xe(W),z=G&&_?"■":J.icon,Z=G&&_?"gray":J.color;let te="";switch(W){case"local-cache":case"local-cache-kept-existing":{te=" [local cache]";break}case"remote-cache":{te=" [remote cache]";break}case"skipped":{te=" [skipped]";break}default:{G&&_?te=" [stopped]":G&&(te=" [skipped]");break}}const K=D.retryAttempts&&D.retryAttempts>0?` [retried ${D.retryAttempts}x]`:"",N=le(X.createElement(f,null," ",X.createElement(f,{color:Z},z),` vis run ${q}`,te?X.createElement(f,{dimColor:!0},` ${te}`):null,K?X.createElement(f,{color:"yellow"},K):null),{columns:O});process.stdout.write(`${N}
18
28
  `)}process.stdout.write(`
19
- `)}startTasks(e){const s=process.stdout.columns||80;for(const r of e){const i=ce(K.createElement(u,null,K.createElement(u,{dimColor:!0},">"),` ${r.id}`),{columns:s});process.stdout.write(`${i}
20
- `)}}endTasks(e){const s=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):ge(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const i=xe(r.status),o=r.startTime&&r.endTime?` (${me(r.endTime-r.startTime)})`:"",n=ge(r.status)?" [cache]":"",l=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",d=ce(K.createElement(u,null,i,` ${r.task.id}`,n?K.createElement(u,{color:"cyan"},n):null,l?K.createElement(u,{color:"yellow"},l):null,o?K.createElement(u,{dimColor:!0},o):null),{columns:s});process.stdout.write(`${d}
21
- `)}}#l(e){const s=process.stdout.columns||80,r=ce(K.createElement(u,{dimColor:!0},` ⓘ ${e}`),{columns:s});process.stdout.write(`${r}
22
- `)}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,s){this.#l(`${e.id}: caching skipped — task modified its own input${s.length===1?"":"s"} (${s.join(", ")})`)}printDeclaredFallback(e){Ne(e,this.#a)!=="quiet"&&this.#l(Yt(e))}printEmptyFingerprintWarning(e,s){this.#l(`${e.id}: caching skipped — ${s}`)}printTaskTerminalOutput(e,s,r){if(Ne(e,this.#a)==="quiet"&&(s==="success"||ge(s)))return;const i=s==="failure"?Ht(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,s,i);return}Ln(e.id,s,i,this.#d)}endCommand(){const e=me(Date.now()-this.#u),s=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
23
- `);const r=process.stdout.columns||80,i=ce(K.createElement(_t,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:s.length>0?s:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${i}
24
- `)}}const Jn=t=>{const{args:e,autoExit:s=!1,onRetryService:r,outputStyle:i="normal",projectNames:o,serviceDockStore:n,stdinRegistry:l,tasks:d,totalTaskCount:h}=t,f=new Ee(d,h),p=typeof e.parallel=="number"?e.parallel:3,a=s===!0?3:typeof s=="number"?s:0,m=new Map,w=(T,b)=>{const B=m.get(T);B?B.push(b):m.set(T,[b])};let j,M;const x=new Promise(T=>{M=T});let g;const k=()=>{g&&(clearInterval(g),g=void 0)},P=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},C=()=>{if(l){for(const T of l.values())T.kill?.();l.clear()}},y=()=>{k(),$(),C(),P(),process.stdout.write("\x1B[?1049l\x1B[?25h"),j?.cleanup(),process.exit(1)},E=()=>{const T=f.getSnapshot(),b=me(Date.now()-T.startTime),B=T.rows.filter(A=>A.status==="failure").map(A=>A.taskId),D=process.stdout.columns||80;process.stdout.write(`
25
- `);for(const A of T.rows){const{persistent:L,status:G,taskId:V}=A,W=G==="running"||G==="pending",X=ve(G),H=W&&L?"■":X.icon,Q=W&&L?"gray":X.color;let J="";switch(G){case"local-cache":case"local-cache-kept-existing":{J=" [local cache]";break}case"remote-cache":{J=" [remote cache]";break}case"skipped":{J=" [skipped]";break}default:{W&&L?J=" [stopped]":W&&(J=" [skipped]");break}}const te=A.retryAttempts&&A.retryAttempts>0?` [retried ${A.retryAttempts}x]`:"",re=ce(K.createElement(u,null," ",K.createElement(u,{color:Q},H),` vis run ${V}`,J?K.createElement(u,{dimColor:!0},` ${J}`):null,te?K.createElement(u,{color:"yellow"},te):null),{columns:D});process.stdout.write(`${re}
26
- `)}process.stdout.write(`
27
- `);const N=ce(K.createElement(_t,{cached:T.cached,failed:T.failed,failedIds:B,projectNames:o,retriedIds:T.retriedIds.length>0?T.retriedIds:void 0,succeeded:T.succeeded,targets:e.targets,tasks:d,took:b}),{columns:D});if(process.stdout.write(`${N}
28
- `),i!=="quiet"){const A=[...T.rows.filter(L=>L.status!=="failure"),...T.rows.filter(L=>L.status==="failure")];for(const L of A){if(L.status==="running"||L.status==="pending")continue;const G=T.outputs.get(L.taskId);if(!G?.trim())continue;const{color:V,icon:W}=ve(L.status),X=ce(K.createElement(u,null,`
29
- `,K.createElement(u,{bold:!0,color:V},` ${W} vis run ${L.taskId}`)),{columns:D});process.stdout.write(`${X}
30
-
31
- `);const H=G.trim().split(`
32
- `).map(Q=>` ${Q}`).join(`
33
- `);process.stdout.write(`${H}
34
- `)}}};let R;const $=()=>{R&&(clearInterval(R),R=void 0)};return{lifeCycle:{endCommand(){k(),f.markDone(),R||(R=setInterval(()=>{},1e3))},endTasks(T){f.endTasks(T);for(const b of T){const B=m.get(b.task.id);if(B){m.delete(b.task.id);for(const D of B)f.addOutput(b.task.id,D)}}},printCacheDisabledByTask(T){w(T.id,`ⓘ caching disabled by task via disableCache()
35
- `)},printDeclaredFallback(T){Ne(T,i)!=="quiet"&&w(T.id,`ⓘ ${Yt(T)}
36
- `)},printEmptyFingerprintWarning(T,b){w(T.id,`ⓘ caching skipped — ${b}
37
- `)},printSelfModifyingSkip(T,b){w(T.id,`ⓘ caching skipped — task modified its own input${b.length===1?"":"s"} (${b.join(", ")})
38
- `)},printTaskTerminalOutput(T,b,B){f.getSnapshot().outputs.has(T.id)||f.addOutput(T.id,B)},startCommand(){process.on("SIGINT",y),process.on("SIGTERM",y),R||(R=setInterval(()=>{},1e3)),j=Qs(K.createElement(zn,{autoExitSeconds:a,onRetryService:r,parallelSlots:p,projectNames:o,serviceDockStore:n,stdinRegistry:l??new Map,store:f,targets:e.targets,tasks:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),j.waitUntilExit().then(()=>{$(),C(),P(),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),E(),M()}).catch(()=>{$(),C(),P(),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),M()})},startTasks(T){f.startTasks(T),g||(g=setInterval(()=>{f.tick()},100))}},renderIsDone:x,store:f}},Qn=t=>{const{killGracePeriodMs:e=5e3,onTimeout:s,sendSignal:r,timeoutMs:i}=t;if(i<=0)return{cancel:()=>{}};const o=Math.max(e,0);let n;const l=setTimeout(()=>{s?.(),r("SIGTERM"),o>0&&(n=setTimeout(()=>{r("SIGKILL")},o))},i);return{cancel:()=>{clearTimeout(l),n&&clearTimeout(n)}}},Zn=async(t,e,s)=>{if(!e)return s();const r=t.get(e)??Promise.resolve();let i;const o=new Promise(l=>{i=l}),n=r.then(()=>o);t.set(e,n),await r;try{return await s()}finally{i(),t.get(e)===n&&t.delete(e)}},ei=t=>{let e=Math.max(0,Math.floor(t));return{claim(s){const r=Math.max(0,Math.min(s,e));return e-=r,r},get remaining(){return e}}},Kt=t=>async(e,s)=>{const{hooks:r,lifeCycle:i,mutexPool:o,onOutput:n,onOutputReplace:l,resolveCommand:d,retryBudget:h,serviceEventBridge:f,spawnContext:p,stdinRegistry:a,strictEnvFailure:m,workspaceRoot:w}=t,j=je(e),M=He(w,s.cwd??e.projectRoot,j?.runFromWorkspaceRoot===!0),x=d(e);if(!x)return{code:0,terminalOutput:`No command configured for ${e.target.project}:${e.target.target}`};const g=ke(p,e,s),k=m(e,x,s);if(k!==void 0)return i?.onTaskStderr?.(e,k),{code:1,terminalOutput:k};const P=j?.pty===!0,C=!!a,y=e.pty===!0?!0:e.pty===!1?!1:C||P;y&&(e.cache=!1);const E=y?void 0:new Qr(Ie),R=y?new We(Ie):void 0;let $;const O=b=>{if(b.kind==="started"&&($=b.kill,b.write&&a&&a.set(e.id,{kill:b.kill,resize:b.resize,write:b.write}),f?.onRegistryTaskStarted(e.id)),(b.kind==="stdout"||b.kind==="stderr")&&b.text!==void 0)if(b.kind==="stdout"?i?.onTaskStdout?.(e,b.text):i?.onTaskStderr?.(e,b.text),R)R.write(b.text),C&&l?.(e.id,R.toString()),f&&f.onTaskOutput(e.id,b.text);else{const B=`${b.text}
39
- `;E.append(B),n?.(e.id,B)}b.kind==="close"&&(a&&a.delete(e.id),f&&f.onRegistryTaskClosed(e.id,b.exitCode??0,!!b.killed).catch(()=>{}))},T=async()=>{const b=j?.retryCount??0,B=j?.retryDelay,D=h?h.claim(b):b,N=typeof j?.timeout=="number"&&j.timeout>0?j.timeout:0,A=typeof j?.killGracePeriodMs=="number"&&j.killGracePeriodMs>=0?j.killGracePeriodMs:5e3;let L=!1,G=0;const V=Qn({killGracePeriodMs:A,onTimeout:()=>{L=!0},sendSignal:Q=>{$?.(Q)},timeoutMs:N});let W;try{W=await $e([{command:x,cwd:M,env:g.env,inheritEnv:g.inheritEnv,name:e.id,...y?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:O,...D>0?{restart:{delay:B??"exponential",onRetry:async(Q,J,te)=>{G=Q,r&&await r.callHook("task:retry",e,Q,te)},tries:D}}:{}})}finally{V.cancel()}const X=W.closeEvents[0],H=R?R.toString():E.toString();return L?{code:124,retryAttempts:G,terminalOutput:`${H}
40
- [timeout] Task "${e.id}" exceeded ${N}ms budget.
41
- `}:{code:X?.exitCode??1,retryAttempts:G,terminalOutput:H}};return o?Zn(o,j?.mutex,T):T()},ti=({injectedServiceIdSet:t,runtime:e,serviceDockStore:s,serviceEventBridge:r,workspaceRoot:i})=>{const{failureLogLifeCycle:o,hookLifeCycle:n,hooks:l,lifecycleOptions:d,outputStyle:h,resolveCommand:f,sharedRetryBudget:p,spawnContext:a,strictEnvFailure:m}=e,w=new Map,j=Jn({...d,onRetryService:r?C=>r.retry(C):void 0,outputStyle:h,serviceDockStore:s,stdinRegistry:w}),{lifeCycle:M,store:x}=j,g=new jt([M,n,o]),P=Kt({hooks:l,lifeCycle:g,mutexPool:new Map,onOutput:(C,y)=>{r&&t.has(C)?r.onTaskOutput(C,y):x.addOutput(C,y)},onOutputReplace:(C,y)=>{x.setOutput(C,y)},resolveCommand:f,retryBudget:p,serviceEventBridge:r??void 0,spawnContext:a,stdinRegistry:w,strictEnvFailure:m,workspaceRoot:i});return{dynamic:j,lifeCycle:g,stdinRegistry:w,store:x,taskExecutor:P}},si=async({dynamic:t,initialTasks:e,lifeCycle:s,options:r,persistentTasks:i,projectGraph:o,runtime:n,stdinRegistry:l,store:d,taskExecutor:h,taskGraph:f,workspaceRoot:p})=>{const{childEnvPolicyFor:a,preTraceCheck:m,resolveCommand:w,runnerOptions:j,spawnContext:M}=n,x=await St(e,j,{childEnvPolicy:a,lifeCycle:s,preTraceCheck:m,projectGraph:o,resolveChildEnv:(g,k)=>ke(M,g,k),resolveCommand:w,taskExecutor:h,taskGraph:f,workspaceRoot:p});if(i.length>0&&!r.failFast){const g=new Promise(k=>{const P=d.subscribe(()=>{const C=d.getSnapshot();(C.rerunRequested||C.retryTaskId)&&(P(),k())});t.renderIsDone.then(()=>{P(),k()}).catch(()=>{P(),k()})});await Bt(i,M,{abortSignal:g,lifeCycle:s,stdinRegistry:l,store:d})}return x},ri=async({dynamic:t,store:e})=>{let s=null;return{action:await new Promise(i=>{const o=e.subscribe(()=>{const n=e.getSnapshot();n.rerunRequested&&(e.acknowledgeRerun(),o(),i("rerun")),n.retryTaskId&&(s=e.acknowledgeRetry(),o(),i("retry"))});t.renderIsDone.then(()=>{o(),i("quit")}).catch(()=>{o(),i("quit")})}),retryTaskId:s}},le="@voidzero-dev/vite-task-client",Ke="@visulima/task-runner-client",Pe=`npm:${Ke}@^1`,Xt=ne(".vis",".vite-client-override-declined"),Me="pnpm-workspace.yaml",ni=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Jt=t=>{try{return JSON.parse(we(t,"utf8"))}catch{return}},ii=t=>{const e=ne(t,Me);if(he(e))try{return Ft(we(e,"utf8")).toJS()?.overrides}catch{return}},oi=t=>t==="pnpm"||t==="aube"?"pnpm.overrides":t==="yarn"?"resolutions":"overrides",ci=t=>{const e=ne(t,Me);try{const s=Ft(we(e,"utf8"));return s.setIn(["overrides",le],Pe),qe(e,s.toString()),!0}catch{return!1}},mt=t=>t!==void 0&&ni.some(e=>t[e]?.[le]!==void 0),ai=(t,e)=>t!==void 0&&(t.pnpm?.overrides?.[le]!==void 0||t.overrides?.[le]!==void 0||t.resolutions?.[le]!==void 0)||e?.[le]!==void 0,li=(t,e=[])=>{const s=Jt(ne(t,"package.json")),r=he(ne(t,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:ai(s,ii(t)),declined:he(ne(t,Xt)),manager:kr(t)?.manager,present:mt(s)||r||e.some(i=>mt(i))}},di=t=>{try{const e=ne(t,Xt);or(Tt(e),{recursive:!0}),qe(e,`Declined adding the ${le} → ${Ke} override.
29
+ `);const B=le(X.createElement(Ht,{cached:T.cached,failed:T.failed,failedIds:k,projectNames:o,retriedIds:T.retriedIds.length>0?T.retriedIds:void 0,succeeded:T.succeeded,targets:e.targets,tasks:d,took:I}),{columns:O});if(process.stdout.write(`${B}
30
+ `),n!=="quiet"){const D=[...T.rows.filter(_=>_.status!=="failure"),...T.rows.filter(_=>_.status==="failure")];for(const _ of D){if(_.status==="running"||_.status==="pending")continue;const W=T.outputs.get(_.taskId);if(!W?.trim())continue;const{color:q,icon:G}=xe(_.status),J=le(X.createElement(f,null,`
31
+ `,X.createElement(f,{bold:!0,color:q},` ${G} vis run ${_.taskId}`)),{columns:O});process.stdout.write(`${J}
32
+
33
+ `);const z=W.trim().split(`
34
+ `).map(Z=>` ${Z}`).join(`
35
+ `);process.stdout.write(`${z}
36
+ `)}}};let P;const $=()=>{P&&(clearInterval(P),P=void 0)};return{lifeCycle:{endCommand(){S(),u.markDone(),P||(P=setInterval(()=>{},1e3))},endTasks(T){u.endTasks(T);for(const I of T){const k=m.get(I.task.id);if(k){m.delete(I.task.id);for(const O of k)u.addOutput(I.task.id,O)}}},printCacheDisabledByTask(T){w(T.id,`ⓘ caching disabled by task via disableCache()
37
+ `)},printDeclaredFallback(T){We(T,n)!=="quiet"&&w(T.id,`ⓘ ${Xt(T)}
38
+ `)},printEmptyFingerprintWarning(T,I){w(T.id,`ⓘ caching skipped — ${I}
39
+ `)},printSelfModifyingSkip(T,I){w(T.id,`ⓘ caching skipped — task modified its own input${I.length===1?"":"s"} (${I.join(", ")})
40
+ `)},printTaskTerminalOutput(T,I,k){u.getSnapshot().outputs.has(T.id)||u.addOutput(T.id,k)},startCommand(){process.on("SIGINT",v),process.on("SIGTERM",v),P||(P=setInterval(()=>{},1e3)),j=Cs(X.createElement(ei,{autoExitSeconds:a,onRetryService:r,parallelSlots:p,projectNames:o,serviceDockStore:i,stdinRegistry:l??new Map,store:u,targets:e.targets,tasks:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),j.waitUntilExit().then(()=>{$(),C(),F(),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),L(),E()}).catch(()=>{$(),C(),F(),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),E()})},startTasks(T){u.startTasks(T),g||(g=setInterval(()=>{u.tick()},100))}},renderIsDone:y,store:u}},ii=t=>{const{killGracePeriodMs:e=5e3,onTimeout:s,sendSignal:r,timeoutMs:n}=t;if(n<=0)return{cancel:()=>{}};const o=Math.max(e,0);let i;const l=setTimeout(()=>{s?.(),r("SIGTERM"),o>0&&(i=setTimeout(()=>{r("SIGKILL")},o))},n);return{cancel:()=>{clearTimeout(l),i&&clearTimeout(i)}}},oi=async(t,e,s)=>{if(!e)return s();const r=t.get(e)??Promise.resolve();let n;const o=new Promise(l=>{n=l}),i=r.then(()=>o);t.set(e,i),await r;try{return await s()}finally{n(),t.get(e)===i&&t.delete(e)}},ci=t=>{let e=Math.max(0,Math.floor(t));return{claim(s){const r=Math.max(0,Math.min(s,e));return e-=r,r},get remaining(){return e}}},Jt=t=>async(e,s)=>{const{hooks:r,lifeCycle:n,mutexPool:o,onOutput:i,onOutputReplace:l,resolveCommand:d,retryBudget:h,serviceEventBridge:u,spawnContext:p,stdinRegistry:a,strictEnvFailure:m,workspaceRoot:w}=t,j=ke(e),E=qe(w,s.cwd??e.projectRoot,j?.runFromWorkspaceRoot===!0),y=d(e);if(!y)return{code:0,terminalOutput:`No command configured for ${e.target.project}:${e.target.target}`};const g=Te(p,e,s),S=m(e,y,s);if(S!==void 0)return n?.onTaskStderr?.(e,S),{code:1,terminalOutput:S};const F=j?.pty===!0,C=!!a,v=e.pty===!0?!0:e.pty===!1?!1:C||F;v&&(e.cache=!1);const L=v?void 0:new ln(Re),P=v?new He(Re):void 0;let $;const M=I=>{if(I.kind==="started"&&($=I.kill,I.write&&a&&a.set(e.id,{kill:I.kill,resize:I.resize,write:I.write}),u?.onRegistryTaskStarted(e.id)),(I.kind==="stdout"||I.kind==="stderr")&&I.text!==void 0)if(I.kind==="stdout"?n?.onTaskStdout?.(e,I.text):n?.onTaskStderr?.(e,I.text),P)P.write(I.text),C&&l?.(e.id,P.toString()),u&&u.onTaskOutput(e.id,I.text);else{const k=`${I.text}
41
+ `;L.append(k),i?.(e.id,k)}I.kind==="close"&&(a&&a.delete(e.id),u&&u.onRegistryTaskClosed(e.id,I.exitCode??0,!!I.killed).catch(()=>{}))},T=async()=>{const I=j?.retryCount??0,k=j?.retryDelay,O=h?h.claim(I):I,B=typeof j?.timeout=="number"&&j.timeout>0?j.timeout:0,D=typeof j?.killGracePeriodMs=="number"&&j.killGracePeriodMs>=0?j.killGracePeriodMs:5e3;let _=!1,W=0;const q=ii({killGracePeriodMs:D,onTimeout:()=>{_=!0},sendSignal:Z=>{$?.(Z)},timeoutMs:B});let G;try{G=await Ce([{command:y,cwd:E,env:g.env,inheritEnv:g.inheritEnv,name:e.id,...v?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:M,...O>0?{restart:{delay:k??"exponential",onRetry:async(Z,te,K)=>{W=Z,r&&await r.callHook("task:retry",e,Z,K)},tries:O}}:{}})}finally{q.cancel()}const J=G.closeEvents[0],z=P?P.toString():L.toString();return _?{code:124,retryAttempts:W,terminalOutput:`${z}
42
+ [timeout] Task "${e.id}" exceeded ${B}ms budget.
43
+ `}:{code:J?.exitCode??1,retryAttempts:W,terminalOutput:z}};return o?oi(o,j?.mutex,T):T()},ai=({injectedServiceIdSet:t,runtime:e,serviceDockStore:s,serviceEventBridge:r,workspaceRoot:n})=>{const{failureLogLifeCycle:o,hookLifeCycle:i,hooks:l,lifecycleOptions:d,outputStyle:h,resolveCommand:u,sharedRetryBudget:p,spawnContext:a,strictEnvFailure:m}=e,w=new Map,j=ni({...d,onRetryService:r?C=>r.retry(C):void 0,outputStyle:h,serviceDockStore:s,stdinRegistry:w}),{lifeCycle:E,store:y}=j,g=new kt([E,i,o]),F=Jt({hooks:l,lifeCycle:g,mutexPool:new Map,onOutput:(C,v)=>{r&&t.has(C)?r.onTaskOutput(C,v):y.addOutput(C,v)},onOutputReplace:(C,v)=>{y.setOutput(C,v)},resolveCommand:u,retryBudget:p,serviceEventBridge:r??void 0,spawnContext:a,stdinRegistry:w,strictEnvFailure:m,workspaceRoot:n});return{dynamic:j,lifeCycle:g,stdinRegistry:w,store:y,taskExecutor:F}},li=async({dynamic:t,initialTasks:e,lifeCycle:s,options:r,persistentTasks:n,projectGraph:o,runtime:i,stdinRegistry:l,store:d,taskExecutor:h,taskGraph:u,workspaceRoot:p})=>{const{childEnvPolicyFor:a,preTraceCheck:m,resolveCommand:w,runnerOptions:j,spawnContext:E}=i,y=await bt(e,j,{childEnvPolicy:a,lifeCycle:s,preTraceCheck:m,projectGraph:o,resolveChildEnv:(g,S)=>Te(E,g,S),resolveCommand:w,taskExecutor:h,taskGraph:u,workspaceRoot:p});if(n.length>0&&!r.failFast){const g=new Promise(S=>{const F=d.subscribe(()=>{const C=d.getSnapshot();(C.rerunRequested||C.retryTaskId)&&(F(),S())});t.renderIsDone.then(()=>{F(),S()}).catch(()=>{F(),S()})});await Gt(n,E,{abortSignal:g,lifeCycle:s,stdinRegistry:l,store:d})}return y},di=async({dynamic:t,store:e})=>{let s=null;return{action:await new Promise(n=>{const o=e.subscribe(()=>{const i=e.getSnapshot();i.rerunRequested&&(e.acknowledgeRerun(),o(),n("rerun")),i.retryTaskId&&(s=e.acknowledgeRetry(),o(),n("retry"))});t.renderIsDone.then(()=>{o(),n("quit")}).catch(()=>{o(),n("quit")})}),retryTaskId:s}},ue="@voidzero-dev/vite-task-client",Xe="@visulima/task-runner-client",Me=`npm:${Xe}@^1`,Qt=ie(".vis",".vite-client-override-declined"),Fe="pnpm-workspace.yaml",ui=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Zt=t=>{try{return JSON.parse(ye(t,"utf8"))}catch{return}},fi=t=>{const e=ie(t,Fe);if(me(e))try{return Lt(ye(e,"utf8")).toJS()?.overrides}catch{return}},hi=t=>t==="pnpm"||t==="aube"?"pnpm.overrides":t==="yarn"?"resolutions":"overrides",pi=t=>{const e=ie(t,Fe);try{const s=Lt(ye(e,"utf8"));return s.setIn(["overrides",ue],Me),Ue(e,s.toString()),!0}catch{return!1}},wt=t=>t!==void 0&&ui.some(e=>t[e]?.[ue]!==void 0),mi=(t,e)=>t!==void 0&&(t.pnpm?.overrides?.[ue]!==void 0||t.overrides?.[ue]!==void 0||t.resolutions?.[ue]!==void 0)||e?.[ue]!==void 0,gi=(t,e=[])=>{const s=Zt(ie(t,"package.json")),r=me(ie(t,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:mi(s,fi(t)),declined:me(ie(t,Qt)),manager:Cr(t)?.manager,present:wt(s)||r||e.some(n=>wt(n))}},wi=t=>{try{const e=ie(t,Qt);dr(Et(e),{recursive:!0}),Ue(e,`Declined adding the ${ue} → ${Xe} override.
42
44
  Delete this file to be asked again.
43
- `)}catch{}},ui=(t,e="npm")=>{const s=`${e} install`;if((e==="pnpm"||e==="aube")&&he(ne(t,Me))&&ci(t))return{file:Me,installCommand:s};const r=ne(t,"package.json"),i=Jt(r);if(!i)return;const o=oi(e);o==="pnpm.overrides"?(i.pnpm??={},i.pnpm.overrides??={},i.pnpm.overrides[le]=Pe):(i[o]??={},i[o][le]=Pe);try{qe(r,`${JSON.stringify(i,void 0,4)}
44
- `)}catch{return}return{file:"package.json",installCommand:s}},fi=async(t,e)=>{const s=li(t,e.projectManifests);if(!s.present||s.alreadyOverridden||s.declined)return!1;const r=Tr({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${le}. Its cache hints no-op under @visulima/task-runner unless aliased to ${Ke} (a drop-in replacement).`);const i=await new Promise(n=>{r.question("Add the override now? [y/N] ",n)});if(!/^y(?:es)?$/i.test(i.trim()))return di(t),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=ui(t,s.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${le}": "${Pe}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},hi=async({config:t,logger:e,options:s,packageJsons:r,workspaceRoot:i})=>{await Cr(i,t.toolchain,{error:l=>{e.error(l)},info:l=>{e.info(l)},warn:l=>{e.warn(l)}},!!s.skipToolchain);const o=s.preflight!==!1&&t.preflight?.lockfile!==!1,n=br(i,Se,{warn:l=>{e.warn(l)}},{skip:!o});if(!n.shouldContinue)throw new Error(`${n.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);o&&!Se&&process.stdin.isTTY&&process.stdout.isTTY&&await fi(i,{interactive:!0,logger:{info:l=>{e.info(l)},warn:l=>{e.warn(l)}},projectManifests:[...r.values()]})},pi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,mi=new Set(["0","!","#","$","*","-","?","@","_"]),gi=t=>{const e=new Map;for(const s of t.matchAll(pi)){const r=s[1],i=s[3],o=s[2],n=r??i;if(n===void 0||mi.has(n))continue;const l=o!==void 0,d=e.get(n);d===void 0?e.set(n,l):d&&!l&&e.set(n,!1)}return[...e.entries()].map(([s,r])=>({hasDefault:r,name:s}))},wi=t=>{const{command:e,processEnv:s,taskEnv:r,taskId:i}=t,o=gi(e);if(o.length===0)return;const n=[];for(const{hasDefault:l,name:d}of o){if(l)continue;const h=r[d],f=s[d];h===void 0&&f===void 0&&n.push(d)}if(n.length!==0)return{missing:n.toSorted(),taskId:i}},vi=t=>{const e=t.missing.map(s=>`$${s}`).join(", ");return`Strict env: ${t.taskId} references unset variable${t.missing.length===1?"":"s"} ${e}. Set ${t.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},yi=async({configTaskRunner:t,logger:e,options:s,runnerOptions:r,workspaceRoot:i})=>{const o=cs(t.remoteCache);if(o){const n=tn(s.cacheMode),l=sn(s.cacheBackend);if(r.remoteCache={...o,...n?{mode:n}:{},...l?{backend:l}:{}},r.remoteCache.attestation){const{expectedIdentity:d,requireOnDownload:h}=r.remoteCache.attestation;if(!(d!==void 0&&("github"in d&&typeof d.github?.ref=="string"&&typeof d.github.repo=="string"&&typeof d.github.workflow=="string"||"oidcIssuer"in d&&typeof d.oidcIssuer=="string"&&(typeof d.san=="string"||typeof d.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in d&&(!d.sanRegex.startsWith("^")||!d.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:p,isSigstoreInstalled:a}=await import("./loader.js");a()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
45
- ${p(i)}`);const{buildCacheAttestationHooks:m}=await import("./cache-attestation.js");r.remoteCache.attestation=m({expectedIdentity:d,onReject:(w,j)=>{e.warn(`[vis run] remote cache entry ${w.slice(0,12)} rejected: attestation ${j}. Treating as a cache miss.`)},onVerifyFailure:w=>{e.warn(`[vis run] attestation verification failed: ${w}`)},requireOnDownload:h,workspaceRoot:i})}}else(s.cacheMode||s.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.")},xi=async({affectedFiles:t,config:e,currentOs:s,initialTasks:r,invocationCwd:i,logger:o,options:n,persistentTasks:l,projectsWithTarget:d,serviceEnvByTaskId:h,serviceResult:f,target:p,taskGraph:a,visConfig:m,workspaceRoot:w})=>{const j=Date.now(),M=Cs(),x=(_,z)=>{const q=z instanceof Error?z.message:String(z);o.warn(`Plugin error in ${_}: ${q}`)};await Is(M,e.plugins);const g=typeof n.profile=="string"?n.profile:void 0,k=async _=>{if(!g)return;const z=kt(_,a,j),q=g.startsWith("/")?g:`${w}/${g}`;await ls(z,q),o.info(`Profile written to ${g}`)},P=e.taskRunner??{},C=Zs(w,n.cacheDir,P.cacheDirectory,e.sharedWorktreeCache),y=er(C,w,e.branchScopedCache),E=Zr(process.env.VIS_RUN_CONCURRENCY_LIMIT);E&&"invalid"in E&&o.warn(`VIS_RUN_CONCURRENCY_LIMIT=${E.invalid} is not a positive number; falling back to default concurrency.`);const R=E&&"value"in E?E.value:void 0,$=n.parallel??R??3,O=n.strictEnv??e.strictEnv??!1,T=new Set,b={dryRun:n.dryRun??!1,parallel:$,skipNxCache:!n.cache,summarize:n.summarize??!1,...P,cacheDirectory:y,dataDirectory:P.dataDirectory??Ce(w),namedInputs:e.namedInputs,onDiagnostic:(_,z)=>{T.has(_)||(T.add(_),o.warn(z))},onFingerprint:async(_,z)=>{await M.callHook("task:fingerprint",_,z)}},B=_=>Hs(b.env,je(_)?.env),D=Ws({affectedFiles:t,childEnvPolicy:B,initCwd:i,serviceEnvByTaskId:h,taskSlots:$,workspaceRoot:w}),N=_=>ze(_,t,s),A=(_,z,q)=>{if(!(je(_)?.strictEnv??O))return;const ae=ke(D,_,q),de=D.childEnvPolicy(_),Y=wi({command:z,processEnv:de.mode==="clean"?as(process.env,de):process.env,taskEnv:ae.env,taskId:_.id});return Y?vi(Y):void 0},L=(_,z)=>{const q=N(_);return q===void 0?void 0:A(_,q,z)};await yi({configTaskRunner:P,logger:o,options:n,runnerOptions:b,workspaceRoot:w});const G=process.stdout.isTTY&&!Se,V=m?.run?.quietOnSuccess===!0,W=e.tui?.autoExit??(V?3:!1),X={args:{parallel:b.parallel,targets:[p]},autoExit:W,projectNames:d,tasks:[...r,...l].flatMap(_=>{const z=Object.values(a.tasks).filter(q=>q.segment!==void 0&&q.id.startsWith(`${_.id}#`));return z.length>0?z:[_]}),totalTaskCount:Object.keys(a.tasks).length+l.length},H=typeof n.retryBudget=="number"?n.retryBudget:void 0,Q=H===void 0?void 0:ei(H),J=new Es(M,x),te=new Ir(w),re=Kn(n.outputStyle,m?.run?.quietOnSuccess);if(f.satisfiedServices.length>0)for(const _ of f.satisfiedServices){const z=f.serviceDependentsByServiceId.get(_.id)??[];try{await M.callHook("service:attach",_,z)}catch(q){x("service:attach",q)}}return{childEnvPolicyFor:B,failureLogLifeCycle:te,hookLifeCycle:J,hooks:M,isTTY:G,lifecycleOptions:X,maybeWriteProfile:k,outputStyle:re,preTraceCheck:L,resolveCommand:N,runnerOptions:b,sharedRetryBudget:Q,spawnContext:D,startTime:j,strictEnvFailure:A}},ji=async t=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Gr()==="win32"){try{await bi(t)}catch{}return}const e=process.env.SHELL;if(!e)return;const s=Ds(e);try{if(s==="zsh"){await Si(t);return}if(s==="bash"){await ki(t);return}s==="fish"&&await Ti(t)}catch{}},Xe=t=>t.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Si=async t=>{const e=process.env.HISTFILE??ne(process.env.ZDOTDIR??Ve(),".zsh_history"),s=`: ${Math.floor(Date.now()/1e3)}:0;${Xe(t)}
46
- `;await Oe(e,s)},ki=async t=>{const e=process.env.HISTFILE??ne(Ve(),".bash_history");await Oe(e,`${Xe(t)}
47
- `)},bi=async t=>{const e=process.env.VIS_PSREADLINE_HISTORY,s=process.env.APPDATA;if(e===void 0&&(s===void 0||s===""))return;const r=e??ne(s,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Nr(Tt(r),{recursive:!0}),await Oe(r,`${Xe(t)}\r
48
- `)},Ti=async t=>{const e=ne(Ve(),".local","share","fish","fish_history"),r=`- cmd: ${t.replaceAll("\\","\\\\").replaceAll(`
45
+ `)}catch{}},vi=(t,e="npm")=>{const s=`${e} install`;if((e==="pnpm"||e==="aube")&&me(ie(t,Fe))&&pi(t))return{file:Fe,installCommand:s};const r=ie(t,"package.json"),n=Zt(r);if(!n)return;const o=hi(e);o==="pnpm.overrides"?(n.pnpm??={},n.pnpm.overrides??={},n.pnpm.overrides[ue]=Me):(n[o]??={},n[o][ue]=Me);try{Ue(r,`${JSON.stringify(n,void 0,4)}
46
+ `)}catch{return}return{file:"package.json",installCommand:s}},yi=async(t,e)=>{const s=gi(t,e.projectManifests);if(!s.present||s.alreadyOverridden||s.declined)return!1;const r=Er({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${ue}. Its cache hints no-op under @visulima/task-runner unless aliased to ${Xe} (a drop-in replacement).`);const n=await new Promise(i=>{r.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(n.trim()))return wi(t),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=vi(t,s.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${ue}": "${Me}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},xi=async({config:t,logger:e,options:s,packageJsons:r,workspaceRoot:n})=>{await Pr(n,t.toolchain,{error:l=>{e.error(l)},info:l=>{e.info(l)},warn:l=>{e.warn(l)}},!!s.skipToolchain);const o=s.preflight!==!1&&t.preflight?.lockfile!==!1,i=Ir(n,be,{warn:l=>{e.warn(l)}},{skip:!o});if(!i.shouldContinue)throw new Error(`${i.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);o&&!be&&process.stdin.isTTY&&process.stdout.isTTY&&await yi(n,{interactive:!0,logger:{info:l=>{e.info(l)},warn:l=>{e.warn(l)}},projectManifests:[...r.values()]})},ji=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,Si=new Set(["0","!","#","$","*","-","?","@","_"]),ki=t=>{const e=new Map;for(const s of t.matchAll(ji)){const r=s[1],n=s[3],o=s[2],i=r??n;if(i===void 0||Si.has(i))continue;const l=o!==void 0,d=e.get(i);d===void 0?e.set(i,l):d&&!l&&e.set(i,!1)}return[...e.entries()].map(([s,r])=>({hasDefault:r,name:s}))},bi=t=>{const{command:e,processEnv:s,taskEnv:r,taskId:n}=t,o=ki(e);if(o.length===0)return;const i=[];for(const{hasDefault:l,name:d}of o){if(l)continue;const h=r[d],u=s[d];h===void 0&&u===void 0&&i.push(d)}if(i.length!==0)return{missing:i.toSorted(),taskId:n}},Ti=t=>{const e=t.missing.map(s=>`$${s}`).join(", ");return`Strict env: ${t.taskId} references unset variable${t.missing.length===1?"":"s"} ${e}. Set ${t.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},$i=async({configTaskRunner:t,logger:e,options:s,runnerOptions:r,workspaceRoot:n})=>{const o=ls(t.remoteCache);if(o){const i=fn(s.cacheMode),l=hn(s.cacheBackend);r.remoteCache={...o,...i?{mode:i}:{},...l?{backend:l}:{}};const d=r.remoteCache.onUploadError;if(r.remoteCache.onUploadError=(h,u)=>{d?.(h,u),e.debug?.(`[vis run] remote cache error (${h}): ${u instanceof Error?u.message:String(u)}`)},r.remoteCache.attestation){const{expectedIdentity:h,requireOnDownload:u}=r.remoteCache.attestation;if(!(h!==void 0&&("github"in h&&typeof h.github?.ref=="string"&&typeof h.github.repo=="string"&&typeof h.github.workflow=="string"||"oidcIssuer"in h&&typeof h.oidcIssuer=="string"&&(typeof h.san=="string"||typeof h.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in h&&(!h.sanRegex.startsWith("^")||!h.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:a,isSigstoreInstalled:m}=await import("./loader.js");m()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
47
+ ${a(n)}`);const{buildCacheAttestationHooks:w}=await import("./cache-attestation.js");r.remoteCache.attestation=w({expectedIdentity:h,onReject:(j,E)=>{e.warn(`[vis run] remote cache entry ${j.slice(0,12)} rejected: attestation ${E}. Treating as a cache miss.`)},onVerifyFailure:j=>{e.warn(`[vis run] attestation verification failed: ${j}`)},requireOnDownload:u,workspaceRoot:n})}}else(s.cacheMode||s.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.")},Ci=async({affectedFiles:t,config:e,currentOs:s,initialTasks:r,invocationCwd:n,logger:o,options:i,persistentTasks:l,projectsWithTarget:d,runCacheDirectory:h,serviceEnvByTaskId:u,serviceResult:p,target:a,taskGraph:m,visConfig:w,workspaceRoot:j})=>{const E=Date.now(),y=Hs(),g=(N,H)=>{const V=H instanceof Error?H.message:String(H);o.warn(`Plugin error in ${N}: ${V}`)};await qs(y,e.plugins);const S=typeof i.profile=="string"?i.profile:void 0,F=async N=>{if(!S)return;const H=Tt(N,m,E),V=S.startsWith("/")?S:`${j}/${S}`;await us(H,V),o.info(`Profile written to ${S}`)},C=e.taskRunner??{},v=dn(process.env.VIS_RUN_CONCURRENCY_LIMIT);v&&"invalid"in v&&o.warn(`VIS_RUN_CONCURRENCY_LIMIT=${v.invalid} is not a positive number; falling back to default concurrency.`);const L=v&&"value"in v?v.value:void 0,P=i.parallel??L??3,$=i.strictEnv??e.strictEnv??!1,M=new Set,T={dryRun:i.dryRun??!1,parallel:P,skipNxCache:!i.cache,summarize:i.summarize??!1,...C,cacheDirectory:h,dataDirectory:C.dataDirectory??Ie(j),namedInputs:e.namedInputs,onDiagnostic:(N,H)=>{M.has(N)||(M.add(N),o.warn(H))},onFingerprint:async(N,H)=>{await y.callHook("task:fingerprint",N,H)}},I=N=>ir(T.env,ke(N)?.env),k=nr({affectedFiles:t,childEnvPolicy:I,initCwd:n,serviceEnvByTaskId:u,taskSlots:P,workspaceRoot:j}),O=N=>Ye(N,t,s),B=(N,H,V)=>{if(!(ke(N)?.strictEnv??$))return;const oe=Te(k,N,V),fe=k.childEnvPolicy(N),de=bi({command:H,processEnv:fe.mode==="clean"?ds(process.env,fe):process.env,taskEnv:oe.env,taskId:N.id});return de?Ti(de):void 0},D=(N,H)=>{const V=O(N);return V===void 0?void 0:B(N,V,H)};await $i({configTaskRunner:C,logger:o,options:i,runnerOptions:T,workspaceRoot:j});const _=process.stdout.isTTY&&!be,W=w?.run?.quietOnSuccess===!0,q=e.tui?.autoExit??(W?3:!1),G={args:{parallel:T.parallel,targets:[a]},autoExit:q,projectNames:d,tasks:[...r,...l].flatMap(N=>{const H=Object.values(m.tasks).filter(V=>V.segment!==void 0&&V.id.startsWith(`${N.id}#`));return H.length>0?H:[N]}),totalTaskCount:Object.keys(m.tasks).length+l.length},J=typeof i.retryBudget=="number"?i.retryBudget:void 0,z=J===void 0?void 0:ci(J),Z=new Us(y,g),te=new Mr(j),K=si(i.outputStyle,w?.run?.quietOnSuccess);if(p.satisfiedServices.length>0)for(const N of p.satisfiedServices){const H=p.serviceDependentsByServiceId.get(N.id)??[];try{await y.callHook("service:attach",N,H)}catch(V){g("service:attach",V)}}return{childEnvPolicyFor:I,failureLogLifeCycle:te,hookLifeCycle:Z,hooks:y,isTTY:_,lifecycleOptions:G,maybeWriteProfile:F,outputStyle:K,preTraceCheck:D,resolveCommand:O,runnerOptions:T,sharedRetryBudget:z,spawnContext:k,startTime:E,strictEnvFailure:B}},Ii=async t=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(qr()==="win32"){try{await Pi(t)}catch{}return}const e=process.env.SHELL;if(!e)return;const s=Zs(e);try{if(s==="zsh"){await Ei(t);return}if(s==="bash"){await Ri(t);return}s==="fish"&&await Mi(t)}catch{}},Je=t=>t.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Ei=async t=>{const e=process.env.HISTFILE??ie(process.env.ZDOTDIR??Ve(),".zsh_history"),s=`: ${Math.floor(Date.now()/1e3)}:0;${Je(t)}
48
+ `;await Ae(e,s)},Ri=async t=>{const e=process.env.HISTFILE??ie(Ve(),".bash_history");await Ae(e,`${Je(t)}
49
+ `)},Pi=async t=>{const e=process.env.VIS_PSREADLINE_HISTORY,s=process.env.APPDATA;if(e===void 0&&(s===void 0||s===""))return;const r=e??ie(s,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Hr(Et(r),{recursive:!0}),await Ae(r,`${Je(t)}\r
50
+ `)},Mi=async t=>{const e=ie(Ve(),".local","share","fish","fish_history"),r=`- cmd: ${t.replaceAll("\\","\\\\").replaceAll(`
49
51
  `,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
50
52
  when: ${Math.floor(Date.now()/1e3)}
51
- `;await Oe(e,r)},$i=t=>t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||t.startsWith("**"),Ci=t=>{let e=t.trim();if(e==="")return;let s=!1,r=!1,i=!1;e.startsWith("...")&&(s=!0,e=e.slice(3),e.startsWith("^")&&(i=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(i=!0,e=e.slice(0,-1)));let o;const n=/\[([^\]]*)\]$/.exec(e);n&&(o=n[1]??"",e=e.slice(0,n.index));let l=e.trim(),d=!1;return l.startsWith("{")&&l.endsWith("}")&&l.length>=2?(l=l.slice(1,-1),d=!0):$i(l)&&(d=!0),{changedSince:o,excludeSelf:i,includeDependencies:r,includeDependents:s,isPath:d,pattern:l}},Ge=t=>{let e=t.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},Ii=(t,e,s)=>t===""?!1:Be(t,e)?!0:s!==void 0&&Be(t,s),Ei=(t,e)=>{if(e===void 0||e==="")return!1;const s=Ge(t),r=Ge(e);return Be(s,r)},Ri=(t,e,s)=>{const{affected:r,downstream:i,upstream:o}=ds(t,s,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const n=new Set([...i,...o]);for(const l of t)n.delete(l);return n},Pi=async(t,e)=>{const{packageNameByProject:s,projectGraph:r}=e,i=Object.keys(r.nodes);let o=new Set;if(t.pattern!=="")for(const n of i)t.isPath?Ei(t.pattern,r.nodes[n]?.data.root)&&o.add(n):Ii(t.pattern,n,s?.get(n))&&o.add(n);if(t.changedSince!==void 0){const n=t.changedSince===""?e.defaultBase??"main":t.changedSince,l=e.changedProjectsForRef??Mi(e),d=new Set(await l(n));o=t.pattern===""?d:new Set([...o].filter(h=>d.has(h)))}return!t.includeDependents&&!t.includeDependencies?o:Ri(o,t,r)},Mi=t=>async e=>{const{projectGraph:s,workspaceRoot:r}=t;if(!r)return[];let i;try{i=await us(r,e,"HEAD")}catch(n){const l=n instanceof Error?n.message:String(n);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${l})`,{cause:n})}const o=new Set;for(const[n,l]of Object.entries(s.nodes)){const d=Ge(l.data.root??n);if(!(d===""||d==="."))for(const h of i){const f=Bs(r,h).replaceAll("\\","/");if(f===d||f.startsWith(`${d}/`)){o.add(n);break}}}return[...o]},Fi=async(t,e)=>{const s=new Set;for(const r of t)for(const i of await Pi(r,e))s.add(i);return[...s]},Oi=async(t,e)=>{const s=[];for(const r of t){const i=Ci(r);i&&s.push(i)}return Fi(s,e)},Ai=({logger:t,options:e,projectNames:s,projectOptions:r,target:i,workspace:o})=>{const n=(typeof e.runnerTags=="string"?e.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,l=n?new Set(n.split(",").map(f=>f.trim()).filter(Boolean)):void 0,d=[],h=new Map;for(const f of s){const a=r.get(f)?.[i];if(!a)continue;const m=a.options;if(!m?.internal){if(!_s(m,!!Se)){t.debug?.(`Skipping ${f}:${i} — runInCI filter`);continue}if(!Ns(m,l)){t.debug?.(`Skipping ${f}:${i} — runner-tags filter`);continue}d.push(f),h.set(f,a)}}if(d.length===0){if(e.ifPresent){t.info(`No projects have the "${i}" target; skipping (--if-present).`);return}const f=Ot(o),p=Object.entries(o.projects).filter(([,m])=>m.targets?.[i]!==void 0).map(([m])=>m),a=[`No projects have the "${i}" target.`];if(p.length>0)a.push("",`Target "${i}" exists in these projects but was filtered out:`,...p.slice(0,5).map(m=>` - ${m}`)),p.length>5&&a.push(` …and ${p.length-5} more`);else{const m=Rr(i,f,3);m.length>0&&a.push("",m.length===1?`Did you mean "${m[0]}"?`:`Did you mean one of: ${m.map(w=>`"${w}"`).join(", ")}?`),a.push("","Run `vis run` without arguments to see all available targets, or pass --if-present to skip when no project has the target.")}throw new pe(a.join(`
52
- `))}return{projectsWithTarget:d,projectTargetIndex:h}},Li=async({argument:t,logger:e,workspace:s})=>{let r=t[0];if(!r){const i=Ot(s);if(process.stdout.isTTY&&process.stdin.isTTY){const o=await Pr(i);if(!o){e.info("No target selected.");return}r=o,await ji(`vis run ${o}`)}else throw e.info("Available targets:"),e.info(""),e.info(Mr(i)),e.info(""),new pe("Missing target. Usage: vis run <target>")}return r},Di=({config:t,logger:e,options:s,projectGraph:r})=>{if(t.constraints&&!s.skipConstraints){const i=fs(r,t.constraints);if(i.length>0){for(const o of i)e.error(`[${o.rule}] ${o.message}`);throw new Error(`${i.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}},Bi=({options:t,rawSelector:e})=>{if(!t.affected){const s=t.uncommitted?"--uncommitted":"--no-uncommitted",r=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[s,t.uncommitted]].filter(([,i])=>i!==void 0).map(([i])=>i);if(r.length>0)throw new pe(`${r.join(", ")} ${r.length===1?"requires":"require"} --affected.
53
- Did you mean: vis run ${e} --affected ${r.map(i=>i.includes("uncommitted")?i:`${i}=…`).join(" ")}
54
- Or use the dedicated command: vis affected ${e} …`)}},_i=async({logger:t,options:e,packageJsons:s,projectGraph:r,projectOptions:i,rawSelector:o,visConfig:n,workspace:l,workspaceRoot:d})=>{const h=await Lr(o,l,process.cwd(),d),f=Fr(i),p=Or(h.target,f);p!==h.target&&t.debug?.(`Resolved alias "${h.target}" → "${p}"`);let a=h.projects;e.projects!==void 0&&(a=Ar(a,String(e.projects),Object.keys(l.projects)));const m=w=>{if(e.ifPresent){t.info(`${w}; skipping (--if-present).`);return}throw new pe(`${w}.
55
-
56
- Pass --if-present to skip quietly when nothing matches.`)};if(e.filter&&e.filter.length>0){const w=new Map;for(const[x,g]of s)w.set(x,g.name);const j=await Oi(e.filter,{defaultBase:n?.defaultBase,packageNameByProject:w,projectGraph:r,workspaceRoot:d}),M=new Set(j);if(a=a.filter(x=>M.has(x)),a.length===0){m(`Filter ${e.filter.map(x=>`"${x}"`).join(", ")} matched no projects`);return}}if(e.query&&(a=Dr(a,l,e.query),a.length===0)){m(`Query "${String(e.query)}" matched no projects`);return}if(e.tag&&e.tag.length>0&&(a=Br(a,l,e.tag),a.length===0)){m(`Tag filter ${e.tag.map(w=>`"${w}"`).join(", ")} matched no projects`);return}return{projectNames:a,target:p}},Ni=async({fileOwners:t,logger:e,options:s,projectGraph:r,projectNames:i,visConfig:o,workspace:n,workspaceRoot:l})=>{let d=i,h;if(s.affected){const f=await Er({base:s.base,downstream:s.downstream,head:s.head,uncommitted:s.uncommitted,upstream:s.upstream},{fileOwners:t,projectGraph:r,projects:n.projects,workspaceRoot:l},{affectedIgnore:o?.affectedIgnore,defaultBase:o?.defaultBase});for(const m of f.notes)e.info(`▸ ${m}`);if(f.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const p=new Set(f.affectedProjects);if(d=d.filter(m=>p.has(m)),d.length===0){e.info("No projects affected by the changes.");return}const a=new Set(f.ignoredFiles);h=f.changedFiles.filter(m=>!a.has(m)),e.info(`Affected projects: ${d.join(", ")}`)}return{affectedChangedFiles:h,projectNames:d}},Gi=async({argument:t,config:e,fileOwners:s,logger:r,options:i,packageJsons:o,projectGraph:n,projectOptions:l,visConfig:d,workspace:h,workspaceRoot:f})=>{const p=await Li({argument:t,logger:r,workspace:h});if(p===void 0)return;Di({config:e,logger:r,options:i,projectGraph:n}),Bi({options:i,rawSelector:p});const a=await _i({logger:r,options:i,packageJsons:o,projectGraph:n,projectOptions:l,rawSelector:p,visConfig:d,workspace:h,workspaceRoot:f});if(!a)return;const{target:m}=a,w=t.slice(1).map(String),j=await Ni({fileOwners:s,logger:r,options:i,projectGraph:n,projectNames:a.projectNames,visConfig:d,workspace:h,workspaceRoot:f});if(!j)return;const{affectedChangedFiles:M,projectNames:x}=j,g=Ct(),k=process.env[qs],P=M??(k?k.split(`
57
- `).filter(Boolean):void 0),C=Ai({logger:r,options:i,projectNames:x,projectOptions:l,target:m,workspace:h});if(!C)return;const{projectsWithTarget:y,projectTargetIndex:E}=C;return{affectedFiles:P,currentOs:g,forwardedArgs:w,projectsWithTarget:y,projectTargetIndex:E,target:m}},Wi=64*1024,gt=256,Hi=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),Le=t=>t.replaceAll(Hi,"").replaceAll("\r","");class wt{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const s of e)this.#n.set(s,{id:s,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,s=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(s=!0);return e?"crash":s?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,s=>({...s,errorMessage:void 0,startedAt:s.startedAt??Date.now(),status:"starting"}))}markStarted(e,s){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,s){this.#t(e,r=>({...r,errorMessage:void 0,port:s.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,s,r){const i=r?.message;this.#t(e,o=>({...o,errorMessage:Le(i??s),status:"failed"}))}markCrashed(e,s){const r=s.slice(-gt).map(i=>Le(i));this.#t(e,i=>({...i,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,s){const r=s.split(`
58
- `).map(i=>Le(i)).filter(i=>i.length>0);r.length!==0&&this.#t(e,i=>{const o=[...i.tailLines,...r];for(;o.length>gt;)o.shift();let n=0;for(let l=o.length-1;l>=0;l--)if(n+=o[l].length+1,n>Wi){o.splice(0,l+1);break}return{...i,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let s=!1;const r=new Map(this.#n);for(const[i,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(i,{...o,errorMessage:e,status:"failed"}),s=!0);s&&(this.#n=r,this.#i(),this.#o())}#t(e,s){const r=this.#n.get(e);r&&(this.#n.set(e,s(r)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#n)}#o(){for(const e of this.#r)try{e()}catch{}}}const qi=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Vi=async t=>{const{initialTasks:e,probe:s,registeredEntries:r,taskGraph:i,visVersion:o}=t,n=new Map,l=new Map,d=new Map;for(const y of r)if(Rs(y.pid)){if(y.visVersion!==o){l.set(y.id,y);continue}n.set(y.id,y)}if(s){const y=[...n.values()],E=await Promise.all(y.map(async R=>{try{return[R.id,await s(R)]}catch{return[R.id,!1]}}));for(const[R,$]of E)if(!$){const O=n.get(R);n.delete(R),O&&d.set(R,O)}}const h=new Set(e.map(y=>y.id)),f=new Set,p=[],a=[],m=new Set;for(const y of Object.values(i.dependencies))for(const E of y)m.add(E);for(const[y,E]of Object.entries(i.tasks)){if(!qi(E)?.service)continue;if(n.has(y)){f.add(y),a.push(n.get(y));continue}if(h.has(y)||!m.has(y))continue;const O=l.get(y),T=d.get(y);let b;O?b=`Service ${y} is registered with vis ${O.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${y}\` to pick up the new version.`:T?b=`Service ${y} is registered (PID ${String(T.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${y}\` to recover.`:b=`Target depends on the service ${y}, which is not running. Run \`vis service start ${y}\` first, or invoke \`${y}\` directly.`,p.push({message:b,targetId:y})}if(f.size===0)return{diagnostics:p,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:i};const w=new Map,j=y=>{const E=new Set,R=[...i.dependencies[y]??[]],$=new Set;for(;R.length>0;){const O=R.pop();if(!$.has(O)){$.add(O),f.has(O)&&E.add(O);for(const T of i.dependencies[O]??[])$.has(T)||R.push(T)}}return[...E].sort()},M=new Map;for(const y of Object.keys(i.dependencies)){if(f.has(y))continue;const E=j(y);if(E.length===0)continue;const R={};for(const $ of E){const O=n.get($);if(!O)continue;Object.assign(R,O.env);const T=M.get($);T?T.push(y):M.set($,[y])}Object.keys(R).length>0&&w.set(y,R)}for(const y of M.values())y.sort();const x={};for(const[y,E]of Object.entries(i.tasks))f.has(y)||(x[y]=E);const g={};for(const[y,E]of Object.entries(i.dependencies))f.has(y)||(g[y]=E.filter(R=>!f.has(R)));const k=new Map;for(const y of Object.keys(x))k.set(y,0);for(const y of Object.values(g))for(const E of y)k.has(E)&&k.set(E,(k.get(E)??0)+1);const P=[];for(const y of i.roots)!f.has(y)&&x[y]&&P.push(y);for(const[y,E]of k)E===0&&!P.includes(y)&&x[y]&&P.push(y);const C=e.filter(y=>!f.has(y.id));return{diagnostics:p,initialTasks:C,satisfiedServices:a,serviceDependentsByServiceId:M,serviceEnvByTaskId:w,taskGraph:{dependencies:g,roots:P,tasks:x}}},Te="[[VIS_BOOT]]",Ui=250,zi=1e3,vt=3,Yi=t=>{try{return process.kill(t,0),!0}catch{return!1}},yt=t=>{try{const e=we(t,"utf8").trim(),s=Number.parseInt(e,10);return Number.isFinite(s)&&s>0?s:null}catch{return null}};class Ki{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const s=this.#e.get(e.index);s===void 0||e.text===void 0||this.onTaskOutput(s,e.text)};onTaskOutput(e,s){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+s).split(`
59
- `),n=o.pop()??"";this.#t.set(e,n);for(const l of o)this.#d(e,l)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,s){this.#s.started(e,s)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,s,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||s!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:s,killed:r});return}const o=await Ps(this.#n,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:n}=o,l=n.readiness?.tcp?.port??n.port??0,d=n.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:d,logFile:o.logFile,pid:o.pid,port:l})}notifyRegistryReady(e,s){this.#s.ready(e,{host:s.host,port:s.port}),this.#h(e,s.logFile),s.pid!==null&&this.#p(e,s.pid)}notifyRegistryFailed(e,s,r){this.#s.failed(e,s,r)}async retry(e){const s=this.#r.get(e);if(s){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),s.mode==="registry"){await this.#y(e,s.registry);return}s.mode==="ephemeral"&&this.#v(e,s.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#c.keys()])this.#f(e);this.#a.size>0&&(await Promise.race([Promise.all(this.#a),new Promise(e=>{setTimeout(e,2e3)})]),this.#a.clear()),this.#t.clear(),this.#i.clear()}#d(e,s){if(s.startsWith(Te)){this.#u(e,s.slice(Te.length));return}const r=this.#i.get(e)??[];r.push(s),r.length>vt&&r.shift(),this.#i.set(e,r),this.#s.log(e,`${s}
60
- `)}#u(e,s){let r;try{r=JSON.parse(s)}catch{this.#s.log(e,`${Te+s}
61
- `);return}switch(r.event){case"failed":{const i=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[n,l]of Object.entries(r))n!=="event"&&n!=="id"&&n!=="reason"&&(o[n]=l);this.#s.failed(e,i,o);break}case"ready":{const i=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:i,port:o}),this.#l(e);break}case"started":{const i=typeof r.pid=="number"?r.pid:null;this.#s.started(e,i);break}default:this.#s.log(e,`${Te+s}
62
- `)}}#l(e){const s=this.#r.get(e);if(s?.ephemeral===void 0)return;this.#h(e,s.ephemeral.logFile);const r=yt(s.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,s){if(this.#o.has(e)||!he(s))return;const r=cr(s,"r"),i=(()=>{try{return Qe(s).size}catch{return 0}})(),o={fd:r,logFile:s,pollTimer:setInterval(()=>{this.#g(e)},Ui),position:i};this.#o.set(e,o)}#g(e){const s=this.#o.get(e);if(s)try{const r=Qe(s.logFile);if(r.size<=s.position)return;const i=Buffer.alloc(r.size-s.position),o=ar(s.fd,i,0,i.length,s.position);if(o>0){s.position+=o;const n=i.subarray(0,o).toString("utf8");for(const l of n.split(`
63
- `))l.length!==0&&this.#w(e,l);this.#s.log(e,n)}}catch{}}#w(e,s){const r=this.#i.get(e)??[];for(r.push(s);r.length>vt;)r.shift();this.#i.set(e,r)}#p(e,s){if(this.#c.has(e))return;const r={pid:s,timer:setInterval(()=>{if(!Yi(s)){const i=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,i)}},zi)};this.#c.set(e,r)}#f(e){const s=this.#o.get(e);if(s){clearInterval(s.pollTimer);try{lr(s.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,s){if(s===void 0)return;const r=yt(s.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const i=Hr("node",[s.scriptPath,s.configFile],{cwd:s.cwd,stdio:["ignore","pipe","pipe"]});i.stdout.on("data",n=>{this.#m(e,n)}),i.stderr.on("data",n=>{this.#m(e,n)}),i.on("error",n=>{this.#s.failed(e,"respawn-error",{message:n.message})});const o=new Promise(n=>{const l=()=>{this.#a.delete(o),n()};i.once("exit",l),i.once("error",l)});this.#a.add(o)}#m(e,s){const o=((this.#t.get(e)??"")+s.toString("utf8")).split(`
64
- `),n=o.pop()??"";this.#t.set(e,n);for(const l of o)this.#d(e,l)}async#y(e,s){if(s!==void 0){try{await Ms({id:e,workspaceRoot:this.#n})}catch{}try{const r=await Fs({command:s.command,config:s.config,cwd:s.cwd,env:s.env,id:e,workspaceRoot:this.#n}),i=s.config.readiness?.tcp?.port??s.config.port??0,o=s.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:r.entry.logFile,pid:r.entry.pid,port:i})}catch(r){const i=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:i})}}}}const Xi=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Qt=(t,e,s)=>{const r=[],i=[];for(const o of e){const n=s.tasks[o];if(!n){i.push({id:o,reason:"task not in graph"});continue}const l=n.overrides.command;if(!l){i.push({id:o,reason:"no command resolved"});continue}const d=Xi(n);if(!d?.service){i.push({id:o,reason:"no service config"});continue}const h=He(t,n.projectRoot,!!d.runFromWorkspaceRoot),{envFile:f}=d,p=f===void 0||f===!1?{}:Gs(h,f),a=d.service.env??{};r.push({command:l,config:d.service,cwd:h,env:{...p,...a},id:o})}return{services:r,skipped:i}},Ji=(t,e)=>{const s=new Set(t),r=new Map;for(const n of t){const l=(e.dependencies[n]??[]).filter(d=>s.has(d));r.set(n,new Set(l))}const i=[],o=new Set;for(;r.size>0;){const n=[];for(const[l,d]of r){for(const h of d)o.has(h)&&d.delete(h);d.size===0&&n.push(l)}n.length===0&&n.push(...r.keys());for(const l of n)o.add(l),r.delete(l);n.sort(),i.push({ids:n})}return i},Qi=(t,e)=>{const s=[];for(const r of Ji(t,e))s.push(...r.ids);return s},Zi=String.raw`import { spawn } from "node:child_process";
53
+ `;await Ae(e,r)},Fi=t=>t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||t.startsWith("**"),Oi=t=>{let e=t.trim();if(e==="")return;let s=!1,r=!1,n=!1;e.startsWith("...")&&(s=!0,e=e.slice(3),e.startsWith("^")&&(n=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(n=!0,e=e.slice(0,-1)));let o;const i=/\[([^\]]*)\]$/.exec(e);i&&(o=i[1]??"",e=e.slice(0,i.index));let l=e.trim(),d=!1;return l.startsWith("{")&&l.endsWith("}")&&l.length>=2?(l=l.slice(1,-1),d=!0):Fi(l)&&(d=!0),{changedSince:o,excludeSelf:n,includeDependencies:r,includeDependents:s,isPath:d,pattern:l}},Ge=t=>{let e=t.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},Ai=(t,e,s)=>t===""?!1:_e(t,e)?!0:s!==void 0&&_e(t,s),Li=(t,e)=>{if(e===void 0||e==="")return!1;const s=Ge(t),r=Ge(e);return _e(s,r)},Di=(t,e,s)=>{const{affected:r,downstream:n,upstream:o}=fs(t,s,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const i=new Set([...n,...o]);for(const l of t)i.delete(l);return i},Bi=async(t,e)=>{const{packageNameByProject:s,projectGraph:r}=e,n=Object.keys(r.nodes);let o=new Set;if(t.pattern!=="")for(const i of n)t.isPath?Li(t.pattern,r.nodes[i]?.data.root)&&o.add(i):Ai(t.pattern,i,s?.get(i))&&o.add(i);if(t.changedSince!==void 0){const i=t.changedSince===""?e.defaultBase??"main":t.changedSince,l=e.changedProjectsForRef??_i(e),d=new Set(await l(i));o=t.pattern===""?d:new Set([...o].filter(h=>d.has(h)))}return!t.includeDependents&&!t.includeDependencies?o:Di(o,t,r)},_i=t=>async e=>{const{projectGraph:s,workspaceRoot:r}=t;if(!r)return[];let n;try{n=await hs(r,e,"HEAD")}catch(i){const l=i instanceof Error?i.message:String(i);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${l})`,{cause:i})}const o=new Set;for(const[i,l]of Object.entries(s.nodes)){const d=Ge(l.data.root??i);if(!(d===""||d==="."))for(const h of n){const u=er(r,h).replaceAll("\\","/");if(u===d||u.startsWith(`${d}/`)){o.add(i);break}}}return[...o]},Ni=async(t,e)=>{const s=new Set;for(const r of t)for(const n of await Bi(r,e))s.add(n);return[...s]},Wi=async(t,e)=>{const s=[];for(const r of t){const n=Oi(r);n&&s.push(n)}return Ni(s,e)},Gi=({logger:t,options:e,projectNames:s,projectOptions:r,target:n,workspace:o})=>{const i=(typeof e.runnerTags=="string"?e.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,l=i?new Set(i.split(",").map(u=>u.trim()).filter(Boolean)):void 0,d=[],h=new Map;for(const u of s){const a=r.get(u)?.[n];if(!a)continue;const m=a.options;if(!m?.internal){if(!tr(m,!!be)){t.debug?.(`Skipping ${u}:${n} — runInCI filter`);continue}if(!sr(m,l)){t.debug?.(`Skipping ${u}:${n} — runner-tags filter`);continue}d.push(u),h.set(u,a)}}if(d.length===0){if(e.ifPresent){t.info(`No projects have the "${n}" target; skipping (--if-present).`);return}const u=Dt(o),p=Object.entries(o.projects).filter(([,m])=>m.targets?.[n]!==void 0).map(([m])=>m),a=[`No projects have the "${n}" target.`];if(p.length>0)a.push("",`Target "${n}" exists in these projects but was filtered out:`,...p.slice(0,5).map(m=>` - ${m}`)),p.length>5&&a.push(` …and ${p.length-5} more`);else{const m=Fr(n,u,3);m.length>0&&a.push("",m.length===1?`Did you mean "${m[0]}"?`:`Did you mean one of: ${m.map(w=>`"${w}"`).join(", ")}?`),a.push("","Run `vis run` without arguments to see all available targets, or pass --if-present to skip when no project has the target.")}throw new ge(a.join(`
54
+ `))}return{projectsWithTarget:d,projectTargetIndex:h}},Hi=async({argument:t,logger:e,workspace:s})=>{let r=t[0];if(!r){const n=Dt(s);if(process.stdout.isTTY&&process.stdin.isTTY){const o=await Or(n);if(!o){e.info("No target selected.");return}r=o,await Ii(`vis run ${o}`)}else throw e.info("Available targets:"),e.info(""),e.info(Ar(n)),e.info(""),new ge("Missing target. Usage: vis run <target>")}return r},qi=({config:t,logger:e,options:s,projectGraph:r})=>{if(t.constraints&&!s.skipConstraints){const n=ps(r,t.constraints);if(n.length>0){for(const o of n)e.error(`[${o.rule}] ${o.message}`);throw new Error(`${n.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}},Ui=({options:t,rawSelector:e})=>{if(!t.affected){const s=t.uncommitted?"--uncommitted":"--no-uncommitted",r=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[s,t.uncommitted]].filter(([,n])=>n!==void 0).map(([n])=>n);if(r.length>0)throw new ge(`${r.join(", ")} ${r.length===1?"requires":"require"} --affected.
55
+ Did you mean: vis run ${e} --affected ${r.map(n=>n.includes("uncommitted")?n:`${n}=…`).join(" ")}
56
+ Or use the dedicated command: vis affected ${e} …`)}},Vi=async({logger:t,options:e,packageJsons:s,projectGraph:r,projectOptions:n,rawSelector:o,visConfig:i,workspace:l,workspaceRoot:d})=>{const h=await _r(o,l,process.cwd(),d),u=Lr(n),p=Dr(h.target,u);p!==h.target&&t.debug?.(`Resolved alias "${h.target}" → "${p}"`);let a=h.projects;e.projects!==void 0&&(a=Br(a,String(e.projects),Object.keys(l.projects)));const m=w=>{if(e.ifPresent){t.info(`${w}; skipping (--if-present).`);return}throw new ge(`${w}.
57
+
58
+ Pass --if-present to skip quietly when nothing matches.`)};if(e.filter&&e.filter.length>0){const w=new Map;for(const[y,g]of s)w.set(y,g.name);const j=await Wi(e.filter,{defaultBase:i?.defaultBase,packageNameByProject:w,projectGraph:r,workspaceRoot:d}),E=new Set(j);if(a=a.filter(y=>E.has(y)),a.length===0){m(`Filter ${e.filter.map(y=>`"${y}"`).join(", ")} matched no projects`);return}}if(e.query&&(a=Nr(a,l,e.query),a.length===0)){m(`Query "${String(e.query)}" matched no projects`);return}if(e.tag&&e.tag.length>0&&(a=Wr(a,l,e.tag),a.length===0)){m(`Tag filter ${e.tag.map(w=>`"${w}"`).join(", ")} matched no projects`);return}return{projectNames:a,target:p}},zi=async({cacheDirectory:t,fileOwners:e,logger:s,options:r,projectGraph:n,projectNames:o,visConfig:i,workspace:l,workspaceRoot:d})=>{let h=o,u,p,a;if(r.affected){const m=await Bs({base:r.base,downstream:r.downstream,head:r.head,uncommitted:r.uncommitted,upstream:r.upstream},{fileOwners:e,namedInputs:i?.namedInputs,projectGraph:n,projects:l.projects,workspaceRoot:d},{affectedIgnore:i?.affectedIgnore,defaultBase:i?.defaultBase,externalInputStatePath:t?ie(t,"external-inputs.json"):void 0,persistExternalInputState:!1});for(const E of m.notes)s.info(`▸ ${E}`);if(u=m.externalInputHashes,p=m.externalInputStatePath,m.changedFiles.length===0&&(m.changedExternalInputs?.length??0)===0){s.info("No files changed. Nothing to run.");return}const w=new Set(m.affectedProjects);if(h=h.filter(E=>w.has(E)),h.length===0){s.info("No projects affected by the changes.");return}const j=new Set(m.ignoredFiles);a=m.changedFiles.filter(E=>!j.has(E)),s.info(`Affected projects: ${h.join(", ")}`)}return{affectedChangedFiles:a,externalInputHashes:u,externalInputStatePath:p,projectNames:h}},Yi=async({argument:t,cacheDirectory:e,config:s,fileOwners:r,logger:n,options:o,packageJsons:i,projectGraph:l,projectOptions:d,visConfig:h,workspace:u,workspaceRoot:p})=>{const a=await Hi({argument:t,logger:n,workspace:u});if(a===void 0)return;qi({config:s,logger:n,options:o,projectGraph:l}),Ui({options:o,rawSelector:a});const m=await Vi({logger:n,options:o,packageJsons:i,projectGraph:l,projectOptions:d,rawSelector:a,visConfig:h,workspace:u,workspaceRoot:p});if(!m)return;const{target:w}=m,j=t.slice(1).map(String),E=await zi({cacheDirectory:e,fileOwners:r,logger:n,options:o,projectGraph:l,projectNames:m.projectNames,visConfig:h,workspace:u,workspaceRoot:p});if(!E)return;const{affectedChangedFiles:y,externalInputHashes:g,externalInputStatePath:S,projectNames:F}=E,C=Pt(),v=process.env[or],L=y??(v?v.split(`
59
+ `).filter(Boolean):void 0),P=Gi({logger:n,options:o,projectNames:F,projectOptions:d,target:w,workspace:u});if(!P)return;const{projectsWithTarget:$,projectTargetIndex:M}=P;return{affectedExternalInputState:S&&g?{hashes:g,path:S}:void 0,affectedFiles:L,currentOs:C,forwardedArgs:j,projectsWithTarget:$,projectTargetIndex:M,target:w}},Ki=64*1024,vt=256,Xi=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),De=t=>t.replaceAll(Xi,"").replaceAll("\r","");class yt{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const s of e)this.#n.set(s,{id:s,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,s=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(s=!0);return e?"crash":s?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,s=>({...s,errorMessage:void 0,startedAt:s.startedAt??Date.now(),status:"starting"}))}markStarted(e,s){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,s){this.#t(e,r=>({...r,errorMessage:void 0,port:s.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,s,r){const n=r?.message;this.#t(e,o=>({...o,errorMessage:De(n??s),status:"failed"}))}markCrashed(e,s){const r=s.slice(-vt).map(n=>De(n));this.#t(e,n=>({...n,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,s){const r=s.split(`
60
+ `).map(n=>De(n)).filter(n=>n.length>0);r.length!==0&&this.#t(e,n=>{const o=[...n.tailLines,...r];for(;o.length>vt;)o.shift();let i=0;for(let l=o.length-1;l>=0;l--)if(i+=o[l].length+1,i>Ki){o.splice(0,l+1);break}return{...n,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let s=!1;const r=new Map(this.#n);for(const[n,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(n,{...o,errorMessage:e,status:"failed"}),s=!0);s&&(this.#n=r,this.#i(),this.#o())}#t(e,s){const r=this.#n.get(e);r&&(this.#n.set(e,s(r)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#n)}#o(){for(const e of this.#r)try{e()}catch{}}}const Ji=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Qi=async t=>{const{initialTasks:e,probe:s,registeredEntries:r,taskGraph:n,visVersion:o}=t,i=new Map,l=new Map,d=new Map;for(const v of r)if(Vs(v.pid)){if(v.visVersion!==o){l.set(v.id,v);continue}i.set(v.id,v)}if(s){const v=[...i.values()],L=await Promise.all(v.map(async P=>{try{return[P.id,await s(P)]}catch{return[P.id,!1]}}));for(const[P,$]of L)if(!$){const M=i.get(P);i.delete(P),M&&d.set(P,M)}}const h=new Set(e.map(v=>v.id)),u=new Set,p=[],a=[],m=new Set;for(const v of Object.values(n.dependencies))for(const L of v)m.add(L);for(const[v,L]of Object.entries(n.tasks)){if(!Ji(L)?.service)continue;if(i.has(v)){u.add(v),a.push(i.get(v));continue}if(h.has(v)||!m.has(v))continue;const M=l.get(v),T=d.get(v);let I;M?I=`Service ${v} is registered with vis ${M.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${v}\` to pick up the new version.`:T?I=`Service ${v} is registered (PID ${String(T.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${v}\` to recover.`:I=`Target depends on the service ${v}, which is not running. Run \`vis service start ${v}\` first, or invoke \`${v}\` directly.`,p.push({message:I,targetId:v})}if(u.size===0)return{diagnostics:p,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:n};const w=new Map,j=v=>{const L=new Set,P=[...n.dependencies[v]??[]],$=new Set;for(;P.length>0;){const M=P.pop();if(!$.has(M)){$.add(M),u.has(M)&&L.add(M);for(const T of n.dependencies[M]??[])$.has(T)||P.push(T)}}return[...L].sort()},E=new Map;for(const v of Object.keys(n.dependencies)){if(u.has(v))continue;const L=j(v);if(L.length===0)continue;const P={};for(const $ of L){const M=i.get($);if(!M)continue;Object.assign(P,M.env);const T=E.get($);T?T.push(v):E.set($,[v])}Object.keys(P).length>0&&w.set(v,P)}for(const v of E.values())v.sort();const y={};for(const[v,L]of Object.entries(n.tasks))u.has(v)||(y[v]=L);const g={};for(const[v,L]of Object.entries(n.dependencies))u.has(v)||(g[v]=L.filter(P=>!u.has(P)));const S=new Map;for(const v of Object.keys(y))S.set(v,0);for(const v of Object.values(g))for(const L of v)S.has(L)&&S.set(L,(S.get(L)??0)+1);const F=[];for(const v of n.roots)!u.has(v)&&y[v]&&F.push(v);for(const[v,L]of S)L===0&&!F.includes(v)&&y[v]&&F.push(v);const C=e.filter(v=>!u.has(v.id));return{diagnostics:p,initialTasks:C,satisfiedServices:a,serviceDependentsByServiceId:E,serviceEnvByTaskId:w,taskGraph:{dependencies:g,roots:F,tasks:y}}},$e="[[VIS_BOOT]]",Zi=250,eo=1e3,xt=3,to=t=>{try{return process.kill(t,0),!0}catch{return!1}},jt=t=>{try{const e=ye(t,"utf8").trim(),s=Number.parseInt(e,10);return Number.isFinite(s)&&s>0?s:null}catch{return null}};class so{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const s=this.#e.get(e.index);s===void 0||e.text===void 0||this.onTaskOutput(s,e.text)};onTaskOutput(e,s){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+s).split(`
61
+ `),i=o.pop()??"";this.#t.set(e,i);for(const l of o)this.#d(e,l)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,s){this.#s.started(e,s)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,s,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||s!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:s,killed:r});return}const o=await zs(this.#n,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:i}=o,l=i.readiness?.tcp?.port??i.port??0,d=i.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:d,logFile:o.logFile,pid:o.pid,port:l})}notifyRegistryReady(e,s){this.#s.ready(e,{host:s.host,port:s.port}),this.#h(e,s.logFile),s.pid!==null&&this.#p(e,s.pid)}notifyRegistryFailed(e,s,r){this.#s.failed(e,s,r)}async retry(e){const s=this.#r.get(e);if(s){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),s.mode==="registry"){await this.#y(e,s.registry);return}s.mode==="ephemeral"&&this.#v(e,s.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#c.keys()])this.#f(e);this.#a.size>0&&(await Promise.race([Promise.all(this.#a),new Promise(e=>{setTimeout(e,2e3)})]),this.#a.clear()),this.#t.clear(),this.#i.clear()}#d(e,s){if(s.startsWith($e)){this.#u(e,s.slice($e.length));return}const r=this.#i.get(e)??[];r.push(s),r.length>xt&&r.shift(),this.#i.set(e,r),this.#s.log(e,`${s}
62
+ `)}#u(e,s){let r;try{r=JSON.parse(s)}catch{this.#s.log(e,`${$e+s}
63
+ `);return}switch(r.event){case"failed":{const n=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[i,l]of Object.entries(r))i!=="event"&&i!=="id"&&i!=="reason"&&(o[i]=l);this.#s.failed(e,n,o);break}case"ready":{const n=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:n,port:o}),this.#l(e);break}case"started":{const n=typeof r.pid=="number"?r.pid:null;this.#s.started(e,n);break}default:this.#s.log(e,`${$e+s}
64
+ `)}}#l(e){const s=this.#r.get(e);if(s?.ephemeral===void 0)return;this.#h(e,s.ephemeral.logFile);const r=jt(s.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,s){if(this.#o.has(e)||!me(s))return;const r=ur(s,"r"),n=(()=>{try{return Ze(s).size}catch{return 0}})(),o={fd:r,logFile:s,pollTimer:setInterval(()=>{this.#g(e)},Zi),position:n};this.#o.set(e,o)}#g(e){const s=this.#o.get(e);if(s)try{const r=Ze(s.logFile);if(r.size<=s.position)return;const n=Buffer.alloc(r.size-s.position),o=fr(s.fd,n,0,n.length,s.position);if(o>0){s.position+=o;const i=n.subarray(0,o).toString("utf8");for(const l of i.split(`
65
+ `))l.length!==0&&this.#w(e,l);this.#s.log(e,i)}}catch{}}#w(e,s){const r=this.#i.get(e)??[];for(r.push(s);r.length>xt;)r.shift();this.#i.set(e,r)}#p(e,s){if(this.#c.has(e))return;const r={pid:s,timer:setInterval(()=>{if(!to(s)){const n=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,n)}},eo)};this.#c.set(e,r)}#f(e){const s=this.#o.get(e);if(s){clearInterval(s.pollTimer);try{hr(s.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,s){if(s===void 0)return;const r=jt(s.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const n=Vr("node",[s.scriptPath,s.configFile],{cwd:s.cwd,stdio:["ignore","pipe","pipe"]});n.stdout.on("data",i=>{this.#m(e,i)}),n.stderr.on("data",i=>{this.#m(e,i)}),n.on("error",i=>{this.#s.failed(e,"respawn-error",{message:i.message})});const o=new Promise(i=>{const l=()=>{this.#a.delete(o),i()};n.once("exit",l),n.once("error",l)});this.#a.add(o)}#m(e,s){const o=((this.#t.get(e)??"")+s.toString("utf8")).split(`
66
+ `),i=o.pop()??"";this.#t.set(e,i);for(const l of o)this.#d(e,l)}async#y(e,s){if(s!==void 0){try{await Ys({id:e,workspaceRoot:this.#n})}catch{}try{const r=await Ks({command:s.command,config:s.config,cwd:s.cwd,env:s.env,id:e,workspaceRoot:this.#n}),n=s.config.readiness?.tcp?.port??s.config.port??0,o=s.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:r.entry.logFile,pid:r.entry.pid,port:n})}catch(r){const n=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:n})}}}}const ro=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},es=(t,e,s)=>{const r=[],n=[];for(const o of e){const i=s.tasks[o];if(!i){n.push({id:o,reason:"task not in graph"});continue}const l=i.overrides.command;if(!l){n.push({id:o,reason:"no command resolved"});continue}const d=ro(i);if(!d?.service){n.push({id:o,reason:"no service config"});continue}const h=qe(t,i.projectRoot,!!d.runFromWorkspaceRoot),{envFile:u}=d,p=u===void 0||u===!1?{}:rr(h,u),a=d.service.env??{};r.push({command:l,config:d.service,cwd:h,env:{...p,...a},id:o})}return{services:r,skipped:n}},no=(t,e)=>{const s=new Set(t),r=new Map;for(const i of t){const l=(e.dependencies[i]??[]).filter(d=>s.has(d));r.set(i,new Set(l))}const n=[],o=new Set;for(;r.size>0;){const i=[];for(const[l,d]of r){for(const h of d)o.has(h)&&d.delete(h);d.size===0&&i.push(l)}i.length===0&&i.push(...r.keys());for(const l of i)o.add(l),r.delete(l);i.sort(),n.push({ids:i})}return n},io=(t,e)=>{const s=[];for(const r of no(t,e))s.push(...r.ids);return s},oo=String.raw`import { spawn } from "node:child_process";
65
67
  import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
66
68
  import { createConnection } from "node:net";
67
69
 
@@ -175,17 +177,17 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
175
177
  try { process.kill(-child.pid, "SIGTERM"); } catch {}
176
178
  process.exit(1);
177
179
  })();
178
- `,eo=()=>{const t=dr(ne(Wr(),"vis-services-")),e=ne(t,"bootstrap.mjs");return At(e,Zi),{runDir:t,scriptPath:e}},Zt=(t,e,s)=>{const r=s.replaceAll(/[^\w-]/g,"_");return{configFile:ne(t,`${r}.json`),logFile:ne(t,`${r}.log`),pidFile:ne(t,`${r}.pid`),scriptPath:e}},to=t=>{const{paths:e,service:s}=t,r=s.config.readiness?.tcp?.port??s.config.port;if(typeof r!="number")throw new TypeError(`Service ${s.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const i={...s.env,PATH:hs(s.cwd,s.env)};return{command:s.command,cwd:s.cwd,env:i,host:s.config.readiness?.tcp?.host??"127.0.0.1",id:s.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:s.config.readiness?.tcp?.timeoutMs??3e4}},so=t=>`node ${JSON.stringify(t.scriptPath)} ${JSON.stringify(t.configFile)}`,ro=t=>{const{id:e,visBin:s,workspaceRoot:r}=t;return`node ${JSON.stringify(s)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},no=t=>{const{missingServiceIds:e,mode:s,taskGraph:r,visBin:i,workspaceRoot:o}=t,{services:n,skipped:l}=Qt(o,e,r);if(n.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const d=Qi(n.map(x=>x.id),r),h=new Map(n.map(x=>[x.id,x])),f=[],p=[];if(s==="ephemeral")for(const x of d){const g=h.get(x);g&&p.push({id:x,payload:to({paths:{logFile:"",pidFile:""},service:g})})}let a;s==="ephemeral"&&(a=eo());let m;for(const x of d){const g=h.get(x),k=r.tasks[x];if(!g||!k)continue;let P;if(s==="ephemeral"){const C=Zt(a.runDir,a.scriptPath,x),E={...p.find(R=>R.id===x).payload,logFile:C.logFile,pidFile:C.pidFile};At(C.configFile,JSON.stringify(E)),P=so(C),f.push(C.pidFile)}else P=ro({id:x,visBin:i,workspaceRoot:o});if(k.overrides={...k.overrides,command:P},k.cache=!1,r.tasks[x]=k,m!==void 0){const C=r.dependencies[x]??[];C.includes(m)||(r.dependencies[x]=[...C,m])}m=x}const w=new Set(d),j=new Map,M=x=>{const g=new Set,k=[...r.dependencies[x]??[]],P=new Set;for(;k.length>0;){const C=k.pop();if(!P.has(C)){P.add(C),w.has(C)&&g.add(C);for(const y of r.dependencies[C]??[])P.has(y)||k.push(y)}}return[...g].sort()};for(const x of Object.keys(r.dependencies)){if(w.has(x))continue;const g=M(x);if(g.length===0)continue;const k={};for(const P of g){const C=h.get(P);C?.config.env&&Object.assign(k,C.config.env)}Object.keys(k).length>0&&j.set(x,k)}return{chain:d,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:j,skipped:l}},io=new Set(["auto","ephemeral","off","persistent"]),oo=t=>t.cli!==void 0?"cli":t.config===void 0?"default":"config",co=t=>{const{cli:e,config:s,isCi:r,isPersistentTarget:i,isTty:o,target:n}=t;if(e!==void 0&&!io.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??s??(o&&!r?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":i||n==="dev"?"ephemeral":"registry"},ao=async({config:t,initialTasks:e,logger:s,options:r,persistentTasks:i,target:o,taskGraph:n,workspaceRoot:l})=>{let d=e,h=n;const f=process.env.VIS_VERSION??"0.0.0",p=r.dryRun?void 0:async $=>{try{return await Os($.config,{timeoutMs:ln}),!0}catch{return!1}},a=await As(l),m=await Vi({initialTasks:[...d,...i],probe:p,registeredEntries:a,taskGraph:h,visVersion:f}),w=[];let j,M=0;const x=[],g=new Map;let k=[];const P=new Set;let C=null,y=null;if(m.diagnostics.length>0){const $=!!(process.stdout.isTTY&&process.stdin.isTTY),O=r.dryRun?"off":co({cli:r.services,config:t.run?.services,isCi:!!Se,isPersistentTarget:i.length>0,isTty:$,target:o});if(O==="off"){for(const G of m.diagnostics)s.error(G.message);const A=oo({cli:r.services,config:t.run?.services}),L=[];throw r.dryRun?L.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?L.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?L.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):L.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new pe([`${m.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...L].join(`
179
- `))}const T=m.diagnostics.map(A=>A.targetId),b=O,B=b==="registry"?Qt(l,T,h):void 0,D=process.argv[1]??"vis",N=no({missingServiceIds:T,mode:b,taskGraph:h,visBin:D,workspaceRoot:l});if(N.skipped.length>0){for(const{id:A,reason:L}of N.skipped)s.error(`Cannot auto-start ${A}: ${L}`);throw new pe(`${N.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}w.push(...N.ephemeralPidFiles),j=N.runDir,k=N.chain;for(const A of N.chain)P.add(A);if(b==="registry"&&(M=N.chain.length,x.push(...N.chain)),N.chain.length>0){const A=new wt(N.chain),L=new Map;if(b==="ephemeral"&&N.runDir)for(const G of N.chain){const V=Zt(N.runDir,`${N.runDir}/bootstrap.mjs`,G);L.set(G,{ephemeral:{configFile:V.configFile,cwd:l,logFile:V.logFile,pidFile:V.pidFile,scriptPath:V.scriptPath},mode:"ephemeral"})}else if(b==="registry"&&B)for(const G of B.services)L.set(G.id,{mode:"registry",registry:{command:G.command,config:G.config,cwd:G.cwd,env:G.env}});if(L.size>0){const G=new Ki({indexToId:new Map,services:L,sink:{crashed:(V,W)=>{A.markCrashed(V,W)},failed:(V,W,X)=>{A.markFailed(V,W,X)},log:(V,W)=>{A.appendLog(V,W)},ready:(V,W)=>{A.markReady(V,W)},started:(V,W)=>{A.markStarted(V,W),b==="registry"&&W!==null&&g.set(V,W)},starting:V=>{A.markStarting(V)}},workspaceRoot:l});C=A,y=G}}for(const[A,L]of N.serviceEnvByTaskId){const G=m.serviceEnvByTaskId.get(A)??{};m.serviceEnvByTaskId.set(A,{...G,...L})}}const E=new Set(i.map($=>$.id));if(d=m.initialTasks.filter($=>!E.has($.id)),h=m.taskGraph,k.length>0&&(d=[...k.map(O=>h.tasks[O]).filter(O=>O!==void 0),...d]),i.length>0){const $=new Set(i.map(D=>D.id)),O={};for(const[D,N]of Object.entries(h.tasks))$.has(D)||(O[D]=N);const T={};for(const[D,N]of Object.entries(h.dependencies))$.has(D)||(T[D]=N.filter(A=>!$.has(A)));const b=new Set;for(const D of Object.values(T))for(const N of D)b.add(N);const B=Object.keys(O).filter(D=>!b.has(D));h={dependencies:T,roots:B,tasks:O}}const{serviceEnvByTaskId:R}=m;if(m.satisfiedServices.length>0){const $=m.satisfiedServices.map(O=>O.id).join(", ");if(s.debug?.(`Auto-attached to running services: ${$}`),C)for(const O of m.satisfiedServices)C.registerService(O.id);else C=new wt(m.satisfiedServices.map(O=>O.id));for(const O of m.satisfiedServices){const T=O.config.readiness?.tcp?.port??O.config.port??0,b=O.config.readiness?.tcp?.host??"127.0.0.1";C.markReady(O.id,{host:b,port:T})}}return{ephemeralPidFiles:w,initialTasks:d,injectedServiceIdSet:P,registryStartedCount:M,registryStartedIds:x,registryStartedPids:g,serviceDockStore:C,serviceEnvByTaskId:R,serviceEventBridge:y,serviceResult:m,serviceRunDir:j,taskGraph:h}},lo=(t,e)=>{const s=e?.trim();if(!s)return{filter:void 0,tasks:[...t]};const r=s.toLowerCase();return{filter:s,tasks:t.filter(i=>i.target.project.toLowerCase().includes(r))}},uo=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
180
- `),fo=t=>{t.write(`${uo}
181
- `)},ho=async(t,e)=>{e.write("filter projects (empty to cancel) > ");const s=t,r=s.isRaw===!0;if(r)try{s.setRawMode?.(!1)}catch{}return await new Promise(i=>{let o="";const n=l=>{o+=typeof l=="string"?l:l.toString("utf8");const d=o.indexOf(`
182
- `);if(d===-1)return;const h=o.slice(0,d).replace(/\r$/,"").trim();if(t.off("data",n),r)try{s.setRawMode?.(!0)}catch{}i(h.length>0?h:void 0)};t.on("data",n)})},po=t=>{const{handlers:e}=t,s=t.input??process.stdin,r=t.output??process.stdout,i=t.promptFilter??ho;if(!s||s.isTTY===!1)return{close:()=>{}};$r(s);const o=s.isRaw===!0;try{s.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof s.resume=="function"&&s.resume();let n=!1;const l=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!n)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{n=!0;try{const p=await i(s,r);p===void 0?r.write(`filter cancelled.
183
- `):await e.onFilter(p)}finally{n=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},d=(f,p)=>{l(p).catch(a=>{r.write(`[vis watch] keybind handler failed: ${a.message}
184
- `)})},h=s;return h.on("keypress",d),{close:()=>{if(h.off("keypress",d),!o)try{s.setRawMode?.(!1)}catch{}const f=s;if(typeof f.pause=="function")try{f.pause()}catch{}}}},mo=({firstRun:t,hasFailure:e,logger:s,options:r,workspaceRoot:i})=>{if(r.flaky){const l=tr(i,{minRuns:2},t.runHistory);if(l.length>0){s.info(""),s.info("Flaky tasks (based on historical runs):"),s.info("");for(const d of sr(l))s.info(` ${d}`);s.info("")}}const o=[];for(const[l,d]of t.results)d.retryAttempts&&d.retryAttempts>0&&o.push(l);const n=r.failOnRetry&&o.length>0;if(n){const d=o.slice(0,5),h=o.length-d.length,f=h>0?`${d.join(", ")}, and ${String(h)} more`:d.join(", ");s.warn(""),s.warn(`--fail-on-retry: ${String(o.length)} task(s) succeeded only after retry: ${f}`)}if(e||n){const l=n&&!e?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",d=2e3,h=[];for(const[f,p]of t.results){if(p.status!=="failure")continue;const a=p.terminalOutput??"",m=a.length>d?`…${a.slice(-d)}`:a,w=p.code??"?";h.push(` ${f} (exit ${String(w)}):
180
+ `,co=()=>{const t=pr(ie(Ur(),"vis-services-")),e=ie(t,"bootstrap.mjs");return It(e,oo),{runDir:t,scriptPath:e}},ts=(t,e,s)=>{const r=s.replaceAll(/[^\w-]/g,"_");return{configFile:ie(t,`${r}.json`),logFile:ie(t,`${r}.log`),pidFile:ie(t,`${r}.pid`),scriptPath:e}},ao=t=>{const{paths:e,service:s}=t,r=s.config.readiness?.tcp?.port??s.config.port;if(typeof r!="number")throw new TypeError(`Service ${s.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const n={...s.env,PATH:ms(s.cwd,s.env)};return{command:s.command,cwd:s.cwd,env:n,host:s.config.readiness?.tcp?.host??"127.0.0.1",id:s.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:s.config.readiness?.tcp?.timeoutMs??3e4}},lo=t=>`node ${JSON.stringify(t.scriptPath)} ${JSON.stringify(t.configFile)}`,uo=t=>{const{id:e,visBin:s,workspaceRoot:r}=t;return`node ${JSON.stringify(s)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},fo=t=>{const{missingServiceIds:e,mode:s,taskGraph:r,visBin:n,workspaceRoot:o}=t,{services:i,skipped:l}=es(o,e,r);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const d=io(i.map(y=>y.id),r),h=new Map(i.map(y=>[y.id,y])),u=[],p=[];if(s==="ephemeral")for(const y of d){const g=h.get(y);g&&p.push({id:y,payload:ao({paths:{logFile:"",pidFile:""},service:g})})}let a;s==="ephemeral"&&(a=co());let m;for(const y of d){const g=h.get(y),S=r.tasks[y];if(!g||!S)continue;let F;if(s==="ephemeral"){const C=ts(a.runDir,a.scriptPath,y),L={...p.find(P=>P.id===y).payload,logFile:C.logFile,pidFile:C.pidFile};It(C.configFile,JSON.stringify(L)),F=lo(C),u.push(C.pidFile)}else F=uo({id:y,visBin:n,workspaceRoot:o});if(S.overrides={...S.overrides,command:F},S.cache=!1,r.tasks[y]=S,m!==void 0){const C=r.dependencies[y]??[];C.includes(m)||(r.dependencies[y]=[...C,m])}m=y}const w=new Set(d),j=new Map,E=y=>{const g=new Set,S=[...r.dependencies[y]??[]],F=new Set;for(;S.length>0;){const C=S.pop();if(!F.has(C)){F.add(C),w.has(C)&&g.add(C);for(const v of r.dependencies[C]??[])F.has(v)||S.push(v)}}return[...g].sort()};for(const y of Object.keys(r.dependencies)){if(w.has(y))continue;const g=E(y);if(g.length===0)continue;const S={};for(const F of g){const C=h.get(F);C?.config.env&&Object.assign(S,C.config.env)}Object.keys(S).length>0&&j.set(y,S)}return{chain:d,ephemeralPidFiles:u,runDir:a?.runDir,serviceEnvByTaskId:j,skipped:l}},ho=new Set(["auto","ephemeral","off","persistent"]),po=t=>t.cli!==void 0?"cli":t.config===void 0?"default":"config",mo=t=>{const{cli:e,config:s,isCi:r,isPersistentTarget:n,isTty:o,target:i}=t;if(e!==void 0&&!ho.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??s??(o&&!r?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":n||i==="dev"?"ephemeral":"registry"},go=async({config:t,initialTasks:e,logger:s,options:r,persistentTasks:n,target:o,taskGraph:i,workspaceRoot:l})=>{let d=e,h=i;const u=process.env.VIS_VERSION??"0.0.0",p=r.dryRun?void 0:async $=>{try{return await Xs($.config,{timeoutMs:yn}),!0}catch{return!1}},a=await Js(l),m=await Qi({initialTasks:[...d,...n],probe:p,registeredEntries:a,taskGraph:h,visVersion:u}),w=[];let j,E=0;const y=[],g=new Map;let S=[];const F=new Set;let C=null,v=null;if(m.diagnostics.length>0){const $=!!(process.stdout.isTTY&&process.stdin.isTTY),M=r.dryRun?"off":mo({cli:r.services,config:t.run?.services,isCi:!!be,isPersistentTarget:n.length>0,isTty:$,target:o});if(M==="off"){for(const W of m.diagnostics)s.error(W.message);const D=po({cli:r.services,config:t.run?.services}),_=[];throw r.dryRun?_.push("`--dry-run` never starts services; drop it to let vis boot them."):D==="default"?_.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):D==="cli"?_.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):_.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new ge([`${m.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,..._].join(`
181
+ `))}const T=m.diagnostics.map(D=>D.targetId),I=M,k=I==="registry"?es(l,T,h):void 0,O=process.argv[1]??"vis",B=fo({missingServiceIds:T,mode:I,taskGraph:h,visBin:O,workspaceRoot:l});if(B.skipped.length>0){for(const{id:D,reason:_}of B.skipped)s.error(`Cannot auto-start ${D}: ${_}`);throw new ge(`${B.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}w.push(...B.ephemeralPidFiles),j=B.runDir,S=B.chain;for(const D of B.chain)F.add(D);if(I==="registry"&&(E=B.chain.length,y.push(...B.chain)),B.chain.length>0){const D=new yt(B.chain),_=new Map;if(I==="ephemeral"&&B.runDir)for(const W of B.chain){const q=ts(B.runDir,`${B.runDir}/bootstrap.mjs`,W);_.set(W,{ephemeral:{configFile:q.configFile,cwd:l,logFile:q.logFile,pidFile:q.pidFile,scriptPath:q.scriptPath},mode:"ephemeral"})}else if(I==="registry"&&k)for(const W of k.services)_.set(W.id,{mode:"registry",registry:{command:W.command,config:W.config,cwd:W.cwd,env:W.env}});if(_.size>0){const W=new so({indexToId:new Map,services:_,sink:{crashed:(q,G)=>{D.markCrashed(q,G)},failed:(q,G,J)=>{D.markFailed(q,G,J)},log:(q,G)=>{D.appendLog(q,G)},ready:(q,G)=>{D.markReady(q,G)},started:(q,G)=>{D.markStarted(q,G),I==="registry"&&G!==null&&g.set(q,G)},starting:q=>{D.markStarting(q)}},workspaceRoot:l});C=D,v=W}}for(const[D,_]of B.serviceEnvByTaskId){const W=m.serviceEnvByTaskId.get(D)??{};m.serviceEnvByTaskId.set(D,{...W,..._})}}const L=new Set(n.map($=>$.id));if(d=m.initialTasks.filter($=>!L.has($.id)),h=m.taskGraph,S.length>0&&(d=[...S.map(M=>h.tasks[M]).filter(M=>M!==void 0),...d]),n.length>0){const $=new Set(n.map(O=>O.id)),M={};for(const[O,B]of Object.entries(h.tasks))$.has(O)||(M[O]=B);const T={};for(const[O,B]of Object.entries(h.dependencies))$.has(O)||(T[O]=B.filter(D=>!$.has(D)));const I=new Set;for(const O of Object.values(T))for(const B of O)I.add(B);const k=Object.keys(M).filter(O=>!I.has(O));h={dependencies:T,roots:k,tasks:M}}const{serviceEnvByTaskId:P}=m;if(m.satisfiedServices.length>0){const $=m.satisfiedServices.map(M=>M.id).join(", ");if(s.debug?.(`Auto-attached to running services: ${$}`),C)for(const M of m.satisfiedServices)C.registerService(M.id);else C=new yt(m.satisfiedServices.map(M=>M.id));for(const M of m.satisfiedServices){const T=M.config.readiness?.tcp?.port??M.config.port??0,I=M.config.readiness?.tcp?.host??"127.0.0.1";C.markReady(M.id,{host:I,port:T})}}return{ephemeralPidFiles:w,initialTasks:d,injectedServiceIdSet:F,registryStartedCount:E,registryStartedIds:y,registryStartedPids:g,serviceDockStore:C,serviceEnvByTaskId:P,serviceEventBridge:v,serviceResult:m,serviceRunDir:j,taskGraph:h}},wo=(t,e)=>{const s=e?.trim();if(!s)return{filter:void 0,tasks:[...t]};const r=s.toLowerCase();return{filter:s,tasks:t.filter(n=>n.target.project.toLowerCase().includes(r))}},vo=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
182
+ `),yo=t=>{t.write(`${vo}
183
+ `)},xo=async(t,e)=>{e.write("filter projects (empty to cancel) > ");const s=t,r=s.isRaw===!0;if(r)try{s.setRawMode?.(!1)}catch{}return await new Promise(n=>{let o="";const i=l=>{o+=typeof l=="string"?l:l.toString("utf8");const d=o.indexOf(`
184
+ `);if(d===-1)return;const h=o.slice(0,d).replace(/\r$/,"").trim();if(t.off("data",i),r)try{s.setRawMode?.(!0)}catch{}n(h.length>0?h:void 0)};t.on("data",i)})},jo=t=>{const{handlers:e}=t,s=t.input??process.stdin,r=t.output??process.stdout,n=t.promptFilter??xo;if(!s||s.isTTY===!1)return{close:()=>{}};Rr(s);const o=s.isRaw===!0;try{s.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof s.resume=="function"&&s.resume();let i=!1;const l=async u=>{if(u.ctrl===!0&&u.name==="c"){await e.onQuit();return}if(!i)switch(u.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const p=await n(s,r);p===void 0?r.write(`filter cancelled.
185
+ `):await e.onFilter(p)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},d=(u,p)=>{l(p).catch(a=>{r.write(`[vis watch] keybind handler failed: ${a.message}
186
+ `)})},h=s;return h.on("keypress",d),{close:()=>{if(h.off("keypress",d),!o)try{s.setRawMode?.(!1)}catch{}const u=s;if(typeof u.pause=="function")try{u.pause()}catch{}}}},So=({firstRun:t,hasFailure:e,logger:s,options:r,workspaceRoot:n})=>{if(r.flaky){const l=Is(n,{minRuns:2},t.runHistory);if(l.length>0){s.info(""),s.info("Flaky tasks (based on historical runs):"),s.info("");for(const d of Es(l))s.info(` ${d}`);s.info("")}}const o=[];for(const[l,d]of t.results)d.retryAttempts&&d.retryAttempts>0&&o.push(l);const i=r.failOnRetry&&o.length>0;if(i){const d=o.slice(0,5),h=o.length-d.length,u=h>0?`${d.join(", ")}, and ${String(h)} more`:d.join(", ");s.warn(""),s.warn(`--fail-on-retry: ${String(o.length)} task(s) succeeded only after retry: ${u}`)}if(e||i){const l=i&&!e?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",d=2e3,h=[];for(const[u,p]of t.results){if(p.status!=="failure")continue;const a=p.terminalOutput??"",m=a.length>d?`…${a.slice(-d)}`:a,w=p.code??"?";h.push(` ${u} (exit ${String(w)}):
185
187
  ${m.split(`
186
188
  `).map(j=>` ${j}`).join(`
187
- `)}`)}throw new pe(h.length>0?`${l}
189
+ `)}`)}throw new ge(h.length>0?`${l}
188
190
  ${h.join(`
189
- `)}`:l)}},es=({logger:t,registryStartedCount:e,stopServicesOnExit:s})=>{e>0&&(t.info(""),s?t.info(`${String(e)} service(s) stopped (--stop-services).`):t.info(`${String(e)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))},go=async({initialTasks:t,logger:e,options:s,persistentTasks:r,projectGraph:i,projectsWithTarget:o,registryStartedCount:n,runtime:l,serviceEventBridge:d,stopServicesOnExit:h,taskGraph:f,visConfig:p,workspace:a,workspaceRoot:m})=>{const{childEnvPolicyFor:w,failureLogLifeCycle:j,hookLifeCycle:M,hooks:x,lifecycleOptions:g,maybeWriteProfile:k,outputStyle:P,preTraceCheck:C,resolveCommand:y,runnerOptions:E,sharedRetryBudget:R,spawnContext:$,startTime:O,strictEnvFailure:T}=l;let b=t;const B=new Map,D=typeof s.log=="string"?s.log.toLowerCase():"",N=D==="labeled"||D==="grouped"||D==="interleaved"?D:void 0,A=N?ps(N):void 0,L=new jt([new Xn({...g,ciGrouping:p?.run?.ciGrouping??"auto",logReporter:A,outputStyle:P}),M,j]),G=Kt({hooks:x,lifeCycle:L,mutexPool:B,resolveCommand:y,retryBudget:R,serviceEventBridge:d??void 0,spawnContext:$,strictEnvFailure:T,workspaceRoot:m}),V=async()=>{const H=Date.now(),Q=await St(b,E,{childEnvPolicy:w,lifeCycle:L,preTraceCheck:C,projectGraph:i,resolveChildEnv:(q,oe)=>ke($,q,oe),resolveCommand:y,taskExecutor:G,taskGraph:f,workspaceRoot:m}),J=Date.now()-H;if(s.summarize){const q=kt(Q,f,O);await ms(q,m,{dataDirectory:Ce(m)})}let te=!1;for(const[,q]of Q)q.status==="failure"&&(te=!0);const re=rr(Q,J),_=nr(m),z=ir(m,J,_);return e.info(""),e.info(` ${re}${z?` ${z}`:""}`),{hasFailure:te,results:Q,runHistory:_}},W=await V();await x.callHook("run:after",W.results),await k(W.results);const{hasFailure:X}=W;if(s.watch){const H=o.map(Z=>{const ie=a.projects[Z]?.root;if(ie)return ie.startsWith("/")?ie:`${m}/${ie}`}).filter(Z=>Z!==void 0),Q=b;let J;const te=Z=>{const se=lo(Q,Z);return J=se.filter,b=se.tasks,se.tasks.length};let re=!1,_=W.results;const z=()=>{const Z=tt(_,m);if(Z.directories.length>0&&Z.files.size>0){const se=qr(Z.files,m,Z.directories);return{handle:st({filter:se,onChange:oe,paths:Z.directories}),mode:"tracked"}}return{handle:st({onChange:oe,paths:H}),mode:"roots"}};let q;const oe=async Z=>{if(!re){re=!0;try{e.info(`Change detected in ${Z.length} file(s), rerunning…`),_=(await V()).results,q?.close(),q=z().handle}finally{re=!1}}},ae=z();q=ae.handle;const de=ae.mode==="tracked"?`Watching ${String(tt(_,m).files.size)} tracked file(s)`:`Watching ${String(H.length)} project root(s)`;e.info(`${de} — edit a file to rerun, press h for keybinds, q to quit.`);const Y=async()=>{if(!re){re=!0;try{if(b.length===0){e.info("No tasks match the active filter — press a to clear it.");return}_=(await V()).results,q?.close(),q=z().handle}finally{re=!1}}};await new Promise(Z=>{let se=!1,ie;const ue=()=>{I()},I=()=>{se||(se=!0,ie?.close(),process.off("SIGINT",ue),q?.close(),Z())};process.on("SIGINT",ue),ie=po({handlers:{onClearFilter:async()=>{const S=te(void 0);e.info(`Filter cleared — running ${String(S)} task(s).`),await Y()},onFilter:async S=>{const F=J,ee=te(S);if(ee===0){e.info(`Filter "${S}" matched no projects — keeping previous filter.`),te(F);return}e.info(`Filter "${S}" matched ${String(ee)} task(s).`),await Y()},onHelp:()=>{fo(process.stdout)},onQuit:()=>{I()},onRerun:Y}})});return}mo({firstRun:W,hasFailure:X,logger:e,options:s,workspaceRoot:m}),r.length>0&&!s.failFast&&await Bt(r,$,void 0),es({logger:e,registryStartedCount:n,stopServicesOnExit:h})},wo=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),vo=(t,e,s)=>{const r=new Set,i=[];if(t===void 0||t.trim()==="")return{skipTaskIds:r,unmatchedPatterns:i};const o=[...s],n=new Set(o),l=new Map;for(const d of o){const h=d.lastIndexOf(":");if(h===-1)continue;const f=d.slice(h+1),p=l.get(f);p===void 0?l.set(f,[d]):p.push(d)}for(const d of wo(t)){if(d.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${d}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(n.has(d)){r.add(d);continue}const h=_r(d);if(!h){i.push(d);continue}let f=!1;switch(h.kind){case"all":{const p=l.get(h.target)??[];for(const a of p)r.add(a),f=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;n.has(a)&&(r.add(a),f=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=l.get(h.target)??[];for(const m of a){const w=m.slice(0,m.lastIndexOf(":"));e.projects[w]?.tags?.includes(p)===!0&&(r.add(m),f=!0)}}break}}f||i.push(d)}return{skipTaskIds:r,unmatchedPatterns:i}},yo=({affectedFiles:t,config:e,initialTasks:s,logger:r,options:i,persistentTasks:o,projectGraph:n,projectOptions:l,workspace:d})=>{const h=new Set([...s,...o].map(p=>p.id)),f=vs([...s,...o],{onCycleBroken:p=>{r.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},onUnmatchedProjectSelector:p=>{r.warn(`dependsOn.projects entry "${p}" matched no project — that dependency edge was not created.`)},projectGraph:n,targetDefaults:e.tasks,workspace:d});for(const[p,a]of Object.entries(f.tasks)){const m=a.target.project,w=a.target.target,j=l.get(m)?.[w];if(!j){h.has(p)||r.warn(`${w} required via dependsOn but no command is configured for ${m} — skipping (no-op).`);continue}const M=d.projects[m];let x=!1;const g={...a.overrides};g.visOptions===void 0&&j.options&&(g.visOptions=j.options,x=!0),g.command===void 0&&j.command&&(g.command=bt(j.command,{affectedFiles:t,projectRoot:M?.root}),x=!0),x&&(a.overrides=g,f.tasks[p]=a)}if(typeof i.skipCache=="string"&&i.skipCache.trim()!=="")if(i.cache){const p=vo(i.skipCache,d,Object.keys(f.tasks));for(const a of p.skipTaskIds){const m=f.tasks[a];m!==void 0&&(m.cache=!1)}p.unmatchedPatterns.length>0&&r.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(a=>`"${a}"`).join(", ")}`),p.skipTaskIds.size>0&&r.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else r.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");return f},xo=({logger:t,options:e,projectOptions:s,taskGraph:r})=>{let i=r;e.reverse&&(i=gs(i),t.debug?.(`Reversed task graph: ${String(i.roots.length)} new root(s) (originally leaves)`));for(const o of Object.values(i.tasks)){const n=s.get(o.target.project)?.[o.target.target]?.options;o.splitCompound&&$t(n)!==void 0&&(t.warn(`splitCompound ignored for ${o.id}: it uses a custom shell. Running the command as one unit.`),o.splitCompound=void 0)}return i=ws(i,{commandOf:o=>o.overrides.command,onDiagnostic:(o,n)=>{t.warn(n)}}),i},ts=t=>t.replace(/^--?/u,""),jo=new Set(["0","1","false","no","true","yes"]),So=t=>!t.startsWith("-")||/^-(?:\d|\.\d)/u.test(t),xt=(t,e,s,r,i,o)=>{if(r!==void 0)return t.set(e,r),0;const n=i[o+1];return(s?.type??"string")==="boolean"?n!==void 0&&jo.has(n.toLowerCase())?(t.set(e,n.toLowerCase()),1):(t.set(e,"true"),0):n!==void 0&&So(n)?(t.set(e,n),1):(t.set(e,"true"),0)},ko=(t,e)=>{const s=t.type??"string";if(s==="number"){const r=e.trim(),i=Number(r);return r===""||!Number.isFinite(i)?{error:`--${t.name} expects a number, got "${e}"`}:{value:i}}if(s==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${t.name} expects a boolean, got "${e}"`};if(s==="enum"){const r=t.choices??[];return r.includes(e)?{value:e}:{error:`--${t.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},bo=t=>{const e=[],s=new Set;for(const r of t){const i=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${i}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),s.has(r.name)&&e.push(`duplicate argument name "${i}"`),s.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${i}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${i}" has type "enum" but declares no choices`),r.default!==void 0){const n=typeof r.default;o==="number"&&n==="number"||o==="boolean"&&n==="boolean"||(o==="string"||o==="enum")&&n==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${i}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${i}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},To=(t,e)=>{const s=new Map,r=new Map;for(const h of t)s.set(h.name,h),h.alias&&r.set(h.alias,h);const i=new Map,o=[];for(let h=0;h<e.length;h+=1){const f=e[h];if(f==="--"){o.push(...e.slice(h+1));break}if(f.startsWith("--no-")){i.set(ts(f.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(p){const w=p[1];h+=xt(i,w,s.get(w),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(f),m=a?.[1];if(a&&m!==void 0){const w=r.get(m);h+=xt(i,w?.name??m,w,a[2],e,h);continue}o.push(f)}const n={},l=[];let d=0;for(const h of t){let f=i.get(h.name);if(f===void 0&&h.positional&&d<o.length&&(f=o[d],d+=1),f===void 0){h.default!==void 0?n[h.name]=h.default:h.required&&l.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=ko(h,f);p?l.push(p):a!==void 0&&(n[h.name]=a)}return{errors:l,values:n}},$o=t=>`VIS_ARG_${ts(t).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Co=t=>{const e={};for(const[s,r]of Object.entries(t))e[$o(s)]=String(r);return e},De=(t,e,s)=>{const r=[`Usage: vis run ${t} [-- <args>]`];if(e&&r.push("",e),s.length===0)return r.join(`
190
- `);r.push("","Arguments:");const i=s.map(n=>{const l=n.positional?`<${n.name}>`:`--${n.name}`,d=n.alias?`, -${n.alias}`:"";return{left:`${l}${d}`,right:n}}),o=Math.max(...i.map(n=>n.left.length));for(const{left:n,right:l}of i){const d=[],h=l.type??"string";d.push(h==="enum"?`enum(${(l.choices??[]).join("|")})`:h),l.required&&d.push("required"),l.default!==void 0&&d.push(`default: ${String(l.default)}`);const f=`${l.description??""}${l.description?" ":""}[${d.join(", ")}]`;r.push(` ${n.padEnd(o)} ${f}`)}return r.join(`
191
- `)},Io=(t,e,s,r)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const i=bo(s);if(i.length>0)return{errors:i.map(n=>`invalid \`arguments\` schema for "${t}": ${n}`),help:De(t,e,s),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:De(t,e,s)};const o=To(s,r);return o.errors.length>0?{errors:o.errors,help:De(t,e,s),kind:"invalid"}:{env:Co(o.values),kind:"ok"}},Eo=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:r,target:i})=>{const o=s.map(f=>({project:f,schema:r.get(f)?.arguments})).filter(f=>Array.isArray(f.schema)&&f.schema.length>0),n=new Map;for(const{project:f,schema:p}of o){const a=JSON.stringify(p),m=n.get(a)??[];m.push(f),n.set(a,m)}if(n.size>1){const f=[...n.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${i}" declares conflicting \`arguments\` schemas across projects (${f}). Run a single project (e.g. \`vis run ${o[0]?.project}:${i}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=r.get(o[0]?.project??s[0])?.description,h=Io(i,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${i}":`);for(const f of h.errors)e.info(` ✖ ${f}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${i}"`)}return{env:h.env}},Ro=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Po=t=>t?Object.keys(t).filter(e=>Ro.has(e)).toSorted():[],Mo=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,Fo=({affectedFiles:t,forwardedArgs:e,logger:s,options:r,projectsWithTarget:i,projectTargetIndex:o,target:n,taskArgumentEnvVars:l,workspace:d})=>{const h=r.pty,f=rn(r.hashMode);let p=i.map(j=>{const M=d.projects[j],x=o.get(j),g={project:j,target:n},k=`${j}:${n}`,P=h?{...x.options,pty:x.options?.pty??!0}:x.options,C=x.command?bt(x.command,{affectedFiles:t,projectRoot:M?.root}):x.command,y=M?.root&&M.root.length>0?M.root:".",E=(x.outputs??[]).map($=>typeof $!="string"?$:$.replaceAll("{projectRoot}",y).replaceAll("{projectName}",j)),R=Po(x.options);return R.length>0&&s.warn(Mo(k,R)),{cache:x.cache,declaresInputs:x.inputs!==void 0,fingerprintEnv:x.fingerprintEnv,hashMode:f??x.hashMode,id:k,outputs:E,overrides:{command:C,...e.length>0?{[Dt]:e}:{},...Object.keys(l).length>0?{[Vs]:l}:{},...P?{visOptions:P}:{}},parallelism:x.parallelism,projectRoot:M?.root,splitCompound:x.splitCompound,target:g,untrackedEnv:x.untrackedEnv}});const a=[],m=[];for(const j of p)je(j)?.persistent?(j.cache=!1,a.push(j)):m.push(j);p=m;const w=ys(r.partition);if(w&&(p=xs.partitionTasks(p,w),s.info(`Partition ${w.index}/${w.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Oo=({affectedFiles:t,config:e,forwardedArgs:s,logger:r,options:i,projectGraph:o,projectOptions:n,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:f})=>{const p=Eo({forwardedArgs:s,logger:r,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=Fo({affectedFiles:t,forwardedArgs:s,logger:r,options:i,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:f});if(!a)return;const{persistentTasks:m}=a,{initialTasks:w}=a,j=yo({affectedFiles:t,config:e,initialTasks:w,logger:r,options:i,persistentTasks:m,projectGraph:o,projectOptions:n,workspace:f});return{initialTasks:w,persistentTasks:m,taskGraph:j}},dc=async({argument:t,logger:e,options:s,visConfig:r,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=i;if(bs({options:s,visConfig:r},o),Ts(o),s.lastDetails){await en(o,e);return}const n=process.cwd(),l=await js(o,r),{config:d,fileOwners:h,packageJsons:f,projectOptions:p,workspace:a}=Ss(o,r,l),m=ks(o,a,f),w=await Gi({argument:t,config:d,fileOwners:h,logger:e,options:s,packageJsons:f,projectGraph:m,projectOptions:p,visConfig:r,workspace:a,workspaceRoot:o});if(!w)return;const{affectedFiles:j,currentOs:M,forwardedArgs:x,projectsWithTarget:g,projectTargetIndex:k,target:P}=w,C=Oo({affectedFiles:j,config:d,forwardedArgs:x,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:g,projectTargetIndex:k,target:P,workspace:a});if(!C)return;const{persistentTasks:y}=C;let{initialTasks:E,taskGraph:R}=C;await hi({config:d,logger:e,options:s,packageJsons:f,workspaceRoot:o});const $=await ao({config:d,initialTasks:E,logger:e,options:s,persistentTasks:y,target:P,taskGraph:R,workspaceRoot:o});E=$.initialTasks,R=$.taskGraph;const{ephemeralPidFiles:O,injectedServiceIdSet:T,registryStartedCount:b,registryStartedIds:B,registryStartedPids:D,serviceDockStore:N,serviceEnvByTaskId:A,serviceEventBridge:L,serviceResult:G,serviceRunDir:V}=$,W=s.stopServices,X=fn({ephemeralPidFiles:O,registryStartedIds:B,registryStartedPids:D,serviceEventBridge:L,serviceRunDir:V,stopServicesOnExit:W,workspaceRoot:o});X.install();try{if(R=xo({logger:e,options:s,projectOptions:p,taskGraph:R}),s.dryRun){hn({config:d,logger:e,persistentTasks:y,taskGraph:R});return}const H=await xi({affectedFiles:j,config:d,currentOs:M,initialTasks:E,invocationCwd:n,logger:e,options:s,persistentTasks:y,projectsWithTarget:g,serviceEnvByTaskId:A,serviceResult:G,target:P,taskGraph:R,visConfig:r,workspaceRoot:o});if(await H.hooks.callHook("run:before",{tasks:E,workspaceRoot:o}),H.isTTY){const{spawnContext:Q}=H,{dynamic:J,lifeCycle:te,stdinRegistry:re,store:_,taskExecutor:z}=ti({injectedServiceIdSet:T,runtime:H,serviceDockStore:N,serviceEventBridge:L,workspaceRoot:o});let q="rerun",oe=null,ae=new Map;for(;q!=="quit";){if(q==="rerun")ae=await si({dynamic:J,initialTasks:E,lifeCycle:te,options:s,persistentTasks:y,projectGraph:m,runtime:H,stdinRegistry:re,store:_,taskExecutor:z,taskGraph:R,workspaceRoot:o});else if(q==="retry"&&oe){const Y=R.tasks[oe]??E.find(se=>se.id===oe),Z=Y?ze(Y,Q.affectedFiles,M):void 0;if(Y&&Z){te.startTasks?.([Y]);const se=new We(Ie),ie=Us(Q,Y),I=(await $e([{command:Z,cwd:ie.cwd,env:ie.env,inheritEnv:ie.inheritEnv,name:Y.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:S=>{S.kind==="started"&&S.write&&re.set(Y.id,{kill:S.kill,resize:S.resize,write:S.write}),(S.kind==="stdout"||S.kind==="stderr")&&S.text&&(se.write(S.text),_.setOutput(Y.id,se.toString())),S.kind==="close"&&re.delete(Y.id)}})).closeEvents[0];te.endTasks?.([{code:I?.exitCode??1,status:I?.exitCode===0?"success":"failure",task:Y,terminalOutput:_.getSnapshot().outputs.get(Y.id)}])}else Y&&te.endTasks?.([{code:1,status:"failure",task:Y,terminalOutput:`No command configured for ${Y.id}`}]);oe=null,_.markDone()}const de=await ri({dynamic:J,store:_});q=de.action,oe=de.retryTaskId}await J.renderIsDone,await H.hooks.callHook("run:after",ae),await H.maybeWriteProfile(ae),es({logger:e,registryStartedCount:b,stopServicesOnExit:W})}else await go({initialTasks:E,logger:e,options:s,persistentTasks:y,projectGraph:m,projectsWithTarget:g,registryStartedCount:b,runtime:H,serviceEventBridge:L,stopServicesOnExit:W,taskGraph:R,visConfig:r,workspace:a,workspaceRoot:o})}finally{await X.finish()}};export{dc as default};
191
+ `)}`:l)}},ss=({logger:t,registryStartedCount:e,stopServicesOnExit:s})=>{e>0&&(t.info(""),s?t.info(`${String(e)} service(s) stopped (--stop-services).`):t.info(`${String(e)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))},ko=async({initialTasks:t,logger:e,options:s,persistentTasks:r,projectGraph:n,projectsWithTarget:o,registryStartedCount:i,runtime:l,serviceEventBridge:d,stopServicesOnExit:h,taskGraph:u,visConfig:p,workspace:a,workspaceRoot:m})=>{const{childEnvPolicyFor:w,failureLogLifeCycle:j,hookLifeCycle:E,hooks:y,lifecycleOptions:g,maybeWriteProfile:S,outputStyle:F,preTraceCheck:C,resolveCommand:v,runnerOptions:L,sharedRetryBudget:P,spawnContext:$,startTime:M,strictEnvFailure:T}=l;let I=t;const k=new Map,O=typeof s.log=="string"?s.log.toLowerCase():"",B=O==="labeled"||O==="grouped"||O==="interleaved"?O:void 0,D=B?gs(B):void 0,_=new kt([new ri({...g,ciGrouping:p?.run?.ciGrouping??"auto",logReporter:D,outputStyle:F}),E,j]),W=Jt({hooks:y,lifeCycle:_,mutexPool:k,resolveCommand:v,retryBudget:P,serviceEventBridge:d??void 0,spawnContext:$,strictEnvFailure:T,workspaceRoot:m}),q=async()=>{const z=Date.now(),Z=await bt(I,L,{childEnvPolicy:w,lifeCycle:_,preTraceCheck:C,projectGraph:n,resolveChildEnv:(re,oe)=>Te($,re,oe),resolveCommand:v,taskExecutor:W,taskGraph:u,workspaceRoot:m}),te=Date.now()-z;if(s.summarize){const re=Tt(Z,u,M);await ws(re,m,{dataDirectory:Ie(m)})}let K=!1;for(const[,re]of Z)re.status==="failure"&&(K=!0);const N=Rs(Z,te),H=Ps(m),V=Ms(m,te,H);return e.info(""),e.info(` ${N}${V?` ${V}`:""}`),{hasFailure:K,results:Z,runHistory:H}},G=await q();await y.callHook("run:after",G.results),await S(G.results);const{hasFailure:J}=G;if(s.watch){const z=o.map(ee=>{const Y=a.projects[ee]?.root;if(Y)return Y.startsWith("/")?Y:`${m}/${Y}`}).filter(ee=>ee!==void 0),Z=I;let te;const K=ee=>{const ne=wo(Z,ee);return te=ne.filter,I=ne.tasks,ne.tasks.length};let N=!1,H=G.results;const V=()=>{const ee=st(H,m);if(ee.directories.length>0&&ee.files.size>0){const ne=zr(ee.files,m,ee.directories);return{handle:rt({filter:ne,onChange:oe,paths:ee.directories}),mode:"tracked"}}return{handle:rt({onChange:oe,paths:z}),mode:"roots"}};let re;const oe=async ee=>{if(!N){N=!0;try{e.info(`Change detected in ${ee.length} file(s), rerunning…`),H=(await q()).results,re?.close(),re=V().handle}finally{N=!1}}},fe=V();re=fe.handle;const de=fe.mode==="tracked"?`Watching ${String(st(H,m).files.size)} tracked file(s)`:`Watching ${String(z.length)} project root(s)`;e.info(`${de} — edit a file to rerun, press h for keybinds, q to quit.`);const ce=async()=>{if(!N){N=!0;try{if(I.length===0){e.info("No tasks match the active filter — press a to clear it.");return}H=(await q()).results,re?.close(),re=V().handle}finally{N=!1}}};await new Promise(ee=>{let ne=!1,Y;const he=()=>{R()},R=()=>{ne||(ne=!0,Y?.close(),process.off("SIGINT",he),re?.close(),ee())};process.on("SIGINT",he),Y=jo({handlers:{onClearFilter:async()=>{const b=K(void 0);e.info(`Filter cleared — running ${String(b)} task(s).`),await ce()},onFilter:async b=>{const A=te,Q=K(b);if(Q===0){e.info(`Filter "${b}" matched no projects — keeping previous filter.`),K(A);return}e.info(`Filter "${b}" matched ${String(Q)} task(s).`),await ce()},onHelp:()=>{yo(process.stdout)},onQuit:()=>{R()},onRerun:ce}})});return}So({firstRun:G,hasFailure:J,logger:e,options:s,workspaceRoot:m}),r.length>0&&!s.failFast&&await Gt(r,$,void 0),ss({logger:e,registryStartedCount:i,stopServicesOnExit:h})},bo=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),To=(t,e,s)=>{const r=new Set,n=[];if(t===void 0||t.trim()==="")return{skipTaskIds:r,unmatchedPatterns:n};const o=[...s],i=new Set(o),l=new Map;for(const d of o){const h=d.lastIndexOf(":");if(h===-1)continue;const u=d.slice(h+1),p=l.get(u);p===void 0?l.set(u,[d]):p.push(d)}for(const d of bo(t)){if(d.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${d}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(d)){r.add(d);continue}const h=Gr(d);if(!h){n.push(d);continue}let u=!1;switch(h.kind){case"all":{const p=l.get(h.target)??[];for(const a of p)r.add(a),u=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;i.has(a)&&(r.add(a),u=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=l.get(h.target)??[];for(const m of a){const w=m.slice(0,m.lastIndexOf(":"));e.projects[w]?.tags?.includes(p)===!0&&(r.add(m),u=!0)}}break}}u||n.push(d)}return{skipTaskIds:r,unmatchedPatterns:n}},$o=({affectedFiles:t,config:e,initialTasks:s,logger:r,options:n,persistentTasks:o,projectGraph:i,projectOptions:l,workspace:d})=>{const h=new Set([...s,...o].map(p=>p.id)),u=xs([...s,...o],{onCycleBroken:p=>{r.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},onUnmatchedProjectSelector:p=>{r.warn(`dependsOn.projects entry "${p}" matched no project — that dependency edge was not created.`)},projectGraph:i,targetDefaults:e.tasks,workspace:d});for(const[p,a]of Object.entries(u.tasks)){const m=a.target.project,w=a.target.target,j=l.get(m)?.[w];if(!j){h.has(p)||r.warn(`${w} required via dependsOn but no command is configured for ${m} — skipping (no-op).`);continue}const E=d.projects[m];let y=!1;const g={...a.overrides};g.visOptions===void 0&&j.options&&(g.visOptions=j.options,y=!0),g.command===void 0&&j.command&&(g.command=$t(j.command,{affectedFiles:t,projectRoot:E?.root}),y=!0),y&&(a.overrides=g,u.tasks[p]=a)}if(typeof n.skipCache=="string"&&n.skipCache.trim()!=="")if(n.cache){const p=To(n.skipCache,d,Object.keys(u.tasks));for(const a of p.skipTaskIds){const m=u.tasks[a];m!==void 0&&(m.cache=!1)}p.unmatchedPatterns.length>0&&r.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(a=>`"${a}"`).join(", ")}`),p.skipTaskIds.size>0&&r.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else r.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");return u},Co=({logger:t,options:e,projectOptions:s,taskGraph:r})=>{let n=r;e.reverse&&(n=vs(n),t.debug?.(`Reversed task graph: ${String(n.roots.length)} new root(s) (originally leaves)`));for(const o of Object.values(n.tasks)){const i=s.get(o.target.project)?.[o.target.target]?.options;o.splitCompound&&Rt(i)!==void 0&&(t.warn(`splitCompound ignored for ${o.id}: it uses a custom shell. Running the command as one unit.`),o.splitCompound=void 0)}return n=ys(n,{commandOf:o=>o.overrides.command,onDiagnostic:(o,i)=>{t.warn(i)}}),n},rs=t=>t.replace(/^--?/u,""),Io=new Set(["0","1","false","no","true","yes"]),Eo=t=>!t.startsWith("-")||/^-(?:\d|\.\d)/u.test(t),St=(t,e,s,r,n,o)=>{if(r!==void 0)return t.set(e,r),0;const i=n[o+1];return(s?.type??"string")==="boolean"?i!==void 0&&Io.has(i.toLowerCase())?(t.set(e,i.toLowerCase()),1):(t.set(e,"true"),0):i!==void 0&&Eo(i)?(t.set(e,i),1):(t.set(e,"true"),0)},Ro=(t,e)=>{const s=t.type??"string";if(s==="number"){const r=e.trim(),n=Number(r);return r===""||!Number.isFinite(n)?{error:`--${t.name} expects a number, got "${e}"`}:{value:n}}if(s==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${t.name} expects a boolean, got "${e}"`};if(s==="enum"){const r=t.choices??[];return r.includes(e)?{value:e}:{error:`--${t.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},Po=t=>{const e=[],s=new Set;for(const r of t){const n=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${n}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),s.has(r.name)&&e.push(`duplicate argument name "${n}"`),s.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${n}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${n}" has type "enum" but declares no choices`),r.default!==void 0){const i=typeof r.default;o==="number"&&i==="number"||o==="boolean"&&i==="boolean"||(o==="string"||o==="enum")&&i==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${n}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${n}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},Mo=(t,e)=>{const s=new Map,r=new Map;for(const h of t)s.set(h.name,h),h.alias&&r.set(h.alias,h);const n=new Map,o=[];for(let h=0;h<e.length;h+=1){const u=e[h];if(u==="--"){o.push(...e.slice(h+1));break}if(u.startsWith("--no-")){n.set(rs(u.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(u);if(p){const w=p[1];h+=St(n,w,s.get(w),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(u),m=a?.[1];if(a&&m!==void 0){const w=r.get(m);h+=St(n,w?.name??m,w,a[2],e,h);continue}o.push(u)}const i={},l=[];let d=0;for(const h of t){let u=n.get(h.name);if(u===void 0&&h.positional&&d<o.length&&(u=o[d],d+=1),u===void 0){h.default!==void 0?i[h.name]=h.default:h.required&&l.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=Ro(h,u);p?l.push(p):a!==void 0&&(i[h.name]=a)}return{errors:l,values:i}},Fo=t=>`VIS_ARG_${rs(t).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Oo=t=>{const e={};for(const[s,r]of Object.entries(t))e[Fo(s)]=String(r);return e},Be=(t,e,s)=>{const r=[`Usage: vis run ${t} [-- <args>]`];if(e&&r.push("",e),s.length===0)return r.join(`
192
+ `);r.push("","Arguments:");const n=s.map(i=>{const l=i.positional?`<${i.name}>`:`--${i.name}`,d=i.alias?`, -${i.alias}`:"";return{left:`${l}${d}`,right:i}}),o=Math.max(...n.map(i=>i.left.length));for(const{left:i,right:l}of n){const d=[],h=l.type??"string";d.push(h==="enum"?`enum(${(l.choices??[]).join("|")})`:h),l.required&&d.push("required"),l.default!==void 0&&d.push(`default: ${String(l.default)}`);const u=`${l.description??""}${l.description?" ":""}[${d.join(", ")}]`;r.push(` ${i.padEnd(o)} ${u}`)}return r.join(`
193
+ `)},Ao=(t,e,s,r)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const n=Po(s);if(n.length>0)return{errors:n.map(i=>`invalid \`arguments\` schema for "${t}": ${i}`),help:Be(t,e,s),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:Be(t,e,s)};const o=Mo(s,r);return o.errors.length>0?{errors:o.errors,help:Be(t,e,s),kind:"invalid"}:{env:Oo(o.values),kind:"ok"}},Lo=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:r,target:n})=>{const o=s.map(u=>({project:u,schema:r.get(u)?.arguments})).filter(u=>Array.isArray(u.schema)&&u.schema.length>0),i=new Map;for(const{project:u,schema:p}of o){const a=JSON.stringify(p),m=i.get(a)??[];m.push(u),i.set(a,m)}if(i.size>1){const u=[...i.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${n}" declares conflicting \`arguments\` schemas across projects (${u}). Run a single project (e.g. \`vis run ${o[0]?.project}:${n}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=r.get(o[0]?.project??s[0])?.description,h=Ao(n,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${n}":`);for(const u of h.errors)e.info(` ✖ ${u}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${n}"`)}return{env:h.env}},Do=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Bo=t=>t?Object.keys(t).filter(e=>Do.has(e)).toSorted():[],_o=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,No=({affectedFiles:t,forwardedArgs:e,logger:s,options:r,projectsWithTarget:n,projectTargetIndex:o,target:i,taskArgumentEnvVars:l,workspace:d})=>{const h=r.pty,u=pn(r.hashMode);let p=n.map(j=>{const E=d.projects[j],y=o.get(j),g={project:j,target:i},S=`${j}:${i}`,F=h?{...y.options,pty:y.options?.pty??!0}:y.options,C=y.command?$t(y.command,{affectedFiles:t,projectRoot:E?.root}):y.command,v=E?.root&&E.root.length>0?E.root:".",L=(y.outputs??[]).map($=>typeof $!="string"?$:$.replaceAll("{projectRoot}",v).replaceAll("{projectName}",j)),P=Bo(y.options);return P.length>0&&s.warn(_o(S,P)),{cache:y.cache,declaresInputs:y.inputs!==void 0,fingerprintEnv:y.fingerprintEnv,hashMode:u??y.hashMode,id:S,outputs:L,overrides:{command:C,...e.length>0?{[Wt]:e}:{},...Object.keys(l).length>0?{[cr]:l}:{},...F?{visOptions:F}:{}},parallelism:y.parallelism,projectRoot:E?.root,splitCompound:y.splitCompound,target:g,untrackedEnv:y.untrackedEnv}});const a=[],m=[];for(const j of p)ke(j)?.persistent?(j.cache=!1,a.push(j)):m.push(j);p=m;const w=js(r.partition);if(w&&(p=Ss.partitionTasks(p,w),s.info(`Partition ${w.index}/${w.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Wo=({affectedFiles:t,config:e,forwardedArgs:s,logger:r,options:n,projectGraph:o,projectOptions:i,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:u})=>{const p=Lo({forwardedArgs:s,logger:r,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=No({affectedFiles:t,forwardedArgs:s,logger:r,options:n,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:u});if(!a)return;const{persistentTasks:m}=a,{initialTasks:w}=a,j=$o({affectedFiles:t,config:e,initialTasks:w,logger:r,options:n,persistentTasks:m,projectGraph:o,projectOptions:i,workspace:u});return{initialTasks:w,persistentTasks:m,taskGraph:j}},gc=async({argument:t,logger:e,options:s,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=n;if(Ds({options:s,visConfig:r},o),Ws(o),s.lastDetails){await un(o,e);return}const i=process.cwd(),l=await Os(o,r),{config:d,fileOwners:h,packageJsons:u,projectOptions:p,workspace:a}=As(o,r,l),m=Ls(o,a,u),w=d.taskRunner??{},j=Fs({branchScopedCache:d.branchScopedCache,configCacheDir:w.cacheDirectory,optionsCacheDir:s.cacheDir,sharedWorktreeCache:d.sharedWorktreeCache,workspaceRoot:o}),E=await Yi({argument:t,cacheDirectory:j,config:d,fileOwners:h,logger:e,options:s,packageJsons:u,projectGraph:m,projectOptions:p,visConfig:r,workspace:a,workspaceRoot:o});if(!E)return;const{affectedExternalInputState:y,affectedFiles:g,currentOs:S,forwardedArgs:F,projectsWithTarget:C,projectTargetIndex:v,target:L}=E,P=Wo({affectedFiles:g,config:d,forwardedArgs:F,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:C,projectTargetIndex:v,target:L,workspace:a});if(!P)return;const{persistentTasks:$}=P;let{initialTasks:M,taskGraph:T}=P;await xi({config:d,logger:e,options:s,packageJsons:u,workspaceRoot:o});const I=await go({config:d,initialTasks:M,logger:e,options:s,persistentTasks:$,target:L,taskGraph:T,workspaceRoot:o});M=I.initialTasks,T=I.taskGraph;const{ephemeralPidFiles:k,injectedServiceIdSet:O,registryStartedCount:B,registryStartedIds:D,registryStartedPids:_,serviceDockStore:W,serviceEnvByTaskId:q,serviceEventBridge:G,serviceResult:J,serviceRunDir:z}=I,Z=s.stopServices,te=Sn({ephemeralPidFiles:k,registryStartedIds:D,registryStartedPids:_,serviceEventBridge:G,serviceRunDir:z,stopServicesOnExit:Z,workspaceRoot:o});te.install();try{if(T=Co({logger:e,options:s,projectOptions:p,taskGraph:T}),s.dryRun){kn({config:d,logger:e,persistentTasks:$,taskGraph:T});return}const K=await Ci({affectedFiles:g,config:d,currentOs:S,initialTasks:M,invocationCwd:i,logger:e,options:s,persistentTasks:$,projectsWithTarget:C,runCacheDirectory:j,serviceEnvByTaskId:q,serviceResult:J,target:L,taskGraph:T,visConfig:r,workspaceRoot:o});if(y){K.hooks.hook("run:after",async H=>{[...H.values()].some(re=>re.code!==0)||await _s(y.path,y.hashes)});const N=new Set($.map(H=>H.id));K.hooks.hook("task:failure",async H=>{N.has(H.id)&&await Ns(y.path)})}if(await K.hooks.callHook("run:before",{tasks:M,workspaceRoot:o}),K.isTTY){const{spawnContext:N}=K,{dynamic:H,lifeCycle:V,stdinRegistry:re,store:oe,taskExecutor:fe}=ai({injectedServiceIdSet:O,runtime:K,serviceDockStore:W,serviceEventBridge:G,workspaceRoot:o});let de="rerun",ce=null,ee=new Map;for(;de!=="quit";){if(de==="rerun")ee=await li({dynamic:H,initialTasks:M,lifeCycle:V,options:s,persistentTasks:$,projectGraph:m,runtime:K,stdinRegistry:re,store:oe,taskExecutor:fe,taskGraph:T,workspaceRoot:o});else if(de==="retry"&&ce){const Y=T.tasks[ce]??M.find(R=>R.id===ce),he=Y?Ye(Y,N.affectedFiles,S):void 0;if(Y&&he){V.startTasks?.([Y]);const R=new He(Re),b=ar(N,Y),Q=(await Ce([{command:he,cwd:b.cwd,env:b.env,inheritEnv:b.inheritEnv,name:Y.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ae=>{ae.kind==="started"&&ae.write&&re.set(Y.id,{kill:ae.kill,resize:ae.resize,write:ae.write}),(ae.kind==="stdout"||ae.kind==="stderr")&&ae.text&&(R.write(ae.text),oe.setOutput(Y.id,R.toString())),ae.kind==="close"&&re.delete(Y.id)}})).closeEvents[0];V.endTasks?.([{code:Q?.exitCode??1,status:Q?.exitCode===0?"success":"failure",task:Y,terminalOutput:oe.getSnapshot().outputs.get(Y.id)}])}else Y&&V.endTasks?.([{code:1,status:"failure",task:Y,terminalOutput:`No command configured for ${Y.id}`}]);ce=null,oe.markDone()}const ne=await di({dynamic:H,store:oe});de=ne.action,ce=ne.retryTaskId}await H.renderIsDone,await K.hooks.callHook("run:after",ee),await K.maybeWriteProfile(ee),ss({logger:e,registryStartedCount:B,stopServicesOnExit:Z})}else await ko({initialTasks:M,logger:e,options:s,persistentTasks:$,projectGraph:m,projectsWithTarget:C,registryStartedCount:B,runtime:K,serviceEventBridge:G,stopServicesOnExit:Z,taskGraph:T,visConfig:r,workspace:a,workspaceRoot:o})}finally{await te.finish()}};export{gc as default};