@fnndsc/brasa 0.57.4 → 0.58.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 (512) hide show
  1. package/dist/api/models.d.ts +2 -3
  2. package/dist/api/models.js.map +1 -1
  3. package/dist/buildinfo.json +1 -1
  4. package/dist/builtins/argumentTokens.js +25 -6
  5. package/dist/builtins/argumentTokens.js.map +1 -1
  6. package/dist/builtins/berth/berth.d.ts +0 -14
  7. package/dist/builtins/berth/berth.js +255 -88
  8. package/dist/builtins/berth/berth.js.map +1 -1
  9. package/dist/builtins/berth/berthClose.d.ts +66 -1
  10. package/dist/builtins/berth/berthClose.js +312 -26
  11. package/dist/builtins/berth/berthClose.js.map +1 -1
  12. package/dist/builtins/berth/berthClosed.d.ts +212 -0
  13. package/dist/builtins/berth/berthClosed.js +231 -0
  14. package/dist/builtins/berth/berthClosed.js.map +1 -0
  15. package/dist/builtins/berth/berthCube.js +27 -6
  16. package/dist/builtins/berth/berthCube.js.map +1 -1
  17. package/dist/builtins/berth/berthDisk.js +1 -1
  18. package/dist/builtins/berth/berthDisk.js.map +1 -1
  19. package/dist/builtins/berth/berthProcesses.js +15 -3
  20. package/dist/builtins/berth/berthProcesses.js.map +1 -1
  21. package/dist/builtins/berth/berthRecord.d.ts +14 -2
  22. package/dist/builtins/berth/berthRecord.js +20 -5
  23. package/dist/builtins/berth/berthRecord.js.map +1 -1
  24. package/dist/builtins/berth/berthState.d.ts +26 -6
  25. package/dist/builtins/berth/berthState.js +47 -13
  26. package/dist/builtins/berth/berthState.js.map +1 -1
  27. package/dist/builtins/debug.d.ts +0 -8
  28. package/dist/builtins/debug.js +1 -12
  29. package/dist/builtins/debug.js.map +1 -1
  30. package/dist/builtins/executable.js +102 -75
  31. package/dist/builtins/executable.js.map +1 -1
  32. package/dist/builtins/feedTotals.js +30 -25
  33. package/dist/builtins/feedTotals.js.map +1 -1
  34. package/dist/builtins/fs/acl.args.d.ts +3 -10
  35. package/dist/builtins/fs/acl.args.js +16 -24
  36. package/dist/builtins/fs/acl.args.js.map +1 -1
  37. package/dist/builtins/fs/acl.d.ts +0 -37
  38. package/dist/builtins/fs/acl.js +36 -58
  39. package/dist/builtins/fs/acl.js.map +1 -1
  40. package/dist/builtins/fs/archive.js +4 -7
  41. package/dist/builtins/fs/archive.js.map +1 -1
  42. package/dist/builtins/fs/cat.d.ts +0 -16
  43. package/dist/builtins/fs/cat.js +163 -96
  44. package/dist/builtins/fs/cat.js.map +1 -1
  45. package/dist/builtins/fs/cd.js +23 -5
  46. package/dist/builtins/fs/cd.js.map +1 -1
  47. package/dist/builtins/fs/configWrite.d.ts +0 -8
  48. package/dist/builtins/fs/configWrite.js +33 -46
  49. package/dist/builtins/fs/configWrite.js.map +1 -1
  50. package/dist/builtins/fs/cp.d.ts +6 -10
  51. package/dist/builtins/fs/cp.js +83 -86
  52. package/dist/builtins/fs/cp.js.map +1 -1
  53. package/dist/builtins/fs/deliveryIntent.d.ts +24 -0
  54. package/dist/builtins/fs/deliveryIntent.js +182 -0
  55. package/dist/builtins/fs/deliveryIntent.js.map +1 -0
  56. package/dist/builtins/fs/deliveryMatch.d.ts +138 -0
  57. package/dist/builtins/fs/deliveryMatch.js +135 -0
  58. package/dist/builtins/fs/deliveryMatch.js.map +1 -0
  59. package/dist/builtins/fs/destination.d.ts +37 -1
  60. package/dist/builtins/fs/destination.js +80 -0
  61. package/dist/builtins/fs/destination.js.map +1 -1
  62. package/dist/builtins/fs/download.d.ts +19 -8
  63. package/dist/builtins/fs/download.js +142 -72
  64. package/dist/builtins/fs/download.js.map +1 -1
  65. package/dist/builtins/fs/du.d.ts +0 -8
  66. package/dist/builtins/fs/du.js +23 -20
  67. package/dist/builtins/fs/du.js.map +1 -1
  68. package/dist/builtins/fs/edit.js +117 -50
  69. package/dist/builtins/fs/edit.js.map +1 -1
  70. package/dist/builtins/fs/entries.d.ts +38 -0
  71. package/dist/builtins/fs/entries.js +48 -1
  72. package/dist/builtins/fs/entries.js.map +1 -1
  73. package/dist/builtins/fs/find.d.ts +1 -1
  74. package/dist/builtins/fs/find.js +462 -271
  75. package/dist/builtins/fs/find.js.map +1 -1
  76. package/dist/builtins/fs/ls.d.ts +2 -8
  77. package/dist/builtins/fs/ls.js +144 -93
  78. package/dist/builtins/fs/ls.js.map +1 -1
  79. package/dist/builtins/fs/mkdir.d.ts +2 -7
  80. package/dist/builtins/fs/mkdir.js +110 -58
  81. package/dist/builtins/fs/mkdir.js.map +1 -1
  82. package/dist/builtins/fs/mv.d.ts +7 -10
  83. package/dist/builtins/fs/mv.js +155 -100
  84. package/dist/builtins/fs/mv.js.map +1 -1
  85. package/dist/builtins/fs/pull.js +155 -92
  86. package/dist/builtins/fs/pull.js.map +1 -1
  87. package/dist/builtins/fs/pwd.d.ts +0 -7
  88. package/dist/builtins/fs/pwd.js +0 -12
  89. package/dist/builtins/fs/pwd.js.map +1 -1
  90. package/dist/builtins/fs/rm.d.ts +6 -7
  91. package/dist/builtins/fs/rm.js +364 -174
  92. package/dist/builtins/fs/rm.js.map +1 -1
  93. package/dist/builtins/fs/rmdir.d.ts +0 -7
  94. package/dist/builtins/fs/rmdir.js +40 -21
  95. package/dist/builtins/fs/rmdir.js.map +1 -1
  96. package/dist/builtins/fs/touch.d.ts +0 -7
  97. package/dist/builtins/fs/touch.js +14 -27
  98. package/dist/builtins/fs/touch.js.map +1 -1
  99. package/dist/builtins/fs/transferJobs.d.ts +12 -0
  100. package/dist/builtins/fs/transferJobs.js +19 -0
  101. package/dist/builtins/fs/transferJobs.js.map +1 -1
  102. package/dist/builtins/fs/tree.d.ts +0 -8
  103. package/dist/builtins/fs/tree.js +1 -12
  104. package/dist/builtins/fs/tree.js.map +1 -1
  105. package/dist/builtins/fs/upload.d.ts +0 -8
  106. package/dist/builtins/fs/upload.js +23 -20
  107. package/dist/builtins/fs/upload.js.map +1 -1
  108. package/dist/builtins/fs/url.d.ts +14 -2
  109. package/dist/builtins/fs/url.js +6 -8
  110. package/dist/builtins/fs/url.js.map +1 -1
  111. package/dist/builtins/fs/writeReport.d.ts +40 -0
  112. package/dist/builtins/fs/writeReport.js +71 -0
  113. package/dist/builtins/fs/writeReport.js.map +1 -0
  114. package/dist/builtins/fs/xattr.args.d.ts +14 -13
  115. package/dist/builtins/fs/xattr.args.js +3 -24
  116. package/dist/builtins/fs/xattr.args.js.map +1 -1
  117. package/dist/builtins/fs/xattr.d.ts +0 -25
  118. package/dist/builtins/fs/xattr.js +82 -65
  119. package/dist/builtins/fs/xattr.js.map +1 -1
  120. package/dist/builtins/games/bytes.d.ts +0 -55
  121. package/dist/builtins/games/bytes.js +95 -120
  122. package/dist/builtins/games/bytes.js.map +1 -1
  123. package/dist/builtins/games/chimes.d.ts +0 -36
  124. package/dist/builtins/games/chimes.js +58 -64
  125. package/dist/builtins/games/chimes.js.map +1 -1
  126. package/dist/builtins/games/chrislab.d.ts +0 -12
  127. package/dist/builtins/games/chrislab.js +0 -14
  128. package/dist/builtins/games/chrislab.js.map +1 -1
  129. package/dist/builtins/games/cowsay.d.ts +0 -24
  130. package/dist/builtins/games/cowsay.js +0 -29
  131. package/dist/builtins/games/cowsay.js.map +1 -1
  132. package/dist/builtins/games/figlet.d.ts +0 -24
  133. package/dist/builtins/games/figlet.js +0 -29
  134. package/dist/builtins/games/figlet.js.map +1 -1
  135. package/dist/builtins/games/lab.d.ts +0 -36
  136. package/dist/builtins/games/lab.js +0 -43
  137. package/dist/builtins/games/lab.js.map +1 -1
  138. package/dist/builtins/games/lolcat.d.ts +0 -12
  139. package/dist/builtins/games/lolcat.js +2 -17
  140. package/dist/builtins/games/lolcat.js.map +1 -1
  141. package/dist/builtins/games/numbers.d.ts +0 -60
  142. package/dist/builtins/games/numbers.js +0 -71
  143. package/dist/builtins/games/numbers.js.map +1 -1
  144. package/dist/builtins/games/play.d.ts +0 -36
  145. package/dist/builtins/games/play.js +47 -58
  146. package/dist/builtins/games/play.js.map +1 -1
  147. package/dist/builtins/games/qr.d.ts +0 -12
  148. package/dist/builtins/games/qr.js +189 -68
  149. package/dist/builtins/games/qr.js.map +1 -1
  150. package/dist/builtins/games/show.d.ts +0 -73
  151. package/dist/builtins/games/show.js +0 -85
  152. package/dist/builtins/games/show.js.map +1 -1
  153. package/dist/builtins/games/sky.d.ts +0 -36
  154. package/dist/builtins/games/sky.js +25 -45
  155. package/dist/builtins/games/sky.js.map +1 -1
  156. package/dist/builtins/games/text.d.ts +0 -72
  157. package/dist/builtins/games/text.js +0 -85
  158. package/dist/builtins/games/text.js.map +1 -1
  159. package/dist/builtins/games/trek.d.ts +0 -12
  160. package/dist/builtins/games/trek.js +0 -15
  161. package/dist/builtins/games/trek.js.map +1 -1
  162. package/dist/builtins/games/wtf.d.ts +0 -12
  163. package/dist/builtins/games/wtf.js +0 -15
  164. package/dist/builtins/games/wtf.js.map +1 -1
  165. package/dist/builtins/help.d.ts +0 -19
  166. package/dist/builtins/help.js +56 -39
  167. package/dist/builtins/help.js.map +1 -1
  168. package/dist/builtins/helpSections.js +13 -1
  169. package/dist/builtins/helpSections.js.map +1 -1
  170. package/dist/builtins/index.d.ts +1 -1
  171. package/dist/builtins/index.js +1 -1
  172. package/dist/builtins/index.js.map +1 -1
  173. package/dist/builtins/net/connect.d.ts +1 -8
  174. package/dist/builtins/net/connect.js +2 -13
  175. package/dist/builtins/net/connect.js.map +1 -1
  176. package/dist/builtins/net/cubepath.js +30 -20
  177. package/dist/builtins/net/cubepath.js.map +1 -1
  178. package/dist/builtins/net/logout.d.ts +0 -8
  179. package/dist/builtins/net/logout.js +1 -12
  180. package/dist/builtins/net/logout.js.map +1 -1
  181. package/dist/builtins/net/netstat.d.ts +0 -8
  182. package/dist/builtins/net/netstat.js +1 -12
  183. package/dist/builtins/net/netstat.js.map +1 -1
  184. package/dist/builtins/net/pacs.d.ts +3 -17
  185. package/dist/builtins/net/pacs.js +50 -42
  186. package/dist/builtins/net/pacs.js.map +1 -1
  187. package/dist/builtins/net/pacsUtils.d.ts +0 -2
  188. package/dist/builtins/net/pacsUtils.js +67 -30
  189. package/dist/builtins/net/pacsUtils.js.map +1 -1
  190. package/dist/builtins/net/query.anon.d.ts +61 -0
  191. package/dist/builtins/net/query.anon.js +362 -0
  192. package/dist/builtins/net/query.anon.js.map +1 -0
  193. package/dist/builtins/net/query.args.d.ts +2 -1
  194. package/dist/builtins/net/query.args.js +1 -1
  195. package/dist/builtins/net/query.args.js.map +1 -1
  196. package/dist/builtins/net/query.cohort.d.ts +125 -0
  197. package/dist/builtins/net/query.cohort.js +267 -0
  198. package/dist/builtins/net/query.cohort.js.map +1 -0
  199. package/dist/builtins/net/query.csv.d.ts +26 -5
  200. package/dist/builtins/net/query.csv.js +61 -115
  201. package/dist/builtins/net/query.csv.js.map +1 -1
  202. package/dist/builtins/net/query.d.ts +27 -34
  203. package/dist/builtins/net/query.deliver.d.ts +96 -0
  204. package/dist/builtins/net/query.deliver.js +188 -0
  205. package/dist/builtins/net/query.deliver.js.map +1 -0
  206. package/dist/builtins/net/query.fanout.d.ts +32 -0
  207. package/dist/builtins/net/query.fanout.js +91 -0
  208. package/dist/builtins/net/query.fanout.js.map +1 -1
  209. package/dist/builtins/net/query.held.d.ts +60 -0
  210. package/dist/builtins/net/query.held.js +125 -0
  211. package/dist/builtins/net/query.held.js.map +1 -0
  212. package/dist/builtins/net/query.ignored.d.ts +3 -1
  213. package/dist/builtins/net/query.ignored.js +9 -3
  214. package/dist/builtins/net/query.ignored.js.map +1 -1
  215. package/dist/builtins/net/query.js +360 -634
  216. package/dist/builtins/net/query.js.map +1 -1
  217. package/dist/builtins/net/query.model.d.ts +15 -0
  218. package/dist/builtins/net/query.model.js +109 -46
  219. package/dist/builtins/net/query.model.js.map +1 -1
  220. package/dist/builtins/net/query.view.js +29 -8
  221. package/dist/builtins/net/query.view.js.map +1 -1
  222. package/dist/builtins/operandRuns.js +4 -3
  223. package/dist/builtins/operandRuns.js.map +1 -1
  224. package/dist/builtins/operands.js +97 -39
  225. package/dist/builtins/operands.js.map +1 -1
  226. package/dist/builtins/pluginExecute.js +311 -205
  227. package/dist/builtins/pluginExecute.js.map +1 -1
  228. package/dist/builtins/proc.d.ts +1 -13
  229. package/dist/builtins/proc.helpers.d.ts +0 -7
  230. package/dist/builtins/proc.helpers.js +0 -10
  231. package/dist/builtins/proc.helpers.js.map +1 -1
  232. package/dist/builtins/proc.js +159 -116
  233. package/dist/builtins/proc.js.map +1 -1
  234. package/dist/builtins/procWatch.d.ts +2 -2
  235. package/dist/builtins/procWatch.js +54 -13
  236. package/dist/builtins/procWatch.js.map +1 -1
  237. package/dist/builtins/res/compute.d.ts +0 -13
  238. package/dist/builtins/res/compute.js +0 -16
  239. package/dist/builtins/res/compute.js.map +1 -1
  240. package/dist/builtins/res/diagram.tree.js +36 -12
  241. package/dist/builtins/res/diagram.tree.js.map +1 -1
  242. package/dist/builtins/res/dicom.d.ts +24 -17
  243. package/dist/builtins/res/dicom.js +78 -79
  244. package/dist/builtins/res/dicom.js.map +1 -1
  245. package/dist/builtins/res/expect.d.ts +8 -17
  246. package/dist/builtins/res/expect.js +173 -101
  247. package/dist/builtins/res/expect.js.map +1 -1
  248. package/dist/builtins/res/feed.d.ts +0 -13
  249. package/dist/builtins/res/feed.diagram.js +89 -57
  250. package/dist/builtins/res/feed.diagram.js.map +1 -1
  251. package/dist/builtins/res/feed.js +61 -42
  252. package/dist/builtins/res/feed.js.map +1 -1
  253. package/dist/builtins/res/feed.tree.collapse.d.ts +0 -10
  254. package/dist/builtins/res/feed.tree.collapse.js +12 -5
  255. package/dist/builtins/res/feed.tree.collapse.js.map +1 -1
  256. package/dist/builtins/res/files.d.ts +0 -37
  257. package/dist/builtins/res/files.js +0 -44
  258. package/dist/builtins/res/files.js.map +1 -1
  259. package/dist/builtins/res/gather.d.ts +0 -13
  260. package/dist/builtins/res/gather.facts.js +24 -16
  261. package/dist/builtins/res/gather.facts.js.map +1 -1
  262. package/dist/builtins/res/gather.js +47 -36
  263. package/dist/builtins/res/gather.js.map +1 -1
  264. package/dist/builtins/res/gather.process.js +49 -15
  265. package/dist/builtins/res/gather.process.js.map +1 -1
  266. package/dist/builtins/res/gather.store.d.ts +4 -2
  267. package/dist/builtins/res/gather.store.js +43 -31
  268. package/dist/builtins/res/gather.store.js.map +1 -1
  269. package/dist/builtins/res/group.d.ts +0 -13
  270. package/dist/builtins/res/group.js +78 -40
  271. package/dist/builtins/res/group.js.map +1 -1
  272. package/dist/builtins/res/image.d.ts +0 -13
  273. package/dist/builtins/res/image.js +0 -15
  274. package/dist/builtins/res/image.js.map +1 -1
  275. package/dist/builtins/res/manifestRead.d.ts +65 -0
  276. package/dist/builtins/res/manifestRead.js +161 -0
  277. package/dist/builtins/res/manifestRead.js.map +1 -0
  278. package/dist/builtins/res/pipeline.d.ts +1 -1
  279. package/dist/builtins/res/pipeline.js +152 -103
  280. package/dist/builtins/res/pipeline.js.map +1 -1
  281. package/dist/builtins/res/pipeline.manifest.js +17 -7
  282. package/dist/builtins/res/pipeline.manifest.js.map +1 -1
  283. package/dist/builtins/res/play.d.ts +0 -13
  284. package/dist/builtins/res/play.js +367 -226
  285. package/dist/builtins/res/play.js.map +1 -1
  286. package/dist/builtins/res/plugin.d.ts +1 -13
  287. package/dist/builtins/res/plugin.info.js +36 -14
  288. package/dist/builtins/res/plugin.info.js.map +1 -1
  289. package/dist/builtins/res/plugin.js +1 -17
  290. package/dist/builtins/res/plugin.js.map +1 -1
  291. package/dist/builtins/res/plugin.sync.d.ts +3 -5
  292. package/dist/builtins/res/plugin.sync.js +175 -40
  293. package/dist/builtins/res/plugin.sync.js.map +1 -1
  294. package/dist/builtins/res/plugininstance.d.ts +0 -13
  295. package/dist/builtins/res/plugininstance.js +0 -16
  296. package/dist/builtins/res/plugininstance.js.map +1 -1
  297. package/dist/builtins/res/pluginmeta.d.ts +0 -13
  298. package/dist/builtins/res/pluginmeta.js +0 -16
  299. package/dist/builtins/res/pluginmeta.js.map +1 -1
  300. package/dist/builtins/res/record.d.ts +0 -13
  301. package/dist/builtins/res/record.js +2 -18
  302. package/dist/builtins/res/record.js.map +1 -1
  303. package/dist/builtins/res/runWait.js +32 -8
  304. package/dist/builtins/res/runWait.js.map +1 -1
  305. package/dist/builtins/res/tag.d.ts +0 -13
  306. package/dist/builtins/res/tag.js +0 -16
  307. package/dist/builtins/res/tag.js.map +1 -1
  308. package/dist/builtins/res/thumbnail.js +23 -8
  309. package/dist/builtins/res/thumbnail.js.map +1 -1
  310. package/dist/builtins/res/user.d.ts +0 -12
  311. package/dist/builtins/res/user.js +0 -17
  312. package/dist/builtins/res/user.js.map +1 -1
  313. package/dist/builtins/res/workflow.d.ts +0 -13
  314. package/dist/builtins/res/workflow.js +0 -16
  315. package/dist/builtins/res/workflow.js.map +1 -1
  316. package/dist/builtins/runEcho.js +2 -1
  317. package/dist/builtins/runEcho.js.map +1 -1
  318. package/dist/builtins/store.d.ts +0 -13
  319. package/dist/builtins/store.js +32 -32
  320. package/dist/builtins/store.js.map +1 -1
  321. package/dist/builtins/sys/apropos.d.ts +2 -27
  322. package/dist/builtins/sys/apropos.js +2 -32
  323. package/dist/builtins/sys/apropos.js.map +1 -1
  324. package/dist/builtins/sys/cal.d.ts +0 -12
  325. package/dist/builtins/sys/cal.js +0 -15
  326. package/dist/builtins/sys/cal.js.map +1 -1
  327. package/dist/builtins/sys/command.js +3 -7
  328. package/dist/builtins/sys/command.js.map +1 -1
  329. package/dist/builtins/sys/context.d.ts +0 -8
  330. package/dist/builtins/sys/context.js +1 -12
  331. package/dist/builtins/sys/context.js.map +1 -1
  332. package/dist/builtins/sys/date.d.ts +0 -12
  333. package/dist/builtins/sys/date.js +0 -15
  334. package/dist/builtins/sys/date.js.map +1 -1
  335. package/dist/builtins/sys/echo.d.ts +0 -12
  336. package/dist/builtins/sys/echo.js +54 -49
  337. package/dist/builtins/sys/echo.js.map +1 -1
  338. package/dist/builtins/sys/fortune.d.ts +0 -12
  339. package/dist/builtins/sys/fortune.js +0 -15
  340. package/dist/builtins/sys/fortune.js.map +1 -1
  341. package/dist/builtins/sys/grep.d.ts +14 -18
  342. package/dist/builtins/sys/grep.js +239 -114
  343. package/dist/builtins/sys/grep.js.map +1 -1
  344. package/dist/builtins/sys/hostGrants.d.ts +85 -0
  345. package/dist/builtins/sys/hostGrants.js +207 -0
  346. package/dist/builtins/sys/hostGrants.js.map +1 -0
  347. package/dist/builtins/sys/joblets.d.ts +0 -24
  348. package/dist/builtins/sys/joblets.js +0 -29
  349. package/dist/builtins/sys/joblets.js.map +1 -1
  350. package/dist/builtins/sys/motd.d.ts +0 -12
  351. package/dist/builtins/sys/motd.js +14 -21
  352. package/dist/builtins/sys/motd.js.map +1 -1
  353. package/dist/builtins/sys/notes.js +26 -16
  354. package/dist/builtins/sys/notes.js.map +1 -1
  355. package/dist/builtins/sys/physicalmode.d.ts +0 -8
  356. package/dist/builtins/sys/physicalmode.js +1 -12
  357. package/dist/builtins/sys/physicalmode.js.map +1 -1
  358. package/dist/builtins/sys/tasks.d.ts +0 -24
  359. package/dist/builtins/sys/tasks.js +30 -36
  360. package/dist/builtins/sys/tasks.js.map +1 -1
  361. package/dist/builtins/sys/textFilters.d.ts +0 -84
  362. package/dist/builtins/sys/textFilters.js +33 -110
  363. package/dist/builtins/sys/textFilters.js.map +1 -1
  364. package/dist/builtins/sys/timing.d.ts +0 -8
  365. package/dist/builtins/sys/timing.js +1 -12
  366. package/dist/builtins/sys/timing.js.map +1 -1
  367. package/dist/builtins/sys/variables.d.ts +0 -24
  368. package/dist/builtins/sys/variables.js +0 -29
  369. package/dist/builtins/sys/variables.js.map +1 -1
  370. package/dist/builtins/sys/version.d.ts +0 -12
  371. package/dist/builtins/sys/version.js +0 -15
  372. package/dist/builtins/sys/version.js.map +1 -1
  373. package/dist/builtins/sys/weather.js +46 -27
  374. package/dist/builtins/sys/weather.js.map +1 -1
  375. package/dist/builtins/sys/whoami.d.ts +0 -22
  376. package/dist/builtins/sys/whoami.js +16 -43
  377. package/dist/builtins/sys/whoami.js.map +1 -1
  378. package/dist/builtins/utils.d.ts +4 -39
  379. package/dist/builtins/utils.js +24 -55
  380. package/dist/builtins/utils.js.map +1 -1
  381. package/dist/chris/backend.js +7 -12
  382. package/dist/chris/backend.js.map +1 -1
  383. package/dist/chris/binDeclarations.d.ts +0 -44
  384. package/dist/chris/binDeclarations.js +111 -29
  385. package/dist/chris/binDeclarations.js.map +1 -1
  386. package/dist/chris/binExecutables.js +26 -18
  387. package/dist/chris/binExecutables.js.map +1 -1
  388. package/dist/chris/chiliDelegate.d.ts +104 -0
  389. package/dist/chris/chiliDelegate.js +240 -0
  390. package/dist/chris/chiliDelegate.js.map +1 -1
  391. package/dist/chris/commandFallback.d.ts +2 -2
  392. package/dist/chris/commandFallback.js +107 -50
  393. package/dist/chris/commandFallback.js.map +1 -1
  394. package/dist/chris/completion.d.ts +3 -1
  395. package/dist/chris/completion.js +5 -17
  396. package/dist/chris/completion.js.map +1 -1
  397. package/dist/chris/connect.d.ts +37 -0
  398. package/dist/chris/connect.js +46 -0
  399. package/dist/chris/connect.js.map +1 -1
  400. package/dist/chris/files.js +32 -2
  401. package/dist/chris/files.js.map +1 -1
  402. package/dist/chris/navigation.js +87 -53
  403. package/dist/chris/navigation.js.map +1 -1
  404. package/dist/chris/pacsResources.js +28 -11
  405. package/dist/chris/pacsResources.js.map +1 -1
  406. package/dist/chris/promptContext.js +68 -35
  407. package/dist/chris/promptContext.js.map +1 -1
  408. package/dist/chris/universeLayout.d.ts +8 -2
  409. package/dist/chris/universeLayout.js +40 -11
  410. package/dist/chris/universeLayout.js.map +1 -1
  411. package/dist/chris/warmup.d.ts +140 -0
  412. package/dist/chris/warmup.js +622 -0
  413. package/dist/chris/warmup.js.map +1 -0
  414. package/dist/core/argumentKinds.js +4 -4
  415. package/dist/core/argumentKinds.js.map +1 -1
  416. package/dist/core/assignment.js +8 -6
  417. package/dist/core/assignment.js.map +1 -1
  418. package/dist/core/backend.d.ts +44 -8
  419. package/dist/core/backend.js.map +1 -1
  420. package/dist/core/commandDeclaration.d.ts +8 -0
  421. package/dist/core/commandDeclaration.js.map +1 -1
  422. package/dist/core/commandParse.d.ts +34 -1
  423. package/dist/core/commandParse.js +156 -28
  424. package/dist/core/commandParse.js.map +1 -1
  425. package/dist/core/commandRegistry.d.ts +24 -5
  426. package/dist/core/commandRegistry.js +28 -5
  427. package/dist/core/commandRegistry.js.map +1 -1
  428. package/dist/core/dispatch.d.ts +1 -12
  429. package/dist/core/dispatch.js +12 -16
  430. package/dist/core/dispatch.js.map +1 -1
  431. package/dist/core/elevation.js +30 -5
  432. package/dist/core/elevation.js.map +1 -1
  433. package/dist/core/engine.d.ts +5 -11
  434. package/dist/core/engine.js +126 -50
  435. package/dist/core/engine.js.map +1 -1
  436. package/dist/core/expansion.d.ts +0 -6
  437. package/dist/core/expansion.js +0 -8
  438. package/dist/core/expansion.js.map +1 -1
  439. package/dist/core/filesystem.js +1 -1
  440. package/dist/core/filesystem.js.map +1 -1
  441. package/dist/core/handlerRun.d.ts +13 -0
  442. package/dist/core/handlerRun.js +21 -0
  443. package/dist/core/handlerRun.js.map +1 -1
  444. package/dist/core/holds.js +3 -3
  445. package/dist/core/holds.js.map +1 -1
  446. package/dist/core/hostGate.d.ts +62 -0
  447. package/dist/core/hostGate.js +72 -0
  448. package/dist/core/hostGate.js.map +1 -0
  449. package/dist/core/joblets.js +53 -27
  450. package/dist/core/joblets.js.map +1 -1
  451. package/dist/core/paths.d.ts +3 -5
  452. package/dist/core/paths.js +107 -36
  453. package/dist/core/paths.js.map +1 -1
  454. package/dist/core/preprocess.d.ts +12 -0
  455. package/dist/core/preprocess.js +42 -15
  456. package/dist/core/preprocess.js.map +1 -1
  457. package/dist/core/question.d.ts +27 -3
  458. package/dist/core/question.js +14 -6
  459. package/dist/core/question.js.map +1 -1
  460. package/dist/core/runner.d.ts +31 -7
  461. package/dist/core/runner.js +189 -37
  462. package/dist/core/runner.js.map +1 -1
  463. package/dist/core/sink.d.ts +7 -19
  464. package/dist/core/sink.js +56 -28
  465. package/dist/core/sink.js.map +1 -1
  466. package/dist/core/surface.js +1 -0
  467. package/dist/core/surface.js.map +1 -1
  468. package/dist/core/variables.js +37 -11
  469. package/dist/core/variables.js.map +1 -1
  470. package/dist/core/version.d.ts +0 -20
  471. package/dist/core/version.js +2 -26
  472. package/dist/core/version.js.map +1 -1
  473. package/dist/core/warmupFailures.d.ts +3 -6
  474. package/dist/core/warmupFailures.js.map +1 -1
  475. package/dist/core.d.ts +2 -0
  476. package/dist/core.js +2 -0
  477. package/dist/core.js.map +1 -1
  478. package/dist/index.d.ts +8 -1
  479. package/dist/index.js +8 -1
  480. package/dist/index.js.map +1 -1
  481. package/dist/lib/completer/cfsPaths.js +66 -26
  482. package/dist/lib/completer/cfsPaths.js.map +1 -1
  483. package/dist/lib/completer/declared.js +81 -20
  484. package/dist/lib/completer/declared.js.map +1 -1
  485. package/dist/lib/completer/index.d.ts +3 -0
  486. package/dist/lib/completer/index.js +44 -7
  487. package/dist/lib/completer/index.js.map +1 -1
  488. package/dist/lib/parser.d.ts +0 -16
  489. package/dist/lib/parser.js +223 -135
  490. package/dist/lib/parser.js.map +1 -1
  491. package/dist/lib/vfs/folderListing.d.ts +85 -0
  492. package/dist/lib/vfs/folderListing.js +86 -0
  493. package/dist/lib/vfs/folderListing.js.map +1 -0
  494. package/dist/lib/vfs/vfs.d.ts +37 -9
  495. package/dist/lib/vfs/vfs.js +195 -110
  496. package/dist/lib/vfs/vfs.js.map +1 -1
  497. package/dist/lib/wildcard.d.ts +7 -34
  498. package/dist/lib/wildcard.js +123 -95
  499. package/dist/lib/wildcard.js.map +1 -1
  500. package/dist/notes.json +1 -1
  501. package/dist/session/answerAdapters.js +249 -131
  502. package/dist/session/answerAdapters.js.map +1 -1
  503. package/package.json +12 -10
  504. package/dist/builtins/wildcard.d.ts +0 -8
  505. package/dist/builtins/wildcard.js +0 -9
  506. package/dist/builtins/wildcard.js.map +0 -1
  507. package/dist/lib/quoting.d.ts +0 -40
  508. package/dist/lib/quoting.js +0 -70
  509. package/dist/lib/quoting.js.map +0 -1
  510. package/dist/lib/semicolonParser.d.ts +0 -41
  511. package/dist/lib/semicolonParser.js +0 -93
  512. package/dist/lib/semicolonParser.js.map +0 -1
