@smthrs/std 0.0.0-stage → 1.0.0-rc.12

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 (582) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/LICENSE +21 -0
  3. package/README.md +156 -2
  4. package/dist/cjs/ApplyPatch.d.ts +174 -0
  5. package/dist/cjs/ApplyPatch.d.ts.map +1 -0
  6. package/dist/cjs/ApplyPatch.js +309 -0
  7. package/dist/cjs/ApplyPatch.js.map +7 -0
  8. package/dist/cjs/Bash.d.ts +390 -0
  9. package/dist/cjs/Bash.d.ts.map +1 -0
  10. package/dist/cjs/Bash.js +333 -0
  11. package/dist/cjs/Bash.js.map +7 -0
  12. package/dist/cjs/Checkpoints.d.ts +322 -0
  13. package/dist/cjs/Checkpoints.d.ts.map +1 -0
  14. package/dist/cjs/Checkpoints.js +233 -0
  15. package/dist/cjs/Checkpoints.js.map +7 -0
  16. package/dist/cjs/Container.d.ts +132 -0
  17. package/dist/cjs/Container.d.ts.map +1 -0
  18. package/dist/cjs/Container.js +113 -0
  19. package/dist/cjs/Container.js.map +7 -0
  20. package/dist/cjs/Edit.d.ts +203 -0
  21. package/dist/cjs/Edit.d.ts.map +1 -0
  22. package/dist/cjs/Edit.js +258 -0
  23. package/dist/cjs/Edit.js.map +7 -0
  24. package/dist/cjs/ExaWebSearch.d.ts +22 -0
  25. package/dist/cjs/ExaWebSearch.d.ts.map +1 -0
  26. package/dist/cjs/ExaWebSearch.js +138 -0
  27. package/dist/cjs/ExaWebSearch.js.map +7 -0
  28. package/dist/cjs/Explore.d.ts +328 -0
  29. package/dist/cjs/Explore.d.ts.map +1 -0
  30. package/dist/cjs/Explore.js +90 -0
  31. package/dist/cjs/Explore.js.map +7 -0
  32. package/dist/cjs/Fetch.d.ts +130 -0
  33. package/dist/cjs/Fetch.d.ts.map +1 -0
  34. package/dist/cjs/Fetch.js +64 -0
  35. package/dist/cjs/Fetch.js.map +7 -0
  36. package/dist/cjs/Glob.d.ts +204 -0
  37. package/dist/cjs/Glob.d.ts.map +1 -0
  38. package/dist/cjs/Glob.js +94 -0
  39. package/dist/cjs/Glob.js.map +7 -0
  40. package/dist/cjs/Grep.d.ts +347 -0
  41. package/dist/cjs/Grep.d.ts.map +1 -0
  42. package/dist/cjs/Grep.js +181 -0
  43. package/dist/cjs/Grep.js.map +7 -0
  44. package/dist/cjs/HttpPost.d.ts +130 -0
  45. package/dist/cjs/HttpPost.d.ts.map +1 -0
  46. package/dist/cjs/HttpPost.js +72 -0
  47. package/dist/cjs/HttpPost.js.map +7 -0
  48. package/dist/cjs/LanguageServer.d.ts +90 -0
  49. package/dist/cjs/LanguageServer.d.ts.map +1 -0
  50. package/dist/cjs/LanguageServer.js +60 -0
  51. package/dist/cjs/LanguageServer.js.map +7 -0
  52. package/dist/cjs/Ls.d.ts +164 -0
  53. package/dist/cjs/Ls.d.ts.map +1 -0
  54. package/dist/cjs/Ls.js +136 -0
  55. package/dist/cjs/Ls.js.map +7 -0
  56. package/dist/cjs/Lsp.d.ts +125 -0
  57. package/dist/cjs/Lsp.d.ts.map +1 -0
  58. package/dist/cjs/Lsp.js +137 -0
  59. package/dist/cjs/Lsp.js.map +7 -0
  60. package/dist/cjs/Manifest.d.ts +918 -0
  61. package/dist/cjs/Manifest.d.ts.map +1 -0
  62. package/dist/cjs/Manifest.js +144 -0
  63. package/dist/cjs/Manifest.js.map +7 -0
  64. package/dist/cjs/NativeSearch.d.ts +38 -0
  65. package/dist/cjs/NativeSearch.d.ts.map +1 -0
  66. package/dist/cjs/NativeSearch.js +326 -0
  67. package/dist/cjs/NativeSearch.js.map +7 -0
  68. package/dist/cjs/NodeLanguageServer.d.ts +128 -0
  69. package/dist/cjs/NodeLanguageServer.d.ts.map +1 -0
  70. package/dist/cjs/NodeLanguageServer.js +796 -0
  71. package/dist/cjs/NodeLanguageServer.js.map +7 -0
  72. package/dist/cjs/PortableSearch.d.ts +36 -0
  73. package/dist/cjs/PortableSearch.d.ts.map +1 -0
  74. package/dist/cjs/PortableSearch.js +240 -0
  75. package/dist/cjs/PortableSearch.js.map +7 -0
  76. package/dist/cjs/Probe.d.ts +193 -0
  77. package/dist/cjs/Probe.d.ts.map +1 -0
  78. package/dist/cjs/Probe.js +134 -0
  79. package/dist/cjs/Probe.js.map +7 -0
  80. package/dist/cjs/Read.d.ts +189 -0
  81. package/dist/cjs/Read.d.ts.map +1 -0
  82. package/dist/cjs/Read.js +223 -0
  83. package/dist/cjs/Read.js.map +7 -0
  84. package/dist/cjs/Relocate.d.ts +73 -0
  85. package/dist/cjs/Relocate.d.ts.map +1 -0
  86. package/dist/cjs/Relocate.js +72 -0
  87. package/dist/cjs/Relocate.js.map +7 -0
  88. package/dist/cjs/RemoteSearch.d.ts +54 -0
  89. package/dist/cjs/RemoteSearch.d.ts.map +1 -0
  90. package/dist/cjs/RemoteSearch.js +134 -0
  91. package/dist/cjs/RemoteSearch.js.map +7 -0
  92. package/dist/cjs/Search.d.ts +163 -0
  93. package/dist/cjs/Search.d.ts.map +1 -0
  94. package/dist/cjs/Search.js +51 -0
  95. package/dist/cjs/Search.js.map +7 -0
  96. package/dist/cjs/SearchConformance.d.ts +115 -0
  97. package/dist/cjs/SearchConformance.d.ts.map +1 -0
  98. package/dist/cjs/SearchConformance.js +172 -0
  99. package/dist/cjs/SearchConformance.js.map +7 -0
  100. package/dist/cjs/SearchContract.d.ts +114 -0
  101. package/dist/cjs/SearchContract.d.ts.map +1 -0
  102. package/dist/cjs/SearchContract.js +339 -0
  103. package/dist/cjs/SearchContract.js.map +7 -0
  104. package/dist/cjs/ShellCommand.d.ts +164 -0
  105. package/dist/cjs/ShellCommand.d.ts.map +1 -0
  106. package/dist/cjs/ShellCommand.js +102 -0
  107. package/dist/cjs/ShellCommand.js.map +7 -0
  108. package/dist/cjs/StdError.d.ts +55 -0
  109. package/dist/cjs/StdError.d.ts.map +1 -0
  110. package/dist/cjs/StdError.js +74 -0
  111. package/dist/cjs/StdError.js.map +7 -0
  112. package/dist/cjs/TestRun.d.ts +311 -0
  113. package/dist/cjs/TestRun.d.ts.map +1 -0
  114. package/dist/cjs/TestRun.js +228 -0
  115. package/dist/cjs/TestRun.js.map +7 -0
  116. package/dist/cjs/TestRunner.d.ts +102 -0
  117. package/dist/cjs/TestRunner.d.ts.map +1 -0
  118. package/dist/cjs/TestRunner.js +54 -0
  119. package/dist/cjs/TestRunner.js.map +7 -0
  120. package/dist/cjs/TreeFingerprint.d.ts +140 -0
  121. package/dist/cjs/TreeFingerprint.d.ts.map +1 -0
  122. package/dist/cjs/TreeFingerprint.js +87 -0
  123. package/dist/cjs/TreeFingerprint.js.map +7 -0
  124. package/dist/cjs/UpdatePlan.d.ts +152 -0
  125. package/dist/cjs/UpdatePlan.d.ts.map +1 -0
  126. package/dist/cjs/UpdatePlan.js +87 -0
  127. package/dist/cjs/UpdatePlan.js.map +7 -0
  128. package/dist/cjs/WebFetch.d.ts +134 -0
  129. package/dist/cjs/WebFetch.d.ts.map +1 -0
  130. package/dist/cjs/WebFetch.js +140 -0
  131. package/dist/cjs/WebFetch.js.map +7 -0
  132. package/dist/cjs/WebSearch.d.ts +181 -0
  133. package/dist/cjs/WebSearch.d.ts.map +1 -0
  134. package/dist/cjs/WebSearch.js +86 -0
  135. package/dist/cjs/WebSearch.js.map +7 -0
  136. package/dist/cjs/Write.d.ts +147 -0
  137. package/dist/cjs/Write.d.ts.map +1 -0
  138. package/dist/cjs/Write.js +122 -0
  139. package/dist/cjs/Write.js.map +7 -0
  140. package/dist/cjs/index.d.ts +129 -0
  141. package/dist/cjs/index.d.ts.map +1 -0
  142. package/dist/cjs/index.js +101 -0
  143. package/dist/cjs/index.js.map +7 -0
  144. package/dist/cjs/internal/ApplyPatch.d.ts +145 -0
  145. package/dist/cjs/internal/ApplyPatch.d.ts.map +1 -0
  146. package/dist/cjs/internal/ApplyPatch.js +462 -0
  147. package/dist/cjs/internal/ApplyPatch.js.map +7 -0
  148. package/dist/cjs/internal/CodexText.d.ts +73 -0
  149. package/dist/cjs/internal/CodexText.d.ts.map +1 -0
  150. package/dist/cjs/internal/CodexText.js +108 -0
  151. package/dist/cjs/internal/CodexText.js.map +7 -0
  152. package/dist/cjs/internal/Declaration.d.ts +49 -0
  153. package/dist/cjs/internal/Declaration.d.ts.map +1 -0
  154. package/dist/cjs/internal/Declaration.js +46 -0
  155. package/dist/cjs/internal/Declaration.js.map +7 -0
  156. package/dist/cjs/internal/Diagnostics.d.ts +77 -0
  157. package/dist/cjs/internal/Diagnostics.d.ts.map +1 -0
  158. package/dist/cjs/internal/Diagnostics.js +89 -0
  159. package/dist/cjs/internal/Diagnostics.js.map +7 -0
  160. package/dist/cjs/internal/EnvelopePrecheck.d.ts +69 -0
  161. package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
  162. package/dist/cjs/internal/EnvelopePrecheck.js +323 -0
  163. package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
  164. package/dist/cjs/internal/Exec.d.ts +151 -0
  165. package/dist/cjs/internal/Exec.d.ts.map +1 -0
  166. package/dist/cjs/internal/Exec.js +207 -0
  167. package/dist/cjs/internal/Exec.js.map +7 -0
  168. package/dist/cjs/internal/FileMutation.d.ts +109 -0
  169. package/dist/cjs/internal/FileMutation.d.ts.map +1 -0
  170. package/dist/cjs/internal/FileMutation.js +116 -0
  171. package/dist/cjs/internal/FileMutation.js.map +7 -0
  172. package/dist/cjs/internal/FsFailure.d.ts +38 -0
  173. package/dist/cjs/internal/FsFailure.d.ts.map +1 -0
  174. package/dist/cjs/internal/FsFailure.js +40 -0
  175. package/dist/cjs/internal/FsFailure.js.map +7 -0
  176. package/dist/cjs/internal/GitWorktree.d.ts +108 -0
  177. package/dist/cjs/internal/GitWorktree.d.ts.map +1 -0
  178. package/dist/cjs/internal/GitWorktree.js +276 -0
  179. package/dist/cjs/internal/GitWorktree.js.map +7 -0
  180. package/dist/cjs/internal/Grouping.d.ts +51 -0
  181. package/dist/cjs/internal/Grouping.d.ts.map +1 -0
  182. package/dist/cjs/internal/Grouping.js +83 -0
  183. package/dist/cjs/internal/Grouping.js.map +7 -0
  184. package/dist/cjs/internal/Html.d.ts +20 -0
  185. package/dist/cjs/internal/Html.d.ts.map +1 -0
  186. package/dist/cjs/internal/Html.js +81 -0
  187. package/dist/cjs/internal/Html.js.map +7 -0
  188. package/dist/cjs/internal/Http.d.ts +95 -0
  189. package/dist/cjs/internal/Http.d.ts.map +1 -0
  190. package/dist/cjs/internal/Http.js +153 -0
  191. package/dist/cjs/internal/Http.js.map +7 -0
  192. package/dist/cjs/internal/HttpNetwork.d.ts +27 -0
  193. package/dist/cjs/internal/HttpNetwork.d.ts.map +1 -0
  194. package/dist/cjs/internal/HttpNetwork.js +146 -0
  195. package/dist/cjs/internal/HttpNetwork.js.map +7 -0
  196. package/dist/cjs/internal/Ignore.d.ts +37 -0
  197. package/dist/cjs/internal/Ignore.d.ts.map +1 -0
  198. package/dist/cjs/internal/Ignore.js +100 -0
  199. package/dist/cjs/internal/Ignore.js.map +7 -0
  200. package/dist/cjs/internal/LinearRegex.d.ts +19 -0
  201. package/dist/cjs/internal/LinearRegex.d.ts.map +1 -0
  202. package/dist/cjs/internal/LinearRegex.js +166 -0
  203. package/dist/cjs/internal/LinearRegex.js.map +7 -0
  204. package/dist/cjs/internal/Match.d.ts +85 -0
  205. package/dist/cjs/internal/Match.d.ts.map +1 -0
  206. package/dist/cjs/internal/Match.js +99 -0
  207. package/dist/cjs/internal/Match.js.map +7 -0
  208. package/dist/cjs/internal/Paths.d.ts +23 -0
  209. package/dist/cjs/internal/Paths.d.ts.map +1 -0
  210. package/dist/cjs/internal/Paths.js +52 -0
  211. package/dist/cjs/internal/Paths.js.map +7 -0
  212. package/dist/cjs/internal/Preserve.d.ts +25 -0
  213. package/dist/cjs/internal/Preserve.d.ts.map +1 -0
  214. package/dist/cjs/internal/Preserve.js +88 -0
  215. package/dist/cjs/internal/Preserve.js.map +7 -0
  216. package/dist/cjs/internal/Prune.d.ts +35 -0
  217. package/dist/cjs/internal/Prune.d.ts.map +1 -0
  218. package/dist/cjs/internal/Prune.js +54 -0
  219. package/dist/cjs/internal/Prune.js.map +7 -0
  220. package/dist/cjs/internal/RemoteTree.d.ts +60 -0
  221. package/dist/cjs/internal/RemoteTree.d.ts.map +1 -0
  222. package/dist/cjs/internal/RemoteTree.js +123 -0
  223. package/dist/cjs/internal/RemoteTree.js.map +7 -0
  224. package/dist/cjs/internal/SearchContract.d.ts +63 -0
  225. package/dist/cjs/internal/SearchContract.d.ts.map +1 -0
  226. package/dist/cjs/internal/SearchContract.js +46 -0
  227. package/dist/cjs/internal/SearchContract.js.map +7 -0
  228. package/dist/cjs/internal/Symbols.d.ts +39 -0
  229. package/dist/cjs/internal/Symbols.d.ts.map +1 -0
  230. package/dist/cjs/internal/Symbols.js +59 -0
  231. package/dist/cjs/internal/Symbols.js.map +7 -0
  232. package/dist/cjs/internal/Tar.d.ts +23 -0
  233. package/dist/cjs/internal/Tar.d.ts.map +1 -0
  234. package/dist/cjs/internal/Tar.js +86 -0
  235. package/dist/cjs/internal/Tar.js.map +7 -0
  236. package/dist/cjs/internal/TestReport.d.ts +52 -0
  237. package/dist/cjs/internal/TestReport.d.ts.map +1 -0
  238. package/dist/cjs/internal/TestReport.js +131 -0
  239. package/dist/cjs/internal/TestReport.js.map +7 -0
  240. package/dist/cjs/internal/Text.d.ts +125 -0
  241. package/dist/cjs/internal/Text.d.ts.map +1 -0
  242. package/dist/cjs/internal/Text.js +85 -0
  243. package/dist/cjs/internal/Text.js.map +7 -0
  244. package/dist/cjs/internal/Url.d.ts +13 -0
  245. package/dist/cjs/internal/Url.d.ts.map +1 -0
  246. package/dist/cjs/internal/Url.js +35 -0
  247. package/dist/cjs/internal/Url.js.map +7 -0
  248. package/dist/cjs/internal/Walk.d.ts +72 -0
  249. package/dist/cjs/internal/Walk.d.ts.map +1 -0
  250. package/dist/cjs/internal/Walk.js +108 -0
  251. package/dist/cjs/internal/Walk.js.map +7 -0
  252. package/dist/cjs/package.json +1 -0
  253. package/dist/esm/ApplyPatch.d.ts +174 -0
  254. package/dist/esm/ApplyPatch.d.ts.map +1 -0
  255. package/dist/esm/ApplyPatch.js +346 -0
  256. package/dist/esm/ApplyPatch.js.map +1 -0
  257. package/dist/esm/Bash.d.ts +390 -0
  258. package/dist/esm/Bash.d.ts.map +1 -0
  259. package/dist/esm/Bash.js +514 -0
  260. package/dist/esm/Bash.js.map +1 -0
  261. package/dist/esm/Checkpoints.d.ts +322 -0
  262. package/dist/esm/Checkpoints.d.ts.map +1 -0
  263. package/dist/esm/Checkpoints.js +396 -0
  264. package/dist/esm/Checkpoints.js.map +1 -0
  265. package/dist/esm/Container.d.ts +132 -0
  266. package/dist/esm/Container.d.ts.map +1 -0
  267. package/dist/esm/Container.js +151 -0
  268. package/dist/esm/Container.js.map +1 -0
  269. package/dist/esm/Edit.d.ts +203 -0
  270. package/dist/esm/Edit.d.ts.map +1 -0
  271. package/dist/esm/Edit.js +296 -0
  272. package/dist/esm/Edit.js.map +1 -0
  273. package/dist/esm/ExaWebSearch.d.ts +22 -0
  274. package/dist/esm/ExaWebSearch.d.ts.map +1 -0
  275. package/dist/esm/ExaWebSearch.js +107 -0
  276. package/dist/esm/ExaWebSearch.js.map +1 -0
  277. package/dist/esm/Explore.d.ts +328 -0
  278. package/dist/esm/Explore.d.ts.map +1 -0
  279. package/dist/esm/Explore.js +106 -0
  280. package/dist/esm/Explore.js.map +1 -0
  281. package/dist/esm/Fetch.d.ts +130 -0
  282. package/dist/esm/Fetch.d.ts.map +1 -0
  283. package/dist/esm/Fetch.js +91 -0
  284. package/dist/esm/Fetch.js.map +1 -0
  285. package/dist/esm/Glob.d.ts +204 -0
  286. package/dist/esm/Glob.d.ts.map +1 -0
  287. package/dist/esm/Glob.js +177 -0
  288. package/dist/esm/Glob.js.map +1 -0
  289. package/dist/esm/Grep.d.ts +347 -0
  290. package/dist/esm/Grep.d.ts.map +1 -0
  291. package/dist/esm/Grep.js +289 -0
  292. package/dist/esm/Grep.js.map +1 -0
  293. package/dist/esm/HttpPost.d.ts +130 -0
  294. package/dist/esm/HttpPost.d.ts.map +1 -0
  295. package/dist/esm/HttpPost.js +89 -0
  296. package/dist/esm/HttpPost.js.map +1 -0
  297. package/dist/esm/LanguageServer.d.ts +90 -0
  298. package/dist/esm/LanguageServer.d.ts.map +1 -0
  299. package/dist/esm/LanguageServer.js +57 -0
  300. package/dist/esm/LanguageServer.js.map +1 -0
  301. package/dist/esm/Ls.d.ts +164 -0
  302. package/dist/esm/Ls.d.ts.map +1 -0
  303. package/dist/esm/Ls.js +178 -0
  304. package/dist/esm/Ls.js.map +1 -0
  305. package/dist/esm/Lsp.d.ts +125 -0
  306. package/dist/esm/Lsp.d.ts.map +1 -0
  307. package/dist/esm/Lsp.js +165 -0
  308. package/dist/esm/Lsp.js.map +1 -0
  309. package/dist/esm/Manifest.d.ts +918 -0
  310. package/dist/esm/Manifest.d.ts.map +1 -0
  311. package/dist/esm/Manifest.js +153 -0
  312. package/dist/esm/Manifest.js.map +1 -0
  313. package/dist/esm/NativeSearch.d.ts +38 -0
  314. package/dist/esm/NativeSearch.d.ts.map +1 -0
  315. package/dist/esm/NativeSearch.js +378 -0
  316. package/dist/esm/NativeSearch.js.map +1 -0
  317. package/dist/esm/NodeLanguageServer.d.ts +128 -0
  318. package/dist/esm/NodeLanguageServer.d.ts.map +1 -0
  319. package/dist/esm/NodeLanguageServer.js +843 -0
  320. package/dist/esm/NodeLanguageServer.js.map +1 -0
  321. package/dist/esm/PortableSearch.d.ts +36 -0
  322. package/dist/esm/PortableSearch.d.ts.map +1 -0
  323. package/dist/esm/PortableSearch.js +256 -0
  324. package/dist/esm/PortableSearch.js.map +1 -0
  325. package/dist/esm/Probe.d.ts +193 -0
  326. package/dist/esm/Probe.d.ts.map +1 -0
  327. package/dist/esm/Probe.js +225 -0
  328. package/dist/esm/Probe.js.map +1 -0
  329. package/dist/esm/Read.d.ts +189 -0
  330. package/dist/esm/Read.d.ts.map +1 -0
  331. package/dist/esm/Read.js +300 -0
  332. package/dist/esm/Read.js.map +1 -0
  333. package/dist/esm/Relocate.d.ts +73 -0
  334. package/dist/esm/Relocate.d.ts.map +1 -0
  335. package/dist/esm/Relocate.js +153 -0
  336. package/dist/esm/Relocate.js.map +1 -0
  337. package/dist/esm/RemoteSearch.d.ts +54 -0
  338. package/dist/esm/RemoteSearch.d.ts.map +1 -0
  339. package/dist/esm/RemoteSearch.js +162 -0
  340. package/dist/esm/RemoteSearch.js.map +1 -0
  341. package/dist/esm/Search.d.ts +163 -0
  342. package/dist/esm/Search.d.ts.map +1 -0
  343. package/dist/esm/Search.js +47 -0
  344. package/dist/esm/Search.js.map +1 -0
  345. package/dist/esm/SearchConformance.d.ts +115 -0
  346. package/dist/esm/SearchConformance.d.ts.map +1 -0
  347. package/dist/esm/SearchConformance.js +193 -0
  348. package/dist/esm/SearchConformance.js.map +1 -0
  349. package/dist/esm/SearchContract.d.ts +114 -0
  350. package/dist/esm/SearchContract.d.ts.map +1 -0
  351. package/dist/esm/SearchContract.js +461 -0
  352. package/dist/esm/SearchContract.js.map +1 -0
  353. package/dist/esm/ShellCommand.d.ts +164 -0
  354. package/dist/esm/ShellCommand.d.ts.map +1 -0
  355. package/dist/esm/ShellCommand.js +159 -0
  356. package/dist/esm/ShellCommand.js.map +1 -0
  357. package/dist/esm/StdError.d.ts +55 -0
  358. package/dist/esm/StdError.d.ts.map +1 -0
  359. package/dist/esm/StdError.js +71 -0
  360. package/dist/esm/StdError.js.map +1 -0
  361. package/dist/esm/TestRun.d.ts +311 -0
  362. package/dist/esm/TestRun.d.ts.map +1 -0
  363. package/dist/esm/TestRun.js +316 -0
  364. package/dist/esm/TestRun.js.map +1 -0
  365. package/dist/esm/TestRunner.d.ts +102 -0
  366. package/dist/esm/TestRunner.d.ts.map +1 -0
  367. package/dist/esm/TestRunner.js +68 -0
  368. package/dist/esm/TestRunner.js.map +1 -0
  369. package/dist/esm/TreeFingerprint.d.ts +140 -0
  370. package/dist/esm/TreeFingerprint.d.ts.map +1 -0
  371. package/dist/esm/TreeFingerprint.js +170 -0
  372. package/dist/esm/TreeFingerprint.js.map +1 -0
  373. package/dist/esm/UpdatePlan.d.ts +152 -0
  374. package/dist/esm/UpdatePlan.d.ts.map +1 -0
  375. package/dist/esm/UpdatePlan.js +129 -0
  376. package/dist/esm/UpdatePlan.js.map +1 -0
  377. package/dist/esm/WebFetch.d.ts +134 -0
  378. package/dist/esm/WebFetch.d.ts.map +1 -0
  379. package/dist/esm/WebFetch.js +151 -0
  380. package/dist/esm/WebFetch.js.map +1 -0
  381. package/dist/esm/WebSearch.d.ts +181 -0
  382. package/dist/esm/WebSearch.d.ts.map +1 -0
  383. package/dist/esm/WebSearch.js +134 -0
  384. package/dist/esm/WebSearch.js.map +1 -0
  385. package/dist/esm/Write.d.ts +147 -0
  386. package/dist/esm/Write.d.ts.map +1 -0
  387. package/dist/esm/Write.js +144 -0
  388. package/dist/esm/Write.js.map +1 -0
  389. package/dist/esm/index.d.ts +129 -0
  390. package/dist/esm/index.d.ts.map +1 -0
  391. package/dist/esm/index.js +129 -0
  392. package/dist/esm/index.js.map +1 -0
  393. package/dist/esm/internal/ApplyPatch.d.ts +145 -0
  394. package/dist/esm/internal/ApplyPatch.d.ts.map +1 -0
  395. package/dist/esm/internal/ApplyPatch.js +489 -0
  396. package/dist/esm/internal/ApplyPatch.js.map +1 -0
  397. package/dist/esm/internal/CodexText.d.ts +73 -0
  398. package/dist/esm/internal/CodexText.d.ts.map +1 -0
  399. package/dist/esm/internal/CodexText.js +156 -0
  400. package/dist/esm/internal/CodexText.js.map +1 -0
  401. package/dist/esm/internal/Declaration.d.ts +49 -0
  402. package/dist/esm/internal/Declaration.d.ts.map +1 -0
  403. package/dist/esm/internal/Declaration.js +42 -0
  404. package/dist/esm/internal/Declaration.js.map +1 -0
  405. package/dist/esm/internal/Diagnostics.d.ts +77 -0
  406. package/dist/esm/internal/Diagnostics.d.ts.map +1 -0
  407. package/dist/esm/internal/Diagnostics.js +99 -0
  408. package/dist/esm/internal/Diagnostics.js.map +1 -0
  409. package/dist/esm/internal/EnvelopePrecheck.d.ts +69 -0
  410. package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
  411. package/dist/esm/internal/EnvelopePrecheck.js +426 -0
  412. package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
  413. package/dist/esm/internal/Exec.d.ts +151 -0
  414. package/dist/esm/internal/Exec.d.ts.map +1 -0
  415. package/dist/esm/internal/Exec.js +285 -0
  416. package/dist/esm/internal/Exec.js.map +1 -0
  417. package/dist/esm/internal/FileMutation.d.ts +109 -0
  418. package/dist/esm/internal/FileMutation.d.ts.map +1 -0
  419. package/dist/esm/internal/FileMutation.js +123 -0
  420. package/dist/esm/internal/FileMutation.js.map +1 -0
  421. package/dist/esm/internal/FsFailure.d.ts +38 -0
  422. package/dist/esm/internal/FsFailure.d.ts.map +1 -0
  423. package/dist/esm/internal/FsFailure.js +39 -0
  424. package/dist/esm/internal/FsFailure.js.map +1 -0
  425. package/dist/esm/internal/GitWorktree.d.ts +108 -0
  426. package/dist/esm/internal/GitWorktree.d.ts.map +1 -0
  427. package/dist/esm/internal/GitWorktree.js +352 -0
  428. package/dist/esm/internal/GitWorktree.js.map +1 -0
  429. package/dist/esm/internal/Grouping.d.ts +51 -0
  430. package/dist/esm/internal/Grouping.d.ts.map +1 -0
  431. package/dist/esm/internal/Grouping.js +99 -0
  432. package/dist/esm/internal/Grouping.js.map +1 -0
  433. package/dist/esm/internal/Html.d.ts +20 -0
  434. package/dist/esm/internal/Html.d.ts.map +1 -0
  435. package/dist/esm/internal/Html.js +70 -0
  436. package/dist/esm/internal/Html.js.map +1 -0
  437. package/dist/esm/internal/Http.d.ts +95 -0
  438. package/dist/esm/internal/Http.d.ts.map +1 -0
  439. package/dist/esm/internal/Http.js +154 -0
  440. package/dist/esm/internal/Http.js.map +1 -0
  441. package/dist/esm/internal/HttpNetwork.d.ts +27 -0
  442. package/dist/esm/internal/HttpNetwork.d.ts.map +1 -0
  443. package/dist/esm/internal/HttpNetwork.js +114 -0
  444. package/dist/esm/internal/HttpNetwork.js.map +1 -0
  445. package/dist/esm/internal/Ignore.d.ts +37 -0
  446. package/dist/esm/internal/Ignore.d.ts.map +1 -0
  447. package/dist/esm/internal/Ignore.js +128 -0
  448. package/dist/esm/internal/Ignore.js.map +1 -0
  449. package/dist/esm/internal/LinearRegex.d.ts +19 -0
  450. package/dist/esm/internal/LinearRegex.d.ts.map +1 -0
  451. package/dist/esm/internal/LinearRegex.js +176 -0
  452. package/dist/esm/internal/LinearRegex.js.map +1 -0
  453. package/dist/esm/internal/Match.d.ts +85 -0
  454. package/dist/esm/internal/Match.d.ts.map +1 -0
  455. package/dist/esm/internal/Match.js +142 -0
  456. package/dist/esm/internal/Match.js.map +1 -0
  457. package/dist/esm/internal/Paths.d.ts +23 -0
  458. package/dist/esm/internal/Paths.d.ts.map +1 -0
  459. package/dist/esm/internal/Paths.js +40 -0
  460. package/dist/esm/internal/Paths.js.map +1 -0
  461. package/dist/esm/internal/Preserve.d.ts +25 -0
  462. package/dist/esm/internal/Preserve.d.ts.map +1 -0
  463. package/dist/esm/internal/Preserve.js +70 -0
  464. package/dist/esm/internal/Preserve.js.map +1 -0
  465. package/dist/esm/internal/Prune.d.ts +35 -0
  466. package/dist/esm/internal/Prune.d.ts.map +1 -0
  467. package/dist/esm/internal/Prune.js +60 -0
  468. package/dist/esm/internal/Prune.js.map +1 -0
  469. package/dist/esm/internal/RemoteTree.d.ts +60 -0
  470. package/dist/esm/internal/RemoteTree.d.ts.map +1 -0
  471. package/dist/esm/internal/RemoteTree.js +132 -0
  472. package/dist/esm/internal/RemoteTree.js.map +1 -0
  473. package/dist/esm/internal/SearchContract.d.ts +63 -0
  474. package/dist/esm/internal/SearchContract.d.ts.map +1 -0
  475. package/dist/esm/internal/SearchContract.js +66 -0
  476. package/dist/esm/internal/SearchContract.js.map +1 -0
  477. package/dist/esm/internal/Symbols.d.ts +39 -0
  478. package/dist/esm/internal/Symbols.d.ts.map +1 -0
  479. package/dist/esm/internal/Symbols.js +79 -0
  480. package/dist/esm/internal/Symbols.js.map +1 -0
  481. package/dist/esm/internal/Tar.d.ts +23 -0
  482. package/dist/esm/internal/Tar.d.ts.map +1 -0
  483. package/dist/esm/internal/Tar.js +97 -0
  484. package/dist/esm/internal/Tar.js.map +1 -0
  485. package/dist/esm/internal/TestReport.d.ts +52 -0
  486. package/dist/esm/internal/TestReport.d.ts.map +1 -0
  487. package/dist/esm/internal/TestReport.js +172 -0
  488. package/dist/esm/internal/TestReport.js.map +1 -0
  489. package/dist/esm/internal/Text.d.ts +125 -0
  490. package/dist/esm/internal/Text.d.ts.map +1 -0
  491. package/dist/esm/internal/Text.js +141 -0
  492. package/dist/esm/internal/Text.js.map +1 -0
  493. package/dist/esm/internal/Url.d.ts +13 -0
  494. package/dist/esm/internal/Url.d.ts.map +1 -0
  495. package/dist/esm/internal/Url.js +27 -0
  496. package/dist/esm/internal/Url.js.map +1 -0
  497. package/dist/esm/internal/Walk.d.ts +72 -0
  498. package/dist/esm/internal/Walk.d.ts.map +1 -0
  499. package/dist/esm/internal/Walk.js +126 -0
  500. package/dist/esm/internal/Walk.js.map +1 -0
  501. package/docs/README.md +119 -0
  502. package/docs/api.md +499 -0
  503. package/docs/concepts/effects-and-capabilities.md +138 -0
  504. package/docs/concepts/flows-and-handlers.md +115 -0
  505. package/docs/concepts/limits-and-disclosure.md +105 -0
  506. package/docs/concepts/search-contract.md +182 -0
  507. package/docs/guides/bind-the-standard-flows.md +116 -0
  508. package/docs/guides/implement-a-search-peer.md +133 -0
  509. package/docs/guides/pin-a-checkpoint.md +161 -0
  510. package/docs/guides/query-a-language-server.md +257 -0
  511. package/docs/guides/reach-the-network.md +141 -0
  512. package/docs/guides/read-and-edit-a-file.md +240 -0
  513. package/docs/guides/run-a-shell-command.md +236 -0
  514. package/docs/guides/run-the-test-suite.md +154 -0
  515. package/docs/guides/search-a-workspace.md +148 -0
  516. package/docs/installation.md +115 -0
  517. package/docs/quickstart.md +125 -0
  518. package/docs/reference/flows.md +556 -0
  519. package/docs/troubleshooting.md +347 -0
  520. package/package.json +449 -3
  521. package/src/ApplyPatch.ts +458 -0
  522. package/src/Bash.ts +619 -0
  523. package/src/Checkpoints.ts +589 -0
  524. package/src/Container.ts +212 -0
  525. package/src/Edit.ts +366 -0
  526. package/src/ExaWebSearch.ts +145 -0
  527. package/src/Explore.ts +139 -0
  528. package/src/Fetch.ts +117 -0
  529. package/src/Glob.ts +200 -0
  530. package/src/Grep.ts +320 -0
  531. package/src/HttpPost.ts +120 -0
  532. package/src/LanguageServer.ts +110 -0
  533. package/src/Ls.ts +228 -0
  534. package/src/Lsp.ts +184 -0
  535. package/src/Manifest.ts +162 -0
  536. package/src/NativeSearch.ts +457 -0
  537. package/src/NodeLanguageServer.ts +1148 -0
  538. package/src/PortableSearch.ts +284 -0
  539. package/src/Probe.ts +284 -0
  540. package/src/Read.ts +359 -0
  541. package/src/Relocate.ts +166 -0
  542. package/src/RemoteSearch.ts +199 -0
  543. package/src/Search.ts +185 -0
  544. package/src/SearchConformance.ts +288 -0
  545. package/src/SearchContract.ts +489 -0
  546. package/src/ShellCommand.ts +201 -0
  547. package/src/StdError.ts +80 -0
  548. package/src/TestRun.ts +401 -0
  549. package/src/TestRunner.ts +119 -0
  550. package/src/TreeFingerprint.ts +200 -0
  551. package/src/UpdatePlan.ts +171 -0
  552. package/src/WebFetch.ts +194 -0
  553. package/src/WebSearch.ts +165 -0
  554. package/src/Write.ts +195 -0
  555. package/src/index.ts +157 -0
  556. package/src/internal/ApplyPatch.ts +601 -0
  557. package/src/internal/CodexText.ts +182 -0
  558. package/src/internal/Declaration.ts +60 -0
  559. package/src/internal/Diagnostics.ts +134 -0
  560. package/src/internal/EnvelopePrecheck.ts +489 -0
  561. package/src/internal/Exec.ts +427 -0
  562. package/src/internal/FileMutation.ts +231 -0
  563. package/src/internal/FsFailure.ts +51 -0
  564. package/src/internal/GitWorktree.ts +491 -0
  565. package/src/internal/Grouping.ts +106 -0
  566. package/src/internal/Html.ts +87 -0
  567. package/src/internal/Http.ts +209 -0
  568. package/src/internal/HttpNetwork.ts +153 -0
  569. package/src/internal/Ignore.ts +135 -0
  570. package/src/internal/LinearRegex.ts +173 -0
  571. package/src/internal/Match.ts +172 -0
  572. package/src/internal/Paths.ts +42 -0
  573. package/src/internal/Preserve.ts +108 -0
  574. package/src/internal/Prune.ts +62 -0
  575. package/src/internal/RemoteTree.ts +159 -0
  576. package/src/internal/SearchContract.ts +77 -0
  577. package/src/internal/Symbols.ts +88 -0
  578. package/src/internal/Tar.ts +95 -0
  579. package/src/internal/TestReport.ts +194 -0
  580. package/src/internal/Text.ts +185 -0
  581. package/src/internal/Url.ts +23 -0
  582. package/src/internal/Walk.ts +176 -0
