NoOpShellBackend

ShellBackend that's always unavailable. Useful as a fallback in the "use root if available, Shizuku otherwise" dispatch pattern documented in docs/SHELL.md — when neither backend is reachable on the current device, every tool errors with shell_unavailable: NoOp so the LLM sees a structured failure instead of unexpected behaviour.

Example:

val backend: ShellBackend = when {
RootShellBackend().isAvailable() -> RootShellBackend()
ShizukuShellBackend().isAvailable() -> ShizukuShellBackend()
else -> NoOpShellBackend
}
val tools = ShellTools.all(context, backend)

Properties

Link copied to clipboard
open override val name: String

One-line description of what this backend is, surfaced in tool errors ("Shizuku", "Root (libsu)"). Helps the LLM disambiguate when one tool errors with "shell_unavailable" and the host registered multiple backends.

Functions

Link copied to clipboard

Why the backend can't run commands right now, or null when it can. Lets tools tell "not running / not checked" (ShellException.NotAvailable → shell_unavailable) apart from "access denied" (ShellException.PermissionDenied → shell_permission_denied). The default only knows isAvailable.

Link copied to clipboard
open suspend override fun exec(command: String, args: List<String> = emptyList()): ShellResult

Run command with args as a shell process. Returns stdout/stderr/exit. Implementations should NOT throw on non-zero exit codes — surface them via ShellResult.exitCode so tools can decide whether that's an error.

Link copied to clipboard
open suspend fun execBinary(command: String, args: List<String> = emptyList()): ShellResult

Run command with args and return raw stdout bytes. Defaults to exec — backends whose exec is already binary-safe (Shizuku) don't need to override. Backends with a text-only output API (libsu) MUST override with a binary-safe path (e.g. temp-file roundtrip).

Link copied to clipboard
open override fun isAvailable(): Boolean

True when the backend is currently reachable — Shizuku binder pingable with permission granted, or su available, depending on the impl. Tools call this for fast-fail before constructing a command.