fix: HybridFs subclass, Prettier template literal fixes, path normali…#134
Merged
simongdavies merged 6 commits intoMay 14, 2026
Merged
Conversation
…sation - Refactor bash FS adapter from plain object to HybridFs extends InMemoryFs (cleaner, uses super.method() fallbacks instead of delegating 12 methods) - Add normPath() to strip /home/user/ and /tmp/ prefixes from bash paths - Replace nested template literals inside C.dim/C.err/C.ok/C.warn with string concatenation to prevent Prettier mangling - Use url.indexOf instead of regex for curl URL scheme detection - Silence spurious warning for native-globals module in generate-native-dts - Add prettier-ignore for help command template literal - Null-safe result.error in reset_sandbox handler Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
- Add large output interception to execute_bash handler (mirrors execute_javascript pattern) — saves results to disk before the SDK can truncate to inaccessible host /tmp files - Fix normPath in HybridFs: /tmp/foo.txt now maps to tmp/foo.txt (not foo.txt) preventing file collisions with user files in baseDir - Add HOST FILESYSTEM warning to system message so LLM knows /tmp paths are not accessible from the sandbox - Add /tmp inaccessibility note to execute_bash tool description Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR integrates a sandboxed Bash execution path into HyperAgent (via the new execute_bash tool and a dedicated bash sandbox), along with associated build/lockfile updates and some formatting-oriented refactors to avoid Prettier/template-literal parsing issues.
Changes:
- Refactors bash runner handler generation (HybridFs adapter + handler code assembly) and replaces some nested template literals with string concatenation in
src/agent/index.ts. - Adjusts native .d.ts generation script behavior for modules without
#[rquickjs::function]. - Updates dependency lockfiles (npm + Rust guest).
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/code-validator/guest/Cargo.lock | Rust dependency lockfile drift (tokio patch version change). |
| src/agent/index.ts | Bash sandbox/tool wiring plus HybridFs adapter refactor and string-concat formatting changes. |
| scripts/generate-native-dts.ts | Changes behavior when no Rust-exported functions are detected (now skips silently). |
| package-lock.json | NPM dependency resolution updates (including several version downgrades and an altered @types/node entry). |
Comments suppressed due to low confidence (2)
src/agent/index.ts:2316
- HybridFs.readdir assumes fsRead.listDir returns an object with an
entriesarray, but the fs-read plugin returns either aDirEntry[]array or{ error }. This will throw at runtime (r.entriesis undefined) and breakls/find/treewhen fs-read is enabled. Update this branch to handle the actual return shape (e.g. if Array.isArray(r) mapname, otherwise throw/fallback onr.error).
" async readdir(path) {",
" try { const r = fsRead.listDir(normPath(path)); if (r.error) throw new Error(r.error); return r.entries.map(e => e.name); }",
" catch { return super.readdir(path); }",
src/agent/index.ts:2340
- HybridFs.mkdir calls fsWrite.mkdir() but ignores its
{ ok, error }return value. Since fs-write reports failures viaerror(it generally does not throw), bashmkdircan report success even though the directory was rejected/failed to create. Capture the return value and throw/fallback whenerroris set (similar to writeFile/appendFile).
" async mkdir(path, opts) {",
" try { fsWrite.mkdir(normPath(path)); }",
" catch { await super.mkdir(path, opts); }",
" }",
- Fix HybridFs.stat: use r.isFile/r.isDirectory instead of r.type
(fs-read plugin returns {isFile, isDirectory, size, error}, not type/modified)
- Fix normPath: segment-based normalizer that handles ../a/../b, bare ..,
and Windows backslashes; throws on virtual root escape attempts
- Fix generate-native-dts: only skip native-globals silently; warn for
other modules with no #[rquickjs::function] exports
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
- readdir: handle listDir() returning DirEntry[] directly (not r.entries) - mkdir: capture return value, throw on r.error instead of ignoring - large output: check threshold BEFORE printing stdout to avoid console flood - system message: qualify that auto-save to results/ requires fs-write enabled Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
simongdavies
added a commit
that referenced
this pull request
May 15, 2026
* docs: changelog for v0.6.0 Move [Unreleased] section to [v0.6.0] - 2026-05-15 covering the 23 commits landed on upstream/main since v0.5.0: Added: - User-generated skills from session learnings (#139) - KQL expert skill with requires-mcp frontmatter and Kusto highlighting (#137) - Terminal markdown rendering via marked + marked-terminal (#135, #136) - Verbose/debug gating for diagnostic output (#137) - execute_bash large output interception (#134) Fixed: - marked v15 + marked-terminal v7 incompat in markdown-renderer (#138) - HybridFs sandbox /tmp path mapping + adapter refactor (#134) - Prettier mangling of nested template literals in styled output (#134) - Full error text now wrapped in C.err() across 11 paths (#135) - /markdown toggle now flips sessionNeedsRebuild (#136) - looksLikeMarkdown false positives on bold/unordered-list (#136) Changed: - Dependency bumps: msal-node 5.2.1, tsx 4.22.0, @types/node 25.8.0, tokio in code-validator guest (#142, #143, #146, #147) Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * fix: address PR #148 review feedback (3 issues) CHANGELOG.md: - Fabric RTI CLI flag: `--mcp setup-fabric-rti` was wrong, actual flag in src/agent/cli-parser.ts is `--mcp-setup-fabric-rti` (single hyphenated token). Users copy-pasting the old form would hit "unknown argument" - Terminal markdown rendering default: said "raw streaming remains the default" but cli-parser.ts sets `markdown: process.env.HYPERAGENT_MARKDOWN !== "0"` (default ON) and `--[no-]markdown` help text confirms default: on. Reworded to make default-on explicit and document the three opt-out paths - Missing link reference: added `[v0.6.0]: https://github.com/hyperlight-dev/hyperagent/releases/tag/v0.6.0` to match the existing reference-style link section No code changes. Prettier clean. Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> --------- Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the
src/agent/index.tscodebase, focusing on simplifying string formatting (moving from template literals to string concatenation), enhancing the construction of the bash runner handler, and improving the hybrid filesystem adapter logic. The changes aim to make the code more robust, maintainable, and less error-prone, especially in areas involving code generation and file system operations.Key changes include:
String Formatting and Logging Consistency
src/agent/index.ts, improving compatibility and reducing parsing errors during code generation.Bash Runner Handler and Filesystem Adapter Refactor
hostFsfilesystem adapter to use a class-based approach (HybridFsextendsInMemoryFs) with string concatenation, improving clarity and maintainability. Added anormPathhelper to sanitize paths before delegating to plugins.Bash and Command Handler Improvements
curlcommand and clearer help output.Minor Functional Improvements
curlcommand to prependhttps://only if the URL does not already contain a protocol, making it more robust.These changes collectively improve the maintainability and robustness of the code, especially in areas where code is dynamically generated or where string formatting is critical for correctness.