Skip to main content

Shell

Execute shell commands. Requires shell.enabled: true and the command must match a pattern in shell.allowlist.

Synchronous execution

import { shellExec } from "@luminarys/sdk-as";

const result = shellExec("go build -o myapp .", "/data/project");
if (result.exit_code != 0) {
// result.output contains stderr
}

ShellExecRequest:

FieldTypeDefaultDescription
commandstringrequiredCommand to execute
workdirstringsandbox rootWorking directory
timeout_msint0 (30s)Timeout in milliseconds
tailint0 (all)Return only the last N lines of output
grepstring""Filter output lines by regex
as_daemonboolfalseStart as background daemon, return immediately with PID
log_filestring""Daemon log file path (auto-generated if empty)

ShellExecResult:

FieldTypeDescription
outputstringCombined stdout + stderr
exit_codeintProcess exit code (0 = success)
pidintProcess ID (only when as_daemon = true)
log_filestringLog file path (only when as_daemon = true)

Background processes (daemon mode)

Start a process as a daemon — returns immediately with PID and log file path.

import { shellExec } from "@luminarys/sdk-as";

const result = shellExec(
"./myapp serve --port 9090", // command
"/data/project", // workdir
0, 0, "", // timeoutMs, tail, grep
true, // asDaemon
"/data/project/server.log", // logFile
);
// result.pid — process ID
// result.log_file — log file path

Process management

Use ps and kill commands (must be in shell.allowlist):

// List processes (filter by name)
const ps = shellExec("ps aux", "", 0, 0, "myapp");

// Stop a process
shellExec("kill 1234");

Restrictions

  • Chain operators (&&, ||, ;, |) are blocked
  • Redirections (>, >>, <) are blocked
  • Command substitution ($(), `) are blocked
  • The command must match a pattern in shell.allowlist
  • workdir must be within shell.allowed_dirs

Allowlist patterns

shell:
enabled: true
allowlist:
- "go **"
- "gofmt **"
- "ps **"
- "kill **"
- "./**"
allowed_dirs:
- "/data/project"

** matches all remaining arguments.