Scripts
OpenPocket supports controlled script execution through run_script action and CLI command.
Entry Points
- agent action:
{"type":"run_script","script":"...","timeoutSec":60} - CLI:
openpocket script run --text "..."or--file <path>
Validation
ScriptExecutor.validateScript checks:
- executor enabled (
scriptExecutor.enabled) - non-empty script
- max length <= 12000 chars
- deny pattern match
- command allowlist compliance
If validation fails, script is not executed and a failed result.json is still recorded.
Deny Patterns
Built-in blocked patterns include:
sudo- shutdown/reboot/poweroff/halt
mkfsdd if=rm -rf /
Allowlist Check
- script is split by line
- line comments are stripped
- each line is split by command separators (
&&,||,;) - first command token (after optional env assignments) must be in
allowedCommands
Default allowlist is documented in Config Defaults.
Execution Model
- runtime shell:
bash - working directory:
workspace/scripts - timeout:
scriptExecutor.timeoutSecor action override - output truncation:
scriptExecutor.maxOutputChars
Each run stores artifacts under:
workspace/scripts/runs/run-<runId>/script.shworkspace/scripts/runs/run-<runId>/stdout.logworkspace/scripts/runs/run-<runId>/stderr.logworkspace/scripts/runs/run-<runId>/result.json
Result
See full schema in Session and Memory Formats.
Generated Scripts
After successful tasks, AutoArtifactBuilder may create replay scripts at:
workspace/scripts/auto/<timestamp>-<slug>.sh
Generated scripts convert observed action traces into executable adb commands.