Skip to content
9 min read · 1,826 words

@nhtio/adk/batteries/sandbox

Classes

ClassDescription
DefaultArtifactMinterA pure minter with optional, lazily loaded consumer formats.
SandboxEpochOpaque epoch issued by the sandbox manager and consumed by readers.

Interfaces

InterfaceDescription
ArtifactMinterArtifact-class registry. Format constructors are lazy so unused parsers are never loaded.
BinarySandboxCommand wrapping contract used by the executor adapter.
ConformanceSourcesThe adapter surfaces the shared conformance battery exercises.
CreateSandboxOptionsOptions for createSandbox.
DerivedRulesBackend-derived rules used for admission and drift checks, not a model-facing policy.
EvaluateJavascriptConfigConfiguration for the JavaScript guest battery.
GuestGlobalA declared capability kept in the host runner.
GuestHandleA guest evaluation handle; timeout kills and rejects rather than fabricating a result.
GuestLimitsLimits for a hostile guest: exactly seven fields, resolved before spawning and passed to both realms.
GuestRuntimeRuntime boundary for a hardened guest realm; limits and capability declarations cross the boundary.
GuestRuntimeLikeMinimal runtime seam used by the tool and by browser/Node adapters.
HostcallQuotasPer-evaluation host RPC quotas, separate from the seven guest limits.
PathTranslatorModel-path boundary: normalises ergonomic paths while refusing unambiguous host escapes.
PreflightOptionsInputs to the construction-time environment admission check.
RunShellCommandOptionsConfiguration for the streaming shell-command tool.
SandboxCallDefaultsDefaults visible as model-facing tool arguments; guest limits are intentionally separate.
SandboxedExecutorOptionsConfiguration for the sandboxed binary executor.
SandboxFileSystemFilesystem capability with no copy primitive; traversal is complete and terminal-framed.
SandboxHandleA live sandbox session: the object every sandbox tool is built against.
SandboxMediaOptionsArguments for createSandboxMedia.
SandboxMediaReaderOptionsArguments for createSandboxMediaReader.
SandboxObservabilityOptionsDependencies used to create the redacting firehose.
SandboxPolicyAssembly-facing policy. Reads allow by default; writes and network deny by default.
SandboxPolicyEnforcerPolicy boundary. run resolves on spawn and exposes live streams plus a later completion promise.
SandboxPreflightImmutable decision retained by a sandbox handle for its entire lifetime.
SandboxSearchSearch capability; every result is lazy, complete, and terminal-framed.

Type Aliases

Type AliasDescription
ArtifactFormatA format declaration accepted by the default minter.
DoneTerminal traversal protocol. Done is mandatory so end-of-stream cannot masquerade as completion.
FramedSourceA framed adapter surface exercised by the shared protocol battery.
GuestLogEventOne log event exactly as the trusted guest bootstrap's logger posts it.
GuestLogFramingDelivery and emission framing for guest logs.
GuestOutcomeSettled guest evaluation; partial encoding is still successful execution.
GuestThrownA thrown guest value, preserving whether encoder representation was complete.
HitFrameContent-hit frames contain the whole matched line, followed by exactly one Done.
ListFrameList item frames followed by exactly one Done.
MimeResolverMIME resolver; undefined means the resolver declines and a later resolver may decide.
ModelPathPresentation/normalisation brand only; this is NOT a containment guarantee. Every filesystem use must still pass through PathTranslator.toRelative().
ModelWriteRootOpaque model-facing write root; constructed only by the path layer.
PathFramePath-search item frames followed by exactly one Done.
SandboxEpochIsLiveThe capability needed to decide whether a sandbox handle is still alive.
SandboxEventTyped records emitted by the sandbox's single audit firehose.
SandboxEventSinkConsumer callback for sandbox audit events.
SandboxNarratorModel-facing narration seam; implementations must be total over SandboxOutcome.
SandboxOutcomeExhaustive model-facing sandbox outcome.
SandboxPathRejectionWhy a path was rejected outright, before any normalisation.
SandboxPlatformPlatform identity supplied by the construction site.

Variables

VariableDescription
ALLOWED_RIPGREP_FLAGSFlags emitted by the sandbox's own ripgrep adapter.
artifactMinterSchemaDuck-type schema.
assertPosixBinShellAlias used by the SRT adapter at construction time.
DEFAULT_MIME_PEEK_BYTESThe default prefix available to a custom resolver.
defaultArtifactMinterThe shared default registry. Its format thunks remain lazy until selected.
defaultMimeResolverThe default resolver, also exported under the concise name used by consumers.
defaultSandboxNarratorExistence-blind default narrator; not-found and denied-by-policy intentionally share wording.
DOUBLE_DASH_BINARIESBinaries for which passing -- terminates option parsing.
E_INVALID_SANDBOX_CONFIGInvalid sandbox configuration.
E_SANDBOX_DEPENDENCY_MISSINGSandbox dependency is missing or unavailable at assembly time.
E_SANDBOX_FAILEDSandbox operational failure presented to the model.
E_SANDBOX_GATE_REQUIREDA required approval gate was not supplied.
E_SANDBOX_NARROWING_UNSUPPORTEDA requested policy narrowing cannot be represented by the backend.
E_SANDBOX_NOT_INITIALIZEDSandbox operation was attempted before initialization.
E_SANDBOX_PATH_ESCAPEThrown when a model-supplied path is an UNAMBIGUOUS escape or an unsupported form.
E_SANDBOX_POLICY_CONFLICTRequested policy conflicts with another enforced policy.
E_SANDBOX_REFUSEDSandbox refusal presented to the model.
E_SANDBOX_UNSUPPORTED_ENVSandbox environment is unsupported.
E_SES_EVALUATION_TIMEOUTA guest evaluation exceeded its tool-selected deadline.
E_SES_LOCKDOWN_REQUIREDSES lockdown was unavailable or did not harden the guest realm.
escapeShellArgsCompatibility alias for consumers that describe this operation as escaping.
escapeShellValueCompatibility alias for consumers that describe this operation as escaping.
extensionMimeResolverResolve a MIME type from a filename, without sniffing bytes.
guestLimitFloorsMinimum representable guest values.
guestLimitsDefaultsDefault guest values, each paired with its own floor.
guestLimitsSchemaSchema enforcing every guest field's own floor.
guestRuntimeSchemaDuck-type schema.
hostcallQuotasDefaultsDefault host quotas.
hostcallQuotasSchemaSchema enforcing every host quota floor.
mimeResolverSchemaMIME resolver schema.
pathTranslatorSchemaDuck-type schema.
POSIX_SHELLSShells for which SRT's POSIX quote() and the -c invocation contract agree.
runSandboxPreflightCompatibility alias for the construction-site call in WP-A1.
SANDBOX_EXTENSION_MIMEExtension to MIME mappings used by the default resolver.
sandboxFileSystemSchemaDuck-type schema.
sandboxPolicyEnforcerSchemaDuck-type schema.
sandboxPolicySchemaClosed structural schema for SandboxPolicy.
sandboxSearchSchemaDuck-type schema.

Functions

FunctionDescription
artifactConstructorForPathSelect the default artifact constructor for a path.
assertAllowedRipgrepFlagValidate a flag emitted by a trusted adapter, not a model-supplied value.
assertArgvValueReject an argv value which would otherwise be interpreted as an option.
asyncValidateOrThrowValidates value against schema asynchronously and returns the coerced result typed as T.
binaryHonorsDoubleDashWhether a binary in the table can receive the argv terminator.
classifySandboxPathRejectionClassify an unambiguous host escape, or undefined when the path is acceptable.
constructorFromMinterSelect a constructor from a caller-provided minter, never throwing on bad metadata.
createCompartmentRuntimeConstruct a minimal SES-backed in-process guest. The runtime boundary is intentionally explicit.
createEvaluateJavascriptToolAssemble the SES JavaScript evaluation tool.
createGuestRunnerHost runner that retains capability implementations and exposes only enumerated names.
createGuestRuntimeIn-process runtime factory for environments where SES is available.
createModelPathCreate a presentation/normalisation path only; this is NOT a containment guarantee. Every filesystem use must still pass through PathTranslator.toRelative().
createModelWriteRootConstruct the model root representation used in model-facing outcomes.
createPathTranslatorCreate a translator that applies the five-step, workspace-relative path policy.
createRunShellCommandToolAssemble the factory-style run_shell_command tool. It is intentionally not a bulk-registered battery value. cwd is a model-supplied workspace-relative path and receives the complete PathTranslator gauntlet, including symlink refusal; the default is the workspace root.
createSandboxAdmit one process-global sandbox. Drift is detection, not prevention: SRT consults its proxies per request, so a widening can affect an already-spawned child for its lifetime.
createSandboxEpochIssue a fresh epoch token without requiring a type assertion.
createSandboxMediaConstruct the staged media value returned by a mutating sandbox operation.
createSandboxMediaReaderCreate a non-describable, replayable reader over a sandbox file.
createSandboxObservabilityBuild the one event surface consumed by WP-A1's sandbox handle.
emitBypassEmit a loud audit-only bypass report.
emitDriftCheckEmit a drift result, including an explicit network-domain skip when requested.
emitFallbackEmit the permanent loud report for an unsandboxed invocation.
emitFsNodeVersionEmit the SRT version used by the in-process evaluator.
implementsArtifactMinterStructural guard.
implementsGuestLimitsGuard for resolved guest limits.
implementsGuestRuntimeStructural guard.
implementsHostcallQuotasGuard for resolved host quotas.
implementsMimeResolverMIME resolver guard.
implementsPathTranslatorStructural guard.
implementsSandboxFileSystemStructural guard.
implementsSandboxPolicyDuck-type guard for SandboxPolicy.
implementsSandboxPolicyEnforcerStructural guard.
implementsSandboxSearchStructural guard.
isGuestOutcomeType-only terminal outcome helper.
isRejectedSandboxPathReturn whether a path is an unambiguous host escape before normalisation.
normalizeSandboxPathNormalise a model path; leading separators denote the sandbox root.
passesSchemaReturns true if value satisfies schema without throwing.
preflightSandboxRun the once-only, fail-closed environment gauntlet used by createSandbox().
quoteShellArgsQuote argv using SRT's maintained POSIX implementation.
quoteShellValueQuote one command string as one shell argument.
reportSandboxBypassEmit a bypass through the canonical sink for consumers that do not retain the adapter.
resolveGuestLimitsResolve and validate all seven guest limits exactly once.
resolveHostcallQuotasResolve and validate all three hostcall quotas exactly once.
resolveMimeRun a resolver and fall back to the extension resolver when it declines. The callback supplied to consumer code is always bounded by maxPeekBytes.
runSandboxConformanceRun protocol checks for every framed surface, including laziness and the mandatory terminal frame.
sandboxedExecutorCreate a BinaryExecutor that wraps invocations unless an explicitly audited bypass applies.
validateBinShellValidate the shell selected by the Node SRT adapter.
validateOrThrowValidates value against schema synchronously and returns the coerced result typed as T.

References

createSandboxTools

Re-exports createSandboxTools


forgeSandboxTools

Re-exports forgeSandboxTools


sandboxToolDescriptions

Re-exports sandboxToolDescriptions


SandboxToolsOptions

Re-exports SandboxToolsOptions