Skip to content
2 min read · 365 words

batteries/sandbox/node

Remarks

This subpath is deliberately NOT re-exported from @nhtio/adk/batteries/sandbox. srt_enforcer imports node:child_process and fs_node imports node:fs/node:path, so folding this barrel into the main one would break the browser build and the portability suite. (search_ripgrep has no node:* import of its own — it spawns THROUGH the enforcer — but it belongs here because it is meaningless without one.) Reach for it explicitly:

ts
import { srtEnforcer } from "@nhtio/adk/batteries/sandbox/node";

The OS boundary lives here and nowhere else. srtEnforcer is the ONLY place the ADK-to-SRT policy mapping exists — if a second translation appears anywhere, the "ADK-owned types" firewall is nominal and no non-SRT enforcer can implement the contract. fs_node is the in-process evaluator used by the tools that run OUR code (open_file*, stage_file, save_media, list_directory); it reproduces SRT's derived rules AND its profile-injected mandatory denies, because a gap there lets save_media write paths the shell tool is refused. Only the shell and search paths get real OS enforcement — SRT restricts spawned children, not this process.

Attribution: the sandbox is Anthropic's @anthropic-ai/sandbox-runtime (Apache-2.0), consumed as an optional peer.

Type Aliases

Type AliasDescription
FsNodeThe in-process policy decision procedure.
RipgrepFailureA classified ripgrep outcome.
SrtEnforcerOptionsConstruction options for srtEnforcer.

Variables

VariableDescription
DANGEROUS_DIRECTORIESDirectories SRT mandatory-denies, reproduced from upstream.
DANGEROUS_FILESThe exact upstream dangerous file names, retained for parity tests.

Functions

FunctionDescription
createFsNodeIn-process counterpart of SRT's two derived restriction lists.
createRipgrepSearchRipgrep backend. Both child pipes are drained immediately and concurrently.
derivedRulesFromSrtConstruct a derived snapshot from the shapes returned by SRT.
loadGlobToRegexLoad upstream's own glob matcher.
mapPolicyThe sole ADK-to-SRT translation point. Keep the upstream type behind this local firewall.
primeGlobMatcherCompile every glob-bearing rule through upstream's own globToRegex.
reproduceMandatoryDenyReproduce SRT's profile-injected mandatory-deny set for the CURRENT platform.
srtEnforcerConstruct the SRT-backed policy enforcer — the OS boundary.