@@ -21,13 +21,12 @@
21
21
  *
22
22
  * Key components:
23
23
  * - playCommand: the declaration.
24
- * - builtin_play: the declaration run over words already split.
25
24
  * - playArgs_parse: a line's words to the request it makes.
26
25
  * - manifest_parse, line_expand: a manifest's text and its lines.
27
26
  *
28
27
  * Typical usage:
29
28
  * ```ts
30
- * await builtin_play(['~/flows/battery.mise', '--param', 'MRN=1234567']);
29
+ * await declaredCommand_run(playCommand, ['~/flows/battery.mise', '--param', 'MRN=1234567']);
31
30
  * ```
32
31
  *
33
32
  * Dependencies: the engine's line path (`line_execute`), the session's
@@ -35,25 +34,24 @@
35
34
  *
36
35
  * @module
37
36
  */
37
+ import { AsyncLocalStorage } from 'node:async_hooks';
38
+ import { commandList_parse } from '@fnndsc/menu';
39
+ import { envelope_ok, envelope_error, LINE_DECLINED_MODEL_KIND, MANIFEST_STATUS_MODEL_KIND } from '@fnndsc/menu';
38
40
  import chalk from 'chalk';
39
- import { path_resolve } from '../utils.js';
40
- import { duration_parse } from '../../lib/duration.js';
41
- import { recorderMuted_run } from '../../session/recorder.js';
42
- import { session } from '../../session/index.js';
43
- import { sink_dataLine, sink_errLine } from '../../core/sink.js';
44
- import { commandCancellation_enable, commandCancellation_signalGet } from '../../core/cancellation.js';
41
+ import { manifestText_read } from './manifestRead.js';
45
42
  import { backendInstalled_get } from '../../core/backend.js';
