Commands and files ›
Stream command
POST
/v1/sandboxes/{id}/exec/streamRun a command and stream its output.
RequestTypeScript
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
- for await (const event of sandbox.execStream(["npm", "test"])) console.log(event);
Answer200 OK
No JSON body.
Server-sent events from the child: stdout, stderr, then exit.
Path
idrequiredstring | e.g. "sbx_0123456789abcdef" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
commandrequiredarray of string | Argv. The control plane does not invoke a shell. It runs as root, with the variables of the sandbox's template and its own in its environment, and AGENTAL_SANDBOX_ID, the sandbox's id, AGENTAL_API_URL, where this API answers, and AGENTAL_SANDBOX_TOKEN, the sandbox's own token for the run it is in, which reads and moves its stop and does nothing else. e.g. ["echo","hello"] |
timeoutMsinteger | Defaults to 60000. On timeout the exit code is 124. Up to 600000 for /commands and /exec/stream, and up to 90000 for POST /v1/sandboxes/{id}/exec, which answers only when its command ends: a proxy in front of the API stops waiting after 100 seconds. |
Returns
200 Server-sent events from the child: stdout, stderr, then exit. The synchronous exec route is unchanged. A stream that fails part way ends with an error event, whose data is what went wrong, and no exit event. That is what a command gets that was cut off because its sandbox was moved to another server while it ran: send it again.
Errors and other answers
| 404 | Not found. |
| 409 | Sandbox is not running. |
| 503 | sandbox_moved the sandbox was moved to another server while this was being done, and it was cut off. Send it again. |
Every error answers { "error": { "code", "message" } }; a key without the action a call needs answers 403 key_action_forbidden, naming it.