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