46
- import { exitCode_read, exitCode_set } from '../../core/handlerRun.js';
43
+ import { commandCancellation_enable, commandCancellation_signalGet, commandCancellation_stopped } from '../../core/cancellation.js';
47
44
  import { reference_changedBy, reference_isReserved, reference_resolve, unresolvedStands_run } from '../../core/expansion.js';
45
+ import { exitCode_read, exitCode_set } from '../../core/handlerRun.js';
48
46
  import { pipes_parse } from '../../core/preprocess.js';
49
- import { commandList_parse, semicolons_parse } from '../../lib/semicolonParser.js';
47
+ import { sink_dataLine, sink_errLine } from '../../core/sink.js';
50
48
  import { VARIABLE_NAME, assignment_parse, variable_get, variableScope_run } from '../../core/variables.js';
49
+ import { duration_parse } from '../../lib/duration.js';
51
50
  import { shellWord_literal, shellWords_referencesExpand, shellWords_tokenize } from '../../lib/parser.js';
52
- import { errorStack } from '@fnndsc/fond';
53
- import { envelope_ok, envelope_error, LINE_DECLINED_MODEL_KIND, MANIFEST_STATUS_MODEL_KIND } from '@fnndsc/menu';
54
- import { AsyncLocalStorage } from 'node:async_hooks';
55
51
  import { command_declare } from '../../core/commandDeclaration.js';