package/src/Bash.ts ADDED
@@ -0,0 +1,619 @@
1
+ /**
2
+ * Bash flow declaration and portable handler.
3
+ *
4
+ * Two ways in, and the difference is where the payload is parsed. `command` is
5
+ * a line for the platform shell, exactly as before. `script` is program text
6
+ * delivered to an interpreter on standard input, as data: nothing quotes it,
7
+ * escapes it, or terminates it with a heredoc marker, so the class of failure
8
+ * that produced `docker exec c bash -lc '…python - <<EOF…'` cannot occur. Its
9
+ * `args` reach the script as arguments rather than as interpolated text.
10
+ *
11
+ * `container` names a container the host knows how to reach, and the argv is
12
+ * built by the injected {@link Container} transport rather than typed by the
13
+ * caller. A host that binds no transport refuses such a call by saying so; the
14
+ * requirement is optional here precisely so a host without containers is not
15
+ * forced to declare one.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+
20
+ import type * as ChildProcessSpawner from "@smthrs/kernel/ChildProcessSpawner"
21
+ import * as Path from "@smthrs/kernel/Path"
22
+ import * as Effect from "effect/Effect"
23
+ import * as Option from "effect/Option"
24
+ import * as Schema from "effect/Schema"
25
+ import * as Container from "./Container.ts"
26
+ import { capability, envelope } from "./internal/Declaration.ts"
27
+ import * as Diagnostics from "./internal/Diagnostics.ts"
28
+ import { outsideEnvelope } from "./internal/EnvelopePrecheck.ts"
29
+ import * as Exec from "./internal/Exec.ts"
30
+ import { elideMiddle as elide, MAX_SHELL_OUTPUT_BYTES } from "./internal/Text.ts"
31
+ import * as Probe from "./Probe.ts"
32
+ import * as StdError from "./StdError.ts"
33
+ import * as TreeFingerprint from "./TreeFingerprint.ts"
34
+
35
+ /**
36
+ * Registry name for the bash flow.
37
+ *
38
+ * @category identifiers
39
+ * @since 1.0.0
40
+ */
41
+ export const name = "bash"
42
+
43
+ /**
44
+ * Model-facing description of the bash flow.
45
+ *
46
+ * Capped at 200 characters and read every frame, which is why the
47
+ * invalid-probe contract is not restated here: the cell contract teaches it
48
+ * once, and a result that has one explains itself.
49
+ *
50
+ * @category descriptions
51
+ * @since 1.0.0
52
+ */
53
+ export const description =
54
+ "Run a shell command, or an interpreter over a script passed as data instead of quoted into a line. container routes it through the host's container transport. mode:hermetic pre-checks path tokens."
55
+
56
+ /**
57
+ * Default command timeout in milliseconds.
58
+ *
59
+ * Ten minutes lets full builds and test suites finish while ensuring a stalled
60
+ * process eventually releases the flow.
61
+ *
62
+ * @category constants
63
+ * @since 1.0.0
64
+ */
65
+ export const DEFAULT_TIMEOUT_MS = 600_000
66
+
67
+ const Command = Schema.optional(Schema.String.annotate({
68
+ description: "Shell command line to execute; give this or script, never both"
69
+ }))
70
+ const Script = Schema.optional(Schema.String.annotate({
71
+ description: "Program text delivered to the interpreter on stdin as data, so it needs no quoting or heredoc"
72
+ }))
73
+ const Interpreter = Schema.optional(Schema.String.annotate({
74
+ description:
75
+ "Program that reads script on stdin; defaults to bash. python, python3, sh, zsh, node, ruby and perl are known"
76
+ }))
77
+ const Args = Schema.optional(
78
+ Schema.Array(Schema.String).annotate({
79
+ description: "Arguments passed to the script as data, never interpolated into it"
80
+ })
81
+ )
82
+ const Stdin = Schema.optional(Schema.String.annotate({
83
+ description: "Text written to the command's standard input; use script instead when the text is the program"
84
+ }))
85
+ const ContainerName = Schema.optional(Schema.String.annotate({
86
+ description: "Run inside this container through the host's container transport; requires mode:unhermetic"
87
+ }))
88
+ const Cwd = Schema.optional(Schema.String).annotate({
89
+ description: "Working directory for the command",
90
+ message: "cwd must be a path string. For a checkpoint, pass { at: ctx.base } as the third ctx.call argument."
91
+ })
92
+ const Env = Schema.optional(
93
+ Schema.Record(Schema.String, Schema.String).annotate({ description: "Environment variables for the command" })
94
+ )
95
+ const TimeoutMs = Schema.optional(Schema.Number).annotate({
96
+ description: "Wall-clock timeout in milliseconds; defaults to 600000 ms",
97
+ message: "timeoutMs must be a number of milliseconds."
98
+ })
99
+
100
+ /**
101
+ * Input schema for the bash flow.
102
+ *
103
+ * The mode named `hermetic` requires explicit read and write envelopes for a
104
+ * lexical pre-check; it does not by itself confine the process. Unhermetic mode
105
+ * deliberately omits those declarations so the distinction stays visible in
106
+ * the input shape.
107
+ *
108
+ * @category schemas
109
+ * @since 1.0.0
110
+ */
111
+ export const Input = Schema.Union([
112
+ Schema.Struct({
113
+ mode: Schema.Literal("hermetic").annotate({
114
+ description: "Lexically pre-check explicit path tokens against declared reads and writes; does not sandbox"
115
+ }),
116
+ command: Command,
117
+ script: Script,
118
+ interpreter: Interpreter,
119
+ args: Args,
120
+ stdin: Stdin,
121
+ container: ContainerName,
122
+ reads: Schema.Array(Schema.NonEmptyString).annotate({ description: "Paths or path globs the command may read" }),
123
+ writes: Schema.Array(Schema.NonEmptyString).annotate({ description: "Paths or path globs the command may write" }),
124
+ cwd: Cwd,
125
+ env: Env,
126
+ timeoutMs: TimeoutMs
127
+ }),
128
+ Schema.Struct({
129
+ // Omitted means unhermetic: it is the envelope `effects` already declares
130
+ // for every call, so the default grants nothing a named mode would not.
131
+ mode: Schema.Literal("unhermetic").annotate({
132
+ description: "Run without a declared filesystem envelope as an irreversible effect; the default"
133
+ }).pipe(Schema.optionalKey, Schema.withDecodingDefaultKey(Effect.succeed("unhermetic" as const))),
134
+ command: Command,
135
+ script: Script,
136
+ interpreter: Interpreter,
137
+ args: Args,
138
+ stdin: Stdin,
139
+ container: ContainerName,
140
+ cwd: Cwd,
141
+ env: Env,
142
+ timeoutMs: TimeoutMs
143
+ })
144
+ ])
145
+
146
+ /**
147
+ * Decoded input accepted by the bash handler.
148
+ *
149
+ * @category models
150
+ * @since 1.0.0
151
+ */
152
+ export type Input = typeof Input.Type
153
+
154
+ /**
155
+ * Output schema for the bash flow.
156
+ *
157
+ * `invalidProbe` is present when the shell itself refused to start the
158
+ * command, which its exit code says outright: 127 for a program it could not
159
+ * find, 126 for one it could not execute. Only that. Reading a runner's own
160
+ * wording is a judgment rather than a fact, and `Probe.classify` makes it with
161
+ * Jev for the `test` flow, whose caller is asking about a suite; a shell call
162
+ * is any command at all and stays free of the gateway. See `Probe`.
163
+ *
164
+ * The `<stream>Truncated` flags are a wire convention, not a display detail.
165
+ * A truncated capture is a fragment of what the process printed, and the
166
+ * harness reads these flags to refuse a later write of those exact bytes —
167
+ * `@smthrs/harness/TruncatedOutput` is the consuming half. Renaming a flag, or
168
+ * dropping it when the capture is cut, disarms that guard silently.
169
+ *
170
+ * @category schemas
171
+ * @since 1.0.0
172
+ */
173
+ export const Output = Schema.Struct({
174
+ exitCode: Schema.Number.annotate({ description: "Command exit code, including non-zero codes" }),
175
+ stdout: Schema.String.annotate({
176
+ description:
177
+ "Captured stdout; when stdoutTruncated is true, only its start and end, with one line naming the bytes omitted between them"
178
+ }),
179
+ stderr: Schema.String.annotate({
180
+ description:
181
+ "Captured stderr; when stderrTruncated is true, only its start and end, with one line naming the bytes omitted between them"
182
+ }),
183
+ stdoutTruncated: Schema.Boolean.annotate({
184
+ description:
185
+ "Whether stdout exceeded the capture limit, leaving stdout a fragment that must not be written to a file"
186
+ }),
187
+ stderrTruncated: Schema.Boolean.annotate({
188
+ description:
189
+ "Whether stderr exceeded the capture limit, leaving stderr a fragment that must not be written to a file"
190
+ }),
191
+ stdoutDroppedBytes: Schema.Number.annotate({ description: "UTF-8 bytes omitted from the middle of stdout" }),
192
+ stderrDroppedBytes: Schema.Number.annotate({ description: "UTF-8 bytes omitted from the middle of stderr" }),
193
+ invalidProbe: Schema.optional(
194
+ Probe.InvalidProbe.annotate({
195
+ description: "Reserved for a confirmed launch failure; an exit code alone does not establish one"
196
+ })
197
+ ),
198
+ mutated: Schema.optional(
199
+ Schema.Boolean.annotate({
200
+ description:
201
+ "Present for a containerised command whose working directory was measured before and after it: true when the tree changed, false when it held still. Absent when the tree was not measured, which is never read as unchanged."
202
+ })
203
+ )
204
+ })
205
+
206
+ /**
207
+ * Decoded output returned by the bash handler.
208
+ *
209
+ * @category models
210
+ * @since 1.0.0
211
+ */
212
+ export type Output = typeof Output.Type
213
+
214
+ /**
215
+ * The text of a stream cut to its start and end: the start, one line naming
216
+ * the bytes omitted between them, and the end. A host that captures output
217
+ * itself, such as a terminal behind {@link inTerminal}, cuts with this so every
218
+ * {@link Output} reads the same.
219
+ *
220
+ * @category rendering
221
+ * @since 1.0.0-rc.5
222
+ */
223
+ export const elideMiddle: (start: string, droppedBytes: number, end: string) => string = elide
224
+
225
+ /**
226
+ * Static conservative effect envelope for the bash flow.
227
+ *
228
+ * The declaration is the registry-time worst case because the mode is not
229
+ * known until an invocation is decoded.
230
+ *
231
+ * @category effects
232
+ * @since 1.0.0
233
+ */
234
+ export const effects = envelope({
235
+ tier: "irreversible",
236
+ mode: "expected",
237
+ reads: [],
238
+ writes: []
239
+ })
240
+
241
+ /**
242
+ * Narrows the effect envelope for a decoded invocation.
243
+ *
244
+ * @category effects
245
+ * @since 1.0.0
246
+ */
247
+ export const effectsFor = (input: Input) =>
248
+ input.mode === "hermetic"
249
+ ? envelope({
250
+ tier: "irreversible",
251
+ mode: "hermetic",
252
+ reads: input.reads,
253
+ writes: input.writes
254
+ })
255
+ : envelope({
256
+ tier: "irreversible",
257
+ mode: "expected",
258
+ reads: [],
259
+ writes: []
260
+ })
261
+
262
+ /**
263
+ * Capabilities required by the bash flow.
264
+ *
265
+ * @category capabilities
266
+ * @since 1.0.0
267
+ */
268
+ export const capabilities = [capability("proc:spawn", "*")]
269
+
270
+ /**
271
+ * Declaration-only bash flow.
272
+ *
273
+ * @category flows
274
+ * @since 1.0.0
275
+ */
276
+ export const flow = { name, description, input: Input, output: Output, capabilities, effects } as const
277
+
278
+ /*
279
+ * `bash` declares no activity on purpose. What a shell call does is in the
280
+ * command, not in the declaration: the same flow runs a test suite, a type
281
+ * check, and `cat`. A reader that recognises a direct runner says so from the
282
+ * recorded command; everything else stays unknown, which is what an absent
283
+ * activity means.
284
+ */
285
+
286
+ /**
287
+ * How one recorded call to this flow reads: the verb for each settlement, the
288
+ * input field that is its subject, and the measured output fields a one-line
289
+ * summary may count.
290
+ *
291
+ * Display metadata only, governed by `@smthrs/registry`
292
+ * `Descriptor.CallPresentation` and checked where `StandardFlows` binds it.
293
+ *
294
+ * @category presentation
295
+ * @since 1.0.0-rc.0
296
+ */
297
+ export const presentation = {
298
+ verb: { pending: "running", success: "ran", failure: "failed to run" },
299
+ subject: "command",
300
+ result: "command"
301
+ } as const
302
+
303
+ /**
304
+ * Select standard input explicitly. Shells need `--` before script arguments
305
+ * so even an argument such as `-c` cannot replace the stdin program.
306
+ * Other supported interpreters treat arguments after `-` as program data.
307
+ */
308
+ const stdinArguments = (interpreter: string): ReadonlyArray<string> | undefined => {
309
+ switch (interpreter) {
310
+ case "bash":
311
+ case "zsh":
312
+ case "sh":
313
+ case "dash":
314
+ return ["-s", "--"]
315
+ case "python":
316
+ case "python3":
317
+ case "node":
318
+ case "ruby":
319
+ case "perl":
320
+ return ["-"]
321
+ default:
322
+ return undefined
323
+ }
324
+ }
325
+
326
+ /** Whether a script is shell text the lexical pre-check can actually read. */
327
+ const shells = new Set(["bash", "zsh", "sh", "dash"])
328
+
329
+ /** What one invocation runs, before any container transport rewrites it. */
330
+ interface Plan {
331
+ readonly file: string
332
+ readonly args: ReadonlyArray<string> | undefined
333
+ readonly stdin: string | undefined
334
+ readonly env: Record<string, string> | undefined
335
+ readonly quoted: string
336
+ }
337
+
338
+ const invalid = (message: string): StdError.StdError => new StdError.StdError({ code: "invalid_input", message })
339
+
340
+ /** The invocation an input names, or the failure explaining why it names none. */
341
+ const plan = (input: Input): Plan | StdError.StdError => {
342
+ const interpreter = input.interpreter ?? "bash"
343
+ if (input.command !== undefined && input.script !== undefined) {
344
+ return invalid("Give command or script, never both: a script is program text, a command is a shell line")
345
+ }
346
+ if (input.command === undefined && input.script === undefined) {
347
+ return invalid("Give either command (a shell line) or script (program text run by interpreter)")
348
+ }
349
+ if (input.script !== undefined && input.stdin !== undefined) {
350
+ return invalid("A script already arrives on standard input, so it cannot also carry stdin")
351
+ }
352
+ if (input.command !== undefined && input.args !== undefined) {
353
+ return invalid("args belong to a script; a command carries its own arguments in the line")
354
+ }
355
+ if (input.command !== undefined && input.interpreter !== undefined) {
356
+ return invalid("interpreter runs a script; a command runs in the platform shell")
357
+ }
358
+ if (input.mode === "hermetic" && input.container !== undefined) {
359
+ return invalid(
360
+ "A container has its own filesystem, so declared reads and writes cannot describe it. Use mode:unhermetic for a containerised command"
361
+ )
362
+ }
363
+ if (input.mode === "hermetic" && input.script !== undefined && !shells.has(interpreter)) {
364
+ return invalid(
365
+ `The hermetic pre-check reads shell text, and ${interpreter} is not a shell. Run this script with mode:unhermetic, or express it as shell`
366
+ )
367
+ }
368
+ if (input.command !== undefined) {
369
+ return { file: input.command, args: undefined, stdin: input.stdin, env: input.env, quoted: input.command }
370
+ }
371
+ const selector = stdinArguments(interpreter)
372
+ if (selector === undefined) {
373
+ return invalid(`Unsupported script interpreter: ${interpreter}`)
374
+ }
375
+ const args = [...selector, ...(input.args ?? [])]
376
+ return {
377
+ file: interpreter,
378
+ args,
379
+ stdin: input.script,
380
+ env: input.env,
381
+ quoted: [interpreter, ...args].join(" ")
382
+ }
383
+ }
384
+
385
+ /**
386
+ * The plan, refused when its input names no one invocation or when a hermetic
387
+ * call's paths fall outside its declared envelope. Spawned and terminal
388
+ * execution share this one check.
389
+ */
390
+ const precheck = (input: Input, path: Path.Path): Plan | StdError.StdError => {
391
+ const intent = plan(input)
392
+ if (intent instanceof StdError.StdError || input.mode !== "hermetic") return intent
393
+ // A planned call carries exactly one of command or script.
394
+ return outsideEnvelope(input, input.command ?? input.script!, path) ?? intent
395
+ }
396
+
397
+ /** The plan as the host will spawn it, once the container transport has had it. */
398
+ const routed = (
399
+ plan: Plan,
400
+ input: Input,
401
+ transport: Option.Option<Container.Container>
402
+ ): Effect.Effect<Plan, StdError.StdError> => {
403
+ if (input.container === undefined) return Effect.succeed(plan)
404
+ if (Option.isNone(transport)) return Effect.fail(Container.unavailable(input.container))
405
+ return Effect.map(
406
+ transport.value.exec(request(plan, input, input.container)),
407
+ (routing): Plan => ({
408
+ file: routing.file,
409
+ args: routing.args,
410
+ stdin: plan.stdin,
411
+ env: routing.env,
412
+ // Diagnostics describe the logical invocation, not transport arguments.
413
+ quoted: plan.quoted
414
+ })
415
+ )
416
+ }
417
+
418
+ /**
419
+ * One containerised request, always through a login shell.
420
+ *
421
+ * A container's environment is what its profile makes it. The images this
422
+ * harness runs against activate the project's interpreter — a conda env, a
423
+ * virtualenv, a modified `PATH` — from `/etc/profile.d`, so a program spawned
424
+ * directly by `docker exec` gets a different Python from the one that owns the
425
+ * repository's dependencies. That is measured, not theoretical: r90 typed
426
+ * `docker exec … bash -lc '…'` by hand and got the activation for free, r91
427
+ * routed `interpreter: "python3"` straight at the container and filled its
428
+ * traces with `ModuleNotFoundError: No module named 'numpy'` and
429
+ * `exec: "/usr/local/bin/python": no such file or directory`. Thirty of 45
430
+ * instances then spent 138 cells scanning `/opt` for the real interpreter.
431
+ *
432
+ * So the login shell is the transport's, not the caller's. A command line is
433
+ * one argument to `bash -lc`, as before. A program run under an interpreter
434
+ * becomes `bash -lc 'exec "$@"' bash <interpreter> <args…>`: the shell reads
435
+ * the profile, then `exec` replaces it with the interpreter, so the script
436
+ * still arrives on the inherited standard input and no argument is ever
437
+ * re-parsed as shell text.
438
+ */
439
+ const request = (plan: Plan, input: Input, container: string): Container.Request => ({
440
+ container,
441
+ file: "bash",
442
+ args: plan.args === undefined
443
+ ? ["-lc", plan.file]
444
+ : ["-lc", `exec "$@"`, "bash", plan.file, ...plan.args],
445
+ ...(input.cwd === undefined ? {} : { cwd: input.cwd }),
446
+ ...(input.env === undefined ? {} : { env: input.env }),
447
+ stdin: plan.stdin !== undefined
448
+ })
449
+
450
+ /** How long one fingerprint of the container's working directory may take. */
451
+ const FINGERPRINT_TIMEOUT_MS = 60_000
452
+
453
+ /**
454
+ * Measures the tree a containerised command is about to run in, or just ran in.
455
+ *
456
+ * The host's workspace walk cannot see a container's filesystem, so the
457
+ * measurement is taken where the tree is: `TreeFingerprint.script` runs
458
+ * through the same transport as the command, in the same working directory,
459
+ * and answers with one checksum. Every way this can fail — no transport, a
460
+ * container without `find` or `stat`, a timeout, a bounded listing — is read
461
+ * as "unmeasured" and reported as an absent `mutated`, never as a tree that
462
+ * held still. The time it costs is bounded by the command's own timeout so a
463
+ * stalled container cannot spend more waiting to be measured than it may
464
+ * spend running.
465
+ */
466
+ const fingerprint = (
467
+ input: Input,
468
+ transport: Option.Option<Container.Container>
469
+ ): Effect.Effect<TreeFingerprint.Measurement | undefined, never, ChildProcessSpawner.ChildProcessSpawner> =>
470
+ Effect.gen(function*() {
471
+ if (input.container === undefined || Option.isNone(transport)) return undefined
472
+ const routing = yield* transport.value.exec({
473
+ container: input.container,
474
+ file: "sh",
475
+ args: ["-c", TreeFingerprint.script()],
476
+ ...(input.cwd === undefined ? {} : { cwd: input.cwd }),
477
+ stdin: false
478
+ })
479
+ const result = yield* Exec.exec(routing.file, {
480
+ ...(routing.env === undefined ? {} : { env: routing.env }),
481
+ timeoutMs: Math.min(input.timeoutMs ?? DEFAULT_TIMEOUT_MS, FINGERPRINT_TIMEOUT_MS),
482
+ maxCaptureBytes: MAX_SHELL_OUTPUT_BYTES,
483
+ args: routing.args
484
+ })
485
+ return result.exitCode === 0 ? TreeFingerprint.parse(result.stdout) : undefined
486
+ }).pipe(Effect.orElseSucceed(() => undefined))
487
+
488
+ /**
489
+ * Executes a shell command through the permission-aware kernel service.
490
+ *
491
+ * Non-zero exit codes remain successful values. Only timeout, host, permission,
492
+ * and declared-envelope pre-check failures use the typed error channel.
493
+ *
494
+ * @category handlers
495
+ * @since 1.0.0
496
+ */
497
+ export const run = Effect.fn("Bash.run")(function*(
498
+ input: Input
499
+ ): Effect.fn.Return<Output, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner | Path.Path> {
500
+ const intent = precheck(input, yield* Path.Path)
501
+ if (intent instanceof StdError.StdError) return yield* Effect.fail(intent)
502
+ // The working directory belongs to the container. The transport supplies
503
+ // any environment overrides its host process needs to forward into it.
504
+ const contained = input.container !== undefined
505
+ const transport = yield* Effect.serviceOption(Container.Container)
506
+ const spawned = yield* routed(intent, input, transport)
507
+
508
+ // The tree the command runs in, before it runs. Measured in the container
509
+ // because nothing on this host can see it; see `TreeFingerprint`.
510
+ const before = yield* fingerprint(input, transport)
511
+ const result = yield* Exec.exec(spawned.file, {
512
+ ...(input.cwd === undefined || contained ? {} : { cwd: input.cwd }),
513
+ ...(spawned.env === undefined ? {} : { env: spawned.env }),
514
+ timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,
515
+ maxCaptureBytes: MAX_SHELL_OUTPUT_BYTES,
516
+ overflow: "ends",
517
+ ...(spawned.args === undefined ? {} : { args: spawned.args }),
518
+ ...(spawned.stdin === undefined ? {} : { stdin: spawned.stdin })
519
+ }).pipe(Effect.mapError((error) => Exec.toStdError(spawned.quoted, error)))
520
+ const mutated = TreeFingerprint.moved(before, yield* fingerprint(input, transport))
521
+ // A command on this host may have changed files a language server holds
522
+ // open; a container's files are not the ones it was sent.
523
+ if (!contained) yield* Diagnostics.refresh
524
+ // Exit codes alone cannot establish whether the shell refused to launch a
525
+ // command or a launched runner chose that status after executing tests.
526
+ return {
527
+ exitCode: result.exitCode,
528
+ stdout: result.stdout,
529
+ stderr: result.stderr,
530
+ stdoutTruncated: result.stdoutDroppedBytes > 0,
531
+ stderrTruncated: result.stderrDroppedBytes > 0,
532
+ stdoutDroppedBytes: result.stdoutDroppedBytes,
533
+ stderrDroppedBytes: result.stderrDroppedBytes,
534
+ ...(mutated === undefined ? {} : { mutated })
535
+ }
536
+ })
537
+
538
+ /**
539
+ * What one call runs, after planning and before any transport: the program,
540
+ * its arguments (absent for a shell command line), standard input, the
541
+ * caller's environment, and the logical invocation as a person reads it.
542
+ *
543
+ * @category models
544
+ * @since 1.0.0
545
+ */
546
+ export interface Invocation {
547
+ readonly file: string
548
+ readonly args: ReadonlyArray<string> | undefined
549
+ readonly stdin: string | undefined
550
+ readonly env: Record<string, string> | undefined
551
+ readonly quoted: string
552
+ }
553
+
554
+ /**
555
+ * The invocation `input` names, or the typed refusal explaining why it names
556
+ * none. The same plan {@link run} spawns; a terminal provider runs it instead.
557
+ *
558
+ * @category constructors
559
+ * @since 1.0.0
560
+ */
561
+ export const invocation = (input: Input): Invocation | StdError.StdError => plan(input)
562
+
563
+ /**
564
+ * {@link run}'s contract through a registered terminal (T-TRM-05): the same
565
+ * plan, hermetic pre-check, bounded output and diagnostics refresh, with
566
+ * execution supplied by `execute` instead of a spawn on this host. A terminal
567
+ * has no container transport, so a containerised call is refused before it
568
+ * reaches `execute`.
569
+ *
570
+ * @category handlers
571
+ * @since 1.0.0
572
+ */
573
+ export const inTerminal = <R>(
574
+ execute: (input: Input) => Effect.Effect<Output, StdError.StdError, R>
575
+ ) =>
576
+ Effect.fn("Bash.inTerminal")(function*(
577
+ input: Input
578
+ ): Effect.fn.Return<Output, StdError.StdError, R | Path.Path> {
579
+ const intent = precheck(input, yield* Path.Path)
580
+ if (intent instanceof StdError.StdError) return yield* Effect.fail(intent)
581
+ if (input.container !== undefined) return yield* Effect.fail(Container.unavailable(input.container))
582
+ const output = yield* execute(input)
583
+ // The terminal ran on this workspace: files a language server holds may
584
+ // have changed, exactly as after a spawn here.
585
+ yield* Diagnostics.refresh
586
+ return output
587
+ })
588
+
589
+ /**
590
+ * The refusal a sealed host answers a call outside its container with.
591
+ *
592
+ * @category errors
593
+ * @since 1.0.0-rc.1
594
+ */
595
+ export const outsideContainer = (sealedTo: string, requested: string | undefined): StdError.StdError =>
596
+ new StdError.StdError({
597
+ code: "outside_container",
598
+ message: requested === undefined
599
+ ? `This host runs commands only inside container "${sealedTo}". Name it: { mode: "unhermetic", container: "${sealedTo}", command: "..." }.`
600
+ : `This host runs commands only inside container "${sealedTo}", not "${requested}".`
601
+ })
602
+
603
+ /**
604
+ * {@link run}, sealed to one container.
605
+ *
606
+ * A host that must not be reachable from the cell (a benchmark host holding
607
+ * other tasks' tests and reference solutions, say) binds this instead of
608
+ * {@link run}: a call naming `sealedTo` runs as usual, and every other call,
609
+ * including one with no container that would run on the host, fails with
610
+ * `outside_container` before anything is spawned.
611
+ *
612
+ * @category handlers
613
+ * @since 1.0.0-rc.1
614
+ */
615
+ export const sealed = (sealedTo: string) =>
616
+ (
617
+ input: Input
618
+ ): Effect.Effect<Output, StdError.StdError, ChildProcessSpawner.ChildProcessSpawner | Path.Path> =>
619
+ input.container === sealedTo ? run(input) : Effect.fail(outsideContainer(sealedTo, input.container))