feat(agent): add multi-file JavaScript project execution to exec API#75
Merged
Conversation
Agents can now upload an entire JS project in a single /exec request
and run it through the wasmhub nodejs runtime:
POST /api/v1/sessions/:id/exec
{
"files": {
"main.js": "console.log('hi');",
"lib/util.js": "exports.greet = n => 'hi ' + n;"
},
"entry": "main.js",
"language": "javascript"
}
All files are written to the session work_dir (with intermediate
directories created as needed) before execution; the runtime is
invoked with the entry filename as its script argument. Sibling
files land in the session's preopened WASI directory, so once the
nodejs runtime gains CommonJS support, relative `require()` between
project files will resolve transparently.
Filenames are validated up front: empty names, absolute paths, and
parent-directory traversal are rejected with HTTP 400. Language and
entry-membership checks also run synchronously before the exec
thread is spawned, so invalid requests fail fast without paying the
runtime fetch cost.
The `execute_code` tool schema gains `files` and `entry` fields so
LLM agents discover the new shape via /api/v1/tools.
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.
Agents can now upload an entire JS project in a single /exec request and run it through the wasmhub nodejs runtime:
All files are written to the session work_dir (with intermediate directories created as needed) before execution; the runtime is invoked with the entry filename as its script argument. Sibling files land in the session's preopened WASI directory, so once the nodejs runtime gains CommonJS support, relative
require()between project files will resolve transparently.Filenames are validated up front: empty names, absolute paths, and parent-directory traversal are rejected with HTTP 400. Language and entry-membership checks also run synchronously before the exec thread is spawned, so invalid requests fail fast without paying the runtime fetch cost.
The
execute_codetool schema gainsfilesandentryfields so LLM agents discover the new shape via /api/v1/tools.