feat(agent): add shell emulation to exec API#77
Merged
Conversation
The exec endpoint now accepts a `command` field with a shell-style
command line that runs against the session filesystem via in-process
built-ins. There is no subprocess execution and no access to the host
shell.
curl -X POST .../exec -H "Content-Type: application/json" -d '{
"command": "mkdir -p logs && echo started > logs/run.log && ls logs"
}'
Supports built-ins `echo`, `cat`, `ls`, `pwd`, `cd`, `mkdir` (`-p`),
`rm` (`-r`/`-rf`), `cp`, `mv`, `env`, `export`; pipes (`|`);
redirection (`>`, `>>`, `<`); sequencing (`&&` short-circuit, `;`);
and single/double quoted strings.
CWD is scoped to a single shell invocation so chains like
`cd sub && pwd` work, while `export KEY=value` writes through to the
session's `WasiEnv` so exported variables persist across
`command`/`source`/`files`/`wasm_path` calls in the same session.
The `command` field takes precedence when present; dispatch order in
`handle_exec` is now `command` -> `files` -> `source` -> `wasm_path`.
This also backfills CHANGELOG and docs for the two previously
undocumented additions since v0.19.0 - JavaScript source execution
(`source` + `language`) and multi-file JS project execution (`files` +
`entry`) - and cuts the existing `[Unreleased]` block into a dated
`[0.19.0]` section matching the published GitHub release.
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.
The exec endpoint now accepts a
commandfield with a shell-style command line that runs against the session filesystem via in-process built-ins. There is no subprocess execution and no access to the host shell.Supports built-ins
echo,cat,ls,pwd,cd,mkdir(-p),rm(-r/-rf),cp,mv,env,export; pipes (|); redirection (>,>>,<); sequencing (&&short-circuit,;); and single/double quoted strings.CWD is scoped to a single shell invocation so chains like
cd sub && pwdwork, whileexport KEY=valuewrites through to the session'sWasiEnvso exported variables persist acrosscommand/source/files/wasm_pathcalls in the same session.The
commandfield takes precedence when present; dispatch order inhandle_execis nowcommand->files->source->wasm_path.This also backfills CHANGELOG and docs for the two previously undocumented additions since v0.19.0 - JavaScript source execution (
source+language) and multi-file JS project execution (files+entry) - and cuts the existing[Unreleased]block into a dated[0.19.0]section matching the published GitHub release.