@mesh-tech/mesh-cli 0.1.1 → 0.12.0

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 (504) hide show
  1. package/assets/intent/agents-fence.md +10 -0
  2. package/assets/intent/intent-claude-gate.mjs +255 -0
  3. package/assets/log-shipper.mjs +94 -0
  4. package/bin/mesh.mjs +80 -0
  5. package/dist/bin/mesh.d.ts +7 -9
  6. package/dist/bin/mesh.d.ts.map +1 -1
  7. package/dist/bin/mesh.js +20826 -37
  8. package/dist/bin/mesh.js.map +7 -1
  9. package/dist/build-info.json +4 -0
  10. package/dist/src/commands/agent-api-client.d.ts +79 -0
  11. package/dist/src/commands/agent-api-client.d.ts.map +1 -0
  12. package/dist/src/commands/agent-api-client.js +170 -0
  13. package/dist/src/commands/agent-api-client.js.map +1 -0
  14. package/dist/src/commands/artifacts.d.ts +13 -0
  15. package/dist/src/commands/artifacts.d.ts.map +1 -0
  16. package/dist/src/commands/artifacts.js +140 -0
  17. package/dist/src/commands/artifacts.js.map +1 -0
  18. package/dist/src/commands/cluster.d.ts +45 -0
  19. package/dist/src/commands/cluster.d.ts.map +1 -0
  20. package/dist/src/commands/cluster.js +259 -0
  21. package/dist/src/commands/cluster.js.map +1 -0
  22. package/dist/src/commands/conversations.d.ts +61 -0
  23. package/dist/src/commands/conversations.d.ts.map +1 -0
  24. package/dist/src/commands/conversations.js +239 -0
  25. package/dist/src/commands/conversations.js.map +1 -0
  26. package/dist/src/commands/create-app.d.ts +26 -3
  27. package/dist/src/commands/create-app.d.ts.map +1 -1
  28. package/dist/src/commands/create-app.js +465 -107
  29. package/dist/src/commands/create-app.js.map +1 -1
  30. package/dist/src/commands/deploy.d.ts +19 -0
  31. package/dist/src/commands/deploy.d.ts.map +1 -1
  32. package/dist/src/commands/deploy.js +83 -142
  33. package/dist/src/commands/deploy.js.map +1 -1
  34. package/dist/src/commands/dev-doctor.d.ts +137 -0
  35. package/dist/src/commands/dev-doctor.d.ts.map +1 -0
  36. package/dist/src/commands/dev-doctor.js +671 -0
  37. package/dist/src/commands/dev-doctor.js.map +1 -0
  38. package/dist/src/commands/dev-launch.d.ts +59 -0
  39. package/dist/src/commands/dev-launch.d.ts.map +1 -0
  40. package/dist/src/commands/dev-launch.js +118 -0
  41. package/dist/src/commands/dev-launch.js.map +1 -0
  42. package/dist/src/commands/dev-token-server.d.ts +32 -0
  43. package/dist/src/commands/dev-token-server.d.ts.map +1 -0
  44. package/dist/src/commands/dev-token-server.js +68 -0
  45. package/dist/src/commands/dev-token-server.js.map +1 -0
  46. package/dist/src/commands/dev.d.ts +289 -2
  47. package/dist/src/commands/dev.d.ts.map +1 -1
  48. package/dist/src/commands/dev.js +2501 -574
  49. package/dist/src/commands/dev.js.map +1 -1
  50. package/dist/src/commands/docs.d.ts +3 -0
  51. package/dist/src/commands/docs.d.ts.map +1 -0
  52. package/dist/src/commands/docs.js +262 -0
  53. package/dist/src/commands/docs.js.map +1 -0
  54. package/dist/src/commands/hub/index.d.ts +99 -0
  55. package/dist/src/commands/hub/index.d.ts.map +1 -0
  56. package/dist/src/commands/hub/index.js +452 -0
  57. package/dist/src/commands/hub/index.js.map +1 -0
  58. package/dist/src/commands/init.d.ts +65 -0
  59. package/dist/src/commands/init.d.ts.map +1 -0
  60. package/dist/src/commands/init.js +370 -0
  61. package/dist/src/commands/init.js.map +1 -0
  62. package/dist/src/commands/install-shim.d.ts +21 -0
  63. package/dist/src/commands/install-shim.d.ts.map +1 -0
  64. package/dist/src/commands/install-shim.js +132 -0
  65. package/dist/src/commands/install-shim.js.map +1 -0
  66. package/dist/src/commands/local/auth-provision.d.ts +71 -0
  67. package/dist/src/commands/local/auth-provision.d.ts.map +1 -0
  68. package/dist/src/commands/local/auth-provision.js +286 -0
  69. package/dist/src/commands/local/auth-provision.js.map +1 -0
  70. package/dist/src/commands/local/dev-local.d.ts +97 -0
  71. package/dist/src/commands/local/dev-local.d.ts.map +1 -0
  72. package/dist/src/commands/local/dev-local.js +306 -0
  73. package/dist/src/commands/local/dev-local.js.map +1 -0
  74. package/dist/src/commands/local/docker-runner.d.ts +37 -0
  75. package/dist/src/commands/local/docker-runner.d.ts.map +1 -0
  76. package/dist/src/commands/local/docker-runner.js +104 -0
  77. package/dist/src/commands/local/docker-runner.js.map +1 -0
  78. package/dist/src/commands/local/helpers.d.ts +22 -0
  79. package/dist/src/commands/local/helpers.d.ts.map +1 -0
  80. package/dist/src/commands/local/helpers.js +46 -0
  81. package/dist/src/commands/local/helpers.js.map +1 -0
  82. package/dist/src/commands/local/hub-local.d.ts +51 -0
  83. package/dist/src/commands/local/hub-local.d.ts.map +1 -0
  84. package/dist/src/commands/local/hub-local.js +197 -0
  85. package/dist/src/commands/local/hub-local.js.map +1 -0
  86. package/dist/src/commands/local/index.d.ts +23 -0
  87. package/dist/src/commands/local/index.d.ts.map +1 -0
  88. package/dist/src/commands/local/index.js +386 -0
  89. package/dist/src/commands/local/index.js.map +1 -0
  90. package/dist/src/commands/local/mocks.d.ts +361 -0
  91. package/dist/src/commands/local/mocks.d.ts.map +1 -0
  92. package/dist/src/commands/local/mocks.js +756 -0
  93. package/dist/src/commands/local/mocks.js.map +1 -0
  94. package/dist/src/commands/local/seed-zitadel.d.ts +151 -0
  95. package/dist/src/commands/local/seed-zitadel.d.ts.map +1 -0
  96. package/dist/src/commands/local/seed-zitadel.js +408 -0
  97. package/dist/src/commands/local/seed-zitadel.js.map +1 -0
  98. package/dist/src/commands/local/seed.d.ts +106 -0
  99. package/dist/src/commands/local/seed.d.ts.map +1 -0
  100. package/dist/src/commands/local/seed.js +252 -0
  101. package/dist/src/commands/local/seed.js.map +1 -0
  102. package/dist/src/commands/local/stack.d.ts +173 -0
  103. package/dist/src/commands/local/stack.d.ts.map +1 -0
  104. package/dist/src/commands/local/stack.js +499 -0
  105. package/dist/src/commands/local/stack.js.map +1 -0
  106. package/dist/src/commands/login.d.ts +256 -12
  107. package/dist/src/commands/login.d.ts.map +1 -1
  108. package/dist/src/commands/login.js +978 -50
  109. package/dist/src/commands/login.js.map +1 -1
  110. package/dist/src/commands/peer-addressing.d.ts +51 -0
  111. package/dist/src/commands/peer-addressing.d.ts.map +1 -0
  112. package/dist/src/commands/peer-addressing.js +64 -0
  113. package/dist/src/commands/peer-addressing.js.map +1 -0
  114. package/dist/src/commands/port-ownership.d.ts +69 -0
  115. package/dist/src/commands/port-ownership.d.ts.map +1 -0
  116. package/dist/src/commands/port-ownership.js +161 -0
  117. package/dist/src/commands/port-ownership.js.map +1 -0
  118. package/dist/src/commands/registry-publish.d.ts +3 -0
  119. package/dist/src/commands/registry-publish.d.ts.map +1 -0
  120. package/dist/src/commands/registry-publish.js +161 -0
  121. package/dist/src/commands/registry-publish.js.map +1 -0
  122. package/dist/src/commands/registry.d.ts +146 -2
  123. package/dist/src/commands/registry.d.ts.map +1 -1
  124. package/dist/src/commands/registry.js +541 -85
  125. package/dist/src/commands/registry.js.map +1 -1
  126. package/dist/src/commands/secrets/index.d.ts.map +1 -1
  127. package/dist/src/commands/secrets/index.js +15 -1
  128. package/dist/src/commands/secrets/index.js.map +1 -1
  129. package/dist/src/commands/secrets/migrate-config.d.ts +24 -0
  130. package/dist/src/commands/secrets/migrate-config.d.ts.map +1 -0
  131. package/dist/src/commands/secrets/migrate-config.js +277 -0
  132. package/dist/src/commands/secrets/migrate-config.js.map +1 -0
  133. package/dist/src/commands/secrets/set.d.ts +1 -0
  134. package/dist/src/commands/secrets/set.d.ts.map +1 -1
  135. package/dist/src/commands/secrets/set.js +96 -2
  136. package/dist/src/commands/secrets/set.js.map +1 -1
  137. package/dist/src/commands/skills.d.ts +34 -0
  138. package/dist/src/commands/skills.d.ts.map +1 -0
  139. package/dist/src/commands/skills.js +207 -0
  140. package/dist/src/commands/skills.js.map +1 -0
  141. package/dist/src/commands/stack.d.ts.map +1 -1
  142. package/dist/src/commands/stack.js +361 -23
  143. package/dist/src/commands/stack.js.map +1 -1
  144. package/dist/src/commands/temporal.d.ts +15 -0
  145. package/dist/src/commands/temporal.d.ts.map +1 -0
  146. package/dist/src/commands/temporal.js +781 -0
  147. package/dist/src/commands/temporal.js.map +1 -0
  148. package/dist/src/commands/tenant.d.ts +56 -0
  149. package/dist/src/commands/tenant.d.ts.map +1 -0
  150. package/dist/src/commands/tenant.js +233 -0
  151. package/dist/src/commands/tenant.js.map +1 -0
  152. package/dist/src/commands/tunnel/index.d.ts +49 -3
  153. package/dist/src/commands/tunnel/index.d.ts.map +1 -1
  154. package/dist/src/commands/tunnel/index.js +331 -8
  155. package/dist/src/commands/tunnel/index.js.map +1 -1
  156. package/dist/src/commands/vcs/clone.d.ts +3 -0
  157. package/dist/src/commands/vcs/clone.d.ts.map +1 -0
  158. package/dist/src/commands/vcs/clone.js +20 -0
  159. package/dist/src/commands/vcs/clone.js.map +1 -0
  160. package/dist/src/commands/vcs/common.d.ts +21 -0
  161. package/dist/src/commands/vcs/common.d.ts.map +1 -0
  162. package/dist/src/commands/vcs/common.js +62 -0
  163. package/dist/src/commands/vcs/common.js.map +1 -0
  164. package/dist/src/commands/vcs/drafts.d.ts +13 -0
  165. package/dist/src/commands/vcs/drafts.d.ts.map +1 -0
  166. package/dist/src/commands/vcs/drafts.js +45 -0
  167. package/dist/src/commands/vcs/drafts.js.map +1 -0
  168. package/dist/src/commands/vcs/get.d.ts +8 -0
  169. package/dist/src/commands/vcs/get.d.ts.map +1 -0
  170. package/dist/src/commands/vcs/get.js +61 -0
  171. package/dist/src/commands/vcs/get.js.map +1 -0
  172. package/dist/src/commands/vcs/index.d.ts +3 -0
  173. package/dist/src/commands/vcs/index.d.ts.map +1 -0
  174. package/dist/src/commands/vcs/index.js +58 -0
  175. package/dist/src/commands/vcs/index.js.map +1 -0
  176. package/dist/src/commands/vcs/propose.d.ts +23 -0
  177. package/dist/src/commands/vcs/propose.d.ts.map +1 -0
  178. package/dist/src/commands/vcs/propose.js +94 -0
  179. package/dist/src/commands/vcs/propose.js.map +1 -0
  180. package/dist/src/commands/vcs/review.d.ts +15 -0
  181. package/dist/src/commands/vcs/review.d.ts.map +1 -0
  182. package/dist/src/commands/vcs/review.js +35 -0
  183. package/dist/src/commands/vcs/review.js.map +1 -0
  184. package/dist/src/commands/vcs-enrich.d.ts +15 -0
  185. package/dist/src/commands/vcs-enrich.d.ts.map +1 -0
  186. package/dist/src/commands/vcs-enrich.js +28 -0
  187. package/dist/src/commands/vcs-enrich.js.map +1 -0
  188. package/dist/src/commands/vpn/index.d.ts +24 -0
  189. package/dist/src/commands/vpn/index.d.ts.map +1 -0
  190. package/dist/src/commands/vpn/index.js +543 -0
  191. package/dist/src/commands/vpn/index.js.map +1 -0
  192. package/dist/src/commands/vpn/tunnel.d.ts +11 -0
  193. package/dist/src/commands/vpn/tunnel.d.ts.map +1 -0
  194. package/dist/src/commands/vpn/tunnel.js +188 -0
  195. package/dist/src/commands/vpn/tunnel.js.map +1 -0
  196. package/dist/src/commands/workflow.d.ts +24 -0
  197. package/dist/src/commands/workflow.d.ts.map +1 -0
  198. package/dist/src/commands/workflow.js +577 -0
  199. package/dist/src/commands/workflow.js.map +1 -0
  200. package/dist/src/docs/assemble.d.ts +217 -0
  201. package/dist/src/docs/assemble.d.ts.map +1 -0
  202. package/dist/src/docs/assemble.js +739 -0
  203. package/dist/src/docs/assemble.js.map +1 -0
  204. package/dist/src/docs/cli-reference.d.ts +93 -0
  205. package/dist/src/docs/cli-reference.d.ts.map +1 -0
  206. package/dist/src/docs/cli-reference.js +256 -0
  207. package/dist/src/docs/cli-reference.js.map +1 -0
  208. package/dist/src/docs/discover.d.ts +60 -0
  209. package/dist/src/docs/discover.d.ts.map +1 -0
  210. package/dist/src/docs/discover.js +233 -0
  211. package/dist/src/docs/discover.js.map +1 -0
  212. package/dist/src/docs/portal.d.ts +79 -0
  213. package/dist/src/docs/portal.d.ts.map +1 -0
  214. package/dist/src/docs/portal.js +242 -0
  215. package/dist/src/docs/portal.js.map +1 -0
  216. package/dist/src/docs/registry-docs.d.ts +43 -0
  217. package/dist/src/docs/registry-docs.d.ts.map +1 -0
  218. package/dist/src/docs/registry-docs.js +138 -0
  219. package/dist/src/docs/registry-docs.js.map +1 -0
  220. package/dist/src/docs/schema.d.ts +48 -0
  221. package/dist/src/docs/schema.d.ts.map +1 -0
  222. package/dist/src/docs/schema.js +96 -0
  223. package/dist/src/docs/schema.js.map +1 -0
  224. package/dist/src/docs/serve.d.ts +27 -0
  225. package/dist/src/docs/serve.d.ts.map +1 -0
  226. package/dist/src/docs/serve.js +102 -0
  227. package/dist/src/docs/serve.js.map +1 -0
  228. package/dist/src/docs/start.d.ts +80 -0
  229. package/dist/src/docs/start.d.ts.map +1 -0
  230. package/dist/src/docs/start.js +313 -0
  231. package/dist/src/docs/start.js.map +1 -0
  232. package/dist/src/eval/agent-eval.d.mts +14 -0
  233. package/dist/src/eval/agent-eval.d.mts.map +1 -0
  234. package/dist/src/eval/agent-eval.mjs +273 -0
  235. package/dist/src/eval/agent-eval.mjs.map +1 -0
  236. package/dist/src/index.js +624 -7
  237. package/dist/src/index.js.map +7 -1
  238. package/dist/src/program.d.ts +26 -0
  239. package/dist/src/program.d.ts.map +1 -0
  240. package/dist/src/program.js +76 -0
  241. package/dist/src/program.js.map +1 -0
  242. package/dist/src/utils/auth-preflight.d.ts +159 -0
  243. package/dist/src/utils/auth-preflight.d.ts.map +1 -0
  244. package/dist/src/utils/auth-preflight.js +298 -0
  245. package/dist/src/utils/auth-preflight.js.map +1 -0
  246. package/dist/src/utils/aws-auth.d.ts +181 -0
  247. package/dist/src/utils/aws-auth.d.ts.map +1 -0
  248. package/dist/src/utils/aws-auth.js +527 -0
  249. package/dist/src/utils/aws-auth.js.map +1 -0
  250. package/dist/src/utils/bastion.d.ts +1 -1
  251. package/dist/src/utils/bastion.d.ts.map +1 -1
  252. package/dist/src/utils/bastion.js +29 -8
  253. package/dist/src/utils/bastion.js.map +1 -1
  254. package/dist/src/utils/build-info.d.ts +33 -0
  255. package/dist/src/utils/build-info.d.ts.map +1 -0
  256. package/dist/src/utils/build-info.js +102 -0
  257. package/dist/src/utils/build-info.js.map +1 -0
  258. package/dist/src/utils/capture-history.d.ts +62 -0
  259. package/dist/src/utils/capture-history.d.ts.map +1 -0
  260. package/dist/src/utils/capture-history.js +94 -0
  261. package/dist/src/utils/capture-history.js.map +1 -0
  262. package/dist/src/utils/deploy-preflight.d.ts +52 -0
  263. package/dist/src/utils/deploy-preflight.d.ts.map +1 -0
  264. package/dist/src/utils/deploy-preflight.js +183 -0
  265. package/dist/src/utils/deploy-preflight.js.map +1 -0
  266. package/dist/src/utils/errors.d.ts +75 -0
  267. package/dist/src/utils/errors.d.ts.map +1 -0
  268. package/dist/src/utils/errors.js +106 -0
  269. package/dist/src/utils/errors.js.map +1 -0
  270. package/dist/src/utils/first-party-contexts.d.ts +40 -0
  271. package/dist/src/utils/first-party-contexts.d.ts.map +1 -0
  272. package/dist/src/utils/first-party-contexts.js +53 -0
  273. package/dist/src/utils/first-party-contexts.js.map +1 -0
  274. package/dist/src/utils/index.d.ts +2 -0
  275. package/dist/src/utils/index.d.ts.map +1 -1
  276. package/dist/src/utils/index.js +2 -0
  277. package/dist/src/utils/index.js.map +1 -1
  278. package/dist/src/utils/kubeconfig.d.ts +62 -0
  279. package/dist/src/utils/kubeconfig.d.ts.map +1 -0
  280. package/dist/src/utils/kubeconfig.js +118 -0
  281. package/dist/src/utils/kubeconfig.js.map +1 -0
  282. package/dist/src/utils/log.d.ts +27 -1
  283. package/dist/src/utils/log.d.ts.map +1 -1
  284. package/dist/src/utils/log.js +59 -5
  285. package/dist/src/utils/log.js.map +1 -1
  286. package/dist/src/utils/pid.d.ts +47 -0
  287. package/dist/src/utils/pid.d.ts.map +1 -0
  288. package/dist/src/utils/pid.js +83 -0
  289. package/dist/src/utils/pid.js.map +1 -0
  290. package/dist/src/utils/pulumi-run.d.ts +23 -0
  291. package/dist/src/utils/pulumi-run.d.ts.map +1 -0
  292. package/dist/src/utils/pulumi-run.js +112 -0
  293. package/dist/src/utils/pulumi-run.js.map +1 -0
  294. package/dist/src/utils/pulumi.d.ts +15 -0
  295. package/dist/src/utils/pulumi.d.ts.map +1 -1
  296. package/dist/src/utils/pulumi.js +35 -0
  297. package/dist/src/utils/pulumi.js.map +1 -1
  298. package/dist/src/utils/reachability.d.ts +29 -0
  299. package/dist/src/utils/reachability.d.ts.map +1 -0
  300. package/dist/src/utils/reachability.js +81 -0
  301. package/dist/src/utils/reachability.js.map +1 -0
  302. package/dist/src/utils/recover-conversation.d.ts +154 -0
  303. package/dist/src/utils/recover-conversation.d.ts.map +1 -0
  304. package/dist/src/utils/recover-conversation.js +314 -0
  305. package/dist/src/utils/recover-conversation.js.map +1 -0
  306. package/dist/src/utils/registry-broker.d.ts +148 -0
  307. package/dist/src/utils/registry-broker.d.ts.map +1 -0
  308. package/dist/src/utils/registry-broker.js +180 -0
  309. package/dist/src/utils/registry-broker.js.map +1 -0
  310. package/dist/src/utils/socks-forward.d.ts +40 -0
  311. package/dist/src/utils/socks-forward.d.ts.map +1 -0
  312. package/dist/src/utils/socks-forward.js +97 -0
  313. package/dist/src/utils/socks-forward.js.map +1 -0
  314. package/dist/src/utils/stack-flag.d.ts +23 -0
  315. package/dist/src/utils/stack-flag.d.ts.map +1 -0
  316. package/dist/src/utils/stack-flag.js +41 -0
  317. package/dist/src/utils/stack-flag.js.map +1 -0
  318. package/dist/src/utils/tailscale-targets.d.ts +52 -0
  319. package/dist/src/utils/tailscale-targets.d.ts.map +1 -0
  320. package/dist/src/utils/tailscale-targets.js +93 -0
  321. package/dist/src/utils/tailscale-targets.js.map +1 -0
  322. package/dist/src/utils/tailscale.d.ts +277 -0
  323. package/dist/src/utils/tailscale.d.ts.map +1 -0
  324. package/dist/src/utils/tailscale.js +1007 -0
  325. package/dist/src/utils/tailscale.js.map +1 -0
  326. package/dist/src/utils/temporal-auth.d.ts +43 -0
  327. package/dist/src/utils/temporal-auth.d.ts.map +1 -0
  328. package/dist/src/utils/temporal-auth.js +176 -0
  329. package/dist/src/utils/temporal-auth.js.map +1 -0
  330. package/dist/src/utils/temporal-codec.d.ts +101 -0
  331. package/dist/src/utils/temporal-codec.d.ts.map +1 -0
  332. package/dist/src/utils/temporal-codec.js +319 -0
  333. package/dist/src/utils/temporal-codec.js.map +1 -0
  334. package/dist/src/utils/tunnel-ownership.d.ts +130 -0
  335. package/dist/src/utils/tunnel-ownership.d.ts.map +1 -0
  336. package/dist/src/utils/tunnel-ownership.js +274 -0
  337. package/dist/src/utils/tunnel-ownership.js.map +1 -0
  338. package/dist/src/utils/vpn-join.d.ts +32 -0
  339. package/dist/src/utils/vpn-join.d.ts.map +1 -0
  340. package/dist/src/utils/vpn-join.js +62 -0
  341. package/dist/src/utils/vpn-join.js.map +1 -0
  342. package/dist/src/utils/vpn.d.ts +62 -0
  343. package/dist/src/utils/vpn.d.ts.map +1 -0
  344. package/dist/src/utils/vpn.js +183 -0
  345. package/dist/src/utils/vpn.js.map +1 -0
  346. package/dist/src/utils/workflow-fingerprint.d.ts +49 -0
  347. package/dist/src/utils/workflow-fingerprint.d.ts.map +1 -0
  348. package/dist/src/utils/workflow-fingerprint.js +135 -0
  349. package/dist/src/utils/workflow-fingerprint.js.map +1 -0
  350. package/dist/src/utils/worktree-identity.d.ts +86 -0
  351. package/dist/src/utils/worktree-identity.d.ts.map +1 -0
  352. package/dist/src/utils/worktree-identity.js +164 -0
  353. package/dist/src/utils/worktree-identity.js.map +1 -0
  354. package/fragments/agents/AGENTS.md.hbs +92 -0
  355. package/fragments/agents/CLAUDE.md.hbs +8 -0
  356. package/fragments/base/Pulumi.dev.yaml.hbs +10 -0
  357. package/fragments/base/Pulumi.yaml.hbs +9 -0
  358. package/fragments/base/index.ts.hbs +107 -0
  359. package/fragments/base/package.json.hbs +22 -0
  360. package/{templates/api-web-db/api → fragments/base}/tsconfig.json +3 -4
  361. package/fragments/bucket/api/src/storage.ts.hbs +81 -0
  362. package/fragments/database/api/src/db.ts.hbs +23 -0
  363. package/fragments/database/prisma/schema.prisma.hbs +18 -0
  364. package/{templates/api-web-db → fragments/service}/api/.dockerignore +2 -0
  365. package/fragments/service/api/package.json.hbs +40 -0
  366. package/fragments/service/api/src/index.ts.hbs +58 -0
  367. package/{templates/api-web-db → fragments/service/api}/tsconfig.json +5 -3
  368. package/fragments/temporal/worker/.dockerignore +4 -0
  369. package/fragments/temporal/worker/Dockerfile +15 -0
  370. package/{templates/temporal-api-worker → fragments/temporal}/worker/package.json.hbs +3 -2
  371. package/fragments/temporal/worker/src/activities.ts.hbs +14 -0
  372. package/fragments/temporal/worker/src/worker.ts.hbs +27 -0
  373. package/fragments/temporal/worker/src/workflows.ts.hbs +24 -0
  374. package/fragments/temporal/worker/tsconfig.json +13 -0
  375. package/package.json +36 -22
  376. package/skills/core/SKILL.md +365 -0
  377. package/skills/pull-remote-agent-context/SKILL.md +194 -0
  378. package/stack/docker-compose.hub.yml +134 -0
  379. package/stack/docker-compose.yml +447 -0
  380. package/stack/hub/Dockerfile.api +18 -0
  381. package/stack/hub/Dockerfile.auth +10 -0
  382. package/stack/hub/Dockerfile.ui +10 -0
  383. package/stack/init/01-databases.sql +12 -0
  384. package/stack/observability/blackbox.yml +20 -0
  385. package/stack/observability/otel-collector.yaml +73 -0
  386. package/stack/observability/prometheus.yml +36 -0
  387. package/stack/observability/tempo.yaml +25 -0
  388. package/stack/temporal/local.yaml +44 -0
  389. package/templates/api-auth/AGENTS.md.hbs +16 -0
  390. package/templates/api-auth/Pulumi.dev.yaml.hbs +8 -0
  391. package/templates/api-auth/Pulumi.yaml.hbs +8 -0
  392. package/templates/api-auth/README.md.hbs +67 -0
  393. package/templates/api-auth/api/package.json.hbs +28 -0
  394. package/templates/api-auth/api/src/index.ts.hbs +96 -0
  395. package/templates/api-auth/api/src/schema.ts.hbs +35 -0
  396. package/templates/api-auth/api/src/seed-authz.ts.hbs +48 -0
  397. package/templates/api-auth/api/src/spicedb-http-provider.ts.hbs +89 -0
  398. package/templates/api-auth/index.ts.hbs +65 -0
  399. package/templates/api-auth/package.json.hbs +20 -0
  400. package/templates/api-auth/skills/develop/SKILL.md.hbs +32 -0
  401. package/templates/api-role-gating/AGENTS.md.hbs +20 -0
  402. package/templates/api-role-gating/Pulumi.dev.yaml.hbs +8 -0
  403. package/templates/api-role-gating/Pulumi.yaml.hbs +8 -0
  404. package/templates/api-role-gating/README.md.hbs +64 -0
  405. package/templates/api-role-gating/api/Dockerfile +17 -0
  406. package/templates/api-role-gating/api/package.json.hbs +28 -0
  407. package/templates/api-role-gating/api/src/authn.ts.hbs +29 -0
  408. package/templates/api-role-gating/api/src/authz.ts.hbs +12 -0
  409. package/templates/api-role-gating/api/src/main.ts.hbs +58 -0
  410. package/templates/api-role-gating/api/src/schema.ts.hbs +22 -0
  411. package/templates/api-role-gating/api/tsconfig.json +13 -0
  412. package/templates/api-role-gating/index.ts.hbs +107 -0
  413. package/templates/api-role-gating/package.json.hbs +21 -0
  414. package/templates/api-role-gating/skills/develop/SKILL.md.hbs +60 -0
  415. package/templates/api-role-gating/tsconfig.json +10 -0
  416. package/templates/apps-repo/README.md.hbs +24 -0
  417. package/templates/apps-repo/gitignore +41 -0
  418. package/templates/apps-repo/npmrc.hbs +7 -0
  419. package/templates/apps-repo/package.json.hbs +15 -0
  420. package/templates/apps-repo/pnpm-workspace.yaml +3 -0
  421. package/templates/apps-repo/tsconfig.json +18 -0
  422. package/templates/external-service/AGENTS.md.hbs +20 -0
  423. package/templates/external-service/Pulumi.dev.yaml.hbs +8 -0
  424. package/templates/external-service/Pulumi.yaml.hbs +8 -0
  425. package/templates/external-service/README.md.hbs +56 -0
  426. package/templates/external-service/api/Dockerfile +15 -0
  427. package/templates/external-service/api/package.json.hbs +25 -0
  428. package/templates/external-service/api/src/index.ts.hbs +81 -0
  429. package/templates/external-service/index.ts.hbs +82 -0
  430. package/templates/external-service/mocks/vendorpay/package.json.hbs +9 -0
  431. package/templates/external-service/mocks/vendorpay/server.mjs.hbs +61 -0
  432. package/templates/external-service/package.json.hbs +34 -0
  433. package/templates/external-service/skills/develop/SKILL.md.hbs +55 -0
  434. package/templates/external-service/tsconfig.json +10 -0
  435. package/templates/platform-repo/AGENTS.md.hbs +18 -0
  436. package/templates/platform-repo/README.md.hbs +38 -0
  437. package/templates/platform-repo/core/Pulumi.yaml.hbs +12 -0
  438. package/templates/platform-repo/core/Pulumi.{{tenant}}-{{env}}.yaml.hbs +57 -0
  439. package/templates/platform-repo/core/index.ts +62 -0
  440. package/templates/platform-repo/core/package.json.hbs +22 -0
  441. package/templates/platform-repo/core/tsconfig.json +8 -0
  442. package/templates/platform-repo/package.json.hbs +15 -0
  443. package/templates/platform-repo/platform/Pulumi.yaml.hbs +12 -0
  444. package/templates/platform-repo/platform/Pulumi.{{tenant}}-{{env}}.yaml.hbs +59 -0
  445. package/templates/platform-repo/platform/index.ts +95 -0
  446. package/templates/platform-repo/platform/package.json.hbs +26 -0
  447. package/templates/platform-repo/platform/tsconfig.json +8 -0
  448. package/templates/platform-repo/pnpm-workspace.yaml +3 -0
  449. package/templates/workflow/AGENTS.md.hbs +15 -0
  450. package/templates/workflow/Pulumi.dev.yaml.hbs +8 -0
  451. package/templates/workflow/Pulumi.yaml.hbs +8 -0
  452. package/templates/workflow/README.md.hbs +45 -0
  453. package/templates/workflow/api/.dockerignore +4 -0
  454. package/templates/workflow/api/Dockerfile +15 -0
  455. package/templates/{temporal-api-worker → workflow}/api/package.json.hbs +8 -6
  456. package/templates/workflow/api/src/index.ts.hbs +130 -0
  457. package/templates/workflow/api/tsconfig.json +14 -0
  458. package/templates/workflow/index.ts.hbs +67 -0
  459. package/templates/workflow/package.json.hbs +20 -0
  460. package/templates/workflow/skills/develop/SKILL.md.hbs +32 -0
  461. package/templates/workflow/tsconfig.json +10 -0
  462. package/templates/workflow/worker/.dockerignore +4 -0
  463. package/templates/workflow/worker/Dockerfile +13 -0
  464. package/templates/workflow/worker/package.json.hbs +25 -0
  465. package/templates/workflow/worker/src/worker.ts.hbs +24 -0
  466. package/templates/workflow/worker/tsconfig.json +14 -0
  467. package/dist/src/commands/devbox.d.ts +0 -22
  468. package/dist/src/commands/devbox.d.ts.map +0 -1
  469. package/dist/src/commands/devbox.js +0 -463
  470. package/dist/src/commands/devbox.js.map +0 -1
  471. package/templates/api-web-db/api/Dockerfile +0 -16
  472. package/templates/api-web-db/api/package.json.hbs +0 -21
  473. package/templates/api-web-db/api/src/index.ts.hbs +0 -123
  474. package/templates/api-web-db/package.json.hbs +0 -27
  475. package/templates/api-web-db/sst.config.ts.hbs +0 -151
  476. package/templates/api-web-db/web/.dockerignore +0 -3
  477. package/templates/api-web-db/web/Dockerfile +0 -17
  478. package/templates/api-web-db/web/app/lib/db.server.ts +0 -36
  479. package/templates/api-web-db/web/app/root.tsx +0 -29
  480. package/templates/api-web-db/web/app/routes/home.tsx.hbs +0 -114
  481. package/templates/api-web-db/web/app/routes.ts +0 -3
  482. package/templates/api-web-db/web/package.json.hbs +0 -30
  483. package/templates/api-web-db/web/prisma/schema.prisma +0 -25
  484. package/templates/api-web-db/web/prisma.config.ts +0 -18
  485. package/templates/api-web-db/web/react-router.config.ts +0 -5
  486. package/templates/api-web-db/web/tsconfig.json +0 -19
  487. package/templates/api-web-db/web/vite.config.ts +0 -9
  488. package/templates/temporal-api-worker/README.md.hbs +0 -133
  489. package/templates/temporal-api-worker/api/src/index.ts.hbs +0 -145
  490. package/templates/temporal-api-worker/package.json.hbs +0 -29
  491. package/templates/temporal-api-worker/sst.config.ts.hbs +0 -161
  492. package/templates/temporal-api-worker/worker/Dockerfile +0 -11
  493. package/templates/temporal-api-worker/worker/src/bundle-workflows.ts +0 -38
  494. package/templates/temporal-api-worker/worker/src/worker.ts.hbs +0 -93
  495. /package/templates/{temporal-api-worker → api-auth}/api/.dockerignore +0 -0
  496. /package/templates/{temporal-api-worker → api-auth}/api/Dockerfile +0 -0
  497. /package/templates/{temporal-api-worker → api-auth}/api/tsconfig.json +0 -0
  498. /package/templates/{temporal-api-worker → api-auth}/tsconfig.json +0 -0
  499. /package/templates/{temporal-api-worker/worker → api-role-gating/api}/.dockerignore +0 -0
  500. /package/templates/{temporal-api-worker/worker → external-service/api}/tsconfig.json +0 -0
  501. /package/templates/{temporal-api-worker → workflow}/api/src/encryption-codec.ts +0 -0
  502. /package/templates/{temporal-api-worker → workflow}/worker/src/activities.ts.hbs +0 -0
  503. /package/templates/{temporal-api-worker → workflow}/worker/src/encryption-codec.ts +0 -0
  504. /package/templates/{temporal-api-worker → workflow}/worker/src/workflows.ts.hbs +0 -0
package/dist/src/index.js CHANGED
@@ -1,7 +1,624 @@
1
- /**
2
- * @mesh-tech/mesh-cli
3
- *
4
- * CLI utilities for Mesh Lab development.
5
- */
6
- export * from "./utils/index.js";
7
- //# sourceMappingURL=index.js.map
1
+ // libs/mesh-cli/src/utils/errors.ts
2
+ import chalk from "chalk";
3
+ var MeshCliError = class extends Error {
4
+ remediation;
5
+ exitCode;
6
+ constructor(message, options = {}) {
7
+ super(message, options.cause !== void 0 ? { cause: options.cause } : void 0);
8
+ this.name = "MeshCliError";
9
+ this.remediation = options.remediation;
10
+ this.exitCode = options.exitCode ?? 1;
11
+ }
12
+ };
13
+ function renderErrorBody(err) {
14
+ const message = err instanceof Error ? err.message : String(err);
15
+ if (!(err instanceof MeshCliError)) return message;
16
+ const lines = [message];
17
+ if (err.remediation?.command) {
18
+ lines.push(chalk.cyan(" \u2192 run: ") + err.remediation.command);
19
+ }
20
+ if (err.remediation?.docs) {
21
+ lines.push(chalk.cyan(" \u2192 see: ") + err.remediation.docs);
22
+ }
23
+ return lines.join("\n");
24
+ }
25
+ function renderError(err) {
26
+ return chalk.red("\u2717") + " " + renderErrorBody(err);
27
+ }
28
+ function renderErrorJson(err) {
29
+ if (err instanceof MeshCliError) {
30
+ return JSON.stringify({
31
+ error: err.message,
32
+ ...err.remediation ? { remediation: err.remediation } : {}
33
+ });
34
+ }
35
+ return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });
36
+ }
37
+ var jsonPayloadEmitted = false;
38
+ function emitJsonPayload(payload) {
39
+ console.log(JSON.stringify(payload, null, 2));
40
+ jsonPayloadEmitted = true;
41
+ }
42
+ function hasEmittedJsonPayload() {
43
+ return jsonPayloadEmitted;
44
+ }
45
+ function resetJsonPayloadEmitted() {
46
+ jsonPayloadEmitted = false;
47
+ }
48
+ function handleCliError(err) {
49
+ const wantsJson = process.argv.includes("--json");
50
+ if (wantsJson && !hasEmittedJsonPayload()) {
51
+ console.log(renderErrorJson(err));
52
+ } else {
53
+ console.error(renderError(err));
54
+ }
55
+ process.exit(err instanceof MeshCliError ? err.exitCode : 1);
56
+ }
57
+
58
+ // libs/mesh-cli/src/utils/log.ts
59
+ import chalk2 from "chalk";
60
+ function logPrefix(opts) {
61
+ const enabled = opts.envFlag === "1" || opts.envFlag !== "0" && !opts.isTTY;
62
+ return enabled ? `[${opts.now.toISOString().slice(11, 19)}] ` : "";
63
+ }
64
+ function prefix() {
65
+ return chalk2.dim(
66
+ logPrefix({
67
+ isTTY: !!process.stderr.isTTY,
68
+ envFlag: process.env.MESH_LOG_TIMESTAMPS,
69
+ now: /* @__PURE__ */ new Date()
70
+ })
71
+ );
72
+ }
73
+ function logInfo(message) {
74
+ console.error(prefix() + chalk2.blue("\u2139"), message);
75
+ }
76
+ function logSuccess(message) {
77
+ console.error(prefix() + chalk2.green("\u2713"), message);
78
+ }
79
+ function logWarn(message) {
80
+ console.error(prefix() + chalk2.yellow("\u26A0"), message);
81
+ }
82
+ function logError(message) {
83
+ console.error(prefix() + chalk2.red("\u2717"), message);
84
+ }
85
+ function formatElapsed(ms) {
86
+ const totalSec = Math.max(0, Math.round(ms / 1e3));
87
+ const h = Math.floor(totalSec / 3600);
88
+ const m = Math.floor(totalSec % 3600 / 60);
89
+ const s = totalSec % 60;
90
+ if (h > 0) return `${h}h ${m}m`;
91
+ if (m > 0) return `${m}m ${s}s`;
92
+ return `${s}s`;
93
+ }
94
+ function startHeartbeat(label, intervalMs = 15e3) {
95
+ const startedAt = Date.now();
96
+ let lastOutputAt = startedAt;
97
+ const timer = setInterval(() => {
98
+ if (Date.now() - lastOutputAt < intervalMs) return;
99
+ logInfo(`\u2026 still working: ${label} (${formatElapsed(Date.now() - startedAt)} elapsed)`);
100
+ }, intervalMs);
101
+ timer.unref?.();
102
+ return {
103
+ stop: () => clearInterval(timer),
104
+ touch: () => {
105
+ lastOutputAt = Date.now();
106
+ }
107
+ };
108
+ }
109
+
110
+ // libs/mesh-cli/src/utils/context.ts
111
+ import * as fs from "fs";
112
+ import * as path from "path";
113
+ function findFileUpward(filename, startDir = process.cwd()) {
114
+ let currentDir = startDir;
115
+ const root = path.parse(currentDir).root;
116
+ while (currentDir !== root) {
117
+ const filePath = path.join(currentDir, filename);
118
+ if (fs.existsSync(filePath)) {
119
+ return filePath;
120
+ }
121
+ currentDir = path.dirname(currentDir);
122
+ }
123
+ return void 0;
124
+ }
125
+ function detectContext(stageArg) {
126
+ let tenant;
127
+ let stage;
128
+ const cwd = process.cwd();
129
+ if (fs.existsSync("Pulumi.yaml")) {
130
+ const files = fs.readdirSync(".").filter(
131
+ (f) => f.startsWith("Pulumi.") && f.endsWith(".yaml") && f !== "Pulumi.yaml"
132
+ );
133
+ const configFile = files[0];
134
+ if (configFile) {
135
+ const content = fs.readFileSync(configFile, "utf-8");
136
+ const tenantMatch = content.match(/^\s*mesh:tenant:\s*["']?([^"'\n]+)["']?/m);
137
+ if (tenantMatch?.[1]) {
138
+ tenant = tenantMatch[1].trim();
139
+ }
140
+ const stageMatch = configFile.match(/Pulumi\.(.+)\.yaml/);
141
+ if (stageMatch?.[1]) {
142
+ stage = stageMatch[1];
143
+ }
144
+ }
145
+ }
146
+ const sstConfigPath = findFileUpward("sst.config.ts");
147
+ let sstDir;
148
+ if (sstConfigPath) {
149
+ sstDir = path.dirname(sstConfigPath);
150
+ const parentConfigPath = path.join(sstDir, "..", "config.ts");
151
+ if (fs.existsSync(parentConfigPath)) {
152
+ const configContent = fs.readFileSync(parentConfigPath, "utf-8");
153
+ const tenantMatch = configContent.match(/tenant:\s*["']([^"']+)["']/);
154
+ if (tenantMatch) {
155
+ tenant = tenantMatch[1];
156
+ }
157
+ }
158
+ const sstStagePath = path.join(sstDir, ".sst", "stage");
159
+ if (fs.existsSync(sstStagePath)) {
160
+ stage = fs.readFileSync(sstStagePath, "utf-8").trim();
161
+ }
162
+ }
163
+ if (!tenant) {
164
+ const pathMatch = cwd.match(/tenants\/([^/]+)/);
165
+ if (pathMatch) {
166
+ tenant = pathMatch[1];
167
+ }
168
+ }
169
+ stage = stageArg || process.env.MESH_STAGE || process.env.SST_STAGE || stage || "dev";
170
+ tenant = process.env.MESH_TENANT || tenant || "mesh";
171
+ let platformEnv = stage;
172
+ let platformEnvMap = {};
173
+ let defaultPlatformEnv;
174
+ const configPath = sstDir ? path.join(sstDir, "..", "config.ts") : "../config.ts";
175
+ if (fs.existsSync(configPath)) {
176
+ const configContent = fs.readFileSync(configPath, "utf-8");
177
+ const mapMatch = configContent.match(/platformEnvMap:\s*\{([^}]+)\}/);
178
+ if (mapMatch?.[1]) {
179
+ const entries = mapMatch[1].matchAll(/(\w+):\s*["']([^"']+)["']/g);
180
+ for (const entry of entries) {
181
+ const key = entry[1];
182
+ const value = entry[2];
183
+ if (key && value) {
184
+ platformEnvMap[key] = value;
185
+ }
186
+ }
187
+ }
188
+ const defaultMatch = configContent.match(/defaultPlatformEnv:\s*["']([^"']+)["']/);
189
+ if (defaultMatch?.[1]) {
190
+ defaultPlatformEnv = defaultMatch[1];
191
+ }
192
+ }
193
+ const tenantPrefix = `${tenant}-`;
194
+ const parsedEnv = stage.startsWith(tenantPrefix) ? stage.slice(tenantPrefix.length) : stage;
195
+ platformEnv = platformEnvMap[parsedEnv] ?? platformEnvMap[stage] ?? defaultPlatformEnv ?? parsedEnv;
196
+ logInfo(`Stage: ${stage}, Platform: ${platformEnv}, Tenant: ${tenant}`);
197
+ return { tenant, stage, platformEnv };
198
+ }
199
+
200
+ // libs/mesh-cli/src/utils/bastion.ts
201
+ import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
202
+ async function getPlatformBastionInfo(tenant, platformEnv, region) {
203
+ const ssm = new SSMClient(region ? { region } : {});
204
+ let primaryError;
205
+ const platformPath = `/mesh-platform/${tenant}/${platformEnv}/platform`;
206
+ logInfo(`Looking up platform bastion from ${platformPath}...`);
207
+ try {
208
+ const response = await ssm.send(
209
+ new GetParameterCommand({ Name: platformPath })
210
+ );
211
+ if (response.Parameter?.Value) {
212
+ const platform = JSON.parse(response.Parameter.Value);
213
+ if (platform.platformBastion) {
214
+ const info = platform.platformBastion;
215
+ logSuccess(`Found bastion: ${info.instanceId}`);
216
+ const serviceNames = Object.keys(info.services);
217
+ if (serviceNames.length > 0) {
218
+ logInfo(`Available services: ${serviceNames.join(", ")}`);
219
+ }
220
+ return info;
221
+ }
222
+ }
223
+ } catch (err) {
224
+ primaryError = err;
225
+ }
226
+ const legacyPath = `/mesh-platform/${tenant}/${platformEnv}/platform-bastion`;
227
+ logInfo(`Trying legacy path ${legacyPath}...`);
228
+ try {
229
+ const response = await ssm.send(
230
+ new GetParameterCommand({ Name: legacyPath })
231
+ );
232
+ if (!response.Parameter?.Value) {
233
+ throw new Error(`Platform bastion not found`);
234
+ }
235
+ const info = JSON.parse(response.Parameter.Value);
236
+ logSuccess(`Found bastion: ${info.instanceId}`);
237
+ const serviceNames = Object.keys(info.services);
238
+ if (serviceNames.length > 0) {
239
+ logInfo(`Available services: ${serviceNames.join(", ")}`);
240
+ }
241
+ return info;
242
+ } catch (legacyError) {
243
+ const cause = primaryError ?? legacyError;
244
+ const name = cause?.name ?? "";
245
+ const credsProblem = /Expired|UnrecognizedClient|InvalidClientTokenId|InvalidSignature|CredentialsProviderError|AccessDenied/i.test(
246
+ name
247
+ );
248
+ if (credsProblem) {
249
+ logError(
250
+ `Could not read the platform bastion from ${platformPath} \u2014 AWS error: ${name}.`
251
+ );
252
+ logInfo(
253
+ "This is almost always a CREDENTIALS problem, not a missing bastion."
254
+ );
255
+ logInfo(
256
+ " \u2022 The read uses the ambient AWS creds of this process; they must be valid AND able to read the HUB param above."
257
+ );
258
+ logInfo(
259
+ " \u2022 Check: `aws sts get-caller-identity` (ExpiredToken \u2192 refresh; AccessDenied \u2192 those creds lack hub read \u2014 use InfraAdmin-grade creds)."
260
+ );
261
+ logInfo(
262
+ " \u2022 Stale creds often hide in the tmux GLOBAL env (`tmux show-environment -g | grep AWS_`); a per-shell `unset` won't clear them."
263
+ );
264
+ } else {
265
+ logError(`Platform bastion not found in ${platformPath} or ${legacyPath}`);
266
+ logInfo("Make sure platformBastion is enabled in your platform config and deployed.");
267
+ }
268
+ throw cause;
269
+ }
270
+ }
271
+ async function getBastionInfo(tenant, platformEnv) {
272
+ const info = await getPlatformBastionInfo(tenant, platformEnv);
273
+ const rdsService = info.services["rds"];
274
+ if (!rdsService) {
275
+ throw new Error("RDS service not available in platform bastion. Is RDS enabled?");
276
+ }
277
+ return {
278
+ instanceId: info.instanceId,
279
+ rdsEndpoint: rdsService.host,
280
+ rdsPort: rdsService.port
281
+ };
282
+ }
283
+
284
+ // libs/mesh-cli/src/utils/credentials.ts
285
+ import {
286
+ SecretsManagerClient,
287
+ GetSecretValueCommand
288
+ } from "@aws-sdk/client-secrets-manager";
289
+ async function getDatabaseUrl(tenant, stage, options) {
290
+ const secretsManager = new SecretsManagerClient({});
291
+ const secretName = options?.app ? `mesh/${tenant}/${stage}/${options.app}/db-credentials` : `mesh/${tenant}/${stage}/db-credentials`;
292
+ logInfo(`Looking up credentials at ${secretName}...`);
293
+ try {
294
+ const response = await secretsManager.send(
295
+ new GetSecretValueCommand({ SecretId: secretName })
296
+ );
297
+ if (response.SecretString) {
298
+ const secret = JSON.parse(response.SecretString);
299
+ if (secret.DATABASE_URL) {
300
+ const parsed = new URL(secret.DATABASE_URL);
301
+ logSuccess(`Got credentials for user: ${parsed.username}`);
302
+ return secret.DATABASE_URL;
303
+ }
304
+ if (secret.username && secret.password) {
305
+ logSuccess(`Got credentials for user: ${secret.username}`);
306
+ const database = secret.dbname ?? secret.database ?? "postgres";
307
+ return `postgresql://${secret.username}:${encodeURIComponent(secret.password)}@${secret.host ?? "localhost"}:${secret.port ?? 5432}/${database}`;
308
+ }
309
+ throw new Error(`Secret ${secretName} has unexpected format (needs DATABASE_URL or username/password)`);
310
+ }
311
+ } catch (error) {
312
+ if (error.message?.includes("unexpected format")) {
313
+ throw error;
314
+ }
315
+ }
316
+ throw new Error(`Could not find credentials at ${secretName}`);
317
+ }
318
+ async function getDbCredentials(tenant, stage, _platformEnv, rdsHost, rdsPort, options) {
319
+ const databaseUrl = await getDatabaseUrl(tenant, stage, options);
320
+ const parsed = new URL(databaseUrl);
321
+ return {
322
+ username: parsed.username,
323
+ password: decodeURIComponent(parsed.password),
324
+ host: rdsHost,
325
+ port: rdsPort,
326
+ database: parsed.pathname.slice(1)
327
+ };
328
+ }
329
+ function rewriteDatabaseUrl(url, options) {
330
+ try {
331
+ const parsed = new URL(url);
332
+ if (options.endpoint) {
333
+ if (options.endpoint.includes(":")) {
334
+ const colonIndex = options.endpoint.lastIndexOf(":");
335
+ parsed.hostname = options.endpoint.slice(0, colonIndex);
336
+ parsed.port = options.endpoint.slice(colonIndex + 1);
337
+ } else {
338
+ parsed.hostname = options.endpoint;
339
+ parsed.port = parsed.port || "5432";
340
+ }
341
+ }
342
+ if (options.sslMode) {
343
+ parsed.searchParams.set("sslmode", options.sslMode);
344
+ if (options.sslMode === "require" || options.sslMode === "no-verify") {
345
+ parsed.searchParams.set("sslaccept", "accept_invalid_certs");
346
+ }
347
+ }
348
+ return parsed.toString();
349
+ } catch {
350
+ return url;
351
+ }
352
+ }
353
+ function buildDatabaseUrl(creds, options) {
354
+ const host = options?.endpoint?.split(":")[0] ?? creds.host;
355
+ const port = options?.endpoint?.split(":")[1] ?? String(creds.port);
356
+ let url = `postgresql://${creds.username}:${encodeURIComponent(creds.password)}@${host}:${port}/${creds.database}`;
357
+ if (options?.sslMode) {
358
+ url += `?sslmode=${options.sslMode}`;
359
+ if (options.sslMode === "require" || options.sslMode === "no-verify") {
360
+ url += "&sslaccept=accept_invalid_certs";
361
+ }
362
+ }
363
+ return url;
364
+ }
365
+ async function readSstOutputs() {
366
+ const fs3 = await import("fs");
367
+ if (!fs3.existsSync(".sst/outputs.json")) {
368
+ return null;
369
+ }
370
+ try {
371
+ const content = fs3.readFileSync(".sst/outputs.json", "utf-8");
372
+ const outputs = JSON.parse(content);
373
+ if (outputs.databaseUrl) {
374
+ logInfo("Found SST outputs with database config");
375
+ const secretArnMatch = outputs.databaseUrl.match(/secretArn=([^&]+)/);
376
+ const secretArn = secretArnMatch ? decodeURIComponent(secretArnMatch[1]) : void 0;
377
+ return {
378
+ databaseUrl: outputs.databaseUrl,
379
+ databaseName: outputs.databaseName,
380
+ secretArn
381
+ };
382
+ }
383
+ } catch {
384
+ }
385
+ return null;
386
+ }
387
+
388
+ // libs/mesh-cli/src/utils/pulumi.ts
389
+ import { execFileSync } from "child_process";
390
+ import * as path2 from "path";
391
+ import * as fs2 from "fs";
392
+ function findAppRoot(startDir) {
393
+ let dir = startDir;
394
+ while (true) {
395
+ if (fs2.existsSync(path2.join(dir, "Pulumi.yaml"))) return dir;
396
+ const parent = path2.dirname(dir);
397
+ if (parent === dir) return null;
398
+ dir = parent;
399
+ }
400
+ }
401
+ function findStackConfigs(appRoot) {
402
+ return fs2.readdirSync(appRoot).filter((f) => /^Pulumi\..+\.yaml$/.test(f) && f !== "Pulumi.yaml").map((f) => f.replace(/^Pulumi\./, "").replace(/\.yaml$/, ""));
403
+ }
404
+ function getCurrentStack(appRoot) {
405
+ try {
406
+ const result = execFileSync("pulumi", ["stack", "--show-name"], {
407
+ encoding: "utf-8",
408
+ cwd: appRoot,
409
+ stdio: ["pipe", "pipe", "pipe"]
410
+ });
411
+ return result.trim() || null;
412
+ } catch {
413
+ return null;
414
+ }
415
+ }
416
+ function readStackConfig(appRoot, stack, key) {
417
+ const configFile = path2.join(appRoot, `Pulumi.${stack}.yaml`);
418
+ if (!fs2.existsSync(configFile)) return null;
419
+ const content = fs2.readFileSync(configFile, "utf-8");
420
+ const pattern = new RegExp(`^\\s+${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}:\\s*(.+)$`, "m");
421
+ const match = content.match(pattern);
422
+ if (!match) return null;
423
+ return match[1].trim().replace(/^["']|["']$/g, "");
424
+ }
425
+ function pulumiStackOutput(appRoot, key, extraArgs, env) {
426
+ const execEnv = env ? { ...process.env, ...env } : void 0;
427
+ try {
428
+ const result = execFileSync(
429
+ "pulumi",
430
+ ["stack", "output", key, "--json", ...extraArgs],
431
+ { cwd: appRoot, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"], env: execEnv }
432
+ );
433
+ if (result.includes('"[secret]"')) {
434
+ return execFileSync(
435
+ "pulumi",
436
+ ["stack", "output", key, "--json", "--show-secrets", ...extraArgs],
437
+ { cwd: appRoot, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"], env: execEnv }
438
+ );
439
+ }
440
+ return result;
441
+ } catch (err) {
442
+ const errMsg = err?.stderr ?? "";
443
+ if (errMsg.includes("kms:") || errMsg.includes("KMS") || errMsg.includes("secrets manager")) {
444
+ throw err;
445
+ }
446
+ return execFileSync(
447
+ "pulumi",
448
+ ["stack", "output", key, "--json", "--show-secrets", ...extraArgs],
449
+ { cwd: appRoot, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"], env: execEnv }
450
+ );
451
+ }
452
+ }
453
+
454
+ // libs/mesh-cli/src/utils/vpn.ts
455
+ import { execFile, execFileSync as execFileSync2 } from "node:child_process";
456
+ import { existsSync as existsSync3 } from "node:fs";
457
+ var TAILSCALE_PATHS = [
458
+ "tailscale",
459
+ "/Applications/Tailscale.app/Contents/MacOS/Tailscale"
460
+ ];
461
+ async function isVpnConnected() {
462
+ try {
463
+ const stdout = await execTailscaleCmd(["status", "--json"]);
464
+ const status = JSON.parse(stdout);
465
+ return status.BackendState === "Running" && status.Self?.Online === true;
466
+ } catch {
467
+ return false;
468
+ }
469
+ }
470
+ var TAILSCALE_SOCKET_PATHS = ["/var/run/tailscale/tailscaled.sock", "/tmp/tailscale.sock"];
471
+ function headscaleDnsConfig(tenant = "mesh", env = "dev", overrides) {
472
+ return {
473
+ namespace: `${tenant}-${env}-headscale`,
474
+ pod: "headscale-0",
475
+ container: "dns-writer",
476
+ filePath: "/var/lib/headscale/dns/extra-records.json",
477
+ ...overrides
478
+ };
479
+ }
480
+ function execTailscaleCmd(args) {
481
+ const socketPath = TAILSCALE_SOCKET_PATHS.find(existsSync3);
482
+ const attempts = [];
483
+ for (const binary of TAILSCALE_PATHS) {
484
+ if (socketPath) {
485
+ attempts.push({ binary, args: ["--socket", socketPath, ...args] });
486
+ }
487
+ attempts.push({ binary, args });
488
+ }
489
+ return new Promise((resolve, reject) => {
490
+ let index = 0;
491
+ function tryNext() {
492
+ if (index >= attempts.length) {
493
+ reject(new Error("All tailscale binary attempts failed"));
494
+ return;
495
+ }
496
+ const attempt = attempts[index++];
497
+ execFile(attempt.binary, attempt.args, (error, stdout) => {
498
+ if (error) {
499
+ tryNext();
500
+ } else {
501
+ resolve(stdout);
502
+ }
503
+ });
504
+ }
505
+ tryNext();
506
+ });
507
+ }
508
+ async function getTailscaleInfo() {
509
+ try {
510
+ const stdout = await execTailscaleCmd(["status", "--json"]);
511
+ const status = JSON.parse(stdout);
512
+ if (status.BackendState === "Running" && status.Self?.Online === true && status.Self.HostName && status.Self.TailscaleIPs?.length) {
513
+ return {
514
+ hostname: status.Self.HostName,
515
+ ip: status.Self.TailscaleIPs[0]
516
+ };
517
+ }
518
+ return null;
519
+ } catch {
520
+ return null;
521
+ }
522
+ }
523
+ function dnsWriterExec(cfg, cmd, interactive = false) {
524
+ return [
525
+ "exec",
526
+ ...interactive ? ["-i"] : [],
527
+ "-n",
528
+ cfg.namespace,
529
+ cfg.pod,
530
+ "-c",
531
+ cfg.container,
532
+ "--",
533
+ ...cmd
534
+ ];
535
+ }
536
+ function readDnsRecords(cfg) {
537
+ try {
538
+ const raw = execFileSync2("kubectl", dnsWriterExec(cfg, ["cat", cfg.filePath]), {
539
+ encoding: "utf-8",
540
+ stdio: ["ignore", "pipe", "pipe"]
541
+ });
542
+ const trimmed = raw.trim();
543
+ if (!trimmed || trimmed === "[]") return [];
544
+ try {
545
+ return JSON.parse(trimmed);
546
+ } catch {
547
+ console.warn(`[vpn] DNS records file contains invalid JSON, treating as empty`);
548
+ return [];
549
+ }
550
+ } catch (err) {
551
+ const msg = err.message ?? String(err);
552
+ if (msg.includes("not found") || msg.includes("Unable to connect")) {
553
+ throw new Error(
554
+ `Cannot reach Headscale DNS writer (namespace=${cfg.namespace}, pod=${cfg.pod}).
555
+ Verify kubectl context and that the Headscale pod is running:
556
+ kubectl get pods -n ${cfg.namespace}`
557
+ );
558
+ }
559
+ if (msg.includes("No such file")) {
560
+ return [];
561
+ }
562
+ throw err;
563
+ }
564
+ }
565
+ function registerDnsRecords(cfg, records) {
566
+ const json = JSON.stringify(records);
567
+ try {
568
+ execFileSync2(
569
+ "kubectl",
570
+ dnsWriterExec(cfg, ["sh", "-c", `cat > '${cfg.filePath}'`], true),
571
+ { input: json, stdio: ["pipe", "pipe", "pipe"] }
572
+ );
573
+ } catch (err) {
574
+ const msg = err.message ?? String(err);
575
+ throw new Error(
576
+ `Failed to write DNS records to Headscale (namespace=${cfg.namespace}, pod=${cfg.pod}).
577
+ ${msg.includes("not found") ? "Pod not found. " : ""}Verify kubectl context: kubectl get pods -n ${cfg.namespace}`
578
+ );
579
+ }
580
+ }
581
+ function unregisterDnsRecords(cfg, suffix) {
582
+ try {
583
+ const records = readDnsRecords(cfg);
584
+ const filtered = records.filter((r) => !r.name.endsWith(suffix));
585
+ registerDnsRecords(cfg, filtered);
586
+ } catch {
587
+ }
588
+ }
589
+ export {
590
+ MeshCliError,
591
+ buildDatabaseUrl,
592
+ detectContext,
593
+ emitJsonPayload,
594
+ findAppRoot,
595
+ findStackConfigs,
596
+ formatElapsed,
597
+ getBastionInfo,
598
+ getCurrentStack,
599
+ getDatabaseUrl,
600
+ getDbCredentials,
601
+ getPlatformBastionInfo,
602
+ getTailscaleInfo,
603
+ handleCliError,
604
+ hasEmittedJsonPayload,
605
+ headscaleDnsConfig,
606
+ isVpnConnected,
607
+ logError,
608
+ logInfo,
609
+ logPrefix,
610
+ logSuccess,
611
+ logWarn,
612
+ pulumiStackOutput,
613
+ readDnsRecords,
614
+ readSstOutputs,
615
+ readStackConfig,
616
+ registerDnsRecords,
617
+ renderError,
618
+ renderErrorBody,
619
+ renderErrorJson,
620
+ resetJsonPayloadEmitted,
621
+ rewriteDatabaseUrl,
622
+ startHeartbeat,
623
+ unregisterDnsRecords
624
+ };