werkmeister 0.94.0 → 0.94.2

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 (151) hide show
  1. package/dist/{budget-6BEZP2MF.js → budget-FTLJA7ZD.js} +2 -2
  2. package/dist/{cache-HK7TAPL5.js → cache-NKK5QJIV.js} +2 -2
  3. package/dist/{chunk-EGH4ZUSB.js → chunk-232MOJMO.js} +2 -2
  4. package/dist/{chunk-76QOU4PO.js → chunk-2AIXNENG.js} +2 -2
  5. package/dist/{chunk-TAU7BRTN.js → chunk-2CTXJWFS.js} +49 -49
  6. package/dist/{chunk-TBWHG3QY.js → chunk-2GX6NKSQ.js} +2 -2
  7. package/dist/{chunk-YUSN6ATL.js → chunk-2NRMSYNJ.js} +5 -5
  8. package/dist/{chunk-VU3APKHW.js → chunk-3ZLSFIVT.js} +2 -2
  9. package/dist/{chunk-XMMOB7QK.js → chunk-4JNFHNTY.js} +2 -2
  10. package/dist/{chunk-F4U3AMMH.js → chunk-5RUSISOC.js} +2 -2
  11. package/dist/{chunk-YH36XQ4K.js → chunk-6MDK2RR4.js} +2 -2
  12. package/dist/{chunk-H6U67IB5.js → chunk-7LG2XPTV.js} +2 -2
  13. package/dist/{chunk-LM5RDTYV.js → chunk-7TJLK4I6.js} +2 -2
  14. package/dist/{chunk-UPCRI3OW.js → chunk-7YTKJFPS.js} +2 -2
  15. package/dist/{chunk-4JHTEADK.js → chunk-A5AQFRIA.js} +3 -3
  16. package/dist/{chunk-IJQ2NP5F.js → chunk-ACIJTPQA.js} +2 -2
  17. package/dist/chunk-B26VSQC2.js +115 -0
  18. package/dist/{chunk-HPX7AYPN.js → chunk-CVGCL56F.js} +2 -2
  19. package/dist/{chunk-4DUMKXHS.js → chunk-CXBXI7XT.js} +2 -2
  20. package/dist/{chunk-FQEP2RZP.js → chunk-DKC5Y3G4.js} +2 -2
  21. package/dist/chunk-DUBYPXSM.js +84 -0
  22. package/dist/{chunk-JHM3QBJZ.js → chunk-E5LWGDHW.js} +2 -2
  23. package/dist/{chunk-4TZAFRQL.js → chunk-EQQZQNJG.js} +2 -2
  24. package/dist/{chunk-CS3C6IZJ.js → chunk-EYHG6PQK.js} +2 -2
  25. package/dist/{chunk-SKXZCGUV.js → chunk-F3DKBVVT.js} +2 -2
  26. package/dist/{chunk-XN5UHSRT.js → chunk-FDL7EBME.js} +2 -2
  27. package/dist/{chunk-RK6XWGTK.js → chunk-FTFEMCUI.js} +2 -2
  28. package/dist/{chunk-MZFVZCM3.js → chunk-G7YHXBJA.js} +2 -2
  29. package/dist/{chunk-AHI6JJ7M.js → chunk-HITMIAMG.js} +2 -2
  30. package/dist/{chunk-N63S7XEN.js → chunk-HIYRDPKC.js} +2 -2
  31. package/dist/{chunk-CYYGHFTA.js → chunk-HWLSGWD6.js} +2 -2
  32. package/dist/{chunk-74HXYLXD.js → chunk-IK7VM467.js} +2 -2
  33. package/dist/{chunk-IK7W2LBK.js → chunk-IUWJ2NTR.js} +2 -2
  34. package/dist/{chunk-ATGF4AVD.js → chunk-J77X33IJ.js} +2 -2
  35. package/dist/{chunk-OBFA4YEN.js → chunk-JTH6VZTE.js} +2 -2
  36. package/dist/{chunk-OMLAA2E2.js → chunk-K72V2HLK.js} +2 -2
  37. package/dist/{chunk-XNHLRR2R.js → chunk-KNBPZRXN.js} +2 -2
  38. package/dist/{chunk-QWI55NYX.js → chunk-KPANGOHV.js} +2 -2
  39. package/dist/{chunk-XHYIFBRR.js → chunk-L6B3G5M6.js} +18 -18
  40. package/dist/{chunk-MUSFS3P4.js → chunk-LCB45SSP.js} +2 -2
  41. package/dist/{chunk-PLOU2ZRT.js → chunk-LM53TV37.js} +25 -25
  42. package/dist/{chunk-QQPUGUBV.js → chunk-LMPF3GCE.js} +2 -2
  43. package/dist/{chunk-AK3LSHFT.js → chunk-LRNISDFO.js} +2 -2
  44. package/dist/{chunk-6RXTW4LU.js → chunk-LW7TF2T6.js} +2 -2
  45. package/dist/{chunk-O242ZRGI.js → chunk-MKFUF6Q3.js} +7 -7
  46. package/dist/{chunk-CBDTSTWG.js → chunk-MNPPCCEE.js} +3 -3
  47. package/dist/{chunk-NOYTCS5B.js → chunk-MU2BVPOO.js} +2 -2
  48. package/dist/{chunk-QKNBTD2X.js → chunk-MUHH34N4.js} +2 -2
  49. package/dist/{chunk-EFNV3TFI.js → chunk-NHX34CYT.js} +2 -2
  50. package/dist/{chunk-GINS7EJK.js → chunk-NUTCQUPB.js} +2 -2
  51. package/dist/{chunk-SLVS2TAO.js → chunk-PELPDI4T.js} +2 -2
  52. package/dist/{chunk-HMFIRWVJ.js → chunk-QGV5DRSQ.js} +2 -2
  53. package/dist/{chunk-YELLLMDI.js → chunk-QOXVGCRJ.js} +2 -2
  54. package/dist/{chunk-XAXQJKLP.js → chunk-QPIQDB6Z.js} +2 -2
  55. package/dist/{chunk-LULXY7J5.js → chunk-QWYZ6S7O.js} +2 -2
  56. package/dist/chunk-R4TLZDCX.js +145 -0
  57. package/dist/{chunk-K2W4MAI7.js → chunk-RIYZYOGC.js} +2 -2
  58. package/dist/{chunk-XNPHA7HX.js → chunk-SAN555ST.js} +2 -2
  59. package/dist/{chunk-2XQ52RUU.js → chunk-SUEMTMAK.js} +9 -9
  60. package/dist/{chunk-O22TMXNP.js → chunk-SVMYDOF3.js} +2 -2
  61. package/dist/{chunk-7XABNR7Y.js → chunk-TPEKG7PQ.js} +2 -2
  62. package/dist/{chunk-IFSSMLFN.js → chunk-U2PODCN6.js} +3 -3
  63. package/dist/{chunk-KPIXRVP2.js → chunk-UDLGGZXC.js} +2 -2
  64. package/dist/{chunk-MMZ3SFZC.js → chunk-UFGV42IR.js} +2 -2
  65. package/dist/{chunk-QXRZGJ6P.js → chunk-VNXY7PMH.js} +2 -2
  66. package/dist/chunk-XWU77GCN.js +4 -0
  67. package/dist/chunk-YZICING6.js +4 -0
  68. package/dist/clean-JQ23VGS4.js +8 -0
  69. package/dist/close_out-744Y63XC.js +8 -0
  70. package/dist/code-3DMTUNGH.js +4 -0
  71. package/dist/{config-KNTWG6EB.js → config-YT3JIDCL.js} +2 -2
  72. package/dist/{connect-C7JHA64B.js → connect-2M54SVD2.js} +2 -2
  73. package/dist/{daemon-XYZNTCAM.js → daemon-6MTK2VDU.js} +2 -2
  74. package/dist/dashboard.js +1 -1
  75. package/dist/{detect-VL2VYCV3.js → detect-UIB3OBYA.js} +2 -2
  76. package/dist/{down-6JMGYWXR.js → down-NMZ2DBO3.js} +3 -3
  77. package/dist/{fixture-NOVLAM5W.js → fixture-UIW4KJFN.js} +2 -2
  78. package/dist/form-cli.js +1 -1
  79. package/dist/hooks-GT5XFJFN.js +4 -0
  80. package/dist/{hooks_gen-IRFN64CG.js → hooks_gen-ELUNYN45.js} +2 -2
  81. package/dist/infra-KXRN7OOO.js +4 -0
  82. package/dist/init_workspace-BQJDVZKC.js +4 -0
  83. package/dist/{intercept-NKFHJDSS.js → intercept-NTMX4VHT.js} +2 -2
  84. package/dist/{issue-E2EAVT4O.js → issue-UMW6EGO2.js} +2 -2
  85. package/dist/lib/agent_state.js +1 -1
  86. package/dist/lib/gate.js +1 -1
  87. package/dist/lib/pr_guard.js +1 -1
  88. package/dist/list_workspaces-SYHULZIR.js +7 -0
  89. package/dist/logs-FYA4G5I7.js +6 -0
  90. package/dist/main.js +3 -3
  91. package/dist/mcp-proxy.js +1 -1
  92. package/dist/mcp.js +13 -13
  93. package/dist/{migrate-IICFUXYU.js → migrate-4AS3A4BC.js} +2 -2
  94. package/dist/notes-NAADT5S5.js +4 -0
  95. package/dist/{open-AMNSPLO3.js → open-3ILG6XRJ.js} +2 -2
  96. package/dist/{optimize-PMP7P2UK.js → optimize-HTPIGT4L.js} +2 -2
  97. package/dist/pause-QJMS7ACN.js +4 -0
  98. package/dist/pr-FLQJM2Q2.js +5 -0
  99. package/dist/proxy_reload-Z4GHQR2M.js +6 -0
  100. package/dist/{registry-VQR3PCMJ.js → registry-QMQGFYA5.js} +2 -2
  101. package/dist/remove-EROMS3E3.js +7 -0
  102. package/dist/remove_workspace-MYN3CATF.js +8 -0
  103. package/dist/restart-SEBCGHD3.js +8 -0
  104. package/dist/resume-D6IIS26J.js +8 -0
  105. package/dist/{safari-OZQGP3ME.js → safari-3LNJL7SF.js} +2 -2
  106. package/dist/{sandbox-56EMTKOZ.js → sandbox-XX46HTTE.js} +2 -2
  107. package/dist/{services-QS75OCBZ.js → services-WIMTKZ4J.js} +2 -2
  108. package/dist/{setup-MTWBDAIC.js → setup-3IV34I5W.js} +2 -2
  109. package/dist/skills-5WWMEBIY.js +4 -0
  110. package/dist/{slots-NHWJHL2S.js → slots-SE6INLJA.js} +2 -2
  111. package/dist/{standards-UROAKPMD.js → standards-3PFXY3M6.js} +2 -2
  112. package/dist/start_args-K3D6ZWQV.js +4 -0
  113. package/dist/starting_prompt-IXVFIKPY.js +4 -0
  114. package/dist/stats-KVAEZOUT.js +4 -0
  115. package/dist/{status-R7TOMOBL.js → status-7UE7GC3F.js} +2 -2
  116. package/dist/{stop-QVCPCITU.js → stop-XWE4C4MZ.js} +2 -2
  117. package/dist/{telepresence-7N3K5SSF.js → telepresence-7Y7KWO65.js} +2 -2
  118. package/dist/{test-ZN6SHWTT.js → test-KZJNZ3BJ.js} +2 -2
  119. package/dist/{tokens-2E2LG6YE.js → tokens-JZAVTR6Q.js} +2 -2
  120. package/dist/{up-L27S3JKI.js → up-ST5SJ77O.js} +3 -3
  121. package/dist/{v4-UWZ6HALV.js → v4-IEL527UK.js} +2 -2
  122. package/dist/wait_load-F2SR7S5A.js +4 -0
  123. package/dist/werkmeister-workspaces.vsix +0 -0
  124. package/dist/{workspace-43VU3SGP.js → workspace-I3CSM6NX.js} +2 -2
  125. package/package.json +3 -3
  126. package/dist/chunk-7WDBV2LF.js +0 -84
  127. package/dist/chunk-BZE7LPZS.js +0 -4
  128. package/dist/chunk-HLTNOAF7.js +0 -114
  129. package/dist/chunk-TVYHBSWN.js +0 -145
  130. package/dist/chunk-USB7XTDC.js +0 -4
  131. package/dist/clean-FAYXLB4Z.js +0 -8
  132. package/dist/close_out-6I75ESRZ.js +0 -8
  133. package/dist/code-WTWMNW37.js +0 -4
  134. package/dist/hooks-SDUAIWWN.js +0 -4
  135. package/dist/infra-HOVBHUMZ.js +0 -4
  136. package/dist/init_workspace-VX7OFHTK.js +0 -4
  137. package/dist/list_workspaces-BLHAGXCZ.js +0 -7
  138. package/dist/logs-AQYVO3CT.js +0 -6
  139. package/dist/notes-UPBD5LBR.js +0 -4
  140. package/dist/pause-VEEBLHN5.js +0 -4
  141. package/dist/pr-LWES6IYE.js +0 -5
  142. package/dist/proxy_reload-K7C6EHPH.js +0 -6
  143. package/dist/remove-4J2TWDTL.js +0 -7
  144. package/dist/remove_workspace-WBKG2WUL.js +0 -8
  145. package/dist/restart-7QZO6FO5.js +0 -8
  146. package/dist/resume-JKZXVXAV.js +0 -8
  147. package/dist/skills-CK4FAV74.js +0 -4
  148. package/dist/start_args-OS3YJM4I.js +0 -4
  149. package/dist/starting_prompt-JA4R4GAA.js +0 -4
  150. package/dist/stats-WG2ZTV53.js +0 -4
  151. package/dist/wait_load-WGNYRM67.js +0 -4
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{d as v,m as L}from"./chunk-O242ZRGI.js";import"./chunk-VU3APKHW.js";import"./chunk-PLOU2ZRT.js";import"./chunk-IJQ2NP5F.js";import"./chunk-K2W4MAI7.js";import"./chunk-2XQ52RUU.js";import"./chunk-XHYIFBRR.js";import"./chunk-IK7W2LBK.js";import"./chunk-TAU7BRTN.js";import"./chunk-4DUMKXHS.js";import"./chunk-SLVS2TAO.js";import"./chunk-MUSFS3P4.js";import"./chunk-YELLLMDI.js";import"./chunk-USB7XTDC.js";import"./chunk-IFSSMLFN.js";import"./chunk-7WDBV2LF.js";import"./chunk-QXRZGJ6P.js";import"./chunk-OBFA4YEN.js";import{B as h,C as w,I as b,L as y,Q as k,v as f,w as $}from"./chunk-YH36XQ4K.js";import"./chunk-XMMOB7QK.js";import"./chunk-EGH4ZUSB.js";import"./chunk-QWI55NYX.js";import"./chunk-XNHLRR2R.js";import{p as d}from"./chunk-H6U67IB5.js";import"./chunk-HMFIRWVJ.js";import"./chunk-XAXQJKLP.js";import"./chunk-6RXTW4LU.js";import"./chunk-EFNV3TFI.js";import"./chunk-4TZAFRQL.js";import"./chunk-TVYHBSWN.js";import"./chunk-O22TMXNP.js";import{a as c,f as g}from"./chunk-KPIXRVP2.js";g();import N from"node:os";var M=2**30,x=c((r,t)=>Number.isFinite(r)?`${Number(r.toFixed(1))}${t}`:"no limit","limit");async function P(r){let t=await h(),m=w(N.cpus().length),u=$(),l=await k(),n=L(),a=f(y(l,n??[])).map((o,e)=>{let s=u[o.feature]?.workspace,i=s&&d(s)?.services||null,B=s?b(s,i??void 0):null;return{...o,position:e+1,services:i,cost:B}});if(r.json){let o=c(e=>Number.isFinite(e)?e:null,"n");console.log(JSON.stringify({budget:{memory:o(t.memory),cpus:o(t.cpus),preempt:t.preempt},host_load:m,leases:u,waiting:l,running:n?.map(e=>({feature:e.feature,cpus:e.cost.cpus,memory:e.cost.memory,rank:e.rank,busy:e.busy}))??null,waiters:a.map(e=>({feature:e.feature,position:e.position,services:e.services,cpus:e.cost?.cpus??null,memory:e.cost?.memory??null,waited_ms:e.waitedMs,gate:e.gate}))}));return}console.log(`Budget: ${x(t.memory/M," GiB")} memory, ${x(t.cpus," CPUs")}, host load ${m||"unchecked"}, preemption ${t.preempt?"on":"off"}`);let p=Object.entries(u).sort(([,o],[,e])=>o.slot-e.slot);console.log(p.length?"Slots:":"Slots: none held");for(let[o,e]of p)console.log(` ${e.slot} ${o}${e.workspace?` ${e.workspace}`:""}`);console.log(n?n.length?"Running:":"Running: none":"Running: docker unavailable");for(let o of[...n??[]].sort((e,s)=>s.cost.cpus-e.cost.cpus))console.log(` ${v(o)}`);console.log(a.length?"Waiting:":"Waiting: none");for(let o of a){let e=o.services?`${o.services.join(", ")}${o.gate?" for a running feature":""}`:"whole feature",s=o.cost?` (${Number(o.cost.cpus.toFixed(1))} CPUs, ${(o.cost.memory/M).toFixed(1)} GiB)`:"",i=o.waitedMs?` waited ${Math.round(o.waitedMs/6e4)} min${o.position===1&&o.waitedMs>=3e5?", gets the next free room":""}`:"";console.log(` ${o.position}. ${o.feature} ${e}${s}${i}`)}}c(P,"run");export{P as run};
4
- //# sourceMappingURL=budget-6BEZP2MF.js.map
3
+ import{d as v,m as L}from"./chunk-MKFUF6Q3.js";import"./chunk-3ZLSFIVT.js";import"./chunk-LM53TV37.js";import"./chunk-ACIJTPQA.js";import"./chunk-RIYZYOGC.js";import"./chunk-SUEMTMAK.js";import"./chunk-L6B3G5M6.js";import"./chunk-IUWJ2NTR.js";import"./chunk-2CTXJWFS.js";import"./chunk-CXBXI7XT.js";import"./chunk-PELPDI4T.js";import"./chunk-LCB45SSP.js";import"./chunk-QOXVGCRJ.js";import"./chunk-XWU77GCN.js";import"./chunk-U2PODCN6.js";import"./chunk-DUBYPXSM.js";import"./chunk-VNXY7PMH.js";import"./chunk-JTH6VZTE.js";import{B as h,C as w,I as b,L as y,Q as k,v as f,w as $}from"./chunk-6MDK2RR4.js";import"./chunk-4JNFHNTY.js";import"./chunk-232MOJMO.js";import"./chunk-KPANGOHV.js";import"./chunk-KNBPZRXN.js";import{p as d}from"./chunk-7LG2XPTV.js";import"./chunk-QGV5DRSQ.js";import"./chunk-QPIQDB6Z.js";import"./chunk-LW7TF2T6.js";import"./chunk-NHX34CYT.js";import"./chunk-EQQZQNJG.js";import"./chunk-R4TLZDCX.js";import"./chunk-SVMYDOF3.js";import{a as c,f as g}from"./chunk-UDLGGZXC.js";g();import N from"node:os";var M=2**30,x=c((r,t)=>Number.isFinite(r)?`${Number(r.toFixed(1))}${t}`:"no limit","limit");async function P(r){let t=await h(),m=w(N.cpus().length),u=$(),l=await k(),n=L(),a=f(y(l,n??[])).map((o,e)=>{let s=u[o.feature]?.workspace,i=s&&d(s)?.services||null,B=s?b(s,i??void 0):null;return{...o,position:e+1,services:i,cost:B}});if(r.json){let o=c(e=>Number.isFinite(e)?e:null,"n");console.log(JSON.stringify({budget:{memory:o(t.memory),cpus:o(t.cpus),preempt:t.preempt},host_load:m,leases:u,waiting:l,running:n?.map(e=>({feature:e.feature,cpus:e.cost.cpus,memory:e.cost.memory,rank:e.rank,busy:e.busy}))??null,waiters:a.map(e=>({feature:e.feature,position:e.position,services:e.services,cpus:e.cost?.cpus??null,memory:e.cost?.memory??null,waited_ms:e.waitedMs,gate:e.gate}))}));return}console.log(`Budget: ${x(t.memory/M," GiB")} memory, ${x(t.cpus," CPUs")}, host load ${m||"unchecked"}, preemption ${t.preempt?"on":"off"}`);let p=Object.entries(u).sort(([,o],[,e])=>o.slot-e.slot);console.log(p.length?"Slots:":"Slots: none held");for(let[o,e]of p)console.log(` ${e.slot} ${o}${e.workspace?` ${e.workspace}`:""}`);console.log(n?n.length?"Running:":"Running: none":"Running: docker unavailable");for(let o of[...n??[]].sort((e,s)=>s.cost.cpus-e.cost.cpus))console.log(` ${v(o)}`);console.log(a.length?"Waiting:":"Waiting: none");for(let o of a){let e=o.services?`${o.services.join(", ")}${o.gate?" for a running feature":""}`:"whole feature",s=o.cost?` (${Number(o.cost.cpus.toFixed(1))} CPUs, ${(o.cost.memory/M).toFixed(1)} GiB)`:"",i=o.waitedMs?` waited ${Math.round(o.waitedMs/6e4)} min${o.position===1&&o.waitedMs>=3e5?", gets the next free room":""}`:"";console.log(` ${o.position}. ${o.feature} ${e}${s}${i}`)}}c(P,"run");export{P as run};
4
+ //# sourceMappingURL=budget-FTLJA7ZD.js.map
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import"./chunk-BZE7LPZS.js";import{d as s}from"./chunk-4DUMKXHS.js";import"./chunk-USB7XTDC.js";import"./chunk-XMMOB7QK.js";import"./chunk-QWI55NYX.js";import"./chunk-4TZAFRQL.js";import{h as e,l as c}from"./chunk-TVYHBSWN.js";import"./chunk-O22TMXNP.js";import{a as r,f as i}from"./chunk-KPIXRVP2.js";i();async function u(o){o.action!=="prune"&&(c(`Unknown action \`${String(o.action)}\` \u2014 the only action is \`prune\`.`),process.exit(2));let t=await s({name:typeof o.name=="string"?o.name:void 0,reset:!!o.reset,force:!!o.force,dryRun:!!o.dry_run});t.length||console.log("No caches in the registry.");for(let n of t){let a=n.ok?`${e.GREEN}\u2713${e.RESET}`:`${e.RED}\u2717${e.RESET}`;console.log(`${a} ${n.name} (${n.action}): ${n.detail}`)}t.some(n=>!n.ok)&&process.exit(1)}r(u,"run");export{u as run};
4
- //# sourceMappingURL=cache-HK7TAPL5.js.map
3
+ import"./chunk-YZICING6.js";import{d as s}from"./chunk-CXBXI7XT.js";import"./chunk-XWU77GCN.js";import"./chunk-4JNFHNTY.js";import"./chunk-KPANGOHV.js";import"./chunk-EQQZQNJG.js";import{h as e,l as c}from"./chunk-R4TLZDCX.js";import"./chunk-SVMYDOF3.js";import{a as r,f as i}from"./chunk-UDLGGZXC.js";i();async function u(o){o.action!=="prune"&&(c(`Unknown action \`${String(o.action)}\` \u2014 the only action is \`prune\`.`),process.exit(2));let t=await s({name:typeof o.name=="string"?o.name:void 0,reset:!!o.reset,force:!!o.force,dryRun:!!o.dry_run});t.length||console.log("No caches in the registry.");for(let n of t){let a=n.ok?`${e.GREEN}\u2713${e.RESET}`:`${e.RED}\u2717${e.RESET}`;console.log(`${a} ${n.name} (${n.action}): ${n.detail}`)}t.some(n=>!n.ok)&&process.exit(1)}r(u,"run");export{u as run};
4
+ //# sourceMappingURL=cache-NKK5QJIV.js.map
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{a as r,f as c}from"./chunk-KPIXRVP2.js";c();import*as t from"node:fs";import*as s from"node:path";var i="compose.yml",p="docker-compose.yml";function f(o){try{return t.statSync(o).isFile()}catch{return!1}}r(f,"isFile");function m(o){for(let e of[i,p]){let n=s.join(o,e);if(f(n))return n}return null}r(m,"findWorkspaceCompose");function u(o){let e=s.join(o,p),n=s.join(o,i);f(e)&&!t.existsSync(n)&&t.renameSync(e,n)}r(u,"migrateWorkspaceCompose");export{i as a,p as b,m as c,u as d};
4
- //# sourceMappingURL=chunk-EGH4ZUSB.js.map
3
+ import{a as r,f as c}from"./chunk-UDLGGZXC.js";c();import*as t from"node:fs";import*as s from"node:path";var i="compose.yml",p="docker-compose.yml";function f(o){try{return t.statSync(o).isFile()}catch{return!1}}r(f,"isFile");function m(o){for(let e of[i,p]){let n=s.join(o,e);if(f(n))return n}return null}r(m,"findWorkspaceCompose");function u(o){let e=s.join(o,p),n=s.join(o,i);f(e)&&!t.existsSync(n)&&t.renameSync(e,n)}r(u,"migrateWorkspaceCompose");export{i as a,p as b,m as c,u as d};
4
+ //# sourceMappingURL=chunk-232MOJMO.js.map
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{c as i,d as n,f as s}from"./chunk-YUSN6ATL.js";import{a as o,f as t}from"./chunk-KPIXRVP2.js";t();import*as c from"node:fs";function a(){if(process.stdin.isTTY)return"";try{return c.readFileSync(0,"utf8")}catch{return""}}o(a,"readStdinTask");async function d(e){try{await s(e,void 0,{readStdinTask:a,build:e.build!==!1})}catch(r){throw r instanceof n&&(console.log(r.message),process.exit(1)),r instanceof i&&process.exit(1),r}}o(d,"run");export{a,d as b};
4
- //# sourceMappingURL=chunk-76QOU4PO.js.map
3
+ import{c as i,d as n,f as s}from"./chunk-2NRMSYNJ.js";import{a as o,f as t}from"./chunk-UDLGGZXC.js";t();import*as c from"node:fs";function a(){if(process.stdin.isTTY)return"";try{return c.readFileSync(0,"utf8")}catch{return""}}o(a,"readStdinTask");async function d(e){try{await s(e,void 0,{readStdinTask:a,build:e.build!==!1})}catch(r){throw r instanceof n&&(console.log(r.message),process.exit(1)),r instanceof i&&process.exit(1),r}}o(d,"run");export{a,d as b};
4
+ //# sourceMappingURL=chunk-2AIXNENG.js.map
@@ -1,18 +1,18 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{a as ae}from"./chunk-4DUMKXHS.js";import{a as F,b as H,f as ee}from"./chunk-YELLLMDI.js";import{c as Y,d as K,e as Q,g as J,j as Z}from"./chunk-USB7XTDC.js";import{P as se,Q as oe,v as te}from"./chunk-IFSSMLFN.js";import{b as re}from"./chunk-7WDBV2LF.js";import{a as I,b as ne}from"./chunk-OBFA4YEN.js";import{da as ie}from"./chunk-YH36XQ4K.js";import{r as X}from"./chunk-EFNV3TFI.js";import{D as G,S as q,U as V}from"./chunk-TVYHBSWN.js";import{a as c,f as A}from"./chunk-KPIXRVP2.js";A();import*as le from"node:fs";import*as he from"node:path";A();function ce(t){let n=t.url?`[${t.ref}](${t.url})`:t.ref,i=t.title?`: ${t.title}`:"",a=t.fetchedAt?`Copy taken ${t.fetchedAt.slice(0,10)}: \`.werkmeister/issue.md\`.`:"No stored copy; run `werkmeister workspace init --refresh-issue`.";return["## Issue","",`${n}${i}. ${a}`,"Before each stage, re-read the live issue for newer direction: `werkmeister issue view`","Its status moves by itself (In Progress \u2192 In Review \u2192 Done): `docs/workspace-lifecycle.md` \xA7 Issue status in the werkmeister repo.",""].join(`
4
- `)}c(ce,"renderIssueRef");function Le(t){try{let n=X(),i=I(void 0,n),a=t.find(r=>i[r]?.hostname),s=a?i[a].hostname:Object.values(i).map(r=>r.hostname).filter(Boolean).sort()[0];return s?{host:s,domain:n.local_domain.replace(/^\.+/,"")}:null}catch{return null}}c(Le,"resolveProxyHost");function B(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}c(B,"isDict");function _e(t,n,i){let a=[];for(let[s]of t){let r=!1;try{r=le.statSync(he.join(n,s,"CLAUDE.md")).isFile()}catch{}r&&a.push(`| Working in ${s} | ${s}/CLAUDE.md |`)}return i&&a.push("| Running or validating the change \u2014 test commands, how to validate, ports, lifecycle | .werkmeister/werkmeister-context.md |"),t.length>1&&a.push("| Cross-repo contract change | .werkmeister/notes/ (`contract` notes) |"),a.push("| Open or create a PR (including `/create-pr`), merge, close out | .werkmeister/pr-rules.md |"),a.length===0?"":`| Task | Read |
3
+ import{a as ce}from"./chunk-CXBXI7XT.js";import{a as F,b as H,f as re}from"./chunk-QOXVGCRJ.js";import{a as Y,b as K,e as Q,f as J,g as Z,i as ee,l as te}from"./chunk-XWU77GCN.js";import{P as ne,Q as ae,v as se}from"./chunk-U2PODCN6.js";import{b as oe}from"./chunk-DUBYPXSM.js";import{a as I,b as ie}from"./chunk-JTH6VZTE.js";import{da as le}from"./chunk-6MDK2RR4.js";import{r as X}from"./chunk-NHX34CYT.js";import{D as G,S as q,U as V}from"./chunk-R4TLZDCX.js";import{a as c,f as A}from"./chunk-UDLGGZXC.js";A();import*as de from"node:fs";import*as ue from"node:path";A();function he(t){let s=t.url?`[${t.ref}](${t.url})`:t.ref,i=t.title?`: ${t.title}`:"",a=t.fetchedAt?`Copy taken ${t.fetchedAt.slice(0,10)}: \`.werkmeister/issue.md\`.`:"No stored copy; run `werkmeister workspace init --refresh-issue`.";return["## Issue","",`${s}${i}. ${a}`,"Before each stage, re-read the live issue for newer direction: `werkmeister issue view`","Its status moves by itself (In Progress \u2192 In Review \u2192 Done): `docs/workspace-lifecycle.md` \xA7 Issue status in the werkmeister repo.",""].join(`
4
+ `)}c(he,"renderIssueRef");function Pe(t){try{let s=X(),i=I(void 0,s),a=t.find(r=>i[r]?.hostname),o=a?i[a].hostname:Object.values(i).map(r=>r.hostname).filter(Boolean).sort()[0];return o?{host:o,domain:s.local_domain.replace(/^\.+/,"")}:null}catch{return null}}c(Pe,"resolveProxyHost");function B(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}c(B,"isDict");function je(t,s,i){let a=[];for(let[o]of t){let r=!1;try{r=de.statSync(ue.join(s,o,"CLAUDE.md")).isFile()}catch{}r&&a.push(`| Working in ${o} | ${o}/CLAUDE.md |`)}return i&&a.push("| Running or validating the change \u2014 test commands, how to validate, ports, lifecycle | .werkmeister/werkmeister-context.md |"),t.length>1&&a.push("| Cross-repo contract change | .werkmeister/notes/ (`contract` notes) |"),a.push("| Open or create a PR (including `/create-pr`), merge, close out | .werkmeister/pr-rules.md |"),a.length===0?"":`| Task | Read |
5
5
  |------|------|
6
6
  `+a.join(`
7
- `)}c(_e,"buildRoutingTable");function je(t){return t.path==="spike"?"No implement, review, or PR phase. Deliverable: `finding` notes. Anything built is throwaway.":t.gate===null?"Gate: none \u2014 `w9r-implement` loads the standards.":t.gate.status?`Gate: no source edit until a \`${t.gate.note}\` note in \`.werkmeister/notes/\` reads \`status: ${t.gate.status}\`. Write it at the end of research, after the user approves the design; the flip *is* the approval \u2014 do not ask again.`:`Gate: no source edit until a \`${t.gate.note}\` note in \`.werkmeister/notes/\` names the root cause.`}c(je,"gateLine");function Ke(t,n,i,a=""){let s=ee(n),r=[];for(let m of t){let v=n[m]??{},w;s.includes(m)?w="any code edit":w=(v.applies_to||[]).map(x=>`\`${x}\``).join(", ")||"\u2014",r.push(`| ${m} | \`w9r-${m}-standard\` | ${w} |`)}let f=i.length>0?i.join(", "):"none discovered",$=H(F(),"","tree"),p=$?`
8
- > Module source: ${$}`:"",y=["`ponytail`",...s.map(m=>`\`w9r-${m}-standard\``)].join(" + "),h=oe(a),R={research:"| research / planning | `w9r-research` | nothing \u2014 spawns the read-only `w9r-researcher` agent |",implement:`| implementing (before the first code edit) | \`w9r-implement\` | universal base (${y}) + rows matching the files you edit |`,test:"| testing | `w9r-test` | nothing \u2014 spawns the matching `w9r-tester-<archetype>` agent(s) |",review:"| review (before reading any diff or PR) | `w9r-review` | the standards covering files in the diff |",pr:"| PR / finishing | `w9r-pr` | `.werkmeister/pr-rules.md` \u2014 PRs open only via `werkmeister pr open` |"},C=h===se?"":`**Work type:** ${a.trim().toLowerCase()} (${h.path} path) \u2014 phases: ${h.phases.join(" \u2192 ")}.
9
- ${je(h)}
7
+ `)}c(je,"buildRoutingTable");function Oe(t){return t.path==="spike"?"No implement, review, or PR phase. Deliverable: `finding` notes. Anything built is throwaway.":t.gate===null?"Gate: none \u2014 `w9r-implement` loads the standards.":t.gate.status?`Gate: no source edit until a \`${t.gate.note}\` note in \`.werkmeister/notes/\` reads \`status: ${t.gate.status}\`. Write it at the end of research, after the user approves the design; the flip *is* the approval \u2014 do not ask again.`:`Gate: no source edit until a \`${t.gate.note}\` note in \`.werkmeister/notes/\` names the root cause.`}c(Oe,"gateLine");function Ze(t,s,i,a=""){let o=re(s),r=[];for(let u of t){let v=s[u]??{},k;o.includes(u)?k="any code edit":k=(v.applies_to||[]).map(x=>`\`${x}\``).join(", ")||"\u2014",r.push(`| ${u} | \`w9r-${u}-standard\` | ${k} |`)}let p=i.length>0?i.join(", "):"none discovered",w=H(F(),"","tree"),m=w?`
8
+ > Module source: ${w}`:"",y=["`ponytail`",...o.map(u=>`\`w9r-${u}-standard\``)].join(" + "),h=ae(a),R={research:"| research / planning | `w9r-research` | nothing \u2014 spawns the read-only `w9r-researcher` agent |",implement:`| implementing (before the first code edit) | \`w9r-implement\` | universal base (${y}) + rows matching the files you edit |`,test:"| testing | `w9r-test` | nothing \u2014 spawns the matching `w9r-tester-<archetype>` agent(s) |",review:"| review (before reading any diff or PR) | `w9r-review` | the standards covering files in the diff |",pr:"| PR / finishing | `w9r-pr` | `.werkmeister/pr-rules.md` \u2014 PRs open only via `werkmeister pr open` |"},C=h===ne?"":`**Work type:** ${a.trim().toLowerCase()} (${h.path} path) \u2014 phases: ${h.phases.join(" \u2192 ")}.
9
+ ${Oe(h)}
10
10
 
11
11
  `;return`## Standards routing
12
12
 
13
- > Compiled from services.yaml + .werkmeister/workspace.yml (\`standards_override\`) \u2014 regenerated by \`werkmeister workspace init\`. Do not hand-edit.${p}
13
+ > Compiled from services.yaml + .werkmeister/workspace.yml (\`standards_override\`) \u2014 regenerated by \`werkmeister workspace init\`. Do not hand-edit.${m}
14
14
 
15
- **Active in this workspace** (repos: ${f}):
15
+ **Active in this workspace** (repos: ${p}):
16
16
 
17
17
  | Standard | Skill | Loads on |
18
18
  |----------|-------|----------|
@@ -23,11 +23,11 @@ ${C}**By phase** \u2014 invoke the entry skill before starting the phase:
23
23
 
24
24
  | Phase | Invoke first | Loads |
25
25
  |-------|--------------|-------|
26
- ${h.phases.map(m=>R[m]).join(`
26
+ ${h.phases.map(u=>R[u]).join(`
27
27
  `)}
28
28
 
29
- `}c(Ke,"buildStandardsRoutingSection");function Qe(t,n,i,a,s,r=null,f=null){let $=i.map(([g,L])=>`- ${g}/ \u2014 branch: ${L}`).join(`
30
- `),p=!!(s.FEATURE??"").trim(),y=_e(i,n,p),h=y?`
29
+ `}c(Ze,"buildStandardsRoutingSection");function et(t,s,i,a,o,r=null,p=null){let w=i.map(([g,L])=>`- ${g}/ \u2014 branch: ${L}`).join(`
30
+ `),m=!!(o.FEATURE??"").trim(),y=je(i,s,m),h=y?`
31
31
  ## Routing
32
32
 
33
33
  ${y}
@@ -40,13 +40,13 @@ Load only what the routing table points to for your current task. Target: \u2264
40
40
  Working notes live in [.werkmeister/notes/](.werkmeister/notes/) \u2014 \`NNN-<type>-<slug>.md\`. Types and rules: docs/notes-conventions.md in the werkmeister repo.
41
41
 
42
42
  Read relevant notes first; skip \`status: superseded\`. \`decision\` notes are binding and override task-level instincts \u2014 on conflict, raise it to the user rather than picking a side.
43
- ${R>1?"\nRecord contract changes (API schema, shared types, event contracts) as `contract` notes **before** switching repos; read them when entering the receiving repo.\n":""}`,w=f?null:te(s),x=w?w[1]?`${a} \u2014 [${w[0]}](${w[1]})`:`${a} \u2014 ${w[0]}`:a,b=(s.DESCRIPTION??"").trim(),T=`## Current Task
43
+ ${R>1?"\nRecord contract changes (API schema, shared types, event contracts) as `contract` notes **before** switching repos; read them when entering the receiving repo.\n":""}`,k=p?null:se(o),x=k?k[1]?`${a} \u2014 [${k[0]}](${k[1]})`:`${a} \u2014 ${k[0]}`:a,b=(o.DESCRIPTION??"").trim(),T=`## Current Task
44
44
 
45
45
  ${x}
46
46
 
47
47
  ${b||"<!-- Replace this comment with 1-2 sentences describing what this feature does and the user-visible outcome. -->"}
48
- ${f?`
49
- ${ce(f)}`:""}`,k;if(r!==null)k=r;else{let g=H(F(),"","tree");k=`## Code Standards
48
+ ${p?`
49
+ ${he(p)}`:""}`,$;if(r!==null)$=r;else{let g=H(F(),"","tree");$=`## Code Standards
50
50
 
51
51
  Follow the canonical cross-repo code standards (comment rubric, per-repo quirks)`+(g?`: ${g}`:".")+`
52
52
 
@@ -57,28 +57,28 @@ ${T}
57
57
 
58
58
  ${C}
59
59
 
60
- ${$}
60
+ ${w}
61
61
  ${h}
62
- ${k}${v}
62
+ ${$}${v}
63
63
  ## Issues
64
64
 
65
65
  Hit a bug, or need to log a feature or task, in the \`werkmeister\` tool or a repo's code? If this workspace's changes caused a bug, fix it here; otherwise file an issue (bug | feature | task) where it belongs (the werkmeister repo, or this machine's issue tracker) and report the URL. Rules, labels and templates: [.werkmeister/issues-report.md](.werkmeister/issues-report.md).
66
- `}c(Qe,"buildClaudeMd");function Pe(t,n,i,a,s){let r=Y(n,i[n],a),f=K(i[n]);return f?`- \`${n}\`: no tests (registry: ${f})`:r?`- \`${n}\`: \`${Q(t,n,s?`${s} && ${r}`:r)}\``:`- \`${n}\`: no test command registered (add \`test:\` to its registry entry)`}c(Pe,"testCommandLine");var Oe=c(t=>`A one-off probe is a \`node --test\` file, run as \`${t} --no-wait node --test <file>\` (in the service's container, after its \`docker exec -w <dir> <container>\`, when the host has no node_modules); never host \`node <script>\`, a compound shell line or \`docker exec \u2026 node <script>\`. That form asks each time and is never pre-approved, since it runs any file (SW-510).`,"PROBE_FORM");function Ee(t){let n=Object.entries(t);return n.length?`
67
- Shared caches, mounted by every workspace on this machine: never delete from them (\`werkmeister cache prune\` evicts for every workspace, so it is the person's call). ${n.map(([a,s])=>{let r=ae(a,s),f=r.kind==="volume"?`volume \`${r.name}\``:`host dir \`${r.name}\``,$=Object.entries(s.env??{}).map(([p,y])=>`\`${p}=${y}\``);return`\`${a}\` at \`${s.path}\` (${[...$,f].join(", ")})`}).join("; ")}.
68
- `:""}c(Ee,"sharedCachesLine");function Je(t,n,i,a,s,r,f="",$=null,p=s,y=!1,h="",R={},C=V()){let m=[],v=new Set;try{m=ne(r);for(let e of Object.values(I(r)))e.hostname&&!e.remoteUpstream&&v.add(e.hostname)}catch{m=[]}let w="answers only while a feature runs its service",x=m.length?`These hosts are routed through Caddy:
66
+ `}c(et,"buildClaudeMd");var Ee=c((t,s)=>s&&Y(t)&&K(t,s)?s:"","withTempHome");function Ae(t,s,i,a,o,r=""){let p=Q(s,i[s],a),w=J(i[s]);return w?`- \`${s}\`: no tests (registry: ${w})`:p?`- \`${s}\`: \`${Z(t,s,o?`${o} && ${p}`:p,Ee(i[s],r))}\``:`- \`${s}\`: no test command registered (add \`test:\` to its registry entry)`}c(Ae,"testCommandLine");var Ie=c(t=>`A one-off probe is a \`node --test\` file, run as \`${t} --no-wait node --test <file>\` (in the service's container, after its \`docker exec -w <dir> <container>\`, when the host has no node_modules); never host \`node <script>\`, a compound shell line or \`docker exec \u2026 node <script>\`. That form asks each time and is never pre-approved, since it runs any file (SW-510).`,"PROBE_FORM");function Be(t){let s=Object.entries(t);return s.length?`
67
+ Shared caches, mounted by every workspace on this machine: never delete from them (\`werkmeister cache prune\` evicts for every workspace, so it is the person's call). ${s.map(([a,o])=>{let r=ce(a,o),p=r.kind==="volume"?`volume \`${r.name}\``:`host dir \`${r.name}\``,w=Object.entries(o.env??{}).map(([m,y])=>`\`${m}=${y}\``);return`\`${a}\` at \`${o.path}\` (${[...w,p].join(", ")})`}).join("; ")}.
68
+ `:""}c(Be,"sharedCachesLine");function tt(t,s,i,a,o,r,p="",w=null,m=o,y=!1,h="",R={},C=V()){let u=[],v=new Set;try{u=ie(r);for(let e of Object.values(I(r)))e.hostname&&!e.remoteUpstream&&v.add(e.hostname)}catch{u=[]}let k="answers only while a feature runs its service",x=u.length?`These hosts are routed through Caddy:
69
69
 
70
- `+m.map(e=>`- \`https://${e}\`${v.has(e)?` \u2014 ${w}`:""}`).join(`
71
- `):"No services declare a `feature_router:` block, so Caddy terminates no public hosts for this workspace.",b=[],_=[],T=new Set;try{let e=I(r),o=c(d=>d.map(l=>e[l]?.hostname).filter(l=>!!l).sort(),"hostsOf");b=o(s),_=o(p),T=new Set(p.filter(d=>e[d]?.hostname))}catch{b=[]}let k=s.length>0,g=T.size>0,L=c(e=>R[e]?.lint,"lintOf"),de=c(e=>e.test?`\`${J(h,e.test,L(e.repo))}\``:"\u2014","testCell"),M=c(e=>B(r[e])?r[e].repo:void 0,"repoOf"),me=new Set(p.map(M).filter(Boolean)),pe=Object.keys(r).filter(e=>me.has(M(e))),j=Z([...p,...pe],r,$,T),ue=j.some(e=>!p.includes(e.service)),fe=[...new Set(j.map(e=>e.repo))].map(e=>{let{format:o,release_check:d,ship:l}=R[e]??{},u=[o&&`- Format: \`${o}\` \u2014 ${o.includes("{files}")?"`{files}` replaced with the files you touched":"run as written, from the repo root"}`,l==="tag"&&d&&`- Release check: \`${d}\` \u2014 the PR gate's release row; commit the release entry it looks for`].filter(Boolean);return u.length?`
70
+ `+u.map(e=>`- \`https://${e}\`${v.has(e)?` \u2014 ${k}`:""}`).join(`
71
+ `):"No services declare a `feature_router:` block, so Caddy terminates no public hosts for this workspace.",b=[],_=[],T=new Set;try{let e=I(r),n=c(d=>d.map(l=>e[l]?.hostname).filter(l=>!!l).sort(),"hostsOf");b=n(o),_=n(m),T=new Set(m.filter(d=>e[d]?.hostname))}catch{b=[]}let $=o.length>0,g=T.size>0,L=c(e=>R[e]?.lint,"lintOf"),pe=c(e=>e.test?`\`${ee(h,e.test,L(e.repo))}\``:"\u2014","testCell"),M=c(e=>B(r[e])?r[e].repo:void 0,"repoOf"),me=new Set(m.map(M).filter(Boolean)),fe=Object.keys(r).filter(e=>me.has(M(e))),P=te([...m,...fe],r,w,T),we=P.some(e=>!m.includes(e.service)),ke=[...new Set(P.map(e=>e.repo))].map(e=>{let{format:n,release_check:d,ship:l}=R[e]??{},f=[n&&`- Format: \`${n}\` \u2014 ${n.includes("{files}")?"`{files}` replaced with the files you touched":"run as written, from the repo root"}`,l==="tag"&&d&&`- Release check: \`${d}\` \u2014 the PR gate's release row; commit the release entry it looks for`].filter(Boolean);return f.length?`
72
72
 
73
73
  Repo commands for ${e}:
74
- ${u.join(`
75
- `)}`:""}).join(""),we=j.some(e=>e.test&&L(e.repo)),ke=`| Service | Repo | Path in repo | Test command | Validation |
74
+ ${f.join(`
75
+ `)}`:""}).join(""),$e=P.some(e=>e.test&&L(e.repo)),ge=`| Service | Repo | Path in repo | Test command | Validation |
76
76
  |---------|------|--------------|--------------|------------|
77
- `+j.map(e=>`| \`${e.service}\` | ${e.repo} | \`${e.path}\` | ${de(e)} | ${e.validate} |`).join(`
78
- `),$e=c(e=>{let o=r[e]??{};return B(o)&&o.k8s_forward_port!==null&&o.k8s_forward_port!==void 0?Number(o.k8s_forward_port):null},"k8sPort"),S=[],P=null;for(let e of[...s].sort()){let o=r[e]??{};if(!B(o))continue;let d=o.port_offset??0,l=ie(n,d);P===null&&T.has(e)&&(P=l);let u=o.internal_port??3e3,N=`${e.toUpperCase().replace(/-/g,"_")}_URL`;S.push(`| \`${e}\` | local | \`${o.path??"."}\` | \`${t}-${e}\` | ${l} | \`${N}=http://${e}:${u}\` |`)}for(let e of Object.keys(r).sort()){if(s.includes(e)||!k&&!p.includes(e))continue;let o=r[e]??{};if(!B(o))continue;let d=`${e.toUpperCase().replace(/-/g,"_")}_URL`,l=G(e,o);if(l){S.push(`| \`${e}\` | baseline | \`${o.path??"."}\` | \u2014 | \u2014 | \`${d}=http://${l.host}:${l.port}\` |`);continue}let u=$e(e);u&&S.push(`| \`${e}\` | k8s | \`${o.path??"."}\` | \u2014 | \u2014 | \`${d}=http://k8s-forwards:${u}\` |`)}let U;S.length>0?U=`| Service | Location | Path in repo | Container | Host Port | In-cluster URL (env var) |
77
+ `+P.map(e=>`| \`${e.service}\` | ${e.repo} | \`${e.path}\` | ${pe(e)} | ${e.validate} |`).join(`
78
+ `),ye=c(e=>{let n=r[e]??{};return B(n)&&n.k8s_forward_port!==null&&n.k8s_forward_port!==void 0?Number(n.k8s_forward_port):null},"k8sPort"),S=[],j=null;for(let e of[...o].sort()){let n=r[e]??{};if(!B(n))continue;let d=n.port_offset??0,l=le(s,d);j===null&&T.has(e)&&(j=l);let f=n.internal_port??3e3,N=`${e.toUpperCase().replace(/-/g,"_")}_URL`;S.push(`| \`${e}\` | local | \`${n.path??"."}\` | \`${t}-${e}\` | ${l} | \`${N}=http://${e}:${f}\` |`)}for(let e of Object.keys(r).sort()){if(o.includes(e)||!$&&!m.includes(e))continue;let n=r[e]??{};if(!B(n))continue;let d=`${e.toUpperCase().replace(/-/g,"_")}_URL`,l=G(e,n);if(l){S.push(`| \`${e}\` | baseline | \`${n.path??"."}\` | \u2014 | \u2014 | \`${d}=http://${l.host}:${l.port}\` |`);continue}let f=ye(e);f&&S.push(`| \`${e}\` | k8s | \`${n.path??"."}\` | \u2014 | \u2014 | \`${d}=http://k8s-forwards:${f}\` |`)}let U;S.length>0?U=`| Service | Location | Path in repo | Container | Host Port | In-cluster URL (env var) |
79
79
  |---------|----------|--------------|-----------|-----------|--------------------------|
80
80
  `+S.join(`
81
- `):U="_No services configured._";let D;if(s.length>0){let e=[...s].sort(),o=e.map(u=>L(String(r[u]?.repo??""))),d=e.map(u=>`\`${t}-${u}\``).join(", "),l=e[0];D=`### Container Commands
81
+ `):U="_No services configured._";let D;if(o.length>0){let e=[...o].sort(),n=e.map(f=>L(String(r[f]?.repo??""))),d=e.map(f=>`\`${t}-${f}\``).join(", "),l=e[0];D=`### Container Commands
82
82
 
83
83
  Container naming pattern: \`${t}-<service>\` \u2014 ${d}
84
84
 
@@ -95,24 +95,24 @@ docker compose restart ${l}
95
95
 
96
96
  ### Test commands
97
97
 
98
- The registry's \`test:\` for each service (or its archetype's), run in its container \u2014 the worktree is mounted at \`/app\` with its \`node_modules\`; the host checkout has none. The pre-PR gate runs these (\`werkmeister pr gate\`).${o.some(Boolean)?" A line starting with `<lint> &&` first runs the repo's lint, the PR gate's lint row, so a `docs:check` or format failure shows here, before the tests, and not first at the gate.":""}
98
+ The registry's \`test:\` for each service (or its archetype's), run in its container \u2014 the worktree is mounted at \`/app\` with its \`node_modules\`; the host checkout has none. The pre-PR gate runs these (\`werkmeister pr gate\`).${n.some(Boolean)?" A line starting with `<lint> &&` first runs the repo's lint, the PR gate's lint row, so a `docs:check` or format failure shows here, before the tests, and not first at the gate.":""}
99
99
 
100
- ${e.map((u,N)=>Pe(t,u,r,$??q(),o[N])).join(`
100
+ ${e.map((f,N)=>Ae(t,f,r,w??q(),n[N],h)).join(`
101
101
  `)}
102
- ${Ee(C)}
103
- `}else D="";let O,W=c(e=>v.has(e)?`# ${e} ${w}
104
- `:"","noteFor");if(P!==null){let e=`# Direct to a local service (bypass Caddy \u2014 isolates routing vs app issues):
105
- curl -s -o /dev/null -w "HTTP %{http_code} | Size: %{size_download}\\n" "http://localhost:${P}/"
102
+ ${Be(C)}
103
+ `}else D="";let O,W=c(e=>v.has(e)?`# ${e} ${k}
104
+ `:"","noteFor");if(j!==null){let e=`# Direct to a local service (bypass Caddy \u2014 isolates routing vs app issues):
105
+ curl -s -o /dev/null -w "HTTP %{http_code} | Size: %{size_download}\\n" "http://localhost:${j}/"
106
106
 
107
- `,o=b.length?`# Through Caddy (verifies full proxy routing):
107
+ `,n=b.length?`# Through Caddy (verifies full proxy routing):
108
108
  `+b.map(l=>W(l)+`curl -sk -b "X-Feature=${t}" -o /dev/null -w "HTTP %{http_code} | Size: %{size_download}\\n" "https://${l}/"
109
109
  `).join("")+`
110
110
  `:"",d=`# Container status:
111
- docker ps --format "table {{.Names}}\\t{{.Status}}\\t{{.Ports}}" | grep ${t}`;O=o+e+d}else k?O=`# Container status:
111
+ docker ps --format "table {{.Names}}\\t{{.Status}}\\t{{.Ports}}" | grep ${t}`;O=n+e+d}else $?O=`# Container status:
112
112
  docker ps --format "table {{.Names}}\\t{{.Status}}\\t{{.Ports}}" | grep ${t}`:O=`# Through Caddy (all traffic routes to k8s):
113
113
  `+_.map(e=>W(e)+`curl -sk -o /dev/null -w "HTTP %{http_code} | Size: %{size_download}\\n" "https://${e}/"
114
- `).join("").trimEnd();let E=Le(s),ge=E?`
115
- **Feature URL:** https://${E.host}/${f.replace(/^\/+/,"")}
114
+ `).join("").trimEnd();let E=Pe(o),ve=E?`
115
+ **Feature URL:** https://${E.host}/${p.replace(/^\/+/,"")}
116
116
 
117
117
  Set the routing cookie in the browser (DevTools console):
118
118
 
@@ -121,18 +121,18 @@ document.cookie = "X-Feature=${t}; domain=.${E.domain}; path=/; SameSite=Lax";
121
121
  \`\`\`
122
122
 
123
123
  or visit https://${E.host}/__werkmeister and select \`${t}\` \u2014 the selector is served on every routed host and the cookie applies to each host sharing the base domain.
124
- `:"",z=p.filter(e=>!s.includes(e)).sort(),ye=`## How to validate
124
+ `:"",z=m.filter(e=>!o.includes(e)).sort(),be=`## How to validate
125
125
 
126
- How to exercise a change to each service in this workspace.${ue?" The table also lists the other services in this workspace's repos: the PR gate tests each service a change reaches, the workspace's own or not.":""}${z.length?` A plain \`werkmeister feature up\` skips the on-demand ones, ${z.map(e=>`\`${e}\``).join(", ")}: start one with \`werkmeister feature up --service <name>\`.`:""}${h?` Each test command runs through \`.werkmeister/bin/with-temp-home\`, which gives it a fresh temporary HOME and deletes it on exit: never hand-roll \`HOME=\u2026\`. Start every exercise command with the script itself, never with env assignments or a \`cd\`, so one permission rule matches it: \`${h} <test command>\`. A command that needs an env var takes it after the script (\`${h} env WERKMEISTER_ROOT=\u2026 <cmd>\`); no rule pre-approves that form, so it asks. Put \`--no-wait\` first (\`${h} --no-wait <cmd>\`) to skip its host-load and free-memory wait; the allow rules below cover that form too. That wait lasts up to 90 s; if load or memory is still over its limit then, the script exits 75 without running the command (retry later). It prints only on stderr, so a foreground call shows nothing until it ends and its only child is \`werkmeister internal wait-load\`: that is the wait, not a hang. The allow rule that covers them is \`Bash(${h} <test command>:*)\` for each test command below: run those for a test without a prompt. A test command of more than one command (an \`&&\` chain, a \`{ \u2026; }\` group, \`||\`, \`;\` or a pipe) is shown as \`${h} sh -c '\u2026'\`, so every part runs under the temp HOME, and its rule allows that exact line: run it as shown, with no extra arguments. ${Oe(h)} The script alone is never allowed either, since it runs any command. The temp HOME only keeps a run from writing to the real one by accident; it is not an isolation boundary. A pre-approved test command or built CLI still runs whatever the worktree holds, a test written in this run included, and that code can reach absolute paths, the caller's env, the network, docker and gh (SW-522).`:""}${we?" A test command starting with `<lint> &&` first runs the repo's lint, the same command the PR gate's lint row runs, so a format error fails here, before the tests, and not first at `werkmeister pr open`.":""} ${re}
126
+ How to exercise a change to each service in this workspace.${we?" The table also lists the other services in this workspace's repos: the PR gate tests each service a change reaches, the workspace's own or not.":""}${z.length?` A plain \`werkmeister feature up\` skips the on-demand ones, ${z.map(e=>`\`${e}\``).join(", ")}: start one with \`werkmeister feature up --service <name>\`.`:""}${h?` Each test command runs through \`.werkmeister/bin/with-temp-home\`, which gives it a fresh temporary HOME and deletes it on exit: never hand-roll \`HOME=\u2026\`. Start every exercise command with the script itself, never with env assignments or a \`cd\`, so one permission rule matches it: \`${h} <test command>\`. A command that needs an env var takes it after the script (\`${h} env WERKMEISTER_ROOT=\u2026 <cmd>\`); no rule pre-approves that form, so it asks. Put \`--no-wait\` first (\`${h} --no-wait <cmd>\`) to skip its host-load and free-memory wait; the allow rules below cover that form too. That wait lasts up to 90 s; if load or memory is still over its limit then, the script exits 75 without running the command (retry later). It prints only on stderr, so a foreground call shows nothing until it ends and its only child is \`werkmeister internal wait-load\`: that is the wait, not a hang. The allow rule that covers them is \`Bash(${h} <test command>:*)\` for each test command below: run those for a test without a prompt. A test command of more than one command (an \`&&\` chain, a \`{ \u2026; }\` group, \`||\`, \`;\` or a pipe) is shown as \`${h} sh -c '\u2026'\`, so every part runs under the temp HOME, and its rule allows that exact line: run it as shown, with no extra arguments. ${Ie(h)} The script alone is never allowed either, since it runs any command. The temp HOME only keeps a run from writing to the real one by accident; it is not an isolation boundary. A pre-approved test command or built CLI still runs whatever the worktree holds, a test written in this run included, and that code can reach absolute paths, the caller's env, the network, docker and gh (SW-522).`:""}${$e?" A test command starting with `<lint> &&` first runs the repo's lint, the same command the PR gate's lint row runs, so a format error fails here, before the tests, and not first at `werkmeister pr open`.":""} ${oe}
127
127
 
128
- ${ke}${fe}
128
+ ${ge}${ke}
129
129
 
130
- `,ve=k?`## Slot & Port Range
130
+ `,Re=$?`## Slot & Port Range
131
131
 
132
- - **Slot:** ${n}
132
+ - **Slot:** ${s}
133
133
  - **Port range:** ${i}\u2013${a}
134
134
 
135
- `:"",be=k?`## Container Lifecycle
135
+ `:"",Te=$?`## Container Lifecycle
136
136
 
137
137
  Run from anywhere in the workspace \u2014 \`werkmeister\` reads \`FEATURE\` from \`.env\` at the workspace root.
138
138
 
@@ -146,24 +146,24 @@ werkmeister feature down -v # tear down + remove volumes (node_modules, cach
146
146
  ${y?"\n**Auto-stop is on** (`auto_stop: true` in `.werkmeister/workspace.yml`): when a Claude session here ends and no other session is open in this workspace, a SessionEnd hook runs `werkmeister internal session-end`, which stops this feature's containers (slot and volumes kept \u2014 `werkmeister feature up` resumes). Shared infra is never stopped.\n":""}
147
147
  > **Fallback:** If \`werkmeister\` CLI is unavailable, \`docker compose up -d --build\` / \`docker compose down\` from the workspace root works equivalently. Prefer \`werkmeister\` \u2014 it also manages slot allocation and Caddy proxy regeneration.
148
148
 
149
- `:"",Re=k||S.length>0?`## Services
149
+ `:"",Se=$||S.length>0?`## Services
150
150
 
151
151
  Every container gets each service's URL injected as an env var (the last column). Local services resolve to the Docker DNS alias on the per-feature network; baseline services resolve to their \`baseline_upstream\`; k8s-forwarded services resolve via the shared \`k8s-forwards\` container.
152
152
 
153
153
  ${U}
154
154
 
155
- `:"",Te=[...b,..._].some(e=>v.has(e))?"If every host resets TLS (curl exit 35) while `w9r-caddy` is healthy, check `~/.werkmeister/infra/proxy/features.json` first: `[]` means nothing is routed and it is not an outage.\n\n":"",Se=g||k?`## Quick Health Checks
155
+ `:"",Ce=[...b,..._].some(e=>v.has(e))?"If every host resets TLS (curl exit 35) while `w9r-caddy` is healthy, check `~/.werkmeister/infra/proxy/features.json` first: `[]` means nothing is routed and it is not an outage.\n\n":"",xe=g||$?`## Quick Health Checks
156
156
 
157
- ${Te}\`\`\`bash
157
+ ${Ce}\`\`\`bash
158
158
  ${O}
159
159
  \`\`\`
160
160
 
161
- `:"",Ce=g?`## Proxy Routing
161
+ `:"",Le=g?`## Proxy Routing
162
162
 
163
163
  ${x}
164
164
 
165
165
  Set \`X-Feature=${t}\` (cookie or header) to route to this workspace's local containers; otherwise traffic falls through to the k8s port-forwards.
166
- ${ge}
166
+ ${ve}
167
167
  `:"";return`<!--
168
168
  AUTO-GENERATED FILE \u2014 DO NOT EDIT BY HAND.
169
169
  Source: ~/.werkmeister/services.yaml + ports.yaml
@@ -176,7 +176,7 @@ ${ge}
176
176
 
177
177
  # Werkmeister Context: ${t}
178
178
 
179
- ${ye}${ve}${be}${Re}${D}${Se}${Ce}${g||k?`## Troubleshooting
179
+ ${be}${Re}${Te}${Se}${D}${xe}${Le}${g||$?`## Troubleshooting
180
180
 
181
- ${g?"### Feature missing from `/__werkmeister` selector\n\nThe dropdown is populated from `~/.werkmeister/infra/proxy/features.json` (a static file served by Caddy), which is regenerated alongside the Caddyfile. It can drift from the live container labels (`com.werkmeister.feature` \u2014 the source of truth) if a slot is allocated without a proxy regen.\n\nDiagnose \u2014 compare what's labeled vs. what the UI shows:\n```bash\ndocker ps -a --filter label=com.werkmeister.feature --format '{{ .Label \"com.werkmeister.feature\" }}' | sort -u\njq '[.[].name]' \"$HOME/.werkmeister/infra/proxy/features.json\"\n```\n\nResync:\n```bash\nwerkmeister infra proxy-reload # regenerates Caddyfile + features.json, reloads Caddy\n```\n\n### Caddy returns `content-length: 0` but direct service hit works\n\nCaddy routing issue, not an app issue. Try `werkmeister infra proxy-reload` first; if Caddy is still misrouting, check `docker logs w9r-caddy --tail 50`.\n\n":""}${k?"### Containers expected per the table above are missing from `docker ps`\n\n`werkmeister feature up` may have partially failed. Re-run from the workspace root:\n```bash\nwerkmeister feature up # idempotent \u2014 starts missing containers\ndocker compose logs -f # watch startup if something crashes\n```\n":""}`:""}`}c(Je,"buildSandboxContextMd");export{ce as a,Ke as b,Qe as c,Je as d};
182
- //# sourceMappingURL=chunk-TAU7BRTN.js.map
181
+ ${g?"### Feature missing from `/__werkmeister` selector\n\nThe dropdown is populated from `~/.werkmeister/infra/proxy/features.json` (a static file served by Caddy), which is regenerated alongside the Caddyfile. It can drift from the live container labels (`com.werkmeister.feature` \u2014 the source of truth) if a slot is allocated without a proxy regen.\n\nDiagnose \u2014 compare what's labeled vs. what the UI shows:\n```bash\ndocker ps -a --filter label=com.werkmeister.feature --format '{{ .Label \"com.werkmeister.feature\" }}' | sort -u\njq '[.[].name]' \"$HOME/.werkmeister/infra/proxy/features.json\"\n```\n\nResync:\n```bash\nwerkmeister infra proxy-reload # regenerates Caddyfile + features.json, reloads Caddy\n```\n\n### Caddy returns `content-length: 0` but direct service hit works\n\nCaddy routing issue, not an app issue. Try `werkmeister infra proxy-reload` first; if Caddy is still misrouting, check `docker logs w9r-caddy --tail 50`.\n\n":""}${$?"### Containers expected per the table above are missing from `docker ps`\n\n`werkmeister feature up` may have partially failed. Re-run from the workspace root:\n```bash\nwerkmeister feature up # idempotent \u2014 starts missing containers\ndocker compose logs -f # watch startup if something crashes\n```\n":""}`:""}`}c(tt,"buildSandboxContextMd");export{he as a,Ze as b,et as c,tt as d};
182
+ //# sourceMappingURL=chunk-2CTXJWFS.js.map
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{A,B as C,C as $,D as Y,E as Z,F as f,G as y,H as x,I as E,J as S,K as H,L as ee,M as te,N as re,O as N,P as oe,d as G,g as m,j as P,m as j,o as I,q as M,s as L,t as q,u as F,v as J,w as z,x as K,y as T}from"./chunk-7XABNR7Y.js";import{Ed as e,Gc as B}from"./chunk-MMZ3SFZC.js";import{a as ve}from"./chunk-XNPHA7HX.js";import{a as c,b as v,e as we,f as h}from"./chunk-KPIXRVP2.js";h();var U=we(ve(),1);h();function O(a){return(t,r,o)=>{let i=t.headers.host;if(!i){r.status(403).json({jsonrpc:"2.0",error:{code:-32e3,message:"Missing Host header"},id:null});return}let n;try{n=new URL(`http://${i}`).hostname}catch{r.status(403).json({jsonrpc:"2.0",error:{code:-32e3,message:`Invalid Host header: ${i}`},id:null});return}if(!a.includes(n)){r.status(403).json({jsonrpc:"2.0",error:{code:-32e3,message:`Invalid Host: ${n}`},id:null});return}o()}}c(O,"hostHeaderValidation");function se(){return O(["localhost","127.0.0.1","[::1]"])}c(se,"localhostHostValidation");function Ne(a={}){let{host:t="127.0.0.1",allowedHosts:r}=a,o=(0,U.default)();return o.use(U.default.json()),r?o.use(O(r)):["127.0.0.1","localhost","::1"].includes(t)?o.use(se()):(t==="0.0.0.0"||t==="::")&&console.warn(`Warning: Server is binding to ${t} without DNS rebinding protection. Consider using the allowedHosts option to restrict allowed hosts, or use authentication to protect your server.`),o}c(Ne,"createMcpExpressApp");h();h();var ae=Symbol.for("mcp.completable");function Q(a){return!!a&&typeof a=="object"&&ae in a}c(Q,"isCompletable");function ne(a){return a[ae]?.complete}c(ne,"getCompleter");var ie;(function(a){a.Completable="McpCompletable"})(ie||(ie={}));h();h();var ye=/^[A-Za-z0-9._-]{1,128}$/;function Se(a){let t=[];if(a.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(a.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${a.length})`]};if(a.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),a.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(a.startsWith("-")||a.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(a.startsWith(".")||a.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!ye.test(a)){let r=a.split("").filter(o=>!/[A-Za-z0-9._-]/.test(o)).filter((o,i,n)=>n.indexOf(o)===i);return t.push(`Tool name contains invalid characters: ${r.map(o=>`"${o}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}c(Se,"validateToolName");function _e(a,t){if(t.length>0){console.warn(`Tool name validation warning for "${a}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}c(_e,"issueToolNameWarning");function V(a){let t=Se(a);return _e(a,t.warnings),t.isValid}c(V,"validateAndWarnToolName");h();var k=class{static{c(this,"ExperimentalMcpServerTasks")}constructor(t){this._mcpServer=t}registerToolTask(t,r,o){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,o)}};h();var le=class{static{c(this,"McpServer")}constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new oe(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new k(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(w(T)),this.server.assertCanSetRequestHandler(w(C)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(T,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let o={name:t,title:r.title,description:r.description,inputSchema:(()=>{let i=S(r.inputSchema);return i?N(i,{strictUnions:!0,pipeStrategy:"input"}):Re})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=S(r.outputSchema);i&&(o.outputSchema=N(i,{strictUnions:!0,pipeStrategy:"output"}))}return o})})),this.server.setRequestHandler(C,async(t,r)=>{try{let o=this._registeredTools[t.params.name];if(!o)throw new f(m.InvalidParams,`Tool ${t.params.name} not found`);if(!o.enabled)throw new f(m.InvalidParams,`Tool ${t.params.name} disabled`);let i=!!t.params.task,n=o.execution?.taskSupport,s="createTask"in o.handler;if((n==="required"||n==="optional")&&!s)throw new f(m.InternalError,`Tool ${t.params.name} has taskSupport '${n}' but was not registered with registerToolTask`);if(n==="required"&&!i)throw new f(m.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(n==="optional"&&!i&&s)return await this.handleAutomaticTaskPolling(o,t,r);let l=await this.validateToolInput(o,t.params.arguments,t.params.name),u=await this.executeToolHandler(o,l,r);return i||await this.validateToolOutput(o,u,t.params.name),u}catch(o){if(o instanceof f&&o.code===m.UrlElicitationRequired)throw o;return this.createToolError(o instanceof Error?o.message:String(o))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,o){if(!t.inputSchema)return;let n=S(t.inputSchema)??t.inputSchema,s=await x(n,r);if(!s.success){let l="error"in s?s.error:"Unknown error",u=H(l);throw new f(m.InvalidParams,`Input validation error: Invalid arguments for tool ${o}: ${u}`)}return s.data}async validateToolOutput(t,r,o){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new f(m.InvalidParams,`Output validation error: Tool ${o} has an output schema but no structured content was provided`);let i=S(t.outputSchema),n=await x(i,r.structuredContent);if(!n.success){let s="error"in n?n.error:"Unknown error",l=H(s);throw new f(m.InvalidParams,`Output validation error: Invalid structured content for tool ${o}: ${l}`)}}async executeToolHandler(t,r,o){let i=t.handler;if("createTask"in i){if(!o.taskStore)throw new Error("No task store provided.");let s={...o,taskStore:o.taskStore};if(t.inputSchema){let l=i;return await Promise.resolve(l.createTask(r,s))}else{let l=i;return await Promise.resolve(l.createTask(s))}}if(t.inputSchema){let s=i;return await Promise.resolve(s(r,o))}else{let s=i;return await Promise.resolve(s(o))}}async handleAutomaticTaskPolling(t,r,o){if(!o.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(t,r.params.arguments,r.params.name),n=t.handler,s={...o,taskStore:o.taskStore},l=i?await Promise.resolve(n.createTask(i,s)):await Promise.resolve(n.createTask(s)),u=l.task.taskId,d=l.task,g=d.pollInterval??5e3;for(;d.status!=="completed"&&d.status!=="failed"&&d.status!=="cancelled";){await new Promise(be=>setTimeout(be,g));let p=await o.taskStore.getTask(u);if(!p)throw new f(m.InternalError,`Task ${u} not found during polling`);d=p}return await o.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(w($)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler($,async t=>{switch(t.params.ref.type){case"ref/prompt":return Y(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return Z(t),this.handleResourceCompletion(t,t.params.ref);default:throw new f(m.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let o=this._registeredPrompts[r.name];if(!o)throw new f(m.InvalidParams,`Prompt ${r.name} not found`);if(!o.enabled)throw new f(m.InvalidParams,`Prompt ${r.name} disabled`);if(!o.argsSchema)return _;let n=E(o.argsSchema)?.[t.params.argument.name];if(!Q(n))return _;let s=ne(n);if(!s)return _;let l=await s(t.params.argument.value,t.params.context);return de(l)}async handleResourceCompletion(t,r){let o=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!o){if(this._registeredResources[r.uri])return _;throw new f(m.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let i=o.resourceTemplate.completeCallback(t.params.argument.name);if(!i)return _;let n=await i(t.params.argument.value,t.params.context);return de(n)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(w(j)),this.server.assertCanSetRequestHandler(w(I)),this.server.assertCanSetRequestHandler(w(M)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(j,async(t,r)=>{let o=Object.entries(this._registeredResources).filter(([n,s])=>s.enabled).map(([n,s])=>({uri:n,name:s.name,...s.metadata})),i=[];for(let n of Object.values(this._registeredResourceTemplates)){if(!n.resourceTemplate.listCallback)continue;let s=await n.resourceTemplate.listCallback(r);for(let l of s.resources)i.push({...n.metadata,...l})}return{resources:[...o,...i]}}),this.server.setRequestHandler(I,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,o])=>({name:r,uriTemplate:o.resourceTemplate.uriTemplate.toString(),...o.metadata}))})),this.server.setRequestHandler(M,async(t,r)=>{let o=new URL(t.params.uri),i=this._registeredResources[o.toString()];if(i){if(!i.enabled)throw new f(m.InvalidParams,`Resource ${o} disabled`);return i.readCallback(o,r)}for(let n of Object.values(this._registeredResourceTemplates)){let s=n.resourceTemplate.uriTemplate.match(o.toString());if(s)return n.readCallback(o,s,r)}throw new f(m.InvalidParams,`Resource ${o} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(w(L)),this.server.assertCanSetRequestHandler(w(q)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(L,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?Te(r.argsSchema):void 0}))})),this.server.setRequestHandler(q,async(t,r)=>{let o=this._registeredPrompts[t.params.name];if(!o)throw new f(m.InvalidParams,`Prompt ${t.params.name} not found`);if(!o.enabled)throw new f(m.InvalidParams,`Prompt ${t.params.name} disabled`);if(o.argsSchema){let i=S(o.argsSchema),n=await x(i,t.params.arguments);if(!n.success){let u="error"in n?n.error:"Unknown error",d=H(u);throw new f(m.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${d}`)}let s=n.data,l=o.callback;return await Promise.resolve(l(s,r))}else{let i=o.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...o){let i;typeof o[0]=="object"&&(i=o.shift());let n=o[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,o,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let n=this._createRegisteredResource(t,o.title,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let n=this._createRegisteredResourceTemplate(t,o.title,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}}_createRegisteredResource(t,r,o,i,n){let s={name:t,title:r,metadata:i,readCallback:n,enabled:!0,disable:c(()=>s.update({enabled:!1}),"disable"),enable:c(()=>s.update({enabled:!0}),"enable"),remove:c(()=>s.update({uri:null}),"remove"),update:c(l=>{typeof l.uri<"u"&&l.uri!==o&&(delete this._registeredResources[o],l.uri&&(this._registeredResources[l.uri]=s)),typeof l.name<"u"&&(s.name=l.name),typeof l.title<"u"&&(s.title=l.title),typeof l.metadata<"u"&&(s.metadata=l.metadata),typeof l.callback<"u"&&(s.readCallback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendResourceListChanged()},"update")};return this._registeredResources[o]=s,s}_createRegisteredResourceTemplate(t,r,o,i,n){let s={resourceTemplate:o,title:r,metadata:i,readCallback:n,enabled:!0,disable:c(()=>s.update({enabled:!1}),"disable"),enable:c(()=>s.update({enabled:!0}),"enable"),remove:c(()=>s.update({name:null}),"remove"),update:c(d=>{typeof d.name<"u"&&d.name!==t&&(delete this._registeredResourceTemplates[t],d.name&&(this._registeredResourceTemplates[d.name]=s)),typeof d.title<"u"&&(s.title=d.title),typeof d.template<"u"&&(s.resourceTemplate=d.template),typeof d.metadata<"u"&&(s.metadata=d.metadata),typeof d.callback<"u"&&(s.readCallback=d.callback),typeof d.enabled<"u"&&(s.enabled=d.enabled),this.sendResourceListChanged()},"update")};this._registeredResourceTemplates[t]=s;let l=o.uriTemplate.variableNames;return Array.isArray(l)&&l.some(d=>!!o.completeCallback(d))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,o,i,n){let s={title:r,description:o,argsSchema:i===void 0?void 0:y(i),callback:n,enabled:!0,disable:c(()=>s.update({enabled:!1}),"disable"),enable:c(()=>s.update({enabled:!0}),"enable"),remove:c(()=>s.update({name:null}),"remove"),update:c(l=>{typeof l.name<"u"&&l.name!==t&&(delete this._registeredPrompts[t],l.name&&(this._registeredPrompts[l.name]=s)),typeof l.title<"u"&&(s.title=l.title),typeof l.description<"u"&&(s.description=l.description),typeof l.argsSchema<"u"&&(s.argsSchema=y(l.argsSchema)),typeof l.callback<"u"&&(s.callback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendPromptListChanged()},"update")};return this._registeredPrompts[t]=s,i&&Object.values(i).some(u=>{let d=u instanceof B?u._def?.innerType:u;return Q(d)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,o,i,n,s,l,u,d){V(t);let g={title:r,description:o,inputSchema:ce(i),outputSchema:ce(n),annotations:s,execution:l,_meta:u,handler:d,enabled:!0,disable:c(()=>g.update({enabled:!1}),"disable"),enable:c(()=>g.update({enabled:!0}),"enable"),remove:c(()=>g.update({name:null}),"remove"),update:c(p=>{typeof p.name<"u"&&p.name!==t&&(typeof p.name=="string"&&V(p.name),delete this._registeredTools[t],p.name&&(this._registeredTools[p.name]=g)),typeof p.title<"u"&&(g.title=p.title),typeof p.description<"u"&&(g.description=p.description),typeof p.paramsSchema<"u"&&(g.inputSchema=y(p.paramsSchema)),typeof p.outputSchema<"u"&&(g.outputSchema=y(p.outputSchema)),typeof p.callback<"u"&&(g.handler=p.callback),typeof p.annotations<"u"&&(g.annotations=p.annotations),typeof p._meta<"u"&&(g._meta=p._meta),typeof p.enabled<"u"&&(g.enabled=p.enabled),this.sendToolListChanged()},"update")};return this._registeredTools[t]=g,this.setToolRequestHandlers(),this.sendToolListChanged(),g}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let o,i,n,s;if(typeof r[0]=="string"&&(o=r.shift()),r.length>1){let u=r[0];if(D(u))i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!D(r[0])&&(s=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(d=>typeof d=="object"&&d!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let l=r[0];return this._createRegisteredTool(t,void 0,o,i,n,s,{taskSupport:"forbidden"},void 0,l)}registerTool(t,r,o){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:i,description:n,inputSchema:s,outputSchema:l,annotations:u,_meta:d}=r;return this._createRegisteredTool(t,i,n,s,l,u,{taskSupport:"forbidden"},d,o)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let o;typeof r[0]=="string"&&(o=r.shift());let i;r.length>1&&(i=r.shift());let n=r[0],s=this._createRegisteredPrompt(t,void 0,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,o){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:i,description:n,argsSchema:s}=r,l=this._createRegisteredPrompt(t,i,n,s,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),l}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var Re={type:"object",properties:{}};function ue(a){return a!==null&&typeof a=="object"&&"parse"in a&&typeof a.parse=="function"&&"safeParse"in a&&typeof a.safeParse=="function"}c(ue,"isZodTypeLike");function pe(a){return"_def"in a||"_zod"in a||ue(a)}c(pe,"isZodSchemaInstance");function D(a){return typeof a!="object"||a===null||pe(a)?!1:Object.keys(a).length===0?!0:Object.values(a).some(ue)}c(D,"isZodRawShapeCompat");function ce(a){if(a){if(D(a))return y(a);if(!pe(a))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return a}}c(ce,"getZodSchemaObject");function Te(a){let t=E(a);return t?Object.entries(t).map(([r,o])=>{let i=ee(o),n=te(o);return{name:r,description:i,required:!n}}):[]}c(Te,"promptArgumentsFromSchema");function w(a){let r=E(a)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=re(r);if(typeof o=="string")return o;throw new Error("Schema method literal must be a string")}c(w,"getMethodValue");function de(a){return{completion:{values:a.slice(0,100),total:a.length,hasMore:a.length>100}}}c(de,"createCompletionResult");var _={completion:{values:[],hasMore:!1}};h();var he=class a{static{c(this,"InMemoryTransport")}constructor(){this._messageQueue=[]}static createLinkedPair(){let t=new a,r=new a;return t._otherTransport=r,r._otherTransport=t,[t,r]}async start(){for(;this._messageQueue.length>0;){let t=this._messageQueue.shift();this.onmessage?.(t.message,t.extra)}}async close(){let t=this._otherTransport;this._otherTransport=void 0,await t?.close(),this.onclose?.()}async send(t,r){if(!this._otherTransport)throw new Error("Not connected");this._otherTransport.onmessage?this._otherTransport.onmessage(t,{authInfo:r?.authInfo}):this._otherTransport._messageQueue.push({message:t,extra:{authInfo:r?.authInfo}})}};h();var kt=(a=>typeof v<"u"?v:typeof Proxy<"u"?new Proxy(a,{get:c((t,r)=>(typeof v<"u"?v:t)[r],"get")}):a)(function(a){if(typeof v<"u")return v.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var Ce=e.union([e.literal("light"),e.literal("dark")]).describe("Color theme preference for the host environment."),R=e.union([e.literal("inline"),e.literal("fullscreen"),e.literal("pip")]).describe("Display mode for UI presentation."),xe=e.union([e.literal("--color-background-primary"),e.literal("--color-background-secondary"),e.literal("--color-background-tertiary"),e.literal("--color-background-inverse"),e.literal("--color-background-ghost"),e.literal("--color-background-info"),e.literal("--color-background-danger"),e.literal("--color-background-success"),e.literal("--color-background-warning"),e.literal("--color-background-disabled"),e.literal("--color-text-primary"),e.literal("--color-text-secondary"),e.literal("--color-text-tertiary"),e.literal("--color-text-inverse"),e.literal("--color-text-ghost"),e.literal("--color-text-info"),e.literal("--color-text-danger"),e.literal("--color-text-success"),e.literal("--color-text-warning"),e.literal("--color-text-disabled"),e.literal("--color-border-primary"),e.literal("--color-border-secondary"),e.literal("--color-border-tertiary"),e.literal("--color-border-inverse"),e.literal("--color-border-ghost"),e.literal("--color-border-info"),e.literal("--color-border-danger"),e.literal("--color-border-success"),e.literal("--color-border-warning"),e.literal("--color-border-disabled"),e.literal("--color-ring-primary"),e.literal("--color-ring-secondary"),e.literal("--color-ring-inverse"),e.literal("--color-ring-info"),e.literal("--color-ring-danger"),e.literal("--color-ring-success"),e.literal("--color-ring-warning"),e.literal("--font-sans"),e.literal("--font-mono"),e.literal("--font-weight-normal"),e.literal("--font-weight-medium"),e.literal("--font-weight-semibold"),e.literal("--font-weight-bold"),e.literal("--font-text-xs-size"),e.literal("--font-text-sm-size"),e.literal("--font-text-md-size"),e.literal("--font-text-lg-size"),e.literal("--font-heading-xs-size"),e.literal("--font-heading-sm-size"),e.literal("--font-heading-md-size"),e.literal("--font-heading-lg-size"),e.literal("--font-heading-xl-size"),e.literal("--font-heading-2xl-size"),e.literal("--font-heading-3xl-size"),e.literal("--font-text-xs-line-height"),e.literal("--font-text-sm-line-height"),e.literal("--font-text-md-line-height"),e.literal("--font-text-lg-line-height"),e.literal("--font-heading-xs-line-height"),e.literal("--font-heading-sm-line-height"),e.literal("--font-heading-md-line-height"),e.literal("--font-heading-lg-line-height"),e.literal("--font-heading-xl-line-height"),e.literal("--font-heading-2xl-line-height"),e.literal("--font-heading-3xl-line-height"),e.literal("--border-radius-xs"),e.literal("--border-radius-sm"),e.literal("--border-radius-md"),e.literal("--border-radius-lg"),e.literal("--border-radius-xl"),e.literal("--border-radius-full"),e.literal("--border-width-regular"),e.literal("--shadow-hairline"),e.literal("--shadow-sm"),e.literal("--shadow-md"),e.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Ee=e.record(xe.describe(`Style variables for theming MCP apps.
3
+ import{A,B as C,C as $,D as Y,E as Z,F as f,G as y,H as x,I as E,J as S,K as H,L as ee,M as te,N as re,O as N,P as oe,d as G,g as m,j as P,m as j,o as I,q as M,s as L,t as q,u as F,v as J,w as z,x as K,y as T}from"./chunk-TPEKG7PQ.js";import{Ed as e,Gc as B}from"./chunk-UFGV42IR.js";import{a as ve}from"./chunk-SAN555ST.js";import{a as c,b as v,e as we,f as h}from"./chunk-UDLGGZXC.js";h();var U=we(ve(),1);h();function O(a){return(t,r,o)=>{let i=t.headers.host;if(!i){r.status(403).json({jsonrpc:"2.0",error:{code:-32e3,message:"Missing Host header"},id:null});return}let n;try{n=new URL(`http://${i}`).hostname}catch{r.status(403).json({jsonrpc:"2.0",error:{code:-32e3,message:`Invalid Host header: ${i}`},id:null});return}if(!a.includes(n)){r.status(403).json({jsonrpc:"2.0",error:{code:-32e3,message:`Invalid Host: ${n}`},id:null});return}o()}}c(O,"hostHeaderValidation");function se(){return O(["localhost","127.0.0.1","[::1]"])}c(se,"localhostHostValidation");function Ne(a={}){let{host:t="127.0.0.1",allowedHosts:r}=a,o=(0,U.default)();return o.use(U.default.json()),r?o.use(O(r)):["127.0.0.1","localhost","::1"].includes(t)?o.use(se()):(t==="0.0.0.0"||t==="::")&&console.warn(`Warning: Server is binding to ${t} without DNS rebinding protection. Consider using the allowedHosts option to restrict allowed hosts, or use authentication to protect your server.`),o}c(Ne,"createMcpExpressApp");h();h();var ae=Symbol.for("mcp.completable");function Q(a){return!!a&&typeof a=="object"&&ae in a}c(Q,"isCompletable");function ne(a){return a[ae]?.complete}c(ne,"getCompleter");var ie;(function(a){a.Completable="McpCompletable"})(ie||(ie={}));h();h();var ye=/^[A-Za-z0-9._-]{1,128}$/;function Se(a){let t=[];if(a.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(a.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${a.length})`]};if(a.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),a.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(a.startsWith("-")||a.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(a.startsWith(".")||a.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!ye.test(a)){let r=a.split("").filter(o=>!/[A-Za-z0-9._-]/.test(o)).filter((o,i,n)=>n.indexOf(o)===i);return t.push(`Tool name contains invalid characters: ${r.map(o=>`"${o}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}c(Se,"validateToolName");function _e(a,t){if(t.length>0){console.warn(`Tool name validation warning for "${a}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}c(_e,"issueToolNameWarning");function V(a){let t=Se(a);return _e(a,t.warnings),t.isValid}c(V,"validateAndWarnToolName");h();var k=class{static{c(this,"ExperimentalMcpServerTasks")}constructor(t){this._mcpServer=t}registerToolTask(t,r,o){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,o)}};h();var le=class{static{c(this,"McpServer")}constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new oe(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new k(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(w(T)),this.server.assertCanSetRequestHandler(w(C)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(T,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let o={name:t,title:r.title,description:r.description,inputSchema:(()=>{let i=S(r.inputSchema);return i?N(i,{strictUnions:!0,pipeStrategy:"input"}):Re})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=S(r.outputSchema);i&&(o.outputSchema=N(i,{strictUnions:!0,pipeStrategy:"output"}))}return o})})),this.server.setRequestHandler(C,async(t,r)=>{try{let o=this._registeredTools[t.params.name];if(!o)throw new f(m.InvalidParams,`Tool ${t.params.name} not found`);if(!o.enabled)throw new f(m.InvalidParams,`Tool ${t.params.name} disabled`);let i=!!t.params.task,n=o.execution?.taskSupport,s="createTask"in o.handler;if((n==="required"||n==="optional")&&!s)throw new f(m.InternalError,`Tool ${t.params.name} has taskSupport '${n}' but was not registered with registerToolTask`);if(n==="required"&&!i)throw new f(m.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(n==="optional"&&!i&&s)return await this.handleAutomaticTaskPolling(o,t,r);let l=await this.validateToolInput(o,t.params.arguments,t.params.name),u=await this.executeToolHandler(o,l,r);return i||await this.validateToolOutput(o,u,t.params.name),u}catch(o){if(o instanceof f&&o.code===m.UrlElicitationRequired)throw o;return this.createToolError(o instanceof Error?o.message:String(o))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,o){if(!t.inputSchema)return;let n=S(t.inputSchema)??t.inputSchema,s=await x(n,r);if(!s.success){let l="error"in s?s.error:"Unknown error",u=H(l);throw new f(m.InvalidParams,`Input validation error: Invalid arguments for tool ${o}: ${u}`)}return s.data}async validateToolOutput(t,r,o){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new f(m.InvalidParams,`Output validation error: Tool ${o} has an output schema but no structured content was provided`);let i=S(t.outputSchema),n=await x(i,r.structuredContent);if(!n.success){let s="error"in n?n.error:"Unknown error",l=H(s);throw new f(m.InvalidParams,`Output validation error: Invalid structured content for tool ${o}: ${l}`)}}async executeToolHandler(t,r,o){let i=t.handler;if("createTask"in i){if(!o.taskStore)throw new Error("No task store provided.");let s={...o,taskStore:o.taskStore};if(t.inputSchema){let l=i;return await Promise.resolve(l.createTask(r,s))}else{let l=i;return await Promise.resolve(l.createTask(s))}}if(t.inputSchema){let s=i;return await Promise.resolve(s(r,o))}else{let s=i;return await Promise.resolve(s(o))}}async handleAutomaticTaskPolling(t,r,o){if(!o.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(t,r.params.arguments,r.params.name),n=t.handler,s={...o,taskStore:o.taskStore},l=i?await Promise.resolve(n.createTask(i,s)):await Promise.resolve(n.createTask(s)),u=l.task.taskId,d=l.task,g=d.pollInterval??5e3;for(;d.status!=="completed"&&d.status!=="failed"&&d.status!=="cancelled";){await new Promise(be=>setTimeout(be,g));let p=await o.taskStore.getTask(u);if(!p)throw new f(m.InternalError,`Task ${u} not found during polling`);d=p}return await o.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(w($)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler($,async t=>{switch(t.params.ref.type){case"ref/prompt":return Y(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return Z(t),this.handleResourceCompletion(t,t.params.ref);default:throw new f(m.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let o=this._registeredPrompts[r.name];if(!o)throw new f(m.InvalidParams,`Prompt ${r.name} not found`);if(!o.enabled)throw new f(m.InvalidParams,`Prompt ${r.name} disabled`);if(!o.argsSchema)return _;let n=E(o.argsSchema)?.[t.params.argument.name];if(!Q(n))return _;let s=ne(n);if(!s)return _;let l=await s(t.params.argument.value,t.params.context);return de(l)}async handleResourceCompletion(t,r){let o=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!o){if(this._registeredResources[r.uri])return _;throw new f(m.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let i=o.resourceTemplate.completeCallback(t.params.argument.name);if(!i)return _;let n=await i(t.params.argument.value,t.params.context);return de(n)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(w(j)),this.server.assertCanSetRequestHandler(w(I)),this.server.assertCanSetRequestHandler(w(M)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(j,async(t,r)=>{let o=Object.entries(this._registeredResources).filter(([n,s])=>s.enabled).map(([n,s])=>({uri:n,name:s.name,...s.metadata})),i=[];for(let n of Object.values(this._registeredResourceTemplates)){if(!n.resourceTemplate.listCallback)continue;let s=await n.resourceTemplate.listCallback(r);for(let l of s.resources)i.push({...n.metadata,...l})}return{resources:[...o,...i]}}),this.server.setRequestHandler(I,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,o])=>({name:r,uriTemplate:o.resourceTemplate.uriTemplate.toString(),...o.metadata}))})),this.server.setRequestHandler(M,async(t,r)=>{let o=new URL(t.params.uri),i=this._registeredResources[o.toString()];if(i){if(!i.enabled)throw new f(m.InvalidParams,`Resource ${o} disabled`);return i.readCallback(o,r)}for(let n of Object.values(this._registeredResourceTemplates)){let s=n.resourceTemplate.uriTemplate.match(o.toString());if(s)return n.readCallback(o,s,r)}throw new f(m.InvalidParams,`Resource ${o} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(w(L)),this.server.assertCanSetRequestHandler(w(q)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(L,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?Te(r.argsSchema):void 0}))})),this.server.setRequestHandler(q,async(t,r)=>{let o=this._registeredPrompts[t.params.name];if(!o)throw new f(m.InvalidParams,`Prompt ${t.params.name} not found`);if(!o.enabled)throw new f(m.InvalidParams,`Prompt ${t.params.name} disabled`);if(o.argsSchema){let i=S(o.argsSchema),n=await x(i,t.params.arguments);if(!n.success){let u="error"in n?n.error:"Unknown error",d=H(u);throw new f(m.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${d}`)}let s=n.data,l=o.callback;return await Promise.resolve(l(s,r))}else{let i=o.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...o){let i;typeof o[0]=="object"&&(i=o.shift());let n=o[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,o,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let n=this._createRegisteredResource(t,o.title,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let n=this._createRegisteredResourceTemplate(t,o.title,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}}_createRegisteredResource(t,r,o,i,n){let s={name:t,title:r,metadata:i,readCallback:n,enabled:!0,disable:c(()=>s.update({enabled:!1}),"disable"),enable:c(()=>s.update({enabled:!0}),"enable"),remove:c(()=>s.update({uri:null}),"remove"),update:c(l=>{typeof l.uri<"u"&&l.uri!==o&&(delete this._registeredResources[o],l.uri&&(this._registeredResources[l.uri]=s)),typeof l.name<"u"&&(s.name=l.name),typeof l.title<"u"&&(s.title=l.title),typeof l.metadata<"u"&&(s.metadata=l.metadata),typeof l.callback<"u"&&(s.readCallback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendResourceListChanged()},"update")};return this._registeredResources[o]=s,s}_createRegisteredResourceTemplate(t,r,o,i,n){let s={resourceTemplate:o,title:r,metadata:i,readCallback:n,enabled:!0,disable:c(()=>s.update({enabled:!1}),"disable"),enable:c(()=>s.update({enabled:!0}),"enable"),remove:c(()=>s.update({name:null}),"remove"),update:c(d=>{typeof d.name<"u"&&d.name!==t&&(delete this._registeredResourceTemplates[t],d.name&&(this._registeredResourceTemplates[d.name]=s)),typeof d.title<"u"&&(s.title=d.title),typeof d.template<"u"&&(s.resourceTemplate=d.template),typeof d.metadata<"u"&&(s.metadata=d.metadata),typeof d.callback<"u"&&(s.readCallback=d.callback),typeof d.enabled<"u"&&(s.enabled=d.enabled),this.sendResourceListChanged()},"update")};this._registeredResourceTemplates[t]=s;let l=o.uriTemplate.variableNames;return Array.isArray(l)&&l.some(d=>!!o.completeCallback(d))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,o,i,n){let s={title:r,description:o,argsSchema:i===void 0?void 0:y(i),callback:n,enabled:!0,disable:c(()=>s.update({enabled:!1}),"disable"),enable:c(()=>s.update({enabled:!0}),"enable"),remove:c(()=>s.update({name:null}),"remove"),update:c(l=>{typeof l.name<"u"&&l.name!==t&&(delete this._registeredPrompts[t],l.name&&(this._registeredPrompts[l.name]=s)),typeof l.title<"u"&&(s.title=l.title),typeof l.description<"u"&&(s.description=l.description),typeof l.argsSchema<"u"&&(s.argsSchema=y(l.argsSchema)),typeof l.callback<"u"&&(s.callback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendPromptListChanged()},"update")};return this._registeredPrompts[t]=s,i&&Object.values(i).some(u=>{let d=u instanceof B?u._def?.innerType:u;return Q(d)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,o,i,n,s,l,u,d){V(t);let g={title:r,description:o,inputSchema:ce(i),outputSchema:ce(n),annotations:s,execution:l,_meta:u,handler:d,enabled:!0,disable:c(()=>g.update({enabled:!1}),"disable"),enable:c(()=>g.update({enabled:!0}),"enable"),remove:c(()=>g.update({name:null}),"remove"),update:c(p=>{typeof p.name<"u"&&p.name!==t&&(typeof p.name=="string"&&V(p.name),delete this._registeredTools[t],p.name&&(this._registeredTools[p.name]=g)),typeof p.title<"u"&&(g.title=p.title),typeof p.description<"u"&&(g.description=p.description),typeof p.paramsSchema<"u"&&(g.inputSchema=y(p.paramsSchema)),typeof p.outputSchema<"u"&&(g.outputSchema=y(p.outputSchema)),typeof p.callback<"u"&&(g.handler=p.callback),typeof p.annotations<"u"&&(g.annotations=p.annotations),typeof p._meta<"u"&&(g._meta=p._meta),typeof p.enabled<"u"&&(g.enabled=p.enabled),this.sendToolListChanged()},"update")};return this._registeredTools[t]=g,this.setToolRequestHandlers(),this.sendToolListChanged(),g}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let o,i,n,s;if(typeof r[0]=="string"&&(o=r.shift()),r.length>1){let u=r[0];if(D(u))i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!D(r[0])&&(s=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(d=>typeof d=="object"&&d!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let l=r[0];return this._createRegisteredTool(t,void 0,o,i,n,s,{taskSupport:"forbidden"},void 0,l)}registerTool(t,r,o){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:i,description:n,inputSchema:s,outputSchema:l,annotations:u,_meta:d}=r;return this._createRegisteredTool(t,i,n,s,l,u,{taskSupport:"forbidden"},d,o)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let o;typeof r[0]=="string"&&(o=r.shift());let i;r.length>1&&(i=r.shift());let n=r[0],s=this._createRegisteredPrompt(t,void 0,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,o){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:i,description:n,argsSchema:s}=r,l=this._createRegisteredPrompt(t,i,n,s,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),l}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var Re={type:"object",properties:{}};function ue(a){return a!==null&&typeof a=="object"&&"parse"in a&&typeof a.parse=="function"&&"safeParse"in a&&typeof a.safeParse=="function"}c(ue,"isZodTypeLike");function pe(a){return"_def"in a||"_zod"in a||ue(a)}c(pe,"isZodSchemaInstance");function D(a){return typeof a!="object"||a===null||pe(a)?!1:Object.keys(a).length===0?!0:Object.values(a).some(ue)}c(D,"isZodRawShapeCompat");function ce(a){if(a){if(D(a))return y(a);if(!pe(a))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return a}}c(ce,"getZodSchemaObject");function Te(a){let t=E(a);return t?Object.entries(t).map(([r,o])=>{let i=ee(o),n=te(o);return{name:r,description:i,required:!n}}):[]}c(Te,"promptArgumentsFromSchema");function w(a){let r=E(a)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=re(r);if(typeof o=="string")return o;throw new Error("Schema method literal must be a string")}c(w,"getMethodValue");function de(a){return{completion:{values:a.slice(0,100),total:a.length,hasMore:a.length>100}}}c(de,"createCompletionResult");var _={completion:{values:[],hasMore:!1}};h();var he=class a{static{c(this,"InMemoryTransport")}constructor(){this._messageQueue=[]}static createLinkedPair(){let t=new a,r=new a;return t._otherTransport=r,r._otherTransport=t,[t,r]}async start(){for(;this._messageQueue.length>0;){let t=this._messageQueue.shift();this.onmessage?.(t.message,t.extra)}}async close(){let t=this._otherTransport;this._otherTransport=void 0,await t?.close(),this.onclose?.()}async send(t,r){if(!this._otherTransport)throw new Error("Not connected");this._otherTransport.onmessage?this._otherTransport.onmessage(t,{authInfo:r?.authInfo}):this._otherTransport._messageQueue.push({message:t,extra:{authInfo:r?.authInfo}})}};h();var kt=(a=>typeof v<"u"?v:typeof Proxy<"u"?new Proxy(a,{get:c((t,r)=>(typeof v<"u"?v:t)[r],"get")}):a)(function(a){if(typeof v<"u")return v.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var Ce=e.union([e.literal("light"),e.literal("dark")]).describe("Color theme preference for the host environment."),R=e.union([e.literal("inline"),e.literal("fullscreen"),e.literal("pip")]).describe("Display mode for UI presentation."),xe=e.union([e.literal("--color-background-primary"),e.literal("--color-background-secondary"),e.literal("--color-background-tertiary"),e.literal("--color-background-inverse"),e.literal("--color-background-ghost"),e.literal("--color-background-info"),e.literal("--color-background-danger"),e.literal("--color-background-success"),e.literal("--color-background-warning"),e.literal("--color-background-disabled"),e.literal("--color-text-primary"),e.literal("--color-text-secondary"),e.literal("--color-text-tertiary"),e.literal("--color-text-inverse"),e.literal("--color-text-ghost"),e.literal("--color-text-info"),e.literal("--color-text-danger"),e.literal("--color-text-success"),e.literal("--color-text-warning"),e.literal("--color-text-disabled"),e.literal("--color-border-primary"),e.literal("--color-border-secondary"),e.literal("--color-border-tertiary"),e.literal("--color-border-inverse"),e.literal("--color-border-ghost"),e.literal("--color-border-info"),e.literal("--color-border-danger"),e.literal("--color-border-success"),e.literal("--color-border-warning"),e.literal("--color-border-disabled"),e.literal("--color-ring-primary"),e.literal("--color-ring-secondary"),e.literal("--color-ring-inverse"),e.literal("--color-ring-info"),e.literal("--color-ring-danger"),e.literal("--color-ring-success"),e.literal("--color-ring-warning"),e.literal("--font-sans"),e.literal("--font-mono"),e.literal("--font-weight-normal"),e.literal("--font-weight-medium"),e.literal("--font-weight-semibold"),e.literal("--font-weight-bold"),e.literal("--font-text-xs-size"),e.literal("--font-text-sm-size"),e.literal("--font-text-md-size"),e.literal("--font-text-lg-size"),e.literal("--font-heading-xs-size"),e.literal("--font-heading-sm-size"),e.literal("--font-heading-md-size"),e.literal("--font-heading-lg-size"),e.literal("--font-heading-xl-size"),e.literal("--font-heading-2xl-size"),e.literal("--font-heading-3xl-size"),e.literal("--font-text-xs-line-height"),e.literal("--font-text-sm-line-height"),e.literal("--font-text-md-line-height"),e.literal("--font-text-lg-line-height"),e.literal("--font-heading-xs-line-height"),e.literal("--font-heading-sm-line-height"),e.literal("--font-heading-md-line-height"),e.literal("--font-heading-lg-line-height"),e.literal("--font-heading-xl-line-height"),e.literal("--font-heading-2xl-line-height"),e.literal("--font-heading-3xl-line-height"),e.literal("--border-radius-xs"),e.literal("--border-radius-sm"),e.literal("--border-radius-md"),e.literal("--border-radius-lg"),e.literal("--border-radius-xl"),e.literal("--border-radius-full"),e.literal("--border-width-regular"),e.literal("--shadow-hairline"),e.literal("--shadow-sm"),e.literal("--shadow-md"),e.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Ee=e.record(xe.describe(`Style variables for theming MCP apps.
4
4
 
5
5
  Individual style keys are optional - hosts may provide any subset of these values.
6
6
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -39,4 +39,4 @@ Boolean requesting whether a visible border and background is provided by the ho
39
39
  - "model": Tool visible to and callable by the agent
40
40
  - "app": Tool callable by the app from this server only`),csp:e.never().optional(),permissions:e.never().optional()}),Zt=e.object({mimeTypes:e.array(e.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),er=e.object({method:e.literal("ui/download-file"),params:e.object({contents:e.array(e.union([F,J])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),tr=e.object({method:e.literal("ui/message"),params:e.object({role:e.literal("user").describe('Message role, currently only "user" is supported.'),content:e.array(z).describe("Message content blocks (text, image, etc.).")})}),rr=e.object({method:e.literal("ui/notifications/sandbox-resource-ready"),params:e.object({html:e.string().describe("HTML content to load into the inner iframe."),sandbox:e.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:X.optional().describe("CSP configuration from resource metadata."),permissions:W.optional().describe("Sandbox permissions from resource metadata.")})}),or=e.object({method:e.literal("ui/notifications/tool-result"),params:A.describe("Standard MCP tool execution result.")}),ge=e.object({toolInfo:e.object({id:G.optional().describe("JSON-RPC id of the tools/call request."),tool:K.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Ce.optional().describe("Current color theme preference."),styles:ke.optional().describe("Style configuration for theming the app."),displayMode:R.optional().describe("How the UI is currently displayed."),availableDisplayModes:e.array(R).optional().describe("Display modes the host supports."),containerDimensions:e.union([e.object({height:e.number().describe("Fixed container height in pixels.")}),e.object({maxHeight:e.union([e.number(),e.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(e.union([e.object({width:e.number().describe("Fixed container width in pixels.")}),e.object({maxWidth:e.union([e.number(),e.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
41
41
  container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:e.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:e.string().optional().describe("User's timezone in IANA format."),userAgent:e.string().optional().describe("Host application identifier."),platform:e.union([e.literal("web"),e.literal("desktop"),e.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:e.object({touch:e.boolean().optional().describe("Whether the device supports touch input."),hover:e.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:e.object({top:e.number().describe("Top safe area inset in pixels."),right:e.number().describe("Right safe area inset in pixels."),bottom:e.number().describe("Bottom safe area inset in pixels."),left:e.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),sr=e.object({method:e.literal("ui/notifications/host-context-changed"),params:ge.describe("Partial context update containing only changed fields.")}),ir=e.object({method:e.literal("ui/update-model-context"),params:e.object({content:e.array(z).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:e.record(e.string(),e.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),ar=e.object({method:e.literal("ui/initialize"),params:e.object({appInfo:P.describe("App identification (name and version)."),appCapabilities:je.describe("Features and capabilities this app provides."),protocolVersion:e.string().describe("Protocol version this app supports.")})}),nr=e.object({protocolVersion:e.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:P.describe("Host application identification and version."),hostCapabilities:Pe.describe("Features and capabilities provided by the host."),hostContext:ge.describe("Rich context about the host environment.")}).passthrough();var fe="ui/resourceUri",Me="text/html;profile=mcp-app";function lr(a,t,r,o){let i=r._meta,n=i.ui,s=i[fe],l=i;return n?.resourceUri&&!s?l={...i,[fe]:n.resourceUri}:s&&!n?.resourceUri&&(l={...i,ui:{...n,resourceUri:s}}),a.registerTool(t,{...r,_meta:l},o)}c(lr,"K3");function cr(a,t,r,o,i){return a.registerResource(t,r,{mimeType:Me,...o},i)}c(cr,"N3");var Le="io.modelcontextprotocol/ui";function dr(a){if(a)return a.extensions?.[Le]}c(dr,"Y3");export{Ne as a,le as b,he as c,Me as d,lr as e,cr as f,dr as g};
42
- //# sourceMappingURL=chunk-TBWHG3QY.js.map
42
+ //# sourceMappingURL=chunk-2GX6NKSQ.js.map
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{d as rt}from"./chunk-GINS7EJK.js";import{a as Xe,c as M,d as Ze,f as et,h as tt}from"./chunk-QQPUGUBV.js";import{d as Qe,o as qe}from"./chunk-PLOU2ZRT.js";import{b as ze,c as ce,g as ae,h as Je,i as fe,j as Ye}from"./chunk-IJQ2NP5F.js";import{r as se,s as ie,u as Ke}from"./chunk-2XQ52RUU.js";import{c as ne,d as Pe}from"./chunk-XHYIFBRR.js";import{c as Te}from"./chunk-SLVS2TAO.js";import{o as Oe}from"./chunk-MUSFS3P4.js";import{h as je}from"./chunk-YELLLMDI.js";import{k as Ae}from"./chunk-USB7XTDC.js";import{A as Ne,B as Fe,G as te,H as Me,J as z,L as re,O as Ue,S as Le,T as oe,i as We,o as j,p as Ie,x as De,z as ee}from"./chunk-IFSSMLFN.js";import{b as He,e as Be,g as Ve}from"./chunk-YH36XQ4K.js";import{a as B}from"./chunk-EGH4ZUSB.js";import{m as K}from"./chunk-QWI55NYX.js";import{a as Ge}from"./chunk-XNHLRR2R.js";import{b as be}from"./chunk-XAXQJKLP.js";import{b as Re,c as Ce}from"./chunk-6RXTW4LU.js";import{o as _e,p as Z,s as xe}from"./chunk-EFNV3TFI.js";import{c as ve}from"./chunk-4TZAFRQL.js";import{G as X,M as Se,S as $e,T as Ee,a as Rt,h as A,j as k,k as y,l as g,m as V,n as F,o as ge,r as ye,s as q}from"./chunk-TVYHBSWN.js";import{b as N}from"./chunk-O22TMXNP.js";import{a as i,e as xt,f as C}from"./chunk-KPIXRVP2.js";C();import*as T from"node:fs";import*as J from"node:path";var ot=i(e=>J.join(N(e),"issue.md"),"issueCopyPath"),U=class extends Error{static{i(this,"IssueFetchError")}};async function nt(e,r=()=>new Date,o=j({text:e})){let t=await o.fetchIssue(e);if(!t)throw new U(`couldn't read ${e} from ${o.label}`);return{ref:t.ref,url:t.url??o.url(t.ref),tracker:o.id,title:t.title??"",status:t.status??"",body:t.description??"",comments:t.comments??[],fetchedAt:r().toISOString()}}i(nt,"fetchIssueSnapshot");var ue=`
3
+ import{d as rt}from"./chunk-NUTCQUPB.js";import{a as Xe,c as M,d as Ze,f as et,h as tt}from"./chunk-LMPF3GCE.js";import{d as qe,o as Qe}from"./chunk-LM53TV37.js";import{b as ze,c as ce,g as ae,h as Je,i as fe,j as Ye}from"./chunk-ACIJTPQA.js";import{r as se,s as ie,u as Ke}from"./chunk-SUEMTMAK.js";import{c as ne,d as Pe}from"./chunk-L6B3G5M6.js";import{c as Te}from"./chunk-PELPDI4T.js";import{o as Oe}from"./chunk-LCB45SSP.js";import{h as je}from"./chunk-QOXVGCRJ.js";import{m as Ae}from"./chunk-XWU77GCN.js";import{A as Ne,B as Fe,G as te,H as Me,J as z,L as re,O as Ue,S as Le,T as oe,i as We,o as j,p as Ie,x as De,z as ee}from"./chunk-U2PODCN6.js";import{b as He,e as Be,g as Ve}from"./chunk-6MDK2RR4.js";import{a as B}from"./chunk-232MOJMO.js";import{m as K}from"./chunk-KPANGOHV.js";import{a as Ge}from"./chunk-KNBPZRXN.js";import{b as be}from"./chunk-QPIQDB6Z.js";import{b as Re,c as Ce}from"./chunk-LW7TF2T6.js";import{o as _e,p as Z,s as xe}from"./chunk-NHX34CYT.js";import{c as ve}from"./chunk-EQQZQNJG.js";import{G as X,M as Se,S as $e,T as Ee,a as Rt,h as A,j as k,k as y,l as g,m as V,n as F,o as ge,r as ye,s as Q}from"./chunk-R4TLZDCX.js";import{b as N}from"./chunk-SVMYDOF3.js";import{a as i,e as xt,f as C}from"./chunk-UDLGGZXC.js";C();import*as T from"node:fs";import*as J from"node:path";var ot=i(e=>J.join(N(e),"issue.md"),"issueCopyPath"),U=class extends Error{static{i(this,"IssueFetchError")}};async function nt(e,r=()=>new Date,o=j({text:e})){let t=await o.fetchIssue(e);if(!t)throw new U(`couldn't read ${e} from ${o.label}`);return{ref:t.ref,url:t.url??o.url(t.ref),tracker:o.id,title:t.title??"",status:t.status??"",body:t.description??"",comments:t.comments??[],fetchedAt:r().toISOString()}}i(nt,"fetchIssueSnapshot");var ue=`
4
4
 
5
5
  ## Comments
6
6
  `;function Ct(e){let r=["---",`ref: ${e.ref}`,`url: ${e.url??""}`,`tracker: ${e.tracker}`,`status: ${e.status}`,`fetched: ${e.fetchedAt}`,"---","",`# ${e.title}`,"",e.body].join(`
@@ -10,7 +10,7 @@ import{d as rt}from"./chunk-GINS7EJK.js";import{a as Xe,c as M,d as Ze,f as et,h
10
10
  ${t.body}
11
11
  `).join("");return`${r}${ue}${o}`}i(Ct,"renderIssueCopy");function bt(e){let r=/^---\nref: (.*)\nurl: (.*)\ntracker: (.*)\nstatus: (.*)\nfetched: (.*)\n---\n\n# (.*)\n\n/.exec(e);if(!r)return null;let o=e.slice(r[0].length),t=o.lastIndexOf(ue);if(t<0)return null;let s=o.slice(t+ue.length),n=[];for(let m of s.split(/\n(?=### [^\n]* · [^\n]*\n\n)/).filter(a=>a.trim())){let a=/^\n?### (.*) · (.*)\n\n([\s\S]*?)\n?$/.exec(m);if(!a)return null;n.push({author:a[1],...a[2]?{created:a[2]}:{},body:a[3]})}return{ref:r[1],url:r[2]||null,tracker:r[3],status:r[4],fetchedAt:r[5],title:r[6],body:o.slice(0,t),comments:n}}i(bt,"parseIssueCopy");function le(e,r){let o=ot(e);T.mkdirSync(J.dirname(o),{recursive:!0}),T.writeFileSync(o,Ct(r))}i(le,"writeIssueCopy");function st(e,r,o=""){let t=null;try{t=bt(T.readFileSync(ot(e),"utf8"))}catch{}return t&&t.ref===r?{ref:t.ref,url:t.url,title:t.title,fetchedAt:t.fetchedAt}:r?{ref:r,url:j({project:o,text:r}).url(r),title:"",fetchedAt:null}:null}i(st,"readIssueRef");C();var ht=xt(Rt(),1);import*as l from"node:fs";import*as W from"node:os";import*as f from"node:path";C();import*as _ from"node:fs";import*as E from"node:path";var L=".devcontainer/devcontainer.json",At="werkmeister-claude-home",at="// GENERATED by `werkmeister workspace init` (packages/werkmeister-core/src/devcontainer_gen.ts) \u2014 do not edit; rerun init-workspace.\n",it=i(e=>`source=${e},target=${e},type=bind`,"bind"),jt=i(e=>`'${e.replaceAll("'","'\\''")}'`,"shellQuote"),ct=i((e,r)=>{let o=E.relative(r,e);return!o.startsWith("..")&&!E.isAbsolute(o)},"within");function Ot(e){let r=`${e.home}/.claude`,o=ct(e.workspaceRoot,e.workspacesRoot)?e.workspacesRoot:e.workspaceRoot,t=ct(e.reposRoot,o)?[]:[it(e.reposRoot)],s=`printf '{"Authorization":"Bearer %s"}' "$(cat ${JSON.stringify(E.join(e.workspaceRoot,".werkmeister/token"))})"`,n={type:"http",url:`http://host.docker.internal:${e.port}/mcp`,headersHelper:s},m=['sudo chown node:node "$HOME" "$HOME/.claude"',"npm install -g @anthropic-ai/claude-code","(claude plugin marketplace add DietrichGebert/ponytail >/dev/null 2>&1 || true)","claude plugin install ponytail@ponytail","(claude mcp remove --scope user werkmeister >/dev/null 2>&1 || true)",`claude mcp add-json --scope user werkmeister ${jt(JSON.stringify(n))}`].join(" && ");return{name:e.workspaceName,image:"mcr.microsoft.com/devcontainers/javascript-node:22",features:{"ghcr.io/devcontainers/features/github-cli:1":{}},workspaceMount:it(o),workspaceFolder:e.workspaceRoot,mounts:[...t,`source=${At},target=${r},type=volume`],runArgs:["--add-host=host.docker.internal:host-gateway"],containerEnv:{HOME:e.home,GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"safe.directory",GIT_CONFIG_VALUE_0:"*"},remoteEnv:{CLAUDE_CODE_OAUTH_TOKEN:"${localEnv:CLAUDE_CODE_OAUTH_TOKEN}"},remoteUser:"node",postCreateCommand:m}}i(Ot,"buildDevcontainer");function ft(e){let r=E.join(e.workspaceRoot,L);return _.mkdirSync(E.dirname(r),{recursive:!0}),_.writeFileSync(r,at+JSON.stringify(Ot(e),null,2)+`
12
12
  `),r}i(ft,"writeWorkspaceDevcontainer");function ut(e){let r=E.join(e,L),o;try{o=_.readFileSync(r,"utf8")}catch{return!1}if(!o.startsWith(at))return!1;_.rmSync(r);try{_.rmdirSync(E.dirname(r))}catch{}return!0}i(ut,"removeGeneratedDevcontainer");C();import*as b from"node:fs";import*as pt from"node:path";function lt(e,r){let o=new Set;for(let t of Object.keys(e)){let s=r[t]??{};for(let n of s.mcp_servers??[])o.add(n)}return[...o].sort()}i(lt,"resolveWorkspaceMcpServers");function mt(e,r){let o=[];for(let t of Object.keys(e).sort()){let s=e[t];if(!(typeof s!="object"||s===null||Array.isArray(s)))for(let n of s.mcp_servers??[])n in r||o.push(`services.yaml: archetype '${t}' lists MCP server '${n}' \u2014 no \`mcp_servers.${n}\` definition`)}return o}i(mt,"validateArchetypeMcpServers");function me(e,r){return typeof e=="string"?e.replace(/\$\{(\w+)\}/g,(o,t)=>Object.hasOwn(r,t)?r[t]:o):Array.isArray(e)?e.map(o=>me(o,r)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([o,t])=>[o,me(t,r)])):e}i(me,"substituteVars");function dt(e,r,o,t={}){let s=pt.join(e,".mcp.json"),n=b.existsSync(s)&&b.statSync(s).isFile(),m={};if(n)try{let c=JSON.parse(b.readFileSync(s,"utf8"));if(typeof c=="object"&&c!==null&&!Array.isArray(c))m=c;else return s}catch{return s}let a={};for(let c of r)c in o&&(a[c]=me(o[c],t));if(Object.keys(a).length===0&&!n)return null;"mcpServers"in m||(m.mcpServers={});let d=m.mcpServers;for(let c of Object.keys(d))c in o&&!(c in a)&&delete d[c];return Object.assign(d,a),b.writeFileSync(s,JSON.stringify(m,null,2)+`
13
- `),s}i(dt,"writeWorkspaceMcp");var R=class extends ve{static{i(this,"WorkspaceInitError")}constructor(r){super(r),this.name="WorkspaceInitError"}};function S(e){throw V(e),new R(e)}i(S,"fail");async function Tt(e,r,o){if(o.issue)le(e,o.issue);else if(o.refresh){if(!r)throw new R("--refresh-issue: this workspace has no issue_id.");try{let t=j({project:o.project,text:r});le(e,await nt(r,void 0,t))}catch(t){throw t instanceof U?new R(`${t.message}; run \`werkmeister infra connect\` to check the issue tracker.`):t}}return st(e,r,o.project)}i(Tt,"resolveIssueCopy");var de=class extends Error{static{i(this,"WorkspaceRootError")}};function Wt(e){try{return l.statSync(e).isDirectory()}catch{return!1}}i(Wt,"isDir");function It(){for(let e of["LOGNAME","USER","LNAME","USERNAME"]){let r=process.env[e];if(r)return r}return W.userInfo().username}i(It,"getuser");var Dt=new Set(["labels","group"]);function Nt(e){return e.split(",").map(r=>r.trim()).filter(r=>r)}i(Nt,"splitMultiValue");function Ft(e,r){if(r&&l.existsSync(re(r)))return!0;let o=q("WORKSPACE_CONFIG");if(o&&l.existsSync(re(o)))return!0;let t=N(e);return z.some(s=>l.existsSync(f.join(t,s)))}i(Ft,"hasWorkspaceConfig");var Mt=`# AUTO-GENERATED \u2014 durable source of truth for workspace inputs.
13
+ `),s}i(dt,"writeWorkspaceMcp");var R=class extends ve{static{i(this,"WorkspaceInitError")}constructor(r){super(r),this.name="WorkspaceInitError"}};function S(e){throw V(e),new R(e)}i(S,"fail");async function Tt(e,r,o){if(o.issue)le(e,o.issue);else if(o.refresh){if(!r)throw new R("--refresh-issue: this workspace has no issue_id.");try{let t=j({project:o.project,text:r});le(e,await nt(r,void 0,t))}catch(t){throw t instanceof U?new R(`${t.message}; run \`werkmeister infra connect\` to check the issue tracker.`):t}}return st(e,r,o.project)}i(Tt,"resolveIssueCopy");var de=class extends Error{static{i(this,"WorkspaceRootError")}};function Wt(e){try{return l.statSync(e).isDirectory()}catch{return!1}}i(Wt,"isDir");function It(){for(let e of["LOGNAME","USER","LNAME","USERNAME"]){let r=process.env[e];if(r)return r}return W.userInfo().username}i(It,"getuser");var Dt=new Set(["labels","group"]);function Nt(e){return e.split(",").map(r=>r.trim()).filter(r=>r)}i(Nt,"splitMultiValue");function Ft(e,r){if(r&&l.existsSync(re(r)))return!0;let o=Q("WORKSPACE_CONFIG");if(o&&l.existsSync(re(o)))return!0;let t=N(e);return z.some(s=>l.existsSync(f.join(t,s)))}i(Ft,"hasWorkspaceConfig");var Mt=`# AUTO-GENERATED \u2014 durable source of truth for workspace inputs.
14
14
  # Tool: werkmeister workspace init
15
15
  # Source: src/commands/init_workspace.ts :: _write_workspace_config
16
16
  # Edit: Hand-edit \`feature\`, \`repos\`, \`services\`, \`issue_id\`, \`task\`,
@@ -26,11 +26,11 @@ ${t.body}
26
26
  # Format: YAML \u2014 line comments (\`#\`) are supported. The loader also
27
27
  # accepts legacy JSONC and JSON for back-compat.
28
28
  `;function wt(e,r){if(Object.keys(r).length===0)return;let o=N(e),t=f.join(o,z[0]),s=z.slice(1).map(c=>f.join(o,c)),n={};for(let c of[t,...s])if(l.existsSync(c)&&l.statSync(c).isFile())try{let w=Ne(c);if(typeof w=="object"&&w!==null&&!Array.isArray(w)){n=w;break}}catch{}delete n._generator,delete n.$schema;let m={...n};for(let[,,c]of Fe)if(c in r){let w=r[c];if(Dt.has(c)&&typeof w=="string"&&(w=Nt(w)),(c==="autonomous"||c==="auto_stop")&&(w=w==="true"),c==="auto_stop"&&w===!1&&!(c in n))continue;m[c]=w}let a=ht.stringify(m,{sortMapEntries:!0,blockQuote:"literal"}),d=Mt+a;if(!(l.existsSync(t)&&l.readFileSync(t,"utf8")===d)){l.mkdirSync(o,{recursive:!0}),l.writeFileSync(t,d),y(`Persisted inputs to ${t}`);for(let c of s)l.existsSync(c)&&(l.unlinkSync(c),k(`Removed legacy ${f.basename(c)} (superseded by workspace.yml)`))}}i(wt,"writeWorkspaceConfig");var Ut=/^[a-z0-9]+(-[a-z0-9]+)*$/;function Lt(e,r){let o=(e||"").trim().toLowerCase(),t=(r||"").trim().toLowerCase(),s=o===t||o.startsWith(`${t}-`);return t&&!s?`${t}-${o}`:o}i(Lt,"buildWorkspaceName");function Pt(e,r){return`${e}/${r}`}i(Pt,"buildBranchName");function kt(){return X()}i(kt,"resolveReposRoot");function gt(){let e=_e().workspaces_root;return e?f.resolve(ye(e)):f.resolve(f.join(W.homedir(),"workspace"))}i(gt,"resolveWorkspacesRoot");function Gt(e,r,o){let t=kt(),s=f.join(t,M);if(k(`Workspace: ${e}`),k(`Branch: ${r}`),l.existsSync(f.join(s,".git"))){let n=xe()||tt(),m=n?et(s,Ze(n)):null;m!==null&&S(`${s}'s origin is ${m||"unset"}, but the configured workspace repo is ${n} \u2014 this workspace's record would push to the wrong repo. Run \`werkmeister machine setup\` to repoint it, then rerun.`);try{ae(s,e,r,{force:o})}catch(a){S(`Failed to create workspace root worktree: ${a.message}`)}y(`Created workspace root (worktree of ${M}) at ${e}`)}else g(`No '${M}' repo at ${s} \u2014 workspace root will be a plain directory (no git history for notes/config).`),l.mkdirSync(e,{recursive:!0})}i(Gt,"createWorkspaceRoot");function Ht(e,r){Ye(e,`chore: initialize workspace ${r}`)&&y("Committed initial workspace state (branch not pushed \u2014 push when ready).")}i(Ht,"commitWorkspaceState");function yt(){for(let e of Oe({generatedOnly:!0}))e.ok?e.detail.startsWith("generated")&&k(`Registry: ${e.detail}`):g(`Registry not refreshed: ${e.detail}`)}i(yt,"refreshRegistry");async function Bt(e,r){let o=Se(),[t,s,n]=ce(e??null,r??null,o);return n.length&&S(`Unknown service(s): ${n.join(", ")}. See \`werkmeister feature services\` / config/services.yaml.`),!t.length&&!s.length&&S("No repos selected. Choose at least one service or repo in the wizard, or pass --services svc1,svc2 / --repos r1,r2."),t}i(Bt,"selectRepos");function Vt(){let e=f.resolve(process.cwd()),r=Ge(e,Z());if(r!==null)return r;for(let t of[e,...Kt(e)])if(l.existsSync(f.join(t,".git")))return f.dirname(t);let o=Z().join(", ");throw new de(`${A.RED}[err] Not inside a workspace (checked: ${o}) and no parent \`.git\` directory found.
29
- The workspaces root comes from ~/.werkmeister/config.yaml \u2014 run \`werkmeister machine config --write\` to set it (or \`werkmeister machine config --check\` to verify).`+A.RESET)}i(Vt,"findWorkspaceRoot");function Kt(e){let r=[],o=e;for(;;){let t=f.dirname(o);if(t===o)break;r.push(t),o=t}return r}i(Kt,"ancestors");function St(e){let o=K(["git","-C",e,"branch","--show-current"],{capture:!0}).stdout.trim();return o||K(["git","-C",e,"rev-parse","--short","HEAD"],{capture:!0}).stdout.trim()||"unknown"}i(St,"getBranch");function $t(e){return je(e).map(r=>[f.basename(r),St(r)])}i($t,"discoverRepos");function zt(e){if(l.existsSync(f.join(e,".git"))){let r=St(e);if(r&&r!=="unknown")return r}return`${It()}/${f.basename(e)}`}i(zt,"workspaceBranch");function Jt(e,r,o){let t=X(),s=r.filter(u=>u!==M),n=new Set(s),m=new Set($t(e).map(([u])=>u)),a=s.filter(u=>!m.has(u)),d=[...m].filter(u=>!n.has(u)).sort(),c=s.filter(u=>f.basename(u)!==u||u==="."||u==="..");c.length&&S(`Repo name(s) must be a folder directly under ${t}: ${c.join(", ")}.`);let w=a.filter(u=>!Wt(f.join(t,u)));if(w.length&&S(`Source repo(s) not found under ${t}: ${w.join(", ")}. Clone them there (or fix \`repos\` in .werkmeister/workspace.yml) and rerun.`),d.length&&!o){let u=d.filter(h=>Je(f.join(e,h)));u.length&&S(`Refusing to remove worktree(s) with uncommitted changes: ${u.join(", ")}. Commit or stash them, or rerun with --force to discard them.`)}if(!a.length&&!d.length)return;let I=zt(e);for(let u of d){let[h,v]=fe(f.join(t,u),f.join(e,u),I);h?(y(`Removed worktree '${u}' (no longer in workspace.yml).`),v&&g(v)):S(`Could not remove worktree '${u}': ${v}`)}let x=[];try{for(let u of a){let h=f.join(t,u),v=f.join(e,u);ae(h,v,I,{force:o}),x.push([v,h])}}catch(u){let h=`Failed to create worktree: ${u.message}`;V(h),g("Rolling back worktrees created this run...");for(let[v,P]of[...x].reverse())fe(P,v,I);throw new R(h)}(a.length||d.length)&&y(`Worktrees reconciled (+${a.length} / -${d.length}).`)}i(Jt,"reconcileWorktrees");function Yt(e,r,o){if(e)return[e.trim(),{}];let t=o?.().trim();return t?[t,{}]:[Le(r),{}]}i(Yt,"resolveTask");function Qt(e){if(!l.existsSync(e))return;l.readFileSync(e,"utf8").includes("## Layout")?g("CLAUDE.md already initialised \u2014 overwriting with fresh content."):k("Replacing stub CLAUDE.md with full workspace context.")}i(Qt,"warnIfExisting");function qt(e,r){k(`Task: ${e}`);for(let[o,t]of[["FEATURE","Feature"],["SERVICES","Services"],["ISSUE_ID","Issue"],["TEST_PATH","Test path"]]){let s=r[o];s&&k(` ${(t+":").padEnd(10)} ${s}`)}}i(qt,"logMeta");async function Xt(e,r,o={}){let t=r??Vt(),s=f.basename(t);k(`Workspace root: ${t}`),yt();let n=Ue(e,t),m=se(ie(n.context_strategy));if(ne(n.harness),!Ft(t,e.config_file??null)&&!n.feature&&S("No .werkmeister/workspace.yml found and no --feature given. Run `werkmeister workspace new <name>` to create and initialise a workspace, then rerun `werkmeister workspace init` from inside it to reconcile changes."),te(n),n.model&&!Me(t)){let p=String(e.model||q("MODEL")||"").trim(),$=p?p!==n.model?` (${p} tier)`:"":` (${De().defaultTier} tier, default)`;k(`Model: ${n.model}${$}`)}wt(t,n);let d=n.project??"",c=n.issue_id?j({project:d,text:n.issue_id}).parseRef(n.issue_id)??n.issue_id:"",w;try{w=await Tt(t,c,{issue:o.issue,refresh:!!e.refresh_issue,project:d})}catch(p){throw p instanceof R&&S(p.message),p}if(n.repos){let[p]=oe(),[$,,O]=ce(n.repos,n.services,p);O.length&&g(`Unknown service(s) in workspace.yml (no owning repo): ${O.join(", ")}`),Jt(t,$,!!e.force)}let I=f.join(t,"CLAUDE.md");Qt(I),k("Scanning for git repos...");let x=$t(t);if(!x.length)g("No git repos found in workspace. CLAUDE.md will have an empty layout.");else{for(let[p,$]of x)k(` ${p}/ \u2192 ${$}`);ze(t,x.map(([p])=>p))}let[u,h]=Yt(n.task,s,o.readStdinTask),v={feature:"FEATURE",services:"SERVICES",issue_id:"ISSUE_ID",test_path:"TEST_PATH",description:"DESCRIPTION"};for(let[p,$]of Object.entries(v))p in n&&(h[$]=n[p]);qt(u,h);let P=f.join(t,".env");Qe(P,h),y(`Wrote ${P}`),y(`Wrote ${Te(t)}`),y(`Wrote ${rt(t)}`),m.init({workspaceRoot:t,workspaceName:s,repos:x,task:u,meta:h,inputs:n,configOverride:e.config??null,issue:w,isCreate:!!o.issue});for(let p of ee)p!==m.id&&Ke(t,se(p),m,!!e.prune_context);let[Et,vt]=oe(),Y=$e(),_t=Ae(x,h,Et,vt,Y),he=Ee();for(let p of mt(Y,he))g(p);let we=(h.FEATURE??"").trim(),ke=dt(t,lt(_t,Y),he,we?{FEATURE:we}:{});ke&&y(`Wrote ${ke}`),Ce(s,t),y(`Workspace token: ${f.relative(t,Re(t))}`);let Q=Pe(t).id;if(Q==="claude"){let p=ft({workspaceName:s,workspaceRoot:t,workspacesRoot:gt(),reposRoot:kt(),home:W.homedir(),port:be()});y(`Wrote ${f.relative(t,p)}`)}else ut(t)&&k(`Removed the generated ${L} (harness: ${Q})`),k(`No ${L}: the generated one runs Claude Code, not ${Q}`);for(let p of Xe())g(p);let G=(h.FEATURE??"").trim(),H=!0;if(G){let p=await qe(G,h.SERVICES??"",t,(h.TEST_PATH??"").trim(),x.map(([$])=>$));if(H=p!==null,p!==null&&o.build!==!1){k("Building Docker images (--no-start)...");let $=ge(),O=f.join(t,B);Ve(O),Be(G,O);let D=K(He(G,["up","--build","--no-start"],O),{cwd:t,...$?{stdio:"inherit"}:{capture:!0}});$||(D.stdout&&F(D.stdout),D.stderr&&F(D.stderr,"stderr")),D.status===0?y("Docker images built successfully."):g("docker compose build exited non-zero \u2014 images may be incomplete.")}}return H?(F(`
29
+ The workspaces root comes from ~/.werkmeister/config.yaml \u2014 run \`werkmeister machine config --write\` to set it (or \`werkmeister machine config --check\` to verify).`+A.RESET)}i(Vt,"findWorkspaceRoot");function Kt(e){let r=[],o=e;for(;;){let t=f.dirname(o);if(t===o)break;r.push(t),o=t}return r}i(Kt,"ancestors");function St(e){let o=K(["git","-C",e,"branch","--show-current"],{capture:!0}).stdout.trim();return o||K(["git","-C",e,"rev-parse","--short","HEAD"],{capture:!0}).stdout.trim()||"unknown"}i(St,"getBranch");function $t(e){return je(e).map(r=>[f.basename(r),St(r)])}i($t,"discoverRepos");function zt(e){if(l.existsSync(f.join(e,".git"))){let r=St(e);if(r&&r!=="unknown")return r}return`${It()}/${f.basename(e)}`}i(zt,"workspaceBranch");function Jt(e,r,o){let t=X(),s=r.filter(u=>u!==M),n=new Set(s),m=new Set($t(e).map(([u])=>u)),a=s.filter(u=>!m.has(u)),d=[...m].filter(u=>!n.has(u)).sort(),c=s.filter(u=>f.basename(u)!==u||u==="."||u==="..");c.length&&S(`Repo name(s) must be a folder directly under ${t}: ${c.join(", ")}.`);let w=a.filter(u=>!Wt(f.join(t,u)));if(w.length&&S(`Source repo(s) not found under ${t}: ${w.join(", ")}. Clone them there (or fix \`repos\` in .werkmeister/workspace.yml) and rerun.`),d.length&&!o){let u=d.filter(h=>Je(f.join(e,h)));u.length&&S(`Refusing to remove worktree(s) with uncommitted changes: ${u.join(", ")}. Commit or stash them, or rerun with --force to discard them.`)}if(!a.length&&!d.length)return;let I=zt(e);for(let u of d){let[h,v]=fe(f.join(t,u),f.join(e,u),I);h?(y(`Removed worktree '${u}' (no longer in workspace.yml).`),v&&g(v)):S(`Could not remove worktree '${u}': ${v}`)}let x=[];try{for(let u of a){let h=f.join(t,u),v=f.join(e,u);ae(h,v,I,{force:o}),x.push([v,h])}}catch(u){let h=`Failed to create worktree: ${u.message}`;V(h),g("Rolling back worktrees created this run...");for(let[v,P]of[...x].reverse())fe(P,v,I);throw new R(h)}(a.length||d.length)&&y(`Worktrees reconciled (+${a.length} / -${d.length}).`)}i(Jt,"reconcileWorktrees");function Yt(e,r,o){if(e)return[e.trim(),{}];let t=o?.().trim();return t?[t,{}]:[Le(r),{}]}i(Yt,"resolveTask");function qt(e){if(!l.existsSync(e))return;l.readFileSync(e,"utf8").includes("## Layout")?g("CLAUDE.md already initialised \u2014 overwriting with fresh content."):k("Replacing stub CLAUDE.md with full workspace context.")}i(qt,"warnIfExisting");function Qt(e,r){k(`Task: ${e}`);for(let[o,t]of[["FEATURE","Feature"],["SERVICES","Services"],["ISSUE_ID","Issue"],["TEST_PATH","Test path"]]){let s=r[o];s&&k(` ${(t+":").padEnd(10)} ${s}`)}}i(Qt,"logMeta");async function Xt(e,r,o={}){let t=r??Vt(),s=f.basename(t);k(`Workspace root: ${t}`),yt();let n=Ue(e,t),m=se(ie(n.context_strategy));if(ne(n.harness),!Ft(t,e.config_file??null)&&!n.feature&&S("No .werkmeister/workspace.yml found and no --feature given. Run `werkmeister workspace new <name>` to create and initialise a workspace, then rerun `werkmeister workspace init` from inside it to reconcile changes."),te(n),n.model&&!Me(t)){let p=String(e.model||Q("MODEL")||"").trim(),$=p?p!==n.model?` (${p} tier)`:"":` (${De().defaultTier} tier, default)`;k(`Model: ${n.model}${$}`)}wt(t,n);let d=n.project??"",c=n.issue_id?j({project:d,text:n.issue_id}).parseRef(n.issue_id)??n.issue_id:"",w;try{w=await Tt(t,c,{issue:o.issue,refresh:!!e.refresh_issue,project:d})}catch(p){throw p instanceof R&&S(p.message),p}if(n.repos){let[p]=oe(),[$,,O]=ce(n.repos,n.services,p);O.length&&g(`Unknown service(s) in workspace.yml (no owning repo): ${O.join(", ")}`),Jt(t,$,!!e.force)}let I=f.join(t,"CLAUDE.md");qt(I),k("Scanning for git repos...");let x=$t(t);if(!x.length)g("No git repos found in workspace. CLAUDE.md will have an empty layout.");else{for(let[p,$]of x)k(` ${p}/ \u2192 ${$}`);ze(t,x.map(([p])=>p))}let[u,h]=Yt(n.task,s,o.readStdinTask),v={feature:"FEATURE",services:"SERVICES",issue_id:"ISSUE_ID",test_path:"TEST_PATH",description:"DESCRIPTION"};for(let[p,$]of Object.entries(v))p in n&&(h[$]=n[p]);Qt(u,h);let P=f.join(t,".env");qe(P,h),y(`Wrote ${P}`),y(`Wrote ${Te(t)}`),y(`Wrote ${rt(t)}`),m.init({workspaceRoot:t,workspaceName:s,repos:x,task:u,meta:h,inputs:n,configOverride:e.config??null,issue:w,isCreate:!!o.issue});for(let p of ee)p!==m.id&&Ke(t,se(p),m,!!e.prune_context);let[Et,vt]=oe(),Y=$e(),_t=Ae(x,h,Et,vt,Y),he=Ee();for(let p of mt(Y,he))g(p);let we=(h.FEATURE??"").trim(),ke=dt(t,lt(_t,Y),he,we?{FEATURE:we}:{});ke&&y(`Wrote ${ke}`),Ce(s,t),y(`Workspace token: ${f.relative(t,Re(t))}`);let q=Pe(t).id;if(q==="claude"){let p=ft({workspaceName:s,workspaceRoot:t,workspacesRoot:gt(),reposRoot:kt(),home:W.homedir(),port:be()});y(`Wrote ${f.relative(t,p)}`)}else ut(t)&&k(`Removed the generated ${L} (harness: ${q})`),k(`No ${L}: the generated one runs Claude Code, not ${q}`);for(let p of Xe())g(p);let G=(h.FEATURE??"").trim(),H=!0;if(G){let p=await Qe(G,h.SERVICES??"",t,(h.TEST_PATH??"").trim(),x.map(([$])=>$));if(H=p!==null,p!==null&&o.build!==!1){k("Building Docker images (--no-start)...");let $=ge(),O=f.join(t,B);Ve(O),Be(G,O);let D=K(He(G,["up","--build","--no-start"],O),{cwd:t,...$?{stdio:"inherit"}:{capture:!0}});$||(D.stdout&&F(D.stdout),D.stderr&&F(D.stderr,"stderr")),D.status===0?y("Docker images built successfully."):g("docker compose build exited non-zero \u2014 images may be incomplete.")}}return H?(F(`
30
30
  ${A.BOLD}Workspace initialised.${A.RESET} Open a new Claude Code session from the workspace root to pick up the context.
31
31
 
32
- `),{containers:H}):(g(`Workspace initialised, but the container step did not run: no slot, so ${B} was not (re)generated (see the slot warning above). \`werkmeister feature up\` fails until you free a slot and rerun \`werkmeister workspace init\`.`),{containers:H})}i(Xt,"initWorkspace");async function Zt(e,r,o,t){k(`Running: werkmeister workspace init (feature: ${r})`);try{return await Xt({...o,feature:r,force:t.force},e,t)}catch(s){return s instanceof R||V(`init-workspace failed: ${s.message}`),null}}i(Zt,"runInitWorkspace");async function Lr(e,r={}){let o=(e.feature??"").trim();o||S("A feature name is required (pass it as an argument, set it in ./.werkmeister/workspace.yml, or run interactively)."),ie(e.context_strategy),ne(e.harness);let t=o.toLowerCase();try{let c=Ie(e.issue_id??"",e.project);c&&(e.project=c.name)}catch(c){S(c.message)}let s=j({project:e.project,text:e.issue_id});e.issue_id&&(e.issue_id=s.parseRef(e.issue_id)??e.issue_id);let n=Lt(o,e.issue_id?s.slug(e.issue_id):null);Ut.test(n)||S(`Workspace name '${n}' is not a valid slug (expected lowercase letters, digits, and single hyphens).`);let m=Pt(W.userInfo().username,n),a=f.join(gt(),n);if(l.existsSync(a))k(`Workspace already exists: ${a} \u2014 re-running init-workspace.`);else{te({...e}),yt();let c=await Bt(e.repos,e.services);e.repos=c.join(","),Gt(a,m,!!r.force),e.context_strategy||=ee[0],e.harness||=We[0],wt(a,e)}let d=await Zt(a,t,e,r);if(!d){let c=`werkmeister workspace init failed. The workspace root exists at ${a}; re-run \`werkmeister workspace init\` from there once resolved.`;throw g(c),new R(c)}return Ht(a,n),d.containers?(F(`
32
+ `),{containers:H}):(o.quietNoSlot||g(`Workspace initialised, but the container step did not run: no slot, so ${B} was not (re)generated (see the slot warning above). \`werkmeister feature up\` fails until you free a slot and rerun \`werkmeister workspace init\`.`),{containers:H})}i(Xt,"initWorkspace");async function Zt(e,r,o,t){k(`Running: werkmeister workspace init (feature: ${r})`);try{return await Xt({...o,feature:r,force:t.force},e,{...t,quietNoSlot:!0})}catch(s){return s instanceof R||V(`init-workspace failed: ${s.message}`),null}}i(Zt,"runInitWorkspace");async function Lr(e,r={}){let o=(e.feature??"").trim();o||S("A feature name is required (pass it as an argument, set it in ./.werkmeister/workspace.yml, or run interactively)."),ie(e.context_strategy),ne(e.harness);let t=o.toLowerCase();try{let c=Ie(e.issue_id??"",e.project);c&&(e.project=c.name)}catch(c){S(c.message)}let s=j({project:e.project,text:e.issue_id});e.issue_id&&(e.issue_id=s.parseRef(e.issue_id)??e.issue_id);let n=Lt(o,e.issue_id?s.slug(e.issue_id):null);Ut.test(n)||S(`Workspace name '${n}' is not a valid slug (expected lowercase letters, digits, and single hyphens).`);let m=Pt(W.userInfo().username,n),a=f.join(gt(),n);if(l.existsSync(a))k(`Workspace already exists: ${a} \u2014 re-running init-workspace.`);else{te({...e}),yt();let c=await Bt(e.repos,e.services);e.repos=c.join(","),Gt(a,m,!!r.force),e.context_strategy||=ee[0],e.harness||=We[0],wt(a,e)}let d=await Zt(a,t,e,r);if(!d){let c=`werkmeister workspace init failed. The workspace root exists at ${a}; re-run \`werkmeister workspace init\` from there once resolved.`;throw g(c),new R(c)}return Ht(a,n),d.containers?(F(`
33
33
  ${A.BOLD}Workspace ready.${A.RESET} cd ${a} and open a Claude Code session from there.
34
34
 
35
35
  `),a):(g(`Workspace created at ${a}, but its containers are not set up: it has no slot (see the slot warning above). Free a slot with \`werkmeister feature down <feature>\`, then run \`werkmeister workspace init\` there.`),a)}i(Lr,"provisionWorkspace");export{U as a,nt as b,R as c,de as d,wt as e,Xt as f,Lr as g};
36
- //# sourceMappingURL=chunk-YUSN6ATL.js.map
36
+ //# sourceMappingURL=chunk-2NRMSYNJ.js.map
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __sandboxCreateRequire } from "node:module";
2
2
  const require = __sandboxCreateRequire(import.meta.url);
3
- import{V as x}from"./chunk-YH36XQ4K.js";import{f as y,g as b,h as w}from"./chunk-XMMOB7QK.js";import{b as S}from"./chunk-O22TMXNP.js";import{a,f as h}from"./chunk-KPIXRVP2.js";h();import*as l from"node:fs";import*as m from"node:os";import*as d from"node:path";var M=10,j=2e3,A=5*6e4;function v(t){return d.join(S(t),"starts.json")}a(v,"startsFile");function D(t){try{let e=JSON.parse(l.readFileSync(v(t),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}a(D,"readStarts");function C(t,e,r,n=Date.now()){try{let s=v(t),o=[...D(t),{by:e,from:new Date(r).toISOString(),to:new Date(n).toISOString()}].slice(-M);l.mkdirSync(d.dirname(s),{recursive:!0}),l.writeFileSync(s,`${JSON.stringify(o,null,2)}
3
+ import{V as x}from"./chunk-6MDK2RR4.js";import{f as y,g as b,h as w}from"./chunk-4JNFHNTY.js";import{b as S}from"./chunk-SVMYDOF3.js";import{a,f as h}from"./chunk-UDLGGZXC.js";h();import*as l from"node:fs";import*as m from"node:os";import*as d from"node:path";var M=10,j=2e3,A=5*6e4;function v(t){return d.join(S(t),"starts.json")}a(v,"startsFile");function D(t){try{let e=JSON.parse(l.readFileSync(v(t),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}a(D,"readStarts");function C(t,e,r,n=Date.now()){try{let s=v(t),o=[...D(t),{by:e,from:new Date(r).toISOString(),to:new Date(n).toISOString()}].slice(-M);l.mkdirSync(d.dirname(s),{recursive:!0}),l.writeFileSync(s,`${JSON.stringify(o,null,2)}
4
4
  `)}catch{}}a(C,"recordStart");async function W(t,e,r){let n=Date.now();try{return await r()}finally{C(t,e,n)}}a(W,"withStartRecord");function O(t,e){for(let r=e.length-1;r>=0;r--){let n=e[r];if(t>=Date.parse(n.from)-j&&t<=Date.parse(n.to)+j)return n.by}return"person"}a(O,"startedBy");function L(t,e,r){return t.state==="restarting"?!0:!e||e.restartCount===0?!1:t.state!=="running"||r-e.startedAt<A}a(L,"isCrashLoop");function P(t){return t.state==="running"||t.state==="restarting"||t.state==="exited"&&t.exitCode!==0}a(P,"worthInspecting");function k(t,e,r,n){let s=new Map,o=new Map;for(let c of t){let i=c.labels["com.docker.compose.project"];if(!i)continue;let f=s.get(i)??{started:null,crashLoops:[]};s.set(i,f);let u=e.get(c.name);if(L(c,u,n)&&f.crashLoops.push({service:c.service,restarts:u?.restartCount??0,lastLog:null}),c.state!=="running"||!u||Number.isNaN(u.startedAt))continue;let g=o.get(i);(!g||u.startedAt<g.at)&&o.set(i,{at:u.startedAt,workingDir:c.labels["com.docker.compose.project.working_dir"]??""})}for(let[c,{at:i,workingDir:f}]of o){let u=s.get(c);u.started={at:new Date(i).toISOString(),by:f?O(i,r(f)):"person"}}for(let c of s.values())c.crashLoops.sort((i,f)=>i.service.localeCompare(f.service));return s}a(k,"healthOf");async function B(t,e=Date.now()){let r=t.filter(P),n=await b(r.map(o=>o.name)),s=k(r,n,D,e);return await Promise.all(r.filter(o=>L(o,n.get(o.name),e)).map(async o=>{let c=s.get(o.labels["com.docker.compose.project"])?.crashLoops.find(i=>i.service===o.service&&i.lastLog===null);c&&(c.lastLog=await w(o.name,n.get(o.name)?.tty??!1))})),s}a(B,"projectHealth");var p=a(t=>Math.round(t*10)/10,"round1");function _(t){let e={};for(let r of t){let n=r.labels["com.docker.compose.project"];if(!n)continue;let s=e[n]??={cpuPercent:0,memMib:0};s.cpuPercent+=r.cpuPercent,s.memMib+=r.memMib}for(let r of Object.values(e))r.cpuPercent=p(r.cpuPercent),r.memMib=Math.round(r.memMib);return e}a(_,"usageByProject");function N(t,e=m.loadavg(),r=m.availableParallelism()){let n=t.filter(s=>{let o=x(s.labels,"feature");return o&&o!=="infra"});return{load:[p(e[0]),p(e[1]),p(e[2])],cores:r,featureCpuPercent:p(n.reduce((s,o)=>s+o.cpuPercent,0))}}a(N,"hostSummary");function H(t,e){let[r,n,s]=t.map(o=>p(o).toFixed(1));return`host load ${r} / ${n} / ${s} (1, 5, 15 min) on ${e} cores`}a(H,"loadNote");async function J(t=2e4){let e=await y(AbortSignal.timeout(t));return{projects:_(e),host:N(e)}}a(J,"getWorkspaceResources");export{W as a,B as b,H as c,J as d};
5
- //# sourceMappingURL=chunk-VU3APKHW.js.map
5
+ //# sourceMappingURL=chunk-3ZLSFIVT.js.map