@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.
- package/CHANGELOG.md +148 -0
- package/LICENSE +21 -0
- package/README.md +156 -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 +390 -0
- package/dist/cjs/Bash.d.ts.map +1 -0
- package/dist/cjs/Bash.js +333 -0
- package/dist/cjs/Bash.js.map +7 -0
- package/dist/cjs/Checkpoints.d.ts +322 -0
- package/dist/cjs/Checkpoints.d.ts.map +1 -0
- package/dist/cjs/Checkpoints.js +233 -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 +36 -0
- package/dist/cjs/PortableSearch.d.ts.map +1 -0
- package/dist/cjs/PortableSearch.js +240 -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/RemoteSearch.d.ts +54 -0
- package/dist/cjs/RemoteSearch.d.ts.map +1 -0
- package/dist/cjs/RemoteSearch.js +134 -0
- package/dist/cjs/RemoteSearch.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 +129 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +101 -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 +69 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/cjs/internal/EnvelopePrecheck.js +323 -0
- package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
- package/dist/cjs/internal/Exec.d.ts +151 -0
- package/dist/cjs/internal/Exec.d.ts.map +1 -0
- package/dist/cjs/internal/Exec.js +207 -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/RemoteTree.d.ts +60 -0
- package/dist/cjs/internal/RemoteTree.d.ts.map +1 -0
- package/dist/cjs/internal/RemoteTree.js +123 -0
- package/dist/cjs/internal/RemoteTree.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/Tar.d.ts +23 -0
- package/dist/cjs/internal/Tar.d.ts.map +1 -0
- package/dist/cjs/internal/Tar.js +86 -0
- package/dist/cjs/internal/Tar.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 +125 -0
- package/dist/cjs/internal/Text.d.ts.map +1 -0
- package/dist/cjs/internal/Text.js +85 -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 +390 -0
- package/dist/esm/Bash.d.ts.map +1 -0
- package/dist/esm/Bash.js +514 -0
- package/dist/esm/Bash.js.map +1 -0
- package/dist/esm/Checkpoints.d.ts +322 -0
- package/dist/esm/Checkpoints.d.ts.map +1 -0
- package/dist/esm/Checkpoints.js +396 -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 +36 -0
- package/dist/esm/PortableSearch.d.ts.map +1 -0
- package/dist/esm/PortableSearch.js +256 -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/RemoteSearch.d.ts +54 -0
- package/dist/esm/RemoteSearch.d.ts.map +1 -0
- package/dist/esm/RemoteSearch.js +162 -0
- package/dist/esm/RemoteSearch.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 +129 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +129 -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 +69 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/esm/internal/EnvelopePrecheck.js +426 -0
- package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
- package/dist/esm/internal/Exec.d.ts +151 -0
- package/dist/esm/internal/Exec.d.ts.map +1 -0
- package/dist/esm/internal/Exec.js +285 -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/RemoteTree.d.ts +60 -0
- package/dist/esm/internal/RemoteTree.d.ts.map +1 -0
- package/dist/esm/internal/RemoteTree.js +132 -0
- package/dist/esm/internal/RemoteTree.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/Tar.d.ts +23 -0
- package/dist/esm/internal/Tar.d.ts.map +1 -0
- package/dist/esm/internal/Tar.js +97 -0
- package/dist/esm/internal/Tar.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 +125 -0
- package/dist/esm/internal/Text.d.ts.map +1 -0
- package/dist/esm/internal/Text.js +141 -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 +119 -0
- package/docs/api.md +499 -0
- package/docs/concepts/effects-and-capabilities.md +138 -0
- package/docs/concepts/flows-and-handlers.md +115 -0
- package/docs/concepts/limits-and-disclosure.md +105 -0
- package/docs/concepts/search-contract.md +182 -0
- package/docs/guides/bind-the-standard-flows.md +116 -0
- package/docs/guides/implement-a-search-peer.md +133 -0
- package/docs/guides/pin-a-checkpoint.md +161 -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 +236 -0
- package/docs/guides/run-the-test-suite.md +154 -0
- package/docs/guides/search-a-workspace.md +148 -0
- package/docs/installation.md +115 -0
- package/docs/quickstart.md +125 -0
- package/docs/reference/flows.md +556 -0
- package/docs/troubleshooting.md +347 -0
- package/package.json +449 -3
- package/src/ApplyPatch.ts +458 -0
- package/src/Bash.ts +619 -0
- package/src/Checkpoints.ts +589 -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 +284 -0
- package/src/Probe.ts +284 -0
- package/src/Read.ts +359 -0
- package/src/Relocate.ts +166 -0
- package/src/RemoteSearch.ts +199 -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 +157 -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 +489 -0
- package/src/internal/Exec.ts +427 -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/RemoteTree.ts +159 -0
- package/src/internal/SearchContract.ts +77 -0
- package/src/internal/Symbols.ts +88 -0
- package/src/internal/Tar.ts +95 -0
- package/src/internal/TestReport.ts +194 -0
- package/src/internal/Text.ts +185 -0
- package/src/internal/Url.ts +23 -0
- package/src/internal/Walk.ts +176 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* update_plan flow declaration and portable handler.
|
|
3
|
+
*
|
|
4
|
+
* A Codex CLI clone of the `update_plan` tool: an optional explanation and a
|
|
5
|
+
* list of plan items, acknowledged with "Plan updated". Pure — no host
|
|
6
|
+
* access; the harness observes plan updates through the journal.
|
|
7
|
+
*
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import * as StdError from "./StdError.ts";
|
|
13
|
+
/**
|
|
14
|
+
* Registry name for the update_plan flow. Matches the Codex CLI tool name.
|
|
15
|
+
*
|
|
16
|
+
* @category identifiers
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
export declare const name = "update_plan";
|
|
20
|
+
/**
|
|
21
|
+
* Model-facing description of the update_plan flow. Matches the Codex CLI
|
|
22
|
+
* description.
|
|
23
|
+
*
|
|
24
|
+
* @category descriptions
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*/
|
|
27
|
+
export declare const description: string;
|
|
28
|
+
/**
|
|
29
|
+
* Status of one plan step, matching Codex.
|
|
30
|
+
*
|
|
31
|
+
* @category schemas
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
*/
|
|
34
|
+
export declare const StepStatus: Schema.Literals<readonly ["pending", "in_progress", "completed"]>;
|
|
35
|
+
/**
|
|
36
|
+
* The plan itself: steps, at most one of them `in_progress`.
|
|
37
|
+
*
|
|
38
|
+
* The single-in-progress rule is the last line of the Codex description a
|
|
39
|
+
* model reads every frame, so it is enforced here rather than left as prose a
|
|
40
|
+
* decode ignores. A plan naming two running steps is a decode failure at the
|
|
41
|
+
* `plan` path, not a silent acknowledgement.
|
|
42
|
+
*
|
|
43
|
+
* @category schemas
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
*/
|
|
46
|
+
export declare const Plan: Schema.$Array<Schema.Struct<{
|
|
47
|
+
readonly step: Schema.String;
|
|
48
|
+
readonly status: Schema.Literals<readonly ["pending", "in_progress", "completed"]>;
|
|
49
|
+
}>>;
|
|
50
|
+
/**
|
|
51
|
+
* Input schema for the update_plan flow.
|
|
52
|
+
*
|
|
53
|
+
* @category schemas
|
|
54
|
+
* @since 1.0.0
|
|
55
|
+
*/
|
|
56
|
+
export declare const Input: Schema.Struct<{
|
|
57
|
+
readonly explanation: Schema.optional<Schema.String>;
|
|
58
|
+
readonly plan: Schema.$Array<Schema.Struct<{
|
|
59
|
+
readonly step: Schema.String;
|
|
60
|
+
readonly status: Schema.Literals<readonly ["pending", "in_progress", "completed"]>;
|
|
61
|
+
}>>;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Decoded input accepted by the `update_plan` flow.
|
|
65
|
+
*
|
|
66
|
+
* @category models
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
*/
|
|
69
|
+
export type Input = typeof Input.Type;
|
|
70
|
+
/**
|
|
71
|
+
* Output schema for the update_plan flow.
|
|
72
|
+
*
|
|
73
|
+
* @category schemas
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
*/
|
|
76
|
+
export declare const Output: Schema.Struct<{
|
|
77
|
+
readonly output: Schema.String;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Decoded output returned by the `update_plan` flow.
|
|
81
|
+
*
|
|
82
|
+
* @category models
|
|
83
|
+
* @since 1.0.0
|
|
84
|
+
*/
|
|
85
|
+
export type Output = typeof Output.Type;
|
|
86
|
+
/**
|
|
87
|
+
* Static effect envelope for the update_plan flow: no reads, no writes.
|
|
88
|
+
*
|
|
89
|
+
* @category effects
|
|
90
|
+
* @since 1.0.0
|
|
91
|
+
*/
|
|
92
|
+
export declare const effects: import("@smthrs/plan/Effects").Declaration;
|
|
93
|
+
/**
|
|
94
|
+
* Narrows the effect envelope for a decoded invocation.
|
|
95
|
+
*
|
|
96
|
+
* The flow touches nothing, so every invocation declares what the static
|
|
97
|
+
* envelope declares.
|
|
98
|
+
*
|
|
99
|
+
* @category effects
|
|
100
|
+
* @since 1.0.0
|
|
101
|
+
*/
|
|
102
|
+
export declare const effectsFor: (_input: typeof Input.Type) => import("@smthrs/plan/Effects").Declaration;
|
|
103
|
+
/**
|
|
104
|
+
* Capabilities required by the update_plan flow: none.
|
|
105
|
+
*
|
|
106
|
+
* @category capabilities
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
*/
|
|
109
|
+
export declare const capabilities: ReadonlyArray<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Declaration-only update_plan flow.
|
|
112
|
+
*
|
|
113
|
+
* @category flows
|
|
114
|
+
* @since 1.0.0
|
|
115
|
+
*/
|
|
116
|
+
export declare const flow: {
|
|
117
|
+
readonly name: "update_plan";
|
|
118
|
+
readonly description: string;
|
|
119
|
+
readonly input: Schema.Struct<{
|
|
120
|
+
readonly explanation: Schema.optional<Schema.String>;
|
|
121
|
+
readonly plan: Schema.$Array<Schema.Struct<{
|
|
122
|
+
readonly step: Schema.String;
|
|
123
|
+
readonly status: Schema.Literals<readonly ["pending", "in_progress", "completed"]>;
|
|
124
|
+
}>>;
|
|
125
|
+
}>;
|
|
126
|
+
readonly output: Schema.Struct<{
|
|
127
|
+
readonly output: Schema.String;
|
|
128
|
+
}>;
|
|
129
|
+
readonly capabilities: readonly string[];
|
|
130
|
+
readonly effects: import("@smthrs/plan/Effects").Declaration;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Acknowledges a plan update with Codex's exact response text.
|
|
134
|
+
*
|
|
135
|
+
* The single-in-progress rule is checked again here. `Plan` refuses it at
|
|
136
|
+
* decode time, but a host that calls this handler directly never decodes, and
|
|
137
|
+
* an invariant enforced in only one of the two entrances is enforced in
|
|
138
|
+
* neither.
|
|
139
|
+
*
|
|
140
|
+
* @category handlers
|
|
141
|
+
* @since 1.0.0
|
|
142
|
+
*/
|
|
143
|
+
export declare const run: (input: {
|
|
144
|
+
readonly plan: readonly {
|
|
145
|
+
readonly step: string;
|
|
146
|
+
readonly status: "pending" | "completed" | "in_progress";
|
|
147
|
+
}[];
|
|
148
|
+
readonly explanation?: string | undefined;
|
|
149
|
+
}) => Effect.Effect<{
|
|
150
|
+
readonly output: string;
|
|
151
|
+
}, StdError.StdError, never>;
|
|
152
|
+
//# sourceMappingURL=UpdatePlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdatePlan.d.ts","sourceRoot":"","sources":["../../src/UpdatePlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,gBAAgB,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAE4B,CAAA;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,mEAA2D,CAAA;AAWlF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI;;;GAU+B,CAAA;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;;;;;EAGhB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;EAEjB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,OAAO,4CAAwE,CAAA;AAE5F;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAK,CAAC,IAAI,+CAAY,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,MAAM,CAAM,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;CAAsF,CAAA;AAEvG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG;;;;;;;;4BAad,CAAA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* update_plan flow declaration and portable handler.
|
|
3
|
+
*
|
|
4
|
+
* A Codex CLI clone of the `update_plan` tool: an optional explanation and a
|
|
5
|
+
* list of plan items, acknowledged with "Plan updated". Pure — no host
|
|
6
|
+
* access; the harness observes plan updates through the journal.
|
|
7
|
+
*
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import { envelope } from "./internal/Declaration.js";
|
|
13
|
+
import * as StdError from "./StdError.js";
|
|
14
|
+
/**
|
|
15
|
+
* Registry name for the update_plan flow. Matches the Codex CLI tool name.
|
|
16
|
+
*
|
|
17
|
+
* @category identifiers
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
export const name = "update_plan";
|
|
21
|
+
/**
|
|
22
|
+
* Model-facing description of the update_plan flow. Matches the Codex CLI
|
|
23
|
+
* description.
|
|
24
|
+
*
|
|
25
|
+
* @category descriptions
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
export const description = "Updates the task plan.\n" +
|
|
29
|
+
"Provide an optional explanation and a list of plan items, each with a step and status.\n" +
|
|
30
|
+
"At most one step can be in_progress at a time.\n";
|
|
31
|
+
/**
|
|
32
|
+
* Status of one plan step, matching Codex.
|
|
33
|
+
*
|
|
34
|
+
* @category schemas
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
*/
|
|
37
|
+
export const StepStatus = Schema.Literals(["pending", "in_progress", "completed"]);
|
|
38
|
+
const Step = Schema.Struct({
|
|
39
|
+
step: Schema.String.annotate({ description: "Task step text." }),
|
|
40
|
+
status: StepStatus.annotate({ description: "Step status." })
|
|
41
|
+
});
|
|
42
|
+
/** How many steps of a plan claim to be running right now. */
|
|
43
|
+
const inProgressCount = (plan) => plan.reduce((total, item) => item.status === "in_progress" ? total + 1 : total, 0);
|
|
44
|
+
/**
|
|
45
|
+
* The plan itself: steps, at most one of them `in_progress`.
|
|
46
|
+
*
|
|
47
|
+
* The single-in-progress rule is the last line of the Codex description a
|
|
48
|
+
* model reads every frame, so it is enforced here rather than left as prose a
|
|
49
|
+
* decode ignores. A plan naming two running steps is a decode failure at the
|
|
50
|
+
* `plan` path, not a silent acknowledgement.
|
|
51
|
+
*
|
|
52
|
+
* @category schemas
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
55
|
+
export const Plan = Schema.Array(Step).pipe(Schema.check(Schema.makeFilter((plan) => inProgressCount(plan) <= 1
|
|
56
|
+
? undefined
|
|
57
|
+
: "invalid_input: at most one plan step can be in_progress at a time", { identifier: "invalid_input" }))).annotate({ description: "The list of steps" });
|
|
58
|
+
/**
|
|
59
|
+
* Input schema for the update_plan flow.
|
|
60
|
+
*
|
|
61
|
+
* @category schemas
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
64
|
+
export const Input = Schema.Struct({
|
|
65
|
+
explanation: Schema.optional(Schema.String.annotate({ description: "Optional explanation for this plan update." })),
|
|
66
|
+
plan: Plan
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Output schema for the update_plan flow.
|
|
70
|
+
*
|
|
71
|
+
* @category schemas
|
|
72
|
+
* @since 1.0.0
|
|
73
|
+
*/
|
|
74
|
+
export const Output = Schema.Struct({
|
|
75
|
+
output: Schema.String.annotate({ description: "Acknowledgement text, always 'Plan updated'" })
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Static effect envelope for the update_plan flow: no reads, no writes.
|
|
79
|
+
*
|
|
80
|
+
* @category effects
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
*/
|
|
83
|
+
export const effects = envelope({ tier: "sealed", mode: "hermetic", reads: [], writes: [] });
|
|
84
|
+
/**
|
|
85
|
+
* Narrows the effect envelope for a decoded invocation.
|
|
86
|
+
*
|
|
87
|
+
* The flow touches nothing, so every invocation declares what the static
|
|
88
|
+
* envelope declares.
|
|
89
|
+
*
|
|
90
|
+
* @category effects
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
*/
|
|
93
|
+
export const effectsFor = (_input) => effects;
|
|
94
|
+
/**
|
|
95
|
+
* Capabilities required by the update_plan flow: none.
|
|
96
|
+
*
|
|
97
|
+
* @category capabilities
|
|
98
|
+
* @since 1.0.0
|
|
99
|
+
*/
|
|
100
|
+
export const capabilities = [];
|
|
101
|
+
/**
|
|
102
|
+
* Declaration-only update_plan flow.
|
|
103
|
+
*
|
|
104
|
+
* @category flows
|
|
105
|
+
* @since 1.0.0
|
|
106
|
+
*/
|
|
107
|
+
export const flow = { name, description, input: Input, output: Output, capabilities, effects };
|
|
108
|
+
/**
|
|
109
|
+
* Acknowledges a plan update with Codex's exact response text.
|
|
110
|
+
*
|
|
111
|
+
* The single-in-progress rule is checked again here. `Plan` refuses it at
|
|
112
|
+
* decode time, but a host that calls this handler directly never decodes, and
|
|
113
|
+
* an invariant enforced in only one of the two entrances is enforced in
|
|
114
|
+
* neither.
|
|
115
|
+
*
|
|
116
|
+
* @category handlers
|
|
117
|
+
* @since 1.0.0
|
|
118
|
+
*/
|
|
119
|
+
export const run = Effect.fn("UpdatePlan.run")(function* (input) {
|
|
120
|
+
const running = inProgressCount(input.plan);
|
|
121
|
+
if (running > 1) {
|
|
122
|
+
return yield* Effect.fail(new StdError.StdError({
|
|
123
|
+
code: "invalid_input",
|
|
124
|
+
message: `At most one step can be in_progress at a time; the plan named ${running}`
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
return { output: "Plan updated" };
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=UpdatePlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdatePlan.js","sourceRoot":"","sources":["../../src/UpdatePlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAA;AAEjC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B;IACnD,0FAA0F;IAC1F,kDAAkD,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;AAElF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAChE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;CAC7D,CAAC,CAAA;AAEF,8DAA8D;AAC9D,MAAM,eAAe,GAAG,CAAC,IAAqC,EAAU,EAAE,CACxE,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE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O,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0B,EAAE,CAAA;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAW,CAAA;AAEvG;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,EACtD,KAAwB;IAExB,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3C,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,QAAQ,CAAC,QAAQ,CAAC;YACpB,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,iEAAiE,OAAO,EAAE;SACpF,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;AACnC,CAAC,CAAC,CAAA","sourcesContent":["/**\n * update_plan flow declaration and portable handler.\n *\n * A Codex CLI clone of the `update_plan` tool: an optional explanation and a\n * list of plan items, acknowledged with \"Plan updated\". Pure — no host\n * access; the harness observes plan updates through the journal.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport { envelope } from \"./internal/Declaration.ts\"\nimport * as StdError from \"./StdError.ts\"\n\n/**\n * Registry name for the update_plan flow. Matches the Codex CLI tool name.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"update_plan\"\n\n/**\n * Model-facing description of the update_plan flow. Matches the Codex CLI\n * description.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description = \"Updates the task plan.\\n\" +\n \"Provide an optional explanation and a list of plan items, each with a step and status.\\n\" +\n \"At most one step can be in_progress at a time.\\n\"\n\n/**\n * Status of one plan step, matching Codex.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const StepStatus = Schema.Literals([\"pending\", \"in_progress\", \"completed\"])\n\nconst Step = Schema.Struct({\n step: Schema.String.annotate({ description: \"Task step text.\" }),\n status: StepStatus.annotate({ description: \"Step status.\" })\n})\n\n/** How many steps of a plan claim to be running right now. */\nconst inProgressCount = (plan: ReadonlyArray<typeof Step.Type>): number =>\n plan.reduce((total, item) => item.status === \"in_progress\" ? total + 1 : total, 0)\n\n/**\n * The plan itself: steps, at most one of them `in_progress`.\n *\n * The single-in-progress rule is the last line of the Codex description a\n * model reads every frame, so it is enforced here rather than left as prose a\n * decode ignores. A plan naming two running steps is a decode failure at the\n * `plan` path, not a silent acknowledgement.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Plan = Schema.Array(Step).pipe(\n Schema.check(\n Schema.makeFilter(\n (plan) =>\n inProgressCount(plan) <= 1\n ? undefined\n : \"invalid_input: at most one plan step can be in_progress at a time\",\n { identifier: \"invalid_input\" }\n )\n )\n).annotate({ description: \"The list of steps\" })\n\n/**\n * Input schema for the update_plan flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Struct({\n explanation: Schema.optional(Schema.String.annotate({ description: \"Optional explanation for this plan update.\" })),\n plan: Plan\n})\n\n/**\n * Decoded input accepted by the `update_plan` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n\n/**\n * Output schema for the update_plan flow.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Schema.Struct({\n output: Schema.String.annotate({ description: \"Acknowledgement text, always 'Plan updated'\" })\n})\n\n/**\n * Decoded output returned by the `update_plan` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n\n/**\n * Static effect envelope for the update_plan flow: no reads, no writes.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({ tier: \"sealed\", mode: \"hermetic\", reads: [], writes: [] })\n\n/**\n * Narrows the effect envelope for a decoded invocation.\n *\n * The flow touches nothing, so every invocation declares what the static\n * envelope declares.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (_input: typeof Input.Type) => effects\n\n/**\n * Capabilities required by the update_plan flow: none.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities: ReadonlyArray<string> = []\n\n/**\n * Declaration-only update_plan 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 * Acknowledges a plan update with Codex's exact response text.\n *\n * The single-in-progress rule is checked again here. `Plan` refuses it at\n * decode time, but a host that calls this handler directly never decodes, and\n * an invariant enforced in only one of the two entrances is enforced in\n * neither.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"UpdatePlan.run\")(function*(\n input: typeof Input.Type\n): Effect.fn.Return<typeof Output.Type, StdError.StdError> {\n const running = inProgressCount(input.plan)\n if (running > 1) {\n return yield* Effect.fail(\n new StdError.StdError({\n code: \"invalid_input\",\n message: `At most one step can be in_progress at a time; the plan named ${running}`\n })\n )\n }\n return { output: \"Plan updated\" }\n})\n"]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `webfetch` flow: an HTTP GET rendered as text, Markdown, or HTML.
|
|
3
|
+
*
|
|
4
|
+
* The handler fetches through the permission-checked `HttpClient`, follows at
|
|
5
|
+
* most ten redirects, refuses a body over 5 MiB, and returns the final URL,
|
|
6
|
+
* status, and content type beside the rendered body. The rendered body keeps
|
|
7
|
+
* its first 60,000 bytes and reports any cut with `truncated` and `notice`.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
import type { GrantStore } from "@smthrs/kernel/GrantStore";
|
|
12
|
+
import * as HttpClient from "@smthrs/kernel/HttpClient";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import * as StdError from "./StdError.ts";
|
|
16
|
+
/**
|
|
17
|
+
* The registry name of the `webfetch` flow.
|
|
18
|
+
*
|
|
19
|
+
* @category identifiers
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*/
|
|
22
|
+
export declare const name = "webfetch";
|
|
23
|
+
/**
|
|
24
|
+
* The one-line description the model sees for the `webfetch` flow.
|
|
25
|
+
*
|
|
26
|
+
* @category descriptions
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
*/
|
|
29
|
+
export declare const description = "Fetch an HTTP URL and render its content as text, Markdown, or HTML.";
|
|
30
|
+
/**
|
|
31
|
+
* What the `webfetch` flow accepts.
|
|
32
|
+
*
|
|
33
|
+
* @category schemas
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
export declare const Input: Schema.Struct<{
|
|
37
|
+
readonly url: Schema.String;
|
|
38
|
+
readonly format: Schema.optional<Schema.Literals<readonly ["text", "markdown", "html"]>>;
|
|
39
|
+
readonly timeout: Schema.optional<Schema.Number>;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Decoded input accepted by the `webfetch` flow.
|
|
43
|
+
*
|
|
44
|
+
* @category models
|
|
45
|
+
* @since 1.0.0
|
|
46
|
+
*/
|
|
47
|
+
export type Input = typeof Input.Type;
|
|
48
|
+
/**
|
|
49
|
+
* What the `webfetch` flow returns.
|
|
50
|
+
*
|
|
51
|
+
* @category schemas
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
*/
|
|
54
|
+
export declare const Output: Schema.Struct<{
|
|
55
|
+
readonly url: Schema.String;
|
|
56
|
+
readonly status: Schema.Int;
|
|
57
|
+
readonly contentType: Schema.String;
|
|
58
|
+
readonly content: Schema.String;
|
|
59
|
+
readonly truncated: Schema.Boolean;
|
|
60
|
+
readonly notice: Schema.optional<Schema.String>;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Decoded output returned by the `webfetch` flow.
|
|
64
|
+
*
|
|
65
|
+
* @category models
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
*/
|
|
68
|
+
export type Output = typeof Output.Type;
|
|
69
|
+
/**
|
|
70
|
+
* The declared effect envelope of the `webfetch` flow, before any input is known.
|
|
71
|
+
*
|
|
72
|
+
* @category effects
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*/
|
|
75
|
+
export declare const effects: import("@smthrs/plan/Effects").Declaration;
|
|
76
|
+
/**
|
|
77
|
+
* Narrows {@link effects} to what this particular input actually touches.
|
|
78
|
+
*
|
|
79
|
+
* @category effects
|
|
80
|
+
* @since 1.0.0
|
|
81
|
+
*/
|
|
82
|
+
export declare const effectsFor: (_input: typeof Input.Type) => import("@smthrs/plan/Effects").Declaration;
|
|
83
|
+
/**
|
|
84
|
+
* The authority the `webfetch` flow requires.
|
|
85
|
+
*
|
|
86
|
+
* @category capabilities
|
|
87
|
+
* @since 1.0.0
|
|
88
|
+
*/
|
|
89
|
+
export declare const capabilities: string[];
|
|
90
|
+
/**
|
|
91
|
+
* The `webfetch` flow declaration: schemas, capabilities, and effects, with the
|
|
92
|
+
* implementation attached separately.
|
|
93
|
+
*
|
|
94
|
+
* @category flows
|
|
95
|
+
* @since 1.0.0
|
|
96
|
+
*/
|
|
97
|
+
export declare const flow: {
|
|
98
|
+
readonly name: "webfetch";
|
|
99
|
+
readonly description: "Fetch an HTTP URL and render its content as text, Markdown, or HTML.";
|
|
100
|
+
readonly input: Schema.Struct<{
|
|
101
|
+
readonly url: Schema.String;
|
|
102
|
+
readonly format: Schema.optional<Schema.Literals<readonly ["text", "markdown", "html"]>>;
|
|
103
|
+
readonly timeout: Schema.optional<Schema.Number>;
|
|
104
|
+
}>;
|
|
105
|
+
readonly output: Schema.Struct<{
|
|
106
|
+
readonly url: Schema.String;
|
|
107
|
+
readonly status: Schema.Int;
|
|
108
|
+
readonly contentType: Schema.String;
|
|
109
|
+
readonly content: Schema.String;
|
|
110
|
+
readonly truncated: Schema.Boolean;
|
|
111
|
+
readonly notice: Schema.optional<Schema.String>;
|
|
112
|
+
}>;
|
|
113
|
+
readonly capabilities: string[];
|
|
114
|
+
readonly effects: import("@smthrs/plan/Effects").Declaration;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Runs the `webfetch` flow: fetches one HTTP URL and renders it as text.
|
|
118
|
+
*
|
|
119
|
+
* @category handlers
|
|
120
|
+
* @since 1.0.0
|
|
121
|
+
*/
|
|
122
|
+
export declare const run: (input: {
|
|
123
|
+
readonly url: string;
|
|
124
|
+
readonly timeout?: number | undefined;
|
|
125
|
+
readonly format?: "text" | "markdown" | "html" | undefined;
|
|
126
|
+
}) => Effect.Effect<{
|
|
127
|
+
readonly status: number;
|
|
128
|
+
readonly content: string;
|
|
129
|
+
readonly contentType: string;
|
|
130
|
+
readonly url: string;
|
|
131
|
+
readonly truncated: boolean;
|
|
132
|
+
readonly notice?: string | undefined;
|
|
133
|
+
}, StdError.StdError, GrantStore | HttpClient.HttpClient>;
|
|
134
|
+
//# sourceMappingURL=WebFetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebFetch.d.ts","sourceRoot":"","sources":["../../src/WebFetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAMvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAGzC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,aAAa,CAAA;AAC9B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,yEAAyE,CAAA;AACjG;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;;;EAQhB,CAAA;AACF;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AACrC;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;;;EAOjB,CAAA;AACF;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AACvC;;;;;GAKG;AACH,eAAO,MAAM,OAAO,4CAAwE,CAAA;AAC5F;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAK,CAAC,IAAI,+CAAY,CAAA;AAChE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAA+B,CAAA;AACxD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;CAAsF,CAAA;AAIvG;;;;;GAKG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;yDA0EsD,CAAA"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `webfetch` flow: an HTTP GET rendered as text, Markdown, or HTML.
|
|
3
|
+
*
|
|
4
|
+
* The handler fetches through the permission-checked `HttpClient`, follows at
|
|
5
|
+
* most ten redirects, refuses a body over 5 MiB, and returns the final URL,
|
|
6
|
+
* status, and content type beside the rendered body. The rendered body keeps
|
|
7
|
+
* its first 60,000 bytes and reports any cut with `truncated` and `notice`.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
import * as HttpClient from "@smthrs/kernel/HttpClient";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import { capability, envelope } from "./internal/Declaration.js";
|
|
16
|
+
import { toMarkdown, toText } from "./internal/Html.js";
|
|
17
|
+
import { capOutput, header, MAX_RESPONSE_BYTES, readBounded, Timeout, withDeadline } from "./internal/Http.js";
|
|
18
|
+
import { guarded, refusal } from "./internal/HttpNetwork.js";
|
|
19
|
+
import { parseHttpUrl } from "./internal/Url.js";
|
|
20
|
+
import * as StdError from "./StdError.js";
|
|
21
|
+
const maxRedirects = 10;
|
|
22
|
+
/**
|
|
23
|
+
* The registry name of the `webfetch` flow.
|
|
24
|
+
*
|
|
25
|
+
* @category identifiers
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
export const name = "webfetch";
|
|
29
|
+
/**
|
|
30
|
+
* The one-line description the model sees for the `webfetch` flow.
|
|
31
|
+
*
|
|
32
|
+
* @category descriptions
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
*/
|
|
35
|
+
export const description = "Fetch an HTTP URL and render its content as text, Markdown, or HTML.";
|
|
36
|
+
/**
|
|
37
|
+
* What the `webfetch` flow accepts.
|
|
38
|
+
*
|
|
39
|
+
* @category schemas
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*/
|
|
42
|
+
export const Input = Schema.Struct({
|
|
43
|
+
url: Schema.String.annotate({ description: "Absolute http or https URL to retrieve without user information" }),
|
|
44
|
+
format: Schema.optional(Schema.Literals(["text", "markdown", "html"])).annotate({
|
|
45
|
+
description: "Response rendering format; defaults to markdown"
|
|
46
|
+
}),
|
|
47
|
+
timeout: Schema.optional(Timeout).annotate({
|
|
48
|
+
description: "Total timeout across requests, redirects, and response body in seconds, capped at 120"
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* What the `webfetch` flow returns.
|
|
53
|
+
*
|
|
54
|
+
* @category schemas
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
*/
|
|
57
|
+
export const Output = Schema.Struct({
|
|
58
|
+
url: Schema.String.annotate({ description: "Final URL after redirects" }),
|
|
59
|
+
status: Schema.Int.annotate({ description: "HTTP status code, including error statuses" }),
|
|
60
|
+
contentType: Schema.String.annotate({ description: "Response Content-Type header, or an empty string when absent" }),
|
|
61
|
+
content: Schema.String.annotate({ description: "Response body rendered in the requested format" }),
|
|
62
|
+
truncated: Schema.Boolean.annotate({ description: "Whether the rendered body exceeded the display budget" }),
|
|
63
|
+
notice: Schema.optional(Schema.String.annotate({ description: "Truncation disclosure" }))
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* The declared effect envelope of the `webfetch` flow, before any input is known.
|
|
67
|
+
*
|
|
68
|
+
* @category effects
|
|
69
|
+
* @since 1.0.0
|
|
70
|
+
*/
|
|
71
|
+
export const effects = envelope({ tier: "sealed", mode: "expected", reads: [], writes: [] });
|
|
72
|
+
/**
|
|
73
|
+
* Narrows {@link effects} to what this particular input actually touches.
|
|
74
|
+
*
|
|
75
|
+
* @category effects
|
|
76
|
+
* @since 1.0.0
|
|
77
|
+
*/
|
|
78
|
+
export const effectsFor = (_input) => effects;
|
|
79
|
+
/**
|
|
80
|
+
* The authority the `webfetch` flow requires.
|
|
81
|
+
*
|
|
82
|
+
* @category capabilities
|
|
83
|
+
* @since 1.0.0
|
|
84
|
+
*/
|
|
85
|
+
export const capabilities = [capability("net:get", "*")];
|
|
86
|
+
/**
|
|
87
|
+
* The `webfetch` flow declaration: schemas, capabilities, and effects, with the
|
|
88
|
+
* implementation attached separately.
|
|
89
|
+
*
|
|
90
|
+
* @category flows
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
*/
|
|
93
|
+
export const flow = { name, description, input: Input, output: Output, capabilities, effects };
|
|
94
|
+
const error = (code, message, path) => new StdError.StdError({ code, message, ...(path === undefined ? {} : { path }) });
|
|
95
|
+
/**
|
|
96
|
+
* Runs the `webfetch` flow: fetches one HTTP URL and renders it as text.
|
|
97
|
+
*
|
|
98
|
+
* @category handlers
|
|
99
|
+
* @since 1.0.0
|
|
100
|
+
*/
|
|
101
|
+
export const run = Effect.fn("WebFetch.run")(function* (input) {
|
|
102
|
+
let url = parseHttpUrl(input.url);
|
|
103
|
+
if (url === undefined) {
|
|
104
|
+
return yield* Effect.fail(error("invalid_input", "URL must use http or https without user information", input.url));
|
|
105
|
+
}
|
|
106
|
+
const client = guarded(yield* HttpClient.HttpClient, false);
|
|
107
|
+
let headers = {
|
|
108
|
+
accept: input.format === "html" ? "text/html, text/plain;q=0.8" : "text/markdown, text/plain, text/html;q=0.8"
|
|
109
|
+
};
|
|
110
|
+
for (let redirect = 0; redirect <= maxRedirects; redirect++) {
|
|
111
|
+
const response = yield* client.execute(HttpClientRequest.setHeaders(HttpClientRequest.get(url.toString()), headers)).pipe(Effect.mapError((cause) => refusal(cause) ?? error("request_failed", `Web fetch request failed: ${url}`)));
|
|
112
|
+
const location = header(response.headers, "location");
|
|
113
|
+
if (response.status >= 300 && response.status < 400 && location !== undefined) {
|
|
114
|
+
const next = parseHttpUrl(location, url);
|
|
115
|
+
if (next === undefined) {
|
|
116
|
+
return yield* Effect.fail(error("invalid_input", "Redirect target must use http or https without user information", location));
|
|
117
|
+
}
|
|
118
|
+
if (next.origin !== url.origin) {
|
|
119
|
+
headers = Object.fromEntries(Object.entries(headers).filter(([key]) => key.toLowerCase() !== "authorization" && key.toLowerCase() !== "cookie"));
|
|
120
|
+
}
|
|
121
|
+
url = next;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const contentType = header(response.headers, "content-type") ?? "";
|
|
125
|
+
const normalizedContentType = contentType.toLowerCase();
|
|
126
|
+
if (!normalizedContentType.startsWith("text/")
|
|
127
|
+
&& !normalizedContentType.includes("json")
|
|
128
|
+
&& !normalizedContentType.includes("xml")) {
|
|
129
|
+
return yield* Effect.fail(error("unsupported_content_type", `Unsupported content type: ${contentType || "unknown"}`));
|
|
130
|
+
}
|
|
131
|
+
const length = Number(header(response.headers, "content-length"));
|
|
132
|
+
if (Number.isFinite(length) && length > MAX_RESPONSE_BYTES) {
|
|
133
|
+
return yield* Effect.fail(error("response_too_large", "Response exceeds the 5 MiB limit"));
|
|
134
|
+
}
|
|
135
|
+
const body = yield* readBounded(response.stream, url.toString()).pipe(Effect.mapError((cause) => cause instanceof StdError.StdError
|
|
136
|
+
? cause
|
|
137
|
+
: error("request_failed", "Web fetch response could not be read")));
|
|
138
|
+
const raw = new TextDecoder().decode(body);
|
|
139
|
+
const format = input.format ?? "markdown";
|
|
140
|
+
const { text: content, ...disclosure } = capOutput(format === "html" || !normalizedContentType.includes("html")
|
|
141
|
+
? raw
|
|
142
|
+
: format === "text"
|
|
143
|
+
? toText(raw)
|
|
144
|
+
: toMarkdown(raw));
|
|
145
|
+
return { url: url.toString(), status: response.status, contentType, content, ...disclosure };
|
|
146
|
+
}
|
|
147
|
+
return yield* Effect.fail(error("request_failed", "Web fetch exceeded the redirect limit"));
|
|
148
|
+
}, (effect, input) =>
|
|
149
|
+
// Keep the shared deadline outside the redirect loop and error mapping.
|
|
150
|
+
withDeadline(effect, input.url, input.timeout, (seconds) => error("timeout", `Web fetch timed out after ${seconds} seconds`)));
|
|
151
|
+
//# sourceMappingURL=WebFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebFetch.js","sourceRoot":"","sources":["../../src/WebFetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAA;AAClE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC9G,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,MAAM,YAAY,GAAG,EAAE,CAA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QAAQ,CAAC,QAAQ;YAChC,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,KAAK,CAAC,gBAAgB,EAAE,sCAAsC,CAAC,CACpE,CACF,CAAA;QACD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,CAAA;QACzC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,SAAS,CAChD,MAAM,KAAK,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC1D,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,MAAM,KAAK,MAAM;gBACnB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;gBACb,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CACpB,CAAA;QACD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAC9F,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,uCAAuC,CAAC,CAAC,CAAA;AAC7F,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;AACnB,wEAAwE;AACxE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CACzD,KAAK,CAAC,SAAS,EAAE,6BAA6B,OAAO,UAAU,CAAC,CAAC,CAAC,CAAA","sourcesContent":["/**\n * The `webfetch` flow: an HTTP GET rendered as text, Markdown, or HTML.\n *\n * The handler fetches through the permission-checked `HttpClient`, follows at\n * most ten redirects, refuses a body over 5 MiB, and returns the final URL,\n * status, and content type beside the rendered body. The rendered body keeps\n * its first 60,000 bytes and reports any cut with `truncated` and `notice`.\n *\n * @since 1.0.0\n */\n\nimport type { GrantStore } from \"@smthrs/kernel/GrantStore\"\nimport * as HttpClient from \"@smthrs/kernel/HttpClient\"\nimport * as Effect from \"effect/Effect\"\nimport * as HttpClientRequest from \"effect/http/HttpClientRequest\"\nimport * as Schema from \"effect/Schema\"\nimport { capability, envelope } from \"./internal/Declaration.ts\"\nimport { toMarkdown, toText } from \"./internal/Html.ts\"\nimport { capOutput, header, MAX_RESPONSE_BYTES, readBounded, Timeout, withDeadline } from \"./internal/Http.ts\"\nimport { guarded, refusal } from \"./internal/HttpNetwork.ts\"\nimport { parseHttpUrl } from \"./internal/Url.ts\"\nimport * as StdError from \"./StdError.ts\"\n\nconst maxRedirects = 10\n/**\n * The registry name of the `webfetch` flow.\n *\n * @category identifiers\n * @since 1.0.0\n */\nexport const name = \"webfetch\"\n/**\n * The one-line description the model sees for the `webfetch` flow.\n *\n * @category descriptions\n * @since 1.0.0\n */\nexport const description = \"Fetch an HTTP URL and render its content as text, Markdown, or HTML.\"\n/**\n * What the `webfetch` flow accepts.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Input = Schema.Struct({\n url: Schema.String.annotate({ description: \"Absolute http or https URL to retrieve without user information\" }),\n format: Schema.optional(Schema.Literals([\"text\", \"markdown\", \"html\"])).annotate({\n description: \"Response rendering format; defaults to markdown\"\n }),\n timeout: Schema.optional(Timeout).annotate({\n description: \"Total timeout across requests, redirects, and response body in seconds, capped at 120\"\n })\n})\n/**\n * Decoded input accepted by the `webfetch` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Input = typeof Input.Type\n/**\n * What the `webfetch` flow returns.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Output = Schema.Struct({\n url: Schema.String.annotate({ description: \"Final URL after redirects\" }),\n status: Schema.Int.annotate({ description: \"HTTP status code, including error statuses\" }),\n contentType: Schema.String.annotate({ description: \"Response Content-Type header, or an empty string when absent\" }),\n content: Schema.String.annotate({ description: \"Response body rendered in the requested format\" }),\n truncated: Schema.Boolean.annotate({ description: \"Whether the rendered body exceeded the display budget\" }),\n notice: Schema.optional(Schema.String.annotate({ description: \"Truncation disclosure\" }))\n})\n/**\n * Decoded output returned by the `webfetch` flow.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Output = typeof Output.Type\n/**\n * The declared effect envelope of the `webfetch` flow, before any input is known.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effects = envelope({ tier: \"sealed\", mode: \"expected\", reads: [], writes: [] })\n/**\n * Narrows {@link effects} to what this particular input actually touches.\n *\n * @category effects\n * @since 1.0.0\n */\nexport const effectsFor = (_input: typeof Input.Type) => effects\n/**\n * The authority the `webfetch` flow requires.\n *\n * @category capabilities\n * @since 1.0.0\n */\nexport const capabilities = [capability(\"net:get\", \"*\")]\n/**\n * The `webfetch` flow declaration: schemas, capabilities, and effects, with the\n * implementation attached separately.\n *\n * @category flows\n * @since 1.0.0\n */\nexport const flow = { name, description, input: Input, output: Output, capabilities, effects } as const\n\nconst error = (code: StdError.Code, message: string, path?: string): StdError.StdError =>\n new StdError.StdError({ code, message, ...(path === undefined ? {} : { path }) })\n/**\n * Runs the `webfetch` flow: fetches one HTTP URL and renders it as text.\n *\n * @category handlers\n * @since 1.0.0\n */\nexport const run = Effect.fn(\"WebFetch.run\")(function*(\n input: typeof Input.Type\n): Effect.fn.Return<typeof Output.Type, StdError.StdError, HttpClient.HttpClient | GrantStore> {\n let url = parseHttpUrl(input.url)\n if (url === undefined) {\n return yield* Effect.fail(\n error(\"invalid_input\", \"URL must use http or https without user information\", input.url)\n )\n }\n const client = guarded(yield* HttpClient.HttpClient, false)\n let headers: Readonly<Record<string, string>> = {\n accept: input.format === \"html\" ? \"text/html, text/plain;q=0.8\" : \"text/markdown, text/plain, text/html;q=0.8\"\n }\n for (let redirect = 0; redirect <= maxRedirects; redirect++) {\n const response = yield* client.execute(\n HttpClientRequest.setHeaders(HttpClientRequest.get(url.toString()), headers)\n ).pipe(\n Effect.mapError((cause) => refusal(cause) ?? error(\"request_failed\", `Web fetch request failed: ${url}`))\n )\n const location = header(response.headers, \"location\")\n if (response.status >= 300 && response.status < 400 && location !== undefined) {\n const next = parseHttpUrl(location, url)\n if (next === undefined) {\n return yield* Effect.fail(\n error(\"invalid_input\", \"Redirect target must use http or https without user information\", location)\n )\n }\n if (next.origin !== url.origin) {\n headers = Object.fromEntries(\n Object.entries(headers).filter(([key]) =>\n key.toLowerCase() !== \"authorization\" && key.toLowerCase() !== \"cookie\"\n )\n )\n }\n url = next\n continue\n }\n const contentType = header(response.headers, \"content-type\") ?? \"\"\n const normalizedContentType = contentType.toLowerCase()\n if (\n !normalizedContentType.startsWith(\"text/\")\n && !normalizedContentType.includes(\"json\")\n && !normalizedContentType.includes(\"xml\")\n ) {\n return yield* Effect.fail(\n error(\"unsupported_content_type\", `Unsupported content type: ${contentType || \"unknown\"}`)\n )\n }\n const length = Number(header(response.headers, \"content-length\"))\n if (Number.isFinite(length) && length > MAX_RESPONSE_BYTES) {\n return yield* Effect.fail(error(\"response_too_large\", \"Response exceeds the 5 MiB limit\"))\n }\n const body = yield* readBounded(response.stream, url.toString()).pipe(\n Effect.mapError((cause) =>\n cause instanceof StdError.StdError\n ? cause\n : error(\"request_failed\", \"Web fetch response could not be read\")\n )\n )\n const raw = new TextDecoder().decode(body)\n const format = input.format ?? \"markdown\"\n const { text: content, ...disclosure } = capOutput(\n format === \"html\" || !normalizedContentType.includes(\"html\")\n ? raw\n : format === \"text\"\n ? toText(raw)\n : toMarkdown(raw)\n )\n return { url: url.toString(), status: response.status, contentType, content, ...disclosure }\n }\n return yield* Effect.fail(error(\"request_failed\", \"Web fetch exceeded the redirect limit\"))\n}, (effect, input) =>\n // Keep the shared deadline outside the redirect loop and error mapping.\n withDeadline(effect, input.url, input.timeout, (seconds) =>\n error(\"timeout\", `Web fetch timed out after ${seconds} seconds`)))\n"]}
|