Documentation
¶
Overview ¶
Package scriptbox runs a trigger's transform script: a JavaScript function `(answer, memo) => ({items, memo})` written by an agent or the person, which only reshapes what the runtime fetched. It never fetches anything itself. Two walls stand around it:
- the process: node under Landlock and seccomp (internal/confine, the helper of internal/designkit/kitadd): no sockets at all, nothing writable, only the system's and node's own folders readable, an empty environment, its heap capped (--max-old-space-size), killed after a few seconds whatever it does;
- the script: a fresh vm context with no require, no process, no timers, no fetch, no code from strings, and a timeout on its run (200 ms by default).
The answer and the memo go in as JSON on stdin, the result comes back as JSON on stdout.
Index ¶
Constants ¶
const ( DefaultTimeout = 200 * time.Millisecond DefaultMemoryMB = 32 // ScriptMax is the longest script taken. ScriptMax = 16 << 10 )
Limits of one run.
Variables ¶
ErrUnavailable: this machine cannot run a script safely (no node, or no Landlock).
Functions ¶
Types ¶
type Options ¶
type Options struct {
Timeout time.Duration
MemoryMB int
// Helper is the sandbox helper's command line up to its flags (this binary and kitadd.SandboxHelperArg).
Helper []string
}
Options of a run; zero values take the defaults.
type Result ¶
type Result struct {
Items []any `json:"items"`
Memo json.RawMessage `json:"memo,omitempty"`
}
Result is what the script gave back.