@owlmeans/viable-sdk 0.1.18-rc.8 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (498) hide show
  1. package/README.md +29 -11
  2. package/agent-meta/manifest.json +16 -0
  3. package/agent-meta/skills/viable-sdk/SKILL.md +1033 -0
  4. package/build/api/collect/types.d.ts +30 -0
  5. package/build/api/collect/types.d.ts.map +1 -0
  6. package/build/api/collect/types.js +2 -0
  7. package/build/api/collect/types.js.map +1 -0
  8. package/build/api/collect.d.ts +14 -0
  9. package/build/api/collect.d.ts.map +1 -0
  10. package/build/api/collect.js +132 -0
  11. package/build/api/collect.js.map +1 -0
  12. package/build/api/consts.local.d.ts +21 -0
  13. package/build/api/consts.local.d.ts.map +1 -0
  14. package/build/api/consts.local.js +25 -0
  15. package/build/api/consts.local.js.map +1 -0
  16. package/build/api/index.d.ts +5 -0
  17. package/build/api/index.d.ts.map +1 -1
  18. package/build/api/index.js +2 -0
  19. package/build/api/index.js.map +1 -1
  20. package/build/api/remote.d.ts +13 -6
  21. package/build/api/remote.d.ts.map +1 -1
  22. package/build/api/remote.js +302 -35
  23. package/build/api/remote.js.map +1 -1
  24. package/build/api/transport/types.d.ts +14 -0
  25. package/build/api/transport/types.d.ts.map +1 -0
  26. package/build/api/transport/types.js +2 -0
  27. package/build/api/transport/types.js.map +1 -0
  28. package/build/api/transport.d.ts +4 -0
  29. package/build/api/transport.d.ts.map +1 -0
  30. package/build/api/transport.js +32 -0
  31. package/build/api/transport.js.map +1 -0
  32. package/build/api/types.d.ts +9 -0
  33. package/build/api/types.d.ts.map +1 -0
  34. package/build/api/types.js +2 -0
  35. package/build/api/types.js.map +1 -0
  36. package/build/api/types.local.d.ts +3 -0
  37. package/build/api/types.local.d.ts.map +1 -0
  38. package/build/api/types.local.js +2 -0
  39. package/build/api/types.local.js.map +1 -0
  40. package/build/consts.d.ts +29 -14
  41. package/build/consts.d.ts.map +1 -1
  42. package/build/consts.js +30 -14
  43. package/build/consts.js.map +1 -1
  44. package/build/context/consts.local.d.ts +18 -0
  45. package/build/context/consts.local.d.ts.map +1 -0
  46. package/build/context/consts.local.js +18 -0
  47. package/build/context/consts.local.js.map +1 -0
  48. package/build/context/index.d.ts +3 -7
  49. package/build/context/index.d.ts.map +1 -1
  50. package/build/context/index.js +58 -25
  51. package/build/context/index.js.map +1 -1
  52. package/build/context/types.d.ts +26 -0
  53. package/build/context/types.d.ts.map +1 -0
  54. package/build/context/types.js +2 -0
  55. package/build/context/types.js.map +1 -0
  56. package/build/executor/boot-check.d.ts +1 -40
  57. package/build/executor/boot-check.d.ts.map +1 -1
  58. package/build/executor/boot-check.js +22 -19
  59. package/build/executor/boot-check.js.map +1 -1
  60. package/build/executor/consts.d.ts +55 -0
  61. package/build/executor/consts.d.ts.map +1 -0
  62. package/build/executor/consts.js +66 -0
  63. package/build/executor/consts.js.map +1 -0
  64. package/build/executor/consts.local.d.ts +63 -0
  65. package/build/executor/consts.local.d.ts.map +1 -0
  66. package/build/executor/consts.local.js +69 -0
  67. package/build/executor/consts.local.js.map +1 -0
  68. package/build/executor/env/types.d.ts +40 -0
  69. package/build/executor/env/types.d.ts.map +1 -0
  70. package/build/executor/env/types.js +2 -0
  71. package/build/executor/env/types.js.map +1 -0
  72. package/build/executor/env.d.ts +11 -20
  73. package/build/executor/env.d.ts.map +1 -1
  74. package/build/executor/env.js +39 -59
  75. package/build/executor/env.js.map +1 -1
  76. package/build/executor/errors.d.ts +15 -0
  77. package/build/executor/errors.d.ts.map +1 -1
  78. package/build/executor/errors.js +19 -2
  79. package/build/executor/errors.js.map +1 -1
  80. package/build/executor/files/types.d.ts +106 -0
  81. package/build/executor/files/types.d.ts.map +1 -0
  82. package/build/executor/files/types.js +2 -0
  83. package/build/executor/files/types.js.map +1 -0
  84. package/build/executor/files.d.ts +2 -50
  85. package/build/executor/files.d.ts.map +1 -1
  86. package/build/executor/files.js +225 -68
  87. package/build/executor/files.js.map +1 -1
  88. package/build/executor/git/types.d.ts +19 -0
  89. package/build/executor/git/types.d.ts.map +1 -0
  90. package/build/executor/git/types.js +2 -0
  91. package/build/executor/git/types.js.map +1 -0
  92. package/build/executor/git.d.ts +4 -36
  93. package/build/executor/git.d.ts.map +1 -1
  94. package/build/executor/git.js +206 -241
  95. package/build/executor/git.js.map +1 -1
  96. package/build/executor/glob/types.d.ts +12 -0
  97. package/build/executor/glob/types.d.ts.map +1 -0
  98. package/build/executor/glob/types.js +2 -0
  99. package/build/executor/glob/types.js.map +1 -0
  100. package/build/executor/glob.d.ts +4 -0
  101. package/build/executor/glob.d.ts.map +1 -0
  102. package/build/executor/glob.js +11 -0
  103. package/build/executor/glob.js.map +1 -0
  104. package/build/executor/health/types.d.ts +39 -0
  105. package/build/executor/health/types.d.ts.map +1 -0
  106. package/build/executor/health/types.js +2 -0
  107. package/build/executor/health/types.js.map +1 -0
  108. package/build/executor/health.d.ts +3 -83
  109. package/build/executor/health.d.ts.map +1 -1
  110. package/build/executor/health.js +76 -91
  111. package/build/executor/health.js.map +1 -1
  112. package/build/executor/index.d.ts +14 -15
  113. package/build/executor/index.d.ts.map +1 -1
  114. package/build/executor/index.js +36 -18
  115. package/build/executor/index.js.map +1 -1
  116. package/build/executor/integrity/types.d.ts +25 -0
  117. package/build/executor/integrity/types.d.ts.map +1 -0
  118. package/build/executor/integrity/types.js +2 -0
  119. package/build/executor/integrity/types.js.map +1 -0
  120. package/build/executor/integrity.d.ts +5 -15
  121. package/build/executor/integrity.d.ts.map +1 -1
  122. package/build/executor/integrity.js +28 -39
  123. package/build/executor/integrity.js.map +1 -1
  124. package/build/executor/layout/types.d.ts +69 -0
  125. package/build/executor/layout/types.d.ts.map +1 -0
  126. package/build/executor/layout/types.js +2 -0
  127. package/build/executor/layout/types.js.map +1 -0
  128. package/build/executor/layout.d.ts +9 -56
  129. package/build/executor/layout.d.ts.map +1 -1
  130. package/build/executor/layout.js +35 -82
  131. package/build/executor/layout.js.map +1 -1
  132. package/build/executor/shell/types.d.ts +76 -0
  133. package/build/executor/shell/types.d.ts.map +1 -0
  134. package/build/executor/shell/types.js +2 -0
  135. package/build/executor/shell/types.js.map +1 -0
  136. package/build/executor/shell.d.ts +3 -78
  137. package/build/executor/shell.d.ts.map +1 -1
  138. package/build/executor/shell.js +61 -91
  139. package/build/executor/shell.js.map +1 -1
  140. package/build/executor/spawn/types.d.ts +98 -0
  141. package/build/executor/spawn/types.d.ts.map +1 -0
  142. package/build/executor/spawn/types.js +2 -0
  143. package/build/executor/spawn/types.js.map +1 -0
  144. package/build/executor/spawn.d.ts +3 -103
  145. package/build/executor/spawn.d.ts.map +1 -1
  146. package/build/executor/spawn.js +192 -274
  147. package/build/executor/spawn.js.map +1 -1
  148. package/build/executor/types.d.ts +123 -0
  149. package/build/executor/types.d.ts.map +1 -0
  150. package/build/executor/types.js +2 -0
  151. package/build/executor/types.js.map +1 -0
  152. package/build/executor/types.local.d.ts +6 -0
  153. package/build/executor/types.local.d.ts.map +1 -0
  154. package/build/executor/types.local.js +2 -0
  155. package/build/executor/types.local.js.map +1 -0
  156. package/build/index.d.ts +14 -1
  157. package/build/index.d.ts.map +1 -1
  158. package/build/index.js +5 -1
  159. package/build/index.js.map +1 -1
  160. package/build/project/consts.d.ts +17 -0
  161. package/build/project/consts.d.ts.map +1 -0
  162. package/build/project/consts.js +17 -0
  163. package/build/project/consts.js.map +1 -0
  164. package/build/project/consts.local.d.ts +4 -0
  165. package/build/project/consts.local.d.ts.map +1 -0
  166. package/build/project/consts.local.js +4 -0
  167. package/build/project/consts.local.js.map +1 -0
  168. package/build/project/dotenv/types.d.ts +39 -0
  169. package/build/project/dotenv/types.d.ts.map +1 -0
  170. package/build/project/dotenv/types.js +2 -0
  171. package/build/project/dotenv/types.js.map +1 -0
  172. package/build/project/dotenv.d.ts +4 -0
  173. package/build/project/dotenv.d.ts.map +1 -0
  174. package/build/project/dotenv.js +56 -0
  175. package/build/project/dotenv.js.map +1 -0
  176. package/build/project/env/types.d.ts +40 -0
  177. package/build/project/env/types.d.ts.map +1 -0
  178. package/build/project/env/types.js +2 -0
  179. package/build/project/env/types.js.map +1 -0
  180. package/build/project/env.d.ts +2 -98
  181. package/build/project/env.d.ts.map +1 -1
  182. package/build/project/env.js +63 -215
  183. package/build/project/env.js.map +1 -1
  184. package/build/project/marker/types.d.ts +33 -0
  185. package/build/project/marker/types.d.ts.map +1 -0
  186. package/build/project/marker/types.js +2 -0
  187. package/build/project/marker/types.js.map +1 -0
  188. package/build/project/marker.d.ts +4 -25
  189. package/build/project/marker.d.ts.map +1 -1
  190. package/build/project/marker.js +40 -43
  191. package/build/project/marker.js.map +1 -1
  192. package/build/project/probe/types.d.ts +22 -0
  193. package/build/project/probe/types.d.ts.map +1 -0
  194. package/build/project/probe/types.js +2 -0
  195. package/build/project/probe/types.js.map +1 -0
  196. package/build/project/probe.d.ts +4 -0
  197. package/build/project/probe.d.ts.map +1 -0
  198. package/build/project/probe.js +39 -0
  199. package/build/project/probe.js.map +1 -0
  200. package/build/project/report/types.d.ts +18 -0
  201. package/build/project/report/types.d.ts.map +1 -0
  202. package/build/project/report/types.js +2 -0
  203. package/build/project/report/types.js.map +1 -0
  204. package/build/project/report.d.ts +7 -0
  205. package/build/project/report.d.ts.map +1 -0
  206. package/build/project/report.js +68 -0
  207. package/build/project/report.js.map +1 -0
  208. package/build/project/setup/types.d.ts +32 -0
  209. package/build/project/setup/types.d.ts.map +1 -0
  210. package/build/project/setup/types.js +2 -0
  211. package/build/project/setup/types.js.map +1 -0
  212. package/build/project/setup.d.ts +4 -53
  213. package/build/project/setup.d.ts.map +1 -1
  214. package/build/project/setup.js +112 -175
  215. package/build/project/setup.js.map +1 -1
  216. package/build/project/types.d.ts +37 -0
  217. package/build/project/types.d.ts.map +1 -0
  218. package/build/project/types.js +2 -0
  219. package/build/project/types.js.map +1 -0
  220. package/build/run/consts.local.d.ts +3 -0
  221. package/build/run/consts.local.d.ts.map +1 -0
  222. package/build/run/consts.local.js +26 -0
  223. package/build/run/consts.local.js.map +1 -0
  224. package/build/run/index.d.ts +11 -69
  225. package/build/run/index.d.ts.map +1 -1
  226. package/build/run/index.js +9 -147
  227. package/build/run/index.js.map +1 -1
  228. package/build/run/local/types.d.ts +39 -0
  229. package/build/run/local/types.d.ts.map +1 -0
  230. package/build/run/local/types.js +2 -0
  231. package/build/run/local/types.js.map +1 -0
  232. package/build/run/local.d.ts +3 -0
  233. package/build/run/local.d.ts.map +1 -0
  234. package/build/run/local.js +130 -0
  235. package/build/run/local.js.map +1 -0
  236. package/build/run/process/types.d.ts +15 -0
  237. package/build/run/process/types.d.ts.map +1 -0
  238. package/build/run/process/types.js +2 -0
  239. package/build/run/process/types.js.map +1 -0
  240. package/build/run/process.d.ts +4 -0
  241. package/build/run/process.d.ts.map +1 -0
  242. package/build/run/process.js +20 -0
  243. package/build/run/process.js.map +1 -0
  244. package/build/run/serve.d.ts +14 -9
  245. package/build/run/serve.d.ts.map +1 -1
  246. package/build/run/serve.js +1 -25
  247. package/build/run/serve.js.map +1 -1
  248. package/build/run/state/types.d.ts +35 -0
  249. package/build/run/state/types.d.ts.map +1 -0
  250. package/build/run/state/types.js +2 -0
  251. package/build/run/state/types.js.map +1 -0
  252. package/build/run/state.d.ts +3 -62
  253. package/build/run/state.d.ts.map +1 -1
  254. package/build/run/state.js +96 -123
  255. package/build/run/state.js.map +1 -1
  256. package/build/run/types.d.ts +78 -0
  257. package/build/run/types.d.ts.map +1 -0
  258. package/build/run/types.js +2 -0
  259. package/build/run/types.js.map +1 -0
  260. package/build/session/consts.local.d.ts +5 -0
  261. package/build/session/consts.local.d.ts.map +1 -0
  262. package/build/session/consts.local.js +5 -0
  263. package/build/session/consts.local.js.map +1 -0
  264. package/build/session/index.d.ts +5 -10
  265. package/build/session/index.d.ts.map +1 -1
  266. package/build/session/index.js +84 -15
  267. package/build/session/index.js.map +1 -1
  268. package/build/session/questions.d.ts +16 -0
  269. package/build/session/questions.d.ts.map +1 -0
  270. package/build/session/questions.js +17 -0
  271. package/build/session/questions.js.map +1 -0
  272. package/build/session/queue.d.ts +61 -0
  273. package/build/session/queue.d.ts.map +1 -0
  274. package/build/session/queue.js +156 -0
  275. package/build/session/queue.js.map +1 -0
  276. package/build/session/tasks.d.ts +11 -30
  277. package/build/session/tasks.d.ts.map +1 -1
  278. package/build/session/tasks.js +18 -78
  279. package/build/session/tasks.js.map +1 -1
  280. package/build/session/types.d.ts +20 -0
  281. package/build/session/types.d.ts.map +1 -0
  282. package/build/session/types.js +2 -0
  283. package/build/session/types.js.map +1 -0
  284. package/build/task/consts.d.ts +12 -0
  285. package/build/task/consts.d.ts.map +1 -0
  286. package/build/task/consts.js +12 -0
  287. package/build/task/consts.js.map +1 -0
  288. package/build/task/consts.local.d.ts +19 -0
  289. package/build/task/consts.local.d.ts.map +1 -0
  290. package/build/task/consts.local.js +72 -0
  291. package/build/task/consts.local.js.map +1 -0
  292. package/build/task/driver.d.ts +1 -28
  293. package/build/task/driver.d.ts.map +1 -1
  294. package/build/task/driver.js +2 -9
  295. package/build/task/driver.js.map +1 -1
  296. package/build/task/envelope/types.d.ts +29 -0
  297. package/build/task/envelope/types.d.ts.map +1 -0
  298. package/build/task/envelope/types.js +2 -0
  299. package/build/task/envelope/types.js.map +1 -0
  300. package/build/task/envelope.d.ts +4 -34
  301. package/build/task/envelope.d.ts.map +1 -1
  302. package/build/task/envelope.js +103 -165
  303. package/build/task/envelope.js.map +1 -1
  304. package/build/task/index.d.ts +5 -0
  305. package/build/task/index.d.ts.map +1 -1
  306. package/build/task/index.js +2 -0
  307. package/build/task/index.js.map +1 -1
  308. package/build/task/inquiry/types.d.ts +38 -0
  309. package/build/task/inquiry/types.d.ts.map +1 -0
  310. package/build/task/inquiry/types.js +2 -0
  311. package/build/task/inquiry/types.js.map +1 -0
  312. package/build/task/inquiry.d.ts +5 -0
  313. package/build/task/inquiry.d.ts.map +1 -0
  314. package/build/task/inquiry.js +188 -0
  315. package/build/task/inquiry.js.map +1 -0
  316. package/build/task/types.d.ts +48 -0
  317. package/build/task/types.d.ts.map +1 -0
  318. package/build/task/types.js +2 -0
  319. package/build/task/types.js.map +1 -0
  320. package/build/tools/account/types.d.ts +24 -0
  321. package/build/tools/account/types.d.ts.map +1 -0
  322. package/build/tools/account/types.js +2 -0
  323. package/build/tools/account/types.js.map +1 -0
  324. package/build/tools/account.d.ts +4 -0
  325. package/build/tools/account.d.ts.map +1 -0
  326. package/build/tools/account.js +72 -0
  327. package/build/tools/account.js.map +1 -0
  328. package/build/tools/blueprints/types.d.ts +5 -0
  329. package/build/tools/blueprints/types.d.ts.map +1 -0
  330. package/build/tools/blueprints/types.js +2 -0
  331. package/build/tools/blueprints/types.js.map +1 -0
  332. package/build/tools/blueprints.d.ts +4 -0
  333. package/build/tools/blueprints.d.ts.map +1 -0
  334. package/build/tools/blueprints.js +23 -0
  335. package/build/tools/blueprints.js.map +1 -0
  336. package/build/tools/catalogue/types.d.ts +8 -0
  337. package/build/tools/catalogue/types.d.ts.map +1 -0
  338. package/build/tools/catalogue/types.js +2 -0
  339. package/build/tools/catalogue/types.js.map +1 -0
  340. package/build/tools/catalogue.d.ts +8 -6
  341. package/build/tools/catalogue.d.ts.map +1 -1
  342. package/build/tools/catalogue.js +2565 -213
  343. package/build/tools/catalogue.js.map +1 -1
  344. package/build/tools/config/types.d.ts +19 -0
  345. package/build/tools/config/types.d.ts.map +1 -0
  346. package/build/tools/config/types.js +2 -0
  347. package/build/tools/config/types.js.map +1 -0
  348. package/build/tools/config.d.ts +4 -0
  349. package/build/tools/config.d.ts.map +1 -0
  350. package/build/tools/config.js +42 -0
  351. package/build/tools/config.js.map +1 -0
  352. package/build/tools/consts.d.ts +61 -0
  353. package/build/tools/consts.d.ts.map +1 -0
  354. package/build/tools/consts.js +515 -0
  355. package/build/tools/consts.js.map +1 -0
  356. package/build/tools/consts.local.d.ts +131 -0
  357. package/build/tools/consts.local.d.ts.map +1 -0
  358. package/build/tools/consts.local.js +236 -0
  359. package/build/tools/consts.local.js.map +1 -0
  360. package/build/tools/control/types.d.ts +17 -0
  361. package/build/tools/control/types.d.ts.map +1 -0
  362. package/build/tools/control/types.js +2 -0
  363. package/build/tools/control/types.js.map +1 -0
  364. package/build/tools/control.d.ts +4 -0
  365. package/build/tools/control.d.ts.map +1 -0
  366. package/build/tools/control.js +44 -0
  367. package/build/tools/control.js.map +1 -0
  368. package/build/tools/feed/types.d.ts +21 -0
  369. package/build/tools/feed/types.d.ts.map +1 -0
  370. package/build/tools/feed/types.js +2 -0
  371. package/build/tools/feed/types.js.map +1 -0
  372. package/build/tools/feed.d.ts +4 -0
  373. package/build/tools/feed.d.ts.map +1 -0
  374. package/build/tools/feed.js +75 -0
  375. package/build/tools/feed.js.map +1 -0
  376. package/build/tools/git/types.d.ts +25 -0
  377. package/build/tools/git/types.d.ts.map +1 -0
  378. package/build/tools/git/types.js +2 -0
  379. package/build/tools/git/types.js.map +1 -0
  380. package/build/tools/git.d.ts +4 -0
  381. package/build/tools/git.d.ts.map +1 -0
  382. package/build/tools/git.js +83 -0
  383. package/build/tools/git.js.map +1 -0
  384. package/build/tools/handover/types.d.ts +49 -0
  385. package/build/tools/handover/types.d.ts.map +1 -0
  386. package/build/tools/handover/types.js +2 -0
  387. package/build/tools/handover/types.js.map +1 -0
  388. package/build/tools/handover.d.ts +8 -0
  389. package/build/tools/handover.d.ts.map +1 -0
  390. package/build/tools/handover.js +138 -0
  391. package/build/tools/handover.js.map +1 -0
  392. package/build/tools/host/types.d.ts +34 -0
  393. package/build/tools/host/types.d.ts.map +1 -0
  394. package/build/tools/host/types.js +2 -0
  395. package/build/tools/host/types.js.map +1 -0
  396. package/build/tools/host.d.ts +4 -0
  397. package/build/tools/host.d.ts.map +1 -0
  398. package/build/tools/host.js +13 -0
  399. package/build/tools/host.js.map +1 -0
  400. package/build/tools/iam/types.d.ts +44 -0
  401. package/build/tools/iam/types.d.ts.map +1 -0
  402. package/build/tools/iam/types.js +2 -0
  403. package/build/tools/iam/types.js.map +1 -0
  404. package/build/tools/iam.d.ts +4 -0
  405. package/build/tools/iam.d.ts.map +1 -0
  406. package/build/tools/iam.js +229 -0
  407. package/build/tools/iam.js.map +1 -0
  408. package/build/tools/index.d.ts +27 -1
  409. package/build/tools/index.d.ts.map +1 -1
  410. package/build/tools/index.js +14 -1
  411. package/build/tools/index.js.map +1 -1
  412. package/build/tools/inflight/types.d.ts +47 -0
  413. package/build/tools/inflight/types.d.ts.map +1 -0
  414. package/build/tools/inflight/types.js +2 -0
  415. package/build/tools/inflight/types.js.map +1 -0
  416. package/build/tools/inflight.d.ts +3 -0
  417. package/build/tools/inflight.d.ts.map +1 -0
  418. package/build/tools/inflight.js +88 -0
  419. package/build/tools/inflight.js.map +1 -0
  420. package/build/tools/kits/types.d.ts +12 -0
  421. package/build/tools/kits/types.d.ts.map +1 -0
  422. package/build/tools/kits/types.js +2 -0
  423. package/build/tools/kits/types.js.map +1 -0
  424. package/build/tools/kits.d.ts +4 -0
  425. package/build/tools/kits.d.ts.map +1 -0
  426. package/build/tools/kits.js +33 -0
  427. package/build/tools/kits.js.map +1 -0
  428. package/build/tools/mcp.d.ts +13 -19
  429. package/build/tools/mcp.d.ts.map +1 -1
  430. package/build/tools/mcp.js +117 -38
  431. package/build/tools/mcp.js.map +1 -1
  432. package/build/tools/platform.d.ts +14 -0
  433. package/build/tools/platform.d.ts.map +1 -0
  434. package/build/tools/platform.js +90 -0
  435. package/build/tools/platform.js.map +1 -0
  436. package/build/tools/production/types.d.ts +22 -0
  437. package/build/tools/production/types.d.ts.map +1 -0
  438. package/build/tools/production/types.js +2 -0
  439. package/build/tools/production/types.js.map +1 -0
  440. package/build/tools/production.d.ts +4 -0
  441. package/build/tools/production.d.ts.map +1 -0
  442. package/build/tools/production.js +80 -0
  443. package/build/tools/production.js.map +1 -0
  444. package/build/tools/refusal/types.d.ts +95 -0
  445. package/build/tools/refusal/types.d.ts.map +1 -0
  446. package/build/tools/refusal/types.js +2 -0
  447. package/build/tools/refusal/types.js.map +1 -0
  448. package/build/tools/refusal.d.ts +4 -0
  449. package/build/tools/refusal.d.ts.map +1 -0
  450. package/build/tools/refusal.js +663 -0
  451. package/build/tools/refusal.js.map +1 -0
  452. package/build/tools/settings/types.d.ts +42 -0
  453. package/build/tools/settings/types.d.ts.map +1 -0
  454. package/build/tools/settings/types.js +2 -0
  455. package/build/tools/settings/types.js.map +1 -0
  456. package/build/tools/settings.d.ts +4 -0
  457. package/build/tools/settings.d.ts.map +1 -0
  458. package/build/tools/settings.js +71 -0
  459. package/build/tools/settings.js.map +1 -0
  460. package/build/tools/status/types.d.ts +25 -0
  461. package/build/tools/status/types.d.ts.map +1 -0
  462. package/build/tools/status/types.js +2 -0
  463. package/build/tools/status/types.js.map +1 -0
  464. package/build/tools/status.d.ts +4 -0
  465. package/build/tools/status.d.ts.map +1 -0
  466. package/build/tools/status.js +183 -0
  467. package/build/tools/status.js.map +1 -0
  468. package/build/tools/stories/types.d.ts +48 -0
  469. package/build/tools/stories/types.d.ts.map +1 -0
  470. package/build/tools/stories/types.js +2 -0
  471. package/build/tools/stories/types.js.map +1 -0
  472. package/build/tools/stories.d.ts +8 -0
  473. package/build/tools/stories.d.ts.map +1 -0
  474. package/build/tools/stories.js +79 -0
  475. package/build/tools/stories.js.map +1 -0
  476. package/build/tools/types.d.ts +177 -26
  477. package/build/tools/types.d.ts.map +1 -1
  478. package/build/tools/types.js +1 -32
  479. package/build/tools/types.js.map +1 -1
  480. package/build/types.d.ts +391 -26
  481. package/build/types.d.ts.map +1 -1
  482. package/build/utils.d.ts +8 -0
  483. package/build/utils.d.ts.map +1 -0
  484. package/build/utils.js +12 -0
  485. package/build/utils.js.map +1 -0
  486. package/package.json +30 -34
  487. package/build/harness/index.d.ts +0 -28
  488. package/build/harness/index.d.ts.map +0 -1
  489. package/build/harness/index.js +0 -83
  490. package/build/harness/index.js.map +0 -1
  491. package/build/harness/templates.d.ts +0 -30
  492. package/build/harness/templates.d.ts.map +0 -1
  493. package/build/harness/templates.js +0 -154
  494. package/build/harness/templates.js.map +0 -1
  495. package/build/tools/jobs.d.ts +0 -12
  496. package/build/tools/jobs.d.ts.map +0 -1
  497. package/build/tools/jobs.js +0 -47
  498. package/build/tools/jobs.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { ChildProcess } from 'node:child_process';
1
+ import type { SpawnHelper } from './spawn/types.js';
2
2
  /**
3
3
  * Everything that starts, bounds or ends a child process on the developer's machine.
4
4
  *
@@ -6,106 +6,6 @@ import type { ChildProcess } from 'node:child_process';
6
6
  * about what a failure looks like or when a port is free — the publisher learned both lessons the
7
7
  * expensive way, and neither of them is about Kubernetes.
8
8
  */
9
- /**
10
- * Output ceiling for every validate/build child process.
11
- *
12
- * Node's default is 1 MiB, and a target project with a few hundred type errors exceeds it: the
13
- * child is killed and the fixer receives `stdout maxBuffer length exceeded` instead of the errors
14
- * it is supposed to repair.
15
- */
16
- export declare const MAX_OUTPUT_BUFFER: number;
17
- /** One-shot script ceiling. A build that outlives it is wedged, not slow. */
18
- export declare const BUILD_TIMEOUT = 300000;
19
- /**
20
- * Compose a failed command's output into the text a fixer reads.
21
- *
22
- * Never interpolate the `ExecException` beside `stderr`: its string form is
23
- * `Error: Command failed: <cmd>\n<stderr>`, so the naive `${stdout} ${error} ${stderr}` shape
24
- * emitted every diagnostic twice and prefixed a runner sentence that is not a diagnostic at all.
25
- * Both survive into the fix conversation — the duplicate doubles the prompt for nothing, and the
26
- * preamble is what a model latches onto when it cannot see a real cause. Say it once, and say
27
- * what actually ran only when there is nothing else to report.
28
- */
29
- export declare const failureOutput: (error: unknown, stdout: string, stderr: string, cmd: string) => string;
30
- export interface RunOptions {
31
- cwd: string;
32
- env?: Record<string, string>;
33
- /** Answer with stdout alone on failure — what a type check's diagnostics are. */
34
- stdoutOnly?: boolean;
35
- }
36
- /**
37
- * Run a shell command and answer "error text, or null".
38
- *
39
- * The one contract every shell command here shares. A caller never has to know whether the child
40
- * exited non-zero, failed to spawn or produced nothing — those are all one answer.
41
- */
42
- export declare const runCommand: (cmd: string, options: RunOptions) => Promise<string | null>;
43
- /**
44
- * Run one of the target's own `scripts.*`, bounded.
45
- *
46
- * `spawn` rather than `exec` because a build's output is unbounded and streaming it costs nothing,
47
- * and because a wedged `bunx` resolving forever must die rather than hold the caller open. The
48
- * timeout is reported as a verdict, not thrown, so it reaches the same channel a failed build does.
49
- */
50
- export declare const runScript: (script: string, cwd: string, env?: Record<string, string>) => Promise<string | null>;
51
- /**
52
- * Bound one whole dispatch, whatever it is.
53
- *
54
- * Every operation below already bounds itself, but one that wedges AROUND its own bound — a lock
55
- * nothing releases, a promise that never settles — holds the caller open with nothing to report,
56
- * and the caller's timeout becomes the only limit. Reaching this means the operation failed to
57
- * bound itself, not that it needed longer.
58
- */
59
- export declare const withDeadline: <T>(label: string, ms: number, fn: () => Promise<T>) => Promise<T>;
60
- /** Whether anything answers a TCP connect on a local port. */
61
- export declare const probeListening: (port: number, timeoutMs?: number) => Promise<boolean>;
62
- /**
63
- * Wait until nothing answers on a local port.
64
- *
65
- * The child spawned here is a shell wrapping `bun`, so the shell's exit is not proof the target is
66
- * gone: a signal the shell dies from and `bun` survives leaves an orphan that still owns the port.
67
- * Whether the port answers is the only fact that decides whether a replacement can bind, so a
68
- * restart waits on that and never on an exit event.
69
- */
70
- export declare const waitForPortFree: (port: number, timeoutMs?: number, pollMs?: number) => Promise<boolean>;
71
- /**
72
- * Terminate a detached child's whole process group and wait until it is actually gone.
73
- *
74
- * Awaiting matters: the caller restarts right after, and a process still holding the port makes
75
- * the replacement lose the bind and exit — leaving nothing listening and no error anyone reads.
76
- */
77
- export declare const killGroupAndWait: (proc: ChildProcess, options?: {
78
- term?: number;
79
- kill?: number;
80
- }) => Promise<void>;
81
- /**
82
- * Take a port back from a leftover running the same command.
83
- *
84
- * A connector that was killed — a host restart, a Ctrl-C, a crashed run — leaves its DETACHED
85
- * children alive, because detaching them is what keeps a build from dying with the tool that
86
- * started it. What survives holds the target's port, and every later attempt then fails with the
87
- * target's own "the api port is already in use", which reads as a defect in the generated app.
88
- *
89
- * Matched by the marker the spawn carries, never by the port alone: a process this connector did
90
- * not start is not ours to signal, whatever it is sitting on.
91
- */
92
- export declare const reclaimPort: (port: number, marker: string) => Promise<boolean>;
93
- /**
94
- * The pids whose command line carries a marker.
95
- *
96
- * `/proc` rather than `ps`, for the same reason the publisher reads it: no shell, no parsing of a
97
- * format that differs per platform. Somewhere without `/proc` simply has nothing to reclaim, which
98
- * is the honest answer there.
99
- */
100
- export declare const findProcesses: (needles: string | string[]) => Promise<number[]>;
101
- /**
102
- * Signal a process GROUP, falling back to the process.
103
- *
104
- * The negative pid is the point: a child spawned detached through a shell survives a signal aimed
105
- * at the shell's own pid, and what survives is the `bun` process holding the port.
106
- */
107
- export declare const signalGroup: (pid: number | undefined, signal: NodeJS.Signals) => boolean;
108
- /** Whether a recorded pid is still a live process. */
109
- export declare const isAlive: (pid: number | undefined) => boolean;
110
- export declare const delay: (ms: number) => Promise<void>;
9
+ export declare const createSpawnHelper: () => SpawnHelper;
10
+ export declare const spawnHelper: SpawnHelper;
111
11
  //# sourceMappingURL=spawn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/executor/spawn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAItD;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,aAAa,SAAU,CAAA;AASpC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,UACjB,OAAO,UAAU,MAAM,UAAU,MAAM,OAAO,MAAM,KAC1D,MAKF,CAAA;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,iFAAiF;IACjF,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAe,MAAM,WAAW,UAAU,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAkBrF,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,WACZ,MAAM,OAAO,MAAM,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACxD,OAAO,CAAC,MAAM,GAAG,IAAI,CA4BtB,CAAA;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,SAC3B,MAAM,MAAM,MAAM,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,KAC9C,OAAO,CAAC,CAAC,CAeX,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,cAAc,SAAgB,MAAM,yBAAsB,OAAO,CAAC,OAAO,CAYlF,CAAA;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,SACpB,MAAM,0CACX,OAAO,CAAC,OAAO,CAWjB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SACrB,YAAY,YAAW;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5D,OAAO,CAAC,IAAI,CAcd,CAAA;AAuCD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,SAAgB,MAAM,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAiB/E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,YAAmB,MAAM,GAAG,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,EAAE,CAsBhF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAS,MAAM,GAAG,SAAS,UAAU,MAAM,CAAC,OAAO,KAAG,OAe7E,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,OAAO,QAAS,MAAM,GAAG,SAAS,KAAG,OASjD,CAAA;AAED,eAAO,MAAM,KAAK,OAAc,MAAM,KAAG,OAAO,CAAC,IAAI,CAGnD,CAAA"}
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/executor/spawn.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;;;GAMG;AAEH,eAAO,MAAM,iBAAiB,QAAO,WA+OpC,CAAA;AAED,eAAO,MAAM,WAAW,aAAsB,CAAA"}
@@ -1,6 +1,8 @@
1
1
  import { exec, spawn } from 'node:child_process';
2
2
  import net from 'node:net';
3
3
  import fsp from 'node:fs/promises';
4
+ import { KILL_TIMEOUT, PORT_FREE_TIMEOUT, PORT_POLL_MS, TARGET_SCRIPT, TERM_TIMEOUT } from './consts.local.js';
5
+ import { BUILD_TIMEOUT, MAX_OUTPUT_BUFFER } from './consts.js';
4
6
  /**
5
7
  * Everything that starts, bounds or ends a child process on the developer's machine.
6
8
  *
@@ -8,307 +10,223 @@ import fsp from 'node:fs/promises';
8
10
  * about what a failure looks like or when a port is free — the publisher learned both lessons the
9
11
  * expensive way, and neither of them is about Kubernetes.
10
12
  */
11
- /**
12
- * Output ceiling for every validate/build child process.
13
- *
14
- * Node's default is 1 MiB, and a target project with a few hundred type errors exceeds it: the
15
- * child is killed and the fixer receives `stdout maxBuffer length exceeded` instead of the errors
16
- * it is supposed to repair.
17
- */
18
- export const MAX_OUTPUT_BUFFER = 10 * 1024 * 1024;
19
- /** One-shot script ceiling. A build that outlives it is wedged, not slow. */
20
- export const BUILD_TIMEOUT = 300_000;
21
- /** How long a port may stay bound after the process holding it was told to die. */
22
- const PORT_FREE_TIMEOUT = 10_000;
23
- const PORT_POLL_MS = 200;
24
- const TERM_TIMEOUT = 5_000;
25
- const KILL_TIMEOUT = 2_000;
26
- /**
27
- * Compose a failed command's output into the text a fixer reads.
28
- *
29
- * Never interpolate the `ExecException` beside `stderr`: its string form is
30
- * `Error: Command failed: <cmd>\n<stderr>`, so the naive `${stdout} ${error} ${stderr}` shape
31
- * emitted every diagnostic twice and prefixed a runner sentence that is not a diagnostic at all.
32
- * Both survive into the fix conversation — the duplicate doubles the prompt for nothing, and the
33
- * preamble is what a model latches onto when it cannot see a real cause. Say it once, and say
34
- * what actually ran only when there is nothing else to report.
35
- */
36
- export const failureOutput = (error, stdout, stderr, cmd) => {
37
- const body = [stdout, stderr].map(part => part.trim()).filter(Boolean).join('\n');
38
- const code = error?.code ?? 1;
39
- return body !== '' ? `${body}\nexit ${code}: ${cmd}` : `exit ${code}: ${cmd}`;
40
- };
41
- /**
42
- * Run a shell command and answer "error text, or null".
43
- *
44
- * The one contract every shell command here shares. A caller never has to know whether the child
45
- * exited non-zero, failed to spawn or produced nothing — those are all one answer.
46
- */
47
- export const runCommand = async (cmd, options) => await new Promise(resolve => {
48
- exec(cmd, {
49
- cwd: options.cwd,
50
- maxBuffer: MAX_OUTPUT_BUFFER,
51
- env: options.env != null ? { ...process.env, ...options.env } : process.env,
52
- }, (error, stdout, stderr) => {
53
- if (error != null) {
54
- return resolve(options.stdoutOnly === true
55
- ? stdout
56
- : failureOutput(error, stdout, stderr, cmd));
57
- }
58
- resolve(null);
13
+ export const createSpawnHelper = () => {
14
+ const failureOutput = (error, stdout, stderr, cmd) => {
15
+ const body = [stdout, stderr].map(part => part.trim()).filter(Boolean).join('\n');
16
+ const code = error?.code ?? 1;
17
+ return body !== '' ? `${body}\nexit ${code}: ${cmd}` : `exit ${code}: ${cmd}`;
18
+ };
19
+ const runCommand = async (cmd, options) => await new Promise(resolve => {
20
+ exec(cmd, {
21
+ cwd: options.cwd,
22
+ maxBuffer: MAX_OUTPUT_BUFFER,
23
+ env: options.env != null ? { ...process.env, ...options.env } : process.env,
24
+ }, (error, stdout, stderr) => {
25
+ if (error != null) {
26
+ return resolve(options.stdoutOnly === true
27
+ ? stdout
28
+ : failureOutput(error, stdout, stderr, cmd));
29
+ }
30
+ resolve(null);
31
+ });
59
32
  });
60
- });
61
- /**
62
- * Run one of the target's own `scripts.*`, bounded.
63
- *
64
- * `spawn` rather than `exec` because a build's output is unbounded and streaming it costs nothing,
65
- * and because a wedged `bunx` resolving forever must die rather than hold the caller open. The
66
- * timeout is reported as a verdict, not thrown, so it reaches the same channel a failed build does.
67
- */
68
- export const runScript = async (script, cwd, env) => await new Promise(resolve => {
69
- const proc = spawn('bun', ['run', script], {
70
- cwd,
71
- shell: true,
72
- stdio: ['ignore', 'pipe', 'pipe'],
73
- env: { ...process.env, ...(env ?? {}) },
33
+ const runScript = async (script, cwd, env) => await new Promise(resolve => {
34
+ const proc = spawn('bun', ['run', script], {
35
+ cwd,
36
+ shell: true,
37
+ stdio: ['ignore', 'pipe', 'pipe'],
38
+ env: { ...process.env, ...(env ?? {}) },
39
+ });
40
+ let out = '';
41
+ let err = '';
42
+ let settled = false;
43
+ const finish = (value) => {
44
+ if (settled)
45
+ return;
46
+ settled = true;
47
+ clearTimeout(timer);
48
+ resolve(value);
49
+ };
50
+ const timer = setTimeout(() => {
51
+ try {
52
+ proc.kill('SIGKILL');
53
+ }
54
+ catch { /* already gone */ }
55
+ finish(`${script} timed out after ${BUILD_TIMEOUT}ms`);
56
+ }, BUILD_TIMEOUT);
57
+ timer.unref?.();
58
+ proc.stdout?.on('data', chunk => { out += chunk.toString(); });
59
+ proc.stderr?.on('data', chunk => { err += chunk.toString(); });
60
+ // A spawn error never reaches the exit handler, so it is answered here or it is lost.
61
+ proc.on('error', error => finish(`${error}`));
62
+ proc.on('exit', code => finish(code === 0 ? null : `${out}\n${err}`));
74
63
  });
75
- let out = '';
76
- let err = '';
77
- let settled = false;
78
- const finish = (value) => {
79
- if (settled)
80
- return;
81
- settled = true;
82
- clearTimeout(timer);
83
- resolve(value);
84
- };
85
- const timer = setTimeout(() => {
64
+ const withDeadline = async (label, ms, fn) => {
65
+ let timer;
86
66
  try {
87
- proc.kill('SIGKILL');
67
+ return await Promise.race([
68
+ fn(),
69
+ new Promise((_, reject) => {
70
+ timer = setTimeout(() => reject(new Error(`Slot command timed out: ${label} after ${ms}ms`)), ms);
71
+ timer.unref?.();
72
+ }),
73
+ ]);
74
+ }
75
+ finally {
76
+ if (timer != null)
77
+ clearTimeout(timer);
88
78
  }
89
- catch { /* already gone */ }
90
- finish(`${script} timed out after ${BUILD_TIMEOUT}ms`);
91
- }, BUILD_TIMEOUT);
92
- timer.unref?.();
93
- proc.stdout?.on('data', chunk => { out += chunk.toString(); });
94
- proc.stderr?.on('data', chunk => { err += chunk.toString(); });
95
- // A spawn error never reaches the exit handler, so it is answered here or it is lost.
96
- proc.on('error', error => finish(`${error}`));
97
- proc.on('exit', code => finish(code === 0 ? null : `${out}\n${err}`));
98
- });
99
- /**
100
- * Bound one whole dispatch, whatever it is.
101
- *
102
- * Every operation below already bounds itself, but one that wedges AROUND its own bound — a lock
103
- * nothing releases, a promise that never settles — holds the caller open with nothing to report,
104
- * and the caller's timeout becomes the only limit. Reaching this means the operation failed to
105
- * bound itself, not that it needed longer.
106
- */
107
- export const withDeadline = async (label, ms, fn) => {
108
- let timer;
109
- try {
110
- return await Promise.race([
111
- fn(),
112
- new Promise((_, reject) => {
113
- timer = setTimeout(() => reject(new Error(`Slot command timed out: ${label} after ${ms}ms`)), ms);
114
- timer.unref?.();
115
- }),
116
- ]);
117
- }
118
- finally {
119
- if (timer != null)
120
- clearTimeout(timer);
121
- }
122
- };
123
- /** Whether anything answers a TCP connect on a local port. */
124
- export const probeListening = async (port, timeoutMs = 1_000) => await new Promise(resolve => {
125
- const socket = net.connect({ host: '127.0.0.1', port });
126
- const done = (value) => {
127
- socket.removeAllListeners();
128
- socket.destroy();
129
- resolve(value);
130
79
  };
131
- socket.setTimeout(timeoutMs);
132
- socket.once('connect', () => done(true));
133
- socket.once('timeout', () => done(false));
134
- socket.once('error', () => done(false));
135
- });
136
- /**
137
- * Wait until nothing answers on a local port.
138
- *
139
- * The child spawned here is a shell wrapping `bun`, so the shell's exit is not proof the target is
140
- * gone: a signal the shell dies from and `bun` survives leaves an orphan that still owns the port.
141
- * Whether the port answers is the only fact that decides whether a replacement can bind, so a
142
- * restart waits on that and never on an exit event.
143
- */
144
- export const waitForPortFree = async (port, timeoutMs = PORT_FREE_TIMEOUT, pollMs = PORT_POLL_MS) => {
145
- const deadline = Date.now() + timeoutMs;
146
- for (;;) {
147
- if (!await probeListening(port)) {
148
- return true;
80
+ const probeListening = async (port, timeoutMs = 1_000) => await new Promise(resolve => {
81
+ const socket = net.connect({ host: '127.0.0.1', port });
82
+ const done = (value) => {
83
+ socket.removeAllListeners();
84
+ socket.destroy();
85
+ resolve(value);
86
+ };
87
+ socket.setTimeout(timeoutMs);
88
+ socket.once('connect', () => done(true));
89
+ socket.once('timeout', () => done(false));
90
+ socket.once('error', () => done(false));
91
+ });
92
+ const waitForPortFree = async (port, timeoutMs = PORT_FREE_TIMEOUT, pollMs = PORT_POLL_MS) => {
93
+ const deadline = Date.now() + timeoutMs;
94
+ for (;;) {
95
+ if (!await probeListening(port)) {
96
+ return true;
97
+ }
98
+ if (Date.now() >= deadline) {
99
+ return false;
100
+ }
101
+ await delay(pollMs);
149
102
  }
150
- if (Date.now() >= deadline) {
103
+ };
104
+ const killGroupAndWait = async (proc, options = {}) => {
105
+ const term = options.term ?? TERM_TIMEOUT;
106
+ const kill = options.kill ?? KILL_TIMEOUT;
107
+ const pid = proc.pid;
108
+ // NEVER an early return on the child's own exit code. The child is a shell wrapping `bun`, so a
109
+ // signal the shell dies from leaves `bun` alive and holding the port while `exitCode` says it is
110
+ // gone — the exact shape that leaves a stray server running on somebody's machine and every
111
+ // later boot check failing with "the api port is already in use".
112
+ signalGroup(pid, 'SIGTERM');
113
+ if (await gone(pid, term))
114
+ return;
115
+ signalGroup(pid, 'SIGKILL');
116
+ await gone(pid, kill);
117
+ };
118
+ /** Whether a process group is still around. EPERM counts as alive: it exists and is not ours. */
119
+ const groupAlive = (pid) => {
120
+ if (pid == null)
151
121
  return false;
152
- }
153
- await delay(pollMs);
154
- }
155
- };
156
- /**
157
- * Terminate a detached child's whole process group and wait until it is actually gone.
158
- *
159
- * Awaiting matters: the caller restarts right after, and a process still holding the port makes
160
- * the replacement lose the bind and exit — leaving nothing listening and no error anyone reads.
161
- */
162
- export const killGroupAndWait = async (proc, options = {}) => {
163
- const term = options.term ?? TERM_TIMEOUT;
164
- const kill = options.kill ?? KILL_TIMEOUT;
165
- const pid = proc.pid;
166
- // NEVER an early return on the child's own exit code. The child is a shell wrapping `bun`, so a
167
- // signal the shell dies from leaves `bun` alive and holding the port while `exitCode` says it is
168
- // gone — the exact shape that leaves a stray server running on somebody's machine and every
169
- // later boot check failing with "the api port is already in use".
170
- signalGroup(pid, 'SIGTERM');
171
- if (await gone(pid, term))
172
- return;
173
- signalGroup(pid, 'SIGKILL');
174
- await gone(pid, kill);
175
- };
176
- /** Whether a process group is still around. EPERM counts as alive: it exists and is not ours. */
177
- const groupAlive = (pid) => {
178
- if (pid == null)
179
- return false;
180
- try {
181
- process.kill(-pid, 0);
182
- return true;
183
- }
184
- catch (e) {
185
- if (e.code === 'EPERM')
186
- return true;
187
122
  try {
188
- process.kill(pid, 0);
123
+ process.kill(-pid, 0);
189
124
  return true;
190
125
  }
191
- catch (own) {
192
- return own.code === 'EPERM';
126
+ catch (e) {
127
+ if (e.code === 'EPERM')
128
+ return true;
129
+ try {
130
+ process.kill(pid, 0);
131
+ return true;
132
+ }
133
+ catch (own) {
134
+ return own.code === 'EPERM';
135
+ }
193
136
  }
194
- }
195
- };
196
- /**
197
- * Wait until the whole GROUP is gone, or the budget runs out.
198
- *
199
- * Polled rather than awaited on the child's `exit` event, because that event is about the shell
200
- * and the thing worth waiting for is whatever it started.
201
- */
202
- const gone = async (pid, budgetMs) => {
203
- const deadline = Date.now() + budgetMs;
204
- for (;;) {
205
- if (!groupAlive(pid))
137
+ };
138
+ /**
139
+ * Wait until the whole GROUP is gone, or the budget runs out.
140
+ *
141
+ * Polled rather than awaited on the child's `exit` event, because that event is about the shell
142
+ * and the thing worth waiting for is whatever it started.
143
+ */
144
+ const gone = async (pid, budgetMs) => {
145
+ const deadline = Date.now() + budgetMs;
146
+ for (;;) {
147
+ if (!groupAlive(pid))
148
+ return true;
149
+ if (Date.now() >= deadline)
150
+ return false;
151
+ await delay(50);
152
+ }
153
+ };
154
+ const reclaimPort = async (port, marker) => {
155
+ if (!await probeListening(port))
206
156
  return true;
207
- if (Date.now() >= deadline)
157
+ // BOTH the script and the marker. A marker alone would match any process whose command line
158
+ // merely mentions it — a shell the user is typing in, a grep, an editor — and this sends SIGKILL.
159
+ const orphans = await findProcesses([TARGET_SCRIPT, marker]);
160
+ if (orphans.length < 1)
208
161
  return false;
209
- await delay(50);
210
- }
211
- };
212
- /** What every target process runs; the marker is what tells the three of them apart. */
213
- const TARGET_SCRIPT = 'dist/index.js';
214
- /**
215
- * Take a port back from a leftover running the same command.
216
- *
217
- * A connector that was killed — a host restart, a Ctrl-C, a crashed run — leaves its DETACHED
218
- * children alive, because detaching them is what keeps a build from dying with the tool that
219
- * started it. What survives holds the target's port, and every later attempt then fails with the
220
- * target's own "the api port is already in use", which reads as a defect in the generated app.
221
- *
222
- * Matched by the marker the spawn carries, never by the port alone: a process this connector did
223
- * not start is not ours to signal, whatever it is sitting on.
224
- */
225
- export const reclaimPort = async (port, marker) => {
226
- if (!await probeListening(port))
227
- return true;
228
- // BOTH the script and the marker. A marker alone would match any process whose command line
229
- // merely mentions it — a shell the user is typing in, a grep, an editor — and this sends SIGKILL.
230
- const orphans = await findProcesses([TARGET_SCRIPT, marker]);
231
- if (orphans.length < 1)
232
- return false;
233
- for (const pid of orphans) {
162
+ for (const pid of orphans) {
163
+ try {
164
+ process.kill(pid, 'SIGKILL');
165
+ }
166
+ catch {
167
+ // Already gone.
168
+ }
169
+ }
170
+ return await waitForPortFree(port);
171
+ };
172
+ const findProcesses = async (needles) => {
173
+ const wanted = Array.isArray(needles) ? needles : [needles];
174
+ const pids = [];
175
+ let entries;
234
176
  try {
235
- process.kill(pid, 'SIGKILL');
177
+ entries = await fsp.readdir('/proc');
236
178
  }
237
179
  catch {
238
- // Already gone.
180
+ return pids;
181
+ }
182
+ for (const entry of entries) {
183
+ const pid = Number(entry);
184
+ if (!Number.isInteger(pid) || pid === process.pid)
185
+ continue;
186
+ try {
187
+ const cmdline = (await fsp.readFile(`/proc/${entry}/cmdline`, 'utf8')).replace(/\0/g, ' ').trim();
188
+ if (cmdline !== '' && wanted.every(needle => cmdline.includes(needle)))
189
+ pids.push(pid);
190
+ }
191
+ catch {
192
+ // Ended mid-scan, or not ours to read — either way not a target.
193
+ }
239
194
  }
240
- }
241
- return await waitForPortFree(port);
242
- };
243
- /**
244
- * The pids whose command line carries a marker.
245
- *
246
- * `/proc` rather than `ps`, for the same reason the publisher reads it: no shell, no parsing of a
247
- * format that differs per platform. Somewhere without `/proc` simply has nothing to reclaim, which
248
- * is the honest answer there.
249
- */
250
- export const findProcesses = async (needles) => {
251
- const wanted = Array.isArray(needles) ? needles : [needles];
252
- const pids = [];
253
- let entries;
254
- try {
255
- entries = await fsp.readdir('/proc');
256
- }
257
- catch {
258
195
  return pids;
259
- }
260
- for (const entry of entries) {
261
- const pid = Number(entry);
262
- if (!Number.isInteger(pid) || pid === process.pid)
263
- continue;
196
+ };
197
+ const signalGroup = (pid, signal) => {
198
+ if (pid == null)
199
+ return false;
264
200
  try {
265
- const cmdline = (await fsp.readFile(`/proc/${entry}/cmdline`, 'utf8')).replace(/\0/g, ' ').trim();
266
- if (cmdline !== '' && wanted.every(needle => cmdline.includes(needle)))
267
- pids.push(pid);
201
+ process.kill(-pid, signal);
202
+ return true;
268
203
  }
269
204
  catch {
270
- // Ended mid-scan, or not ours to read — either way not a target.
205
+ try {
206
+ process.kill(pid, signal);
207
+ return true;
208
+ }
209
+ catch {
210
+ return false;
211
+ }
271
212
  }
272
- }
273
- return pids;
274
- };
275
- /**
276
- * Signal a process GROUP, falling back to the process.
277
- *
278
- * The negative pid is the point: a child spawned detached through a shell survives a signal aimed
279
- * at the shell's own pid, and what survives is the `bun` process holding the port.
280
- */
281
- export const signalGroup = (pid, signal) => {
282
- if (pid == null)
283
- return false;
284
- try {
285
- process.kill(-pid, signal);
286
- return true;
287
- }
288
- catch {
213
+ };
214
+ const isAlive = (pid) => {
215
+ if (pid == null)
216
+ return false;
289
217
  try {
290
- process.kill(pid, signal);
218
+ process.kill(pid, 0);
291
219
  return true;
292
220
  }
293
221
  catch {
294
222
  return false;
295
223
  }
296
- }
297
- };
298
- /** Whether a recorded pid is still a live process. */
299
- export const isAlive = (pid) => {
300
- if (pid == null)
301
- return false;
302
- try {
303
- process.kill(pid, 0);
304
- return true;
305
- }
306
- catch {
307
- return false;
308
- }
224
+ };
225
+ const delay = async (ms) => await new Promise(resolve => {
226
+ const timer = setTimeout(resolve, ms);
227
+ timer.unref?.();
228
+ });
229
+ return { failureOutput, runCommand, runScript, withDeadline, probeListening, waitForPortFree, killGroupAndWait, reclaimPort, findProcesses, signalGroup, isAlive, delay };
309
230
  };
310
- export const delay = async (ms) => await new Promise(resolve => {
311
- const timer = setTimeout(resolve, ms);
312
- timer.unref?.();
313
- });
231
+ export const spawnHelper = createSpawnHelper();
314
232
  //# sourceMappingURL=spawn.js.map