56
- import { commandLine_parse, declaredCommand_run } from '../../core/commandParse.js';
52
+ import { commandLine_parse } from '../../core/commandParse.js';
53
+ import { session } from '../../session/index.js';
54
+ import { recorderMuted_run } from '../../session/recorder.js';
57
55
  /** The model kind under which a played manifest's outcome travels. */
58
56
  export const PLAY_MODEL_KIND = 'manifest.played';
59
57
  /** The model `play --status` answers with: one row per line. */
@@ -66,6 +64,37 @@ const depthScope = new AsyncLocalStorage();
66
64
  function depth_get() {
67
65
  return depthScope.getStore() ?? 0;
68
66
  }
67
+ /**
68
+ * Parses a `@param` directive's value into its name and optional default.
69
+ *
70
+ * @param value - Text following `@param`.
71
+ * @returns The parsed parameter descriptor.
72
+ */
73
+ function paramDirective_parse(value) {
74
+ const equals = value.indexOf('=');
75
+ if (equals === -1)
76
+ return { name: value.trim() };
77
+ return { name: value.slice(0, equals).trim(), fallback: value.slice(equals + 1).trim() };
78
+ }
79
+ /**
80
+ * Applies a single `@` header directive line to a manifest under construction.
81
+ *
82
+ * @param trimmed - Trimmed line starting with `@`.
83
+ * @param manifest - Mutable manifest being populated.
84
+ */
85
+ function manifestDirective_apply(trimmed, manifest) {
86
+ const space = trimmed.search(/\s/);
87
+ const directive = space === -1 ? trimmed : trimmed.slice(0, space);
88
+ const value = space === -1 ? '' : trimmed.slice(space + 1).trim();
89
+ if (directive === '@name')
90
+ manifest.name = value;
91
+ else if (directive === '@description')
92
+ manifest.description = value;
93
+ else if (directive === '@answers')
94
+ manifest.answers = value;
95
+ else if (directive === '@param')
96
+ manifest.params.push(paramDirective_parse(value));
97
+ }
69
98
  /**
70
99
  * Reads a manifest.
71
100
  *
@@ -76,11 +105,13 @@ function depth_get() {
76
105
  * @returns What the file says, and the lines to run.
77
106
  */
78
107
  export function manifest_parse(text) {
79
- const params = [];
80
- const lines = [];
81
- let name = null;
82
- let description = null;
83
- let answers = null;
108
+ const manifest = {
109
+ name: null,
110
+ description: null,
111
+ params: [],
112
+ answers: null,
113
+ lines: [],
114
+ };
84
115
  const raw = text.split('\n');
85
116
  for (let index = 0; index < raw.length; index++) {
86
117
  const line = raw[index];
@@ -88,27 +119,12 @@ export function manifest_parse(text) {
88
119
  if (trimmed.length === 0 || trimmed.startsWith('#'))
89
120
  continue;
90
121
  if (trimmed.startsWith('@')) {
91
- const space = trimmed.search(/\s/);
92
- const directive = space === -1 ? trimmed : trimmed.slice(0, space);
93
- const value = space === -1 ? '' : trimmed.slice(space + 1).trim();
94
- if (directive === '@name')
95
- name = value;
96
- else if (directive === '@description')
97
- description = value;
98
- else if (directive === '@answers')
99
- answers = value;
100
- else if (directive === '@param') {
101
- const equals = value.indexOf('=');
102
- if (equals === -1)
103
- params.push({ name: value.trim() });
104
- else
105
- params.push({ name: value.slice(0, equals).trim(), fallback: value.slice(equals + 1).trim() });
106
- }
122
+ manifestDirective_apply(trimmed, manifest);
107
123
  continue;
108
124
  }
109
- lines.push({ number: index + 1, text: trimmed });
125
+ manifest.lines.push({ number: index + 1, text: trimmed });
110
126
  }
111
- return { name, description, params, answers, lines };
127
+ return manifest;
112
128
  }
113
129
  /**
114
130
  * Sleeps between lines, unless the play is cancelled.
@@ -129,47 +145,6 @@ async function pause_take(ms, signal) {
129
145
  signal?.addEventListener('abort', onAbort, { once: true });
130
146
  });
131
147
  }
132
- /**
133
- * Reads a manifest, from the backend's filesystem (ChRIS: CFS) or from the
134
- * engine's own disk.
135
- *
136
- * A manifest is a ChRIS file: that is what makes one shareable, and sharing
137
- * it is `setfacl`, like any other file. But a repository's battery lives
138
- * beside the code that it tests, and uploading itself before it can run
139
- * would be a ritual, not a requirement — so a path that names no CFS file
140
- * is looked for on the host the ENGINE runs on. In a daemon that is the
141
- * daemon's disk, never the surface's, which is why CFS is asked first.
142
- *
143
- * @param target - The manifest, as the operator wrote it.
144
- * @returns The text and where it came from, or a refusal when neither has it.
145
- */
146
- async function manifestText_read(target) {
147
- const resolved = await path_resolve(target);
148
- // Asking CFS is how we find out whether the manifest lives there. The
149
- // miss is an ANSWER, not a fault: left on the stack it made a play that
150
- // ran a host-side battery perfectly exit non-zero.
151
- // The backend's files are asked first (ChRIS: CFS); a backend with no
152
- // files of its own (stratus) has only the engine's disk.
153
- const files = backendInstalled_get()?.files;
154
- if (files !== undefined) {
155
- const mark = errorStack.checkpoint_mark();
156
- try {
157
- const bytes = await files.read(resolved);
158
- return { ok: true, value: { text: bytes.toString('utf8'), from: resolved } };
159
- }
160
- catch {
161
- errorStack.checkpoint_drain(mark);
162
- }
163
- }
164
- try {
165
- const { readFile } = await import('node:fs/promises');
166
- const text = await readFile(target, 'utf8');
167
- return { ok: true, value: { text, from: target } };
168
- }
169
- catch {
170
- return { ok: false };
171
- }
172
- }
173
148
  /**
174
149
  * Renders one command's words as the kernel would expand them.
175
150
  *
@@ -216,6 +191,20 @@ async function line_preview(text, passed) {
216
191
  }
217
192
  return preview;
218
193
  }
194
+ /**
195
+ * Records the leading verb of each pipeline stage in a command body.
196
+ *
197
+ * @param body - The command or capture body.
198
+ * @param verbs - The verbs seen so far, added to.
199
+ */
200
+ function bodyVerbs_note(body, verbs) {
201
+ for (const piece of pipes_parse(body)) {
202
+ const words = shellWords_tokenize(piece).map((word) => word.value);
203
+ const verb = words[0] === 'sudo' ? words[1] : words[0];
204
+ if (verb !== undefined)
205
+ verbs.add(verb);
206
+ }
207
+ }
219
208
  /**
220
209
  * Notes what a line could change, for the lines a dry run previews after
221
210
  * it: the verb of every command it holds (each side of a pipe, each part of
@@ -226,19 +215,14 @@ async function line_preview(text, passed) {
226
215
  * @param assigned - The variables assigned so far, added to.
227
216
  */
228
217
  function linePassed_note(text, verbs, assigned) {
229
- for (const command of semicolons_parse(text.trim())) {
218
+ for (const { command } of commandList_parse(text.trim())) {
230
219
  const assignment = assignment_parse(command.trim());
231
220
  if (assignment !== null)
232
221
  assigned.add(assignment.name);
233
222
  if (assignment !== null && !('capture' in assignment))
234
223
  continue;
235
224
  const body = assignment !== null && 'capture' in assignment ? assignment.capture : command;
236
- for (const piece of pipes_parse(body)) {
237
- const words = shellWords_tokenize(piece).map((word) => word.value);
238
- const verb = words[0] === 'sudo' ? words[1] : words[0];
239
- if (verb !== undefined)
240
- verbs.add(verb);
241
- }
225
+ bodyVerbs_note(body, verbs);
242
226
  }
243
227
  }
244
228
  /**
@@ -346,6 +330,47 @@ function state_show(state) {
346
330
  default: return chalk.gray('—');
347
331
  }
348
332
  }
333
+ /**
334
+ * Merges a line-status provider readout onto a base standing row.
335
+ *
336
+ * @param standing - Initial standing row for the line.
337
+ * @param read - Provider readout, or `null` when the provider declined.
338
+ * @returns The updated standing row.
339
+ */
340
+ function standingRead_apply(standing, read) {
341
+ if (read === null)
342
+ return standing;
343
+ return {
344
+ ...standing,
345
+ state: read.state,
346
+ detail: read.detail,
347
+ ...(read.running === undefined ? {} : { running: read.running }),
348
+ };
349
+ }
350
+ /**
351
+ * Records a provider error on a standing row.
352
+ *
353
+ * @param standing - Initial standing row for the line.
354
+ * @param error - What the provider threw.
355
+ * @returns The standing row with error detail.
356
+ */
357
+ function standingError_apply(standing, error) {
358
+ return { ...standing, detail: error instanceof Error ? error.message : String(error) };
359
+ }
360
+ /**
361
+ * Formats one standing row for the sink readout.
362
+ *
363
+ * @param standing - The line's standing.
364
+ * @param text - Expanded preview text.
365
+ * @returns One formatted status line.
366
+ */
367
+ function lineStanding_format(standing, text) {
368
+ const pad = ' '.repeat(Math.max(1, 8 - (standing.state ?? '—').length));
369
+ // A line whose task runs now says so after its state: the state is what the records hold, the run is what is happening to them.
370
+ const running = standing.running === undefined ? '' : chalk.yellow(` ▶ running: ${standing.running} (wait ${standing.running} follows it)`);
371
+ const detail = standing.detail !== '' ? chalk.gray(` ${standing.detail}`) : '';
372
+ return `${state_show(standing.state)}${pad}${chalk.cyan(`▸ ${text}`)}${detail}${running}`;
373
+ }
349
374
  /**
350
375
  * Reads where every line of a manifest stands, running none: each line is
351
376
  * expanded as a dry run expands it, then its verb's provider on the backend
@@ -373,19 +398,14 @@ async function manifestStatus_read(manifest, name, values) {
373
398
  let standing = { number: line.number, text, state: null, detail: '' };
374
399
  if (provider !== undefined) {
375
400
  try {
376
- const read = await provider.read(words);
377
- if (read !== null)
378
- standing = { ...standing, state: read.state, detail: read.detail, ...(read.running === undefined ? {} : { running: read.running }) };
401
+ standing = standingRead_apply(standing, await provider.read(words));
379
402
  }
380
403
  catch (error) {
381
- standing = { ...standing, detail: error instanceof Error ? error.message : String(error) };
404
+ standing = standingError_apply(standing, error);
382
405
  }
383
406
  }
384
407
  standings.push(standing);
385
- const pad = ' '.repeat(Math.max(1, 8 - (standing.state ?? '—').length));
386
- // A line whose task runs now says so after its state: the state is what the records hold, the run is what is happening to them.
387
- const running = standing.running === undefined ? '' : chalk.yellow(` ▶ running: ${standing.running} (wait ${standing.running} follows it)`);
388
- sink_dataLine(`${state_show(standing.state)}${pad}${chalk.cyan(`▸ ${text}`)}${standing.detail !== '' ? chalk.gray(` ${standing.detail}`) : ''}${running}`);
408
+ sink_dataLine(lineStanding_format(standing, text));
389
409
  }
390
410
  });
391
411
  const counted = (state) => standings.filter((standing) => standing.state === state).length;
@@ -393,56 +413,49 @@ async function manifestStatus_read(manifest, name, values) {
393
413
  return envelope_ok(`${summary}\n`, { kind: PLAY_STATUS_KIND, data: { manifest: name, lines: standings } });
394
414
  }
395
415
  /**
396
- * `play` over words already split: the declaration's parse and handler.
416
+ * Refuses a play: non-zero, the reason in red.
397
417
  *
398
- * @param args - The words after `play`.
399
- * @returns An envelope carrying what the play did, or the refusal that stopped it.
418
+ * @param message - Why.
419
+ * @returns The error envelope.
420
+ */
421
+ function playLine_refuse(message) {
422
+ exitCode_set(1);
423
+ return envelope_error('', undefined, `${chalk.red(message)}\n`);
424
+ }
425
+ /**
426
+ * The manifest a play names, or why the play is refused before any reading:
427
+ * a line that did not parse, no manifest named, or nesting too deep.
400
428
  *
401
- * @example
402
- * ```ts
403
- * await builtin_play(['~/flows/battery.mise', '--dry-run']);
404
- * ```
429
+ * @param parsed - What was asked for.
430
+ * @returns The manifest's name, or the refusal.
405
431
  */
406
- export async function builtin_play(args) {
407
- return declaredCommand_run(playCommand, args);
432
+ function playManifest_name(parsed) {
433
+ if (parsed.parseError !== null)
434
+ return playLine_refuse(`play: ${parsed.parseError}`);
435
+ if (parsed.manifest === null)
436
+ return playLine_refuse('Usage: play <manifest> [--param NAME=value]... [--pace <duration>] [--dry-run] [--status [--text <script>]]');
437
+ if (depth_get() >= NESTING_MAX)
438
+ return playLine_refuse(`play: ${parsed.manifest} is nested too deep — a manifest may play a manifest, not a chain of them.`);
439
+ return parsed.manifest;
408
440
  }
409
441
  /**
410
- * Plays a manifest as asked: reads it, settles its parameters before any
411
- * line runs, then runs (or, with `--status`, reads) its lines in order.
442
+ * Settles everything the manifest needs BEFORE the first line runs: a
443
+ * manifest that gets half way and then asks has already changed the
444
+ * session, and the operator cannot un-ask it. A manifest may not take a name
445
+ * the session answers for: shadowing a built-in would make ${gather} mean
446
+ * two things in one language, and a reader of a shared file could not tell
447
+ * which one they were looking at.
412
448
  *
449
+ * @param name - The manifest as asked.
413
450
  * @param parsed - What was asked for.
414
- * @returns An envelope carrying what the play did, or the refusal that stopped it.
451
+ * @param manifest - The manifest, read.
452
+ * @returns Its parameters' values, or the refusal.
415
453
  */
416
- async function play_run(parsed) {
417
- if (parsed.parseError !== null) {
418
- exitCode_set(1);
419
- return envelope_error('', undefined, `${chalk.red(`play: ${parsed.parseError}`)}\n`);
420
- }
421
- if (parsed.manifest === null) {
422
- exitCode_set(1);
423
- return envelope_error('', undefined, `${chalk.red('Usage: play <manifest> [--param NAME=value]... [--pace <duration>] [--dry-run] [--status [--text <script>]]')}\n`);
424
- }
425
- if (depth_get() >= NESTING_MAX) {
426
- exitCode_set(1);
427
- return envelope_error('', undefined, `${chalk.red(`play: ${parsed.manifest} is nested too deep — a manifest may play a manifest, not a chain of them.`)}\n`);
428
- }
429
- const source = parsed.text !== null ? { ok: true, value: { text: parsed.text, from: parsed.manifest } } : await manifestText_read(parsed.manifest);
430
- if (!source.ok) {
431
- exitCode_set(1);
432
- return envelope_error('', undefined, `${chalk.red(`play: cannot read ${parsed.manifest} — no such manifest in the session's filesystem, and none beside the engine.`)}\n`);
433
- }
434
- const manifest = manifest_parse(source.value.text);
435
- // A manifest may not take a name the session answers for: shadowing a
436
- // built-in would make ${gather} mean two things in one language, and a
437
- // reader of a shared file could not tell which one they were looking at.
454
+ function playValues_settle(name, parsed, manifest) {
438
455
  const shadowed = manifest.params.filter((param) => reference_isReserved(param.name));
439
456
  if (shadowed.length > 0) {
440
- exitCode_set(1);
441
- return envelope_error('', undefined, `${chalk.red(`play: ${parsed.manifest} declares ${shadowed.map((param) => `@param ${param.name}`).join(', ')}, which the session already answers for.`)}\n`);
457
+ return playLine_refuse(`play: ${name} declares ${shadowed.map((param) => `@param ${param.name}`).join(', ')}, which the session already answers for.`);
442
458
  }
443
- // Everything the file needs is settled BEFORE the first line runs: a
444
- // manifest that gets half way and then asks has already changed the
445
- // session, and the operator cannot un-ask it.
446
459
  const values = new Map();
447
460
  const missing = [];
448
461
  for (const param of manifest.params) {
@@ -457,35 +470,239 @@ async function play_run(parsed) {
457
470
  for (const [key, value] of parsed.params)
458
471
  values.set(key, value);
459
472
  if (manifest.answers !== null && !VARIABLE_NAME.test(manifest.answers)) {
460
- exitCode_set(1);
461
- return envelope_error('', undefined, `${chalk.red(`play: ${parsed.manifest} answers '${manifest.answers}', which is not a variable's name.`)}\n`);
473
+ return playLine_refuse(`play: ${name} answers '${manifest.answers}', which is not a variable's name.`);
462
474
  }
463
475
  if (missing.length > 0) {
476
+ return playLine_refuse(`play: ${manifest.name ?? name} needs ${missing.map((one) => `--param ${one}=…`).join(' ')}`);
477
+ }
478
+ return values;
479
+ }
480
+ /**
481
+ * Judges a line that has just run: a STOP during it stops the play there, a
482
+ * failure, though a question in it was answered no first; the operator's no
483
+ * to its question stops the play as their choice, never as a refusal; a
484
+ * failed exit status stops it, since a workflow whose first half failed has
485
+ * a second half that is noise.
486
+ *
487
+ * @param name - The manifest as asked.
488
+ * @param line - The line.
489
+ * @param envelopes - What it answered.
490
+ * @returns 'stopped', 'declined', or null to go on.
491
+ */
492
+ function lineOutcome_judge(name, line, envelopes) {
493
+ if (commandCancellation_stopped()) {
494
+ sink_errLine(chalk.yellow(`play: stopped during ${name}:${String(line.number)}; the lines after it did not run`));
495
+ return 'stopped';
496
+ }
497
+ if (envelopes.some((envelope) => envelope.model?.kind === LINE_DECLINED_MODEL_KIND)) {
498
+ sink_dataLine(chalk.gray(`play: stopped at your answer to ${name}:${line.number}; the lines after it did not run`));
499
+ return 'declined';
500
+ }
501
+ if (exitCode_read() !== 0) {
502
+ sink_errLine(chalk.red(`✗ ${name}:${line.number} refused — stopping.`));
503
+ return 'stopped';
504
+ }
505
+ return null;
506
+ }
507
+ /**
508
+ * Plays a manifest's lines in order, inside the play's scopes, and reads
509
+ * what it answers with before the scope ends.
510
+ *
511
+ * @param name - The manifest as asked.
512
+ * @param parsed - What was asked for.
513
+ * @param manifest - The manifest.
514
+ * @param progress - Where the play has got; written as it goes.
515
+ * @param lineExecute - The engine's line path.
516
+ * @param signal - The STOP a pause listens to, when the play is paced.
517
+ * @returns Once the lines are played or the play stopped.
518
+ */
519
+ async function playLines_walk(name, parsed, manifest, progress, lineExecute, signal) {
520
+ // What the lines a dry run passed over could have changed.
521
+ const passedVerbs = new Set();
522
+ const passedAssigned = new Set();
523
+ for (const line of manifest.lines) {
524
+ // A STOP taken before the line (while the manifest was read, or between lines) starts no line,
525
+ // nor previews one.
526
+ if (commandCancellation_stopped()) {
527
+ sink_errLine(chalk.yellow(`play: stopped before ${name}:${String(line.number)}; it and the lines after it did not run`));
528
+ progress.stoppedAt = line.number;
529
+ break;
530
+ }
531
+ // A dry run shows what WOULD run, expanded by the kernel's own
532
+ // expander rather than a second one living here: a reference nothing
533
+ // can answer yet stands as written, since nothing has run to give it
534
+ // a value, and so does one an earlier line may have changed (#1241).
535
+ if (parsed.dryRun) {
536
+ sink_dataLine(chalk.cyan(`▸ ${await line_preview(line.text, { count: progress.ran, verbs: passedVerbs, assigned: passedAssigned })}`));
537
+ linePassed_note(line.text, passedVerbs, passedAssigned);
538
+ progress.ran += 1;
539
+ continue;
540
+ }
541
+ // The line is SHOWN as written, then handed to the session, which
542
+ // resolves its references the way it resolves every other line's.
543
+ sink_dataLine(chalk.cyan(`▸ ${line.text}`));
544
+ // A line failed when its exit status says so: a refusal sets it, and
545
+ // `a || b` ends with `b`'s. The status is cleared before each line, so
546
+ // one an earlier command left set (before the play, or by a line that
547
+ // passed) is never this line's.
548
+ exitCode_set(0);
549
+ const envelopes = await lineExecute(line.text);
550
+ progress.ran += 1;
551
+ const verdict = lineOutcome_judge(name, line, envelopes);
552
+ if (verdict === 'declined') {
553
+ progress.declinedAt = line.number;
554
+ break;
555
+ }
556
+ if (verdict === 'stopped') {
557
+ progress.stoppedAt = line.number;
558
+ break;
559
+ }
560
+ if (parsed.paceMs > 0 && !await pause_take(parsed.paceMs, signal)) {
561
+ sink_dataLine(chalk.yellow(`play: stopped at ${name}:${line.number}`));
562
+ progress.stoppedAt = line.number;
563
+ break;
564
+ }
565
+ }
566
+ if (manifest.answers !== null)
567
+ progress.answered = variable_get(manifest.answers);
568
+ }
569
+ /**
570
+ * Builds the error envelope for a play that stopped on a refusal or cancellation.
571
+ *
572
+ * @param name - The manifest as asked.
573
+ * @param manifest - The manifest.
574
+ * @param ran - Number of lines run.
575
+ * @param stoppedAt - Line number where the play stopped.
576
+ * @param took - Formatted elapsed duration.
577
+ * @returns The error envelope.
578
+ */
579
+ function stoppedOutcome_answer(name, manifest, ran, stoppedAt, took) {
580
+ exitCode_set(1);
581
+ // With no line to name (a manifest of none), the play says it stopped before any command ran.
582
+ const where = manifest.lines.length === 0
583
+ ? 'stopped before any command ran'
584
+ : `stopped at line ${String(stoppedAt)} after ${String(ran)} of ${String(manifest.lines.length)} lines`;
585
+ return envelope_error('', undefined, `${chalk.red(`play: ${name} ${where} (${took})`)}\n`);
586
+ }
587
+ /**
588
+ * Builds the completion envelope for a manifest that declares `@answers`.
589
+ *
590
+ * @param name - The manifest as asked.
591
+ * @param what - Verb phrase (`played` or `would play`).
592
+ * @param ran - Number of lines run.
593
+ * @param took - Formatted elapsed duration.
594
+ * @param answerName - Declared `@answers` variable name.
595
+ * @param answered - Variable captured before scope teardown.
596
+ * @returns The envelope carrying the answered variable's model, or an error if unset.
597
+ */
598
+ function answeredOutcome_answer(name, what, ran, took, answerName, answered) {
599
+ if (answered === undefined) {
464
600
  exitCode_set(1);
465
- return envelope_error('', undefined, `${chalk.red(`play: ${manifest.name ?? parsed.manifest} needs ${missing.map((name) => `--param ${name}=…`).join(' ')}`)}\n`);
601
+ return envelope_error('', undefined, `${chalk.red(`play: ${name} answers ${answerName}, and ${answerName} was never set`)}\n`);
602
+ }
603
+ return envelope_ok(`${chalk.green(`play: ${what} ${ran} line${ran === 1 ? '' : 's'} of ${name} (${took}), answering ${answerName}`)}\n`, { kind: answered.answer.kind, data: answered.answer.data });
604
+ }
605
+ /**
606
+ * What a play says once its lines are done: a STOP no line saw still stops
607
+ * it; a play that ran through leaves the session's status as it found it;
608
+ * a declined line is an ok, a stopped one a failure; a manifest that
609
+ * declares its answer hands back that variable's model.
610
+ *
611
+ * @param name - The manifest as asked.
612
+ * @param parsed - What was asked for.
613
+ * @param manifest - The manifest.
614
+ * @param progress - Where the play got.
615
+ * @param started - When it began.
616
+ * @param exitBeforePlay - The session's status before it.
617
+ * @returns The play's envelope.
618
+ */
619
+ function playOutcome_answer(name, parsed, manifest, progress, started, exitBeforePlay) {
620
+ // A STOP no line saw (a manifest with no lines, a dry run's last preview, the place being given back)
621
+ // still stops the play, before it is said to have run.
622
+ if (progress.stoppedAt === null && progress.declinedAt === null && commandCancellation_stopped()) {
623
+ sink_errLine(chalk.yellow(`play: stopped during ${name}`));
624
+ progress.stoppedAt = manifest.lines.at(-1)?.number ?? 0;
466
625
  }
626
+ const { ran, stoppedAt, declinedAt, answered } = progress;
627
+ // A play that ran through leaves the session's status as it found it.
628
+ if (stoppedAt === null)
629
+ exitCode_set(exitBeforePlay);
630
+ const outcome = {
631
+ manifest: name,
632
+ ran,
633
+ total: manifest.lines.length,
634
+ stoppedAt,
635
+ elapsedMs: Date.now() - started,
636
+ };
637
+ const model = { kind: PLAY_MODEL_KIND, data: outcome };
638
+ const took = `${Math.round(outcome.elapsedMs / 1000)}s`;
639
+ if (declinedAt !== null) {
640
+ exitCode_set(exitBeforePlay);
641
+ return envelope_ok(`${chalk.gray(`play: ${name} stopped at your answer to line ${declinedAt}, after ${ran} of ${manifest.lines.length} lines (${took})`)}\n`, { kind: LINE_DECLINED_MODEL_KIND, data: { manifest: name, line: declinedAt } });
642
+ }
643
+ if (stoppedAt !== null) {
644
+ return stoppedOutcome_answer(name, manifest, ran, stoppedAt, took);
645
+ }
646
+ const what = parsed.dryRun ? 'would play' : 'played';
647
+ if (parsed.dryRun && manifest.answers !== null)
648
+ sink_dataLine(chalk.cyan(`▸ @answers ${manifest.answers}`));
649
+ // A manifest that declares its answer hands back that variable's model,
650
+ // so `X=$(play f)` holds what the flow made, as a verb's capture would.
651
+ if (!parsed.dryRun && manifest.answers !== null) {
652
+ return answeredOutcome_answer(name, what, ran, took, manifest.answers, answered);
653
+ }
654
+ return envelope_ok(`${chalk.green(`play: ${what} ${ran} line${ran === 1 ? '' : 's'} of ${name} (${took})`)}\n`, model);
655
+ }
656
+ /**
657
+ * Prints the manifest's `@name` and `@description` banner lines when present.
658
+ *
659
+ * @param manifest - The parsed manifest.
660
+ */
661
+ function manifestHeader_print(manifest) {
467
662
  if (manifest.name !== null)
468
663
  sink_dataLine(chalk.bold(manifest.name));
469
664
  if (manifest.description !== null)
470
665
  sink_dataLine(chalk.gray(manifest.description));
666
+ }
667
+ /**
668
+ * Enables command cancellation for a paced play and returns its abort signal.
669
+ *
670
+ * @param paceMs - Milliseconds between lines.
671
+ * @returns The abort signal when paced, else `undefined`.
672
+ */
673
+ function paceCancellation_enable(paceMs) {
674
+ if (paceMs <= 0)
675
+ return undefined;
676
+ commandCancellation_enable();
677
+ return commandCancellation_signalGet();
678
+ }
679
+ /**
680
+ * Plays a manifest as asked: reads it, settles its parameters before any
681
+ * line runs, then runs (or, with `--status`, reads) its lines in order.
682
+ *
683
+ * @param parsed - What was asked for.
684
+ * @returns An envelope carrying what the play did, or the refusal that stopped it.
685
+ */
686
+ async function play_run(parsed) {
687
+ const name = playManifest_name(parsed);
688
+ if (typeof name !== 'string')
689
+ return name;
690
+ const source = parsed.text !== null ? { ok: true, value: { text: parsed.text, from: name } } : await manifestText_read(name);
691
+ if (!source.ok)
692
+ return playLine_refuse(`play: ${source.reason}`);
693
+ const manifest = manifest_parse(source.value.text);
694
+ const values = playValues_settle(name, parsed, manifest);
695
+ if (!(values instanceof Map))
696
+ return values;
697
+ manifestHeader_print(manifest);
471
698
  // A status reads every line against what is kept and runs none: the
472
699
  // script screen colours its rail from this, and chell reads it as text.
473
700
  if (parsed.status)
474
- return await manifestStatus_read(manifest, parsed.manifest, values);
701
+ return await manifestStatus_read(manifest, name, values);
475
702
  const started = Date.now();
476
- if (parsed.paceMs > 0)
477
- commandCancellation_enable();
478
- const signal = parsed.paceMs > 0 ? commandCancellation_signalGet() : undefined;
703
+ const signal = paceCancellation_enable(parsed.paceMs);
479
704
  const { line_execute } = await import('../../core/engine.js');
480
- let ran = 0;
481
- let stoppedAt = null;
482
- /** Whether the play stopped at the operator's no to a line's question: a choice, answered ok, never an error. */
483
- let declinedAt = null;
484
- // What the manifest answers with, read before its scope ends with it.
485
- let answered;
486
- // What the lines a dry run passed over could have changed.
487
- const passedVerbs = new Set();
488
- const passedAssigned = new Set();
705
+ const progress = { ran: 0, stoppedAt: null, declinedAt: null, answered: undefined };
489
706
  const exitBeforePlay = exitCode_read();
490
707
  // Where the play began. A manifest that `cd`s into a feed must not leave a
491
708
  // shared session there: every surface on it stands where the play put
@@ -496,51 +713,7 @@ async function play_run(parsed) {
496
713
  // The depth and the mute are this play's and its lines': a line another
497
714
  // surface runs meanwhile is neither nested nor muted.
498
715
  try {
499
- await depthScope.run(depth_get() + 1, () => recorderMuted_run(() => variableScope_run(values, async () => {
500
- for (const line of manifest.lines) {
501
- // A dry run shows what WOULD run, expanded by the kernel's own
502
- // expander rather than a second one living here: a reference nothing
503
- // can answer yet stands as written, since nothing has run to give it
504
- // a value, and so does one an earlier line may have changed (#1241).
505
- if (parsed.dryRun) {
506
- sink_dataLine(chalk.cyan(`▸ ${await line_preview(line.text, { count: ran, verbs: passedVerbs, assigned: passedAssigned })}`));
507
- linePassed_note(line.text, passedVerbs, passedAssigned);
508
- ran += 1;
509
- continue;
510
- }
511
- // The line is SHOWN as written, then handed to the session, which
512
- // resolves its references the way it resolves every other line's.
513
- sink_dataLine(chalk.cyan(`▸ ${line.text}`));
514
- // A line failed when it refused or set the exit status. The status is
515
- // cleared before each line, so one an earlier command left set (before
516
- // the play, or by a line that passed) is never this line's.
517
- exitCode_set(0);
518
- const envelopes = await line_execute(line.text);
519
- ran += 1;
520
- // The operator answered no to the line's question: the play stops there, as their choice, never as a refusal.
521
- if (envelopes.some((envelope) => envelope.model?.kind === LINE_DECLINED_MODEL_KIND)) {
522
- sink_dataLine(chalk.gray(`play: stopped at your answer to ${parsed.manifest}:${line.number}; the lines after it did not run`));
523
- declinedAt = line.number;
524
- break;
525
- }
526
- const refused = envelopes.some((envelope) => envelope.status === 'error')
527
- || exitCode_read() !== 0;
528
- if (refused) {
529
- // A workflow whose first half failed has a second half that is
530
- // noise: the play stops where the trouble is.
531
- sink_errLine(chalk.red(`✗ ${parsed.manifest}:${line.number} refused — stopping.`));
532
- stoppedAt = line.number;
533
- break;
534
- }
535
- if (parsed.paceMs > 0 && !await pause_take(parsed.paceMs, signal)) {
536
- sink_dataLine(chalk.yellow(`play: stopped at ${parsed.manifest}:${line.number}`));
537
- stoppedAt = line.number;
538
- break;
539
- }
540
- }
541
- if (manifest.answers !== null)
542
- answered = variable_get(manifest.answers);
543
- })));
716
+ await depthScope.run(depth_get() + 1, () => recorderMuted_run(() => variableScope_run(values, () => playLines_walk(name, parsed, manifest, progress, line_execute, signal))));
544
717
  }
545
718
  finally {
546
719
  // A place that cannot be given back (removed during the play) is said,
@@ -554,38 +727,6 @@ async function play_run(parsed) {
554
727
  }
555
728
  }
556
729
  }
557
- // A play that ran through leaves the session's status as it found it.
558
- if (stoppedAt === null)
559
- exitCode_set(exitBeforePlay);
560
- const outcome = {
561
- manifest: parsed.manifest,
562
- ran,
563
- total: manifest.lines.length,
564
- stoppedAt,
565
- elapsedMs: Date.now() - started,
566
- };
567
- const model = { kind: PLAY_MODEL_KIND, data: outcome };
568
- const took = `${Math.round(outcome.elapsedMs / 1000)}s`;
569
- if (declinedAt !== null) {
570
- exitCode_set(exitBeforePlay);
571
- return envelope_ok(`${chalk.gray(`play: ${parsed.manifest} stopped at your answer to line ${declinedAt}, after ${ran} of ${manifest.lines.length} lines (${took})`)}\n`, { kind: LINE_DECLINED_MODEL_KIND, data: { manifest: parsed.manifest, line: declinedAt } });
572
- }
573
- if (stoppedAt !== null) {
574
- exitCode_set(1);
575
- return envelope_error('', undefined, `${chalk.red(`play: ${parsed.manifest} stopped at line ${stoppedAt} after ${ran} of ${manifest.lines.length} lines (${took})`)}\n`);
576
- }
577
- const what = parsed.dryRun ? 'would play' : 'played';
578
- if (parsed.dryRun && manifest.answers !== null)
579
- sink_dataLine(chalk.cyan(`▸ @answers ${manifest.answers}`));
580
- // A manifest that declares its answer hands back that variable's model,
581
- // so `X=$(play f)` holds what the flow made, as a verb's capture would.
582
- if (!parsed.dryRun && manifest.answers !== null) {
583
- if (answered === undefined) {
584
- exitCode_set(1);
585
- return envelope_error('', undefined, `${chalk.red(`play: ${parsed.manifest} answers ${manifest.answers}, and ${manifest.answers} was never set`)}\n`);
586
- }
587
- return envelope_ok(`${chalk.green(`play: ${what} ${ran} line${ran === 1 ? '' : 's'} of ${parsed.manifest} (${took}), answering ${manifest.answers}`)}\n`, { kind: answered.answer.kind, data: answered.answer.data });
588
- }
589
- return envelope_ok(`${chalk.green(`play: ${what} ${ran} line${ran === 1 ? '' : 's'} of ${parsed.manifest} (${took})`)}\n`, model);
730
+ return playOutcome_answer(name, parsed, manifest, progress, started, exitBeforePlay);
590
731
  }
591
732
  //# sourceMappingURL=play.js.map