Class LocalFilesystemWithShell
java.lang.Object
io.agentscope.harness.agent.filesystem.local.LocalFilesystem
io.agentscope.harness.agent.filesystem.local.LocalFilesystemWithShell
- All Implemented Interfaces:
AbstractFilesystem,AbstractSandboxFilesystem
Filesystem with unrestricted local shell command execution.
This implementation extends LocalFilesystem to add shell command execution
capabilities. Commands are executed directly on the host system without any
sandboxing, process isolation, or security restrictions.
WARNING: This implementation grants agents BOTH direct filesystem access AND unrestricted shell execution on your local machine. Use with extreme caution and only in appropriate environments (local dev, CI/CD with proper secret management).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault timeout in seconds for shell command execution. -
Constructor Summary
ConstructorsConstructorDescriptionLocalFilesystemWithShell(String rootDir) Same asLocalFilesystemWithShell(Path)with a path string; seeLocalFilesystem(String)fornull/ blank rules.LocalFilesystemWithShell(String rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv) Same asLocalFilesystemWithShell(Path, boolean, int, int, Map, boolean)with a path string; seeLocalFilesystem(String)fornull/ blank rules.LocalFilesystemWithShell(String rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory) Same asLocalFilesystemWithShell(Path, boolean, int, int, Map, boolean, NamespaceFactory)with a path string; seeLocalFilesystem(String)fornull/ blank rules.LocalFilesystemWithShell(String rootDir, NamespaceFactory namespaceFactory) Same asLocalFilesystemWithShell(Path, NamespaceFactory)with a path string; seeLocalFilesystem(String)fornull/ blank rules.LocalFilesystemWithShell(Path rootDir) Creates an abstract filesystem with default settings.LocalFilesystemWithShell(Path rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv) Creates a abstract filesystem with full configuration.LocalFilesystemWithShell(Path rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory) Creates a abstract filesystem with full configuration and namespace support.LocalFilesystemWithShell(Path rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory, Path shellCwd) Creates a abstract filesystem with full configuration, namespace support, and a custom shell working directory.LocalFilesystemWithShell(Path rootDir, NamespaceFactory namespaceFactory) Creates an abstract filesystem with default settings and namespace support.LocalFilesystemWithShell(Path rootDir, LocalFsMode mode, PathPolicy pathPolicy, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory, Path shellCwd) Most-complete constructor: filesystem operations followmodeandpathPolicy(seeLocalFilesystem(Path, LocalFsMode, PathPolicy, int, NamespaceFactory)); shell commands run withpwd = shellCwdwhen set, otherwise the filesystem root. -
Method Summary
Modifier and TypeMethodDescriptionexecute(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, Integer timeoutSeconds) Execute a shell command in the environment backing this filesystem.Returns the working directory configured for shellexecute()calls, ornullwhen shell falls back to the filesystem root (with namespace prefix).id()Unique identifier for this filesystem/sandbox instance.Methods inherited from class io.agentscope.harness.agent.filesystem.local.LocalFilesystem
delete, downloadFiles, edit, exists, getCwd, getMode, getNamespaceFactory, getPathPolicy, glob, grep, ls, move, read, resolvePath, toVirtualPath, uploadFiles, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.harness.agent.filesystem.AbstractFilesystem
delete, downloadFiles, edit, exists, glob, grep, ls, move, read, uploadFiles, write
-
Field Details
-
DEFAULT_EXECUTE_TIMEOUT
public static final int DEFAULT_EXECUTE_TIMEOUTDefault timeout in seconds for shell command execution.- See Also:
-
-
Constructor Details
-
LocalFilesystemWithShell
Creates an abstract filesystem with default settings.- Parameters:
rootDir- working directory for both filesystem and shell operations
-
LocalFilesystemWithShell
Same asLocalFilesystemWithShell(Path)with a path string; seeLocalFilesystem(String)fornull/ blank rules. -
LocalFilesystemWithShell
Creates an abstract filesystem with default settings and namespace support.- Parameters:
rootDir- working directory for both filesystem and shell operationsnamespaceFactory- optional namespace factory for path scoping (nullfor none)
-
LocalFilesystemWithShell
Same asLocalFilesystemWithShell(Path, NamespaceFactory)with a path string; seeLocalFilesystem(String)fornull/ blank rules. -
LocalFilesystemWithShell
public LocalFilesystemWithShell(Path rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv) Creates a abstract filesystem with full configuration.- Parameters:
rootDir- working directory for both filesystem and shell operationsvirtualMode- enable virtual path mode for filesystem operationstimeout- default maximum time in seconds for shell command executionmaxOutputBytes- maximum number of bytes to capture from command outputenv- environment variables for shell commands (nullfor empty)inheritEnv- whether to inherit the parent process's environment variables
-
LocalFilesystemWithShell
public LocalFilesystemWithShell(String rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv) Same asLocalFilesystemWithShell(Path, boolean, int, int, Map, boolean)with a path string; seeLocalFilesystem(String)fornull/ blank rules. -
LocalFilesystemWithShell
public LocalFilesystemWithShell(Path rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory) Creates a abstract filesystem with full configuration and namespace support.- Parameters:
rootDir- working directory for both filesystem and shell operationsvirtualMode- enable virtual path mode for filesystem operationstimeout- default maximum time in seconds for shell command executionmaxOutputBytes- maximum number of bytes to capture from command outputenv- environment variables for shell commands (nullfor empty)inheritEnv- whether to inherit the parent process's environment variablesnamespaceFactory- optional namespace factory for path scoping (nullfor none)
-
LocalFilesystemWithShell
public LocalFilesystemWithShell(Path rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory, Path shellCwd) Creates a abstract filesystem with full configuration, namespace support, and a custom shell working directory.- Parameters:
rootDir- working directory for filesystem operations (read/write/edit/glob/...)virtualMode- enable virtual path mode for filesystem operationstimeout- default maximum time in seconds for shell command executionmaxOutputBytes- maximum number of bytes to capture from command outputenv- environment variables for shell commands (nullfor empty)inheritEnv- whether to inherit the parent process's environment variablesnamespaceFactory- optional namespace factory for path scoping (nullfor none)shellCwd- working directory for shell command execution; whennull, falls back torootDir(with namespace prefix when configured)
-
LocalFilesystemWithShell
public LocalFilesystemWithShell(Path rootDir, LocalFsMode mode, PathPolicy pathPolicy, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory, Path shellCwd) Most-complete constructor: filesystem operations followmodeandpathPolicy(seeLocalFilesystem(Path, LocalFsMode, PathPolicy, int, NamespaceFactory)); shell commands run withpwd = shellCwdwhen set, otherwise the filesystem root.- Parameters:
rootDir- filesystem root for relative-path operationsmode- path-resolution policy (nulltreated asLocalFsMode.UNRESTRICTED)pathPolicy- allow-list forLocalFsMode.ROOTED; ignored otherwisetimeout- default shell timeout (seconds, must be positive)maxOutputBytes- byte cap for captured shell outputenv- environment variables for shell commands (nullfor empty)inheritEnv- whether to inherit the parent process environmentnamespaceFactory- optional per-user/session namespace factoryshellCwd- shellpwd;nullfalls back torootDir(with namespace prefix when configured)
-
LocalFilesystemWithShell
public LocalFilesystemWithShell(String rootDir, boolean virtualMode, int timeout, int maxOutputBytes, Map<String, String> env, boolean inheritEnv, NamespaceFactory namespaceFactory) Same asLocalFilesystemWithShell(Path, boolean, int, int, Map, boolean, NamespaceFactory)with a path string; seeLocalFilesystem(String)fornull/ blank rules.
-
-
Method Details
-
id
Description copied from interface:AbstractSandboxFilesystemUnique identifier for this filesystem/sandbox instance.- Specified by:
idin interfaceAbstractSandboxFilesystem- Returns:
- id string
-
getShellCwd
Returns the working directory configured for shellexecute()calls, ornullwhen shell falls back to the filesystem root (with namespace prefix). Used by upstream code that needs to expose the user-visible project directory in prompts or diagnostics. -
execute
public ExecuteResponse execute(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, Integer timeoutSeconds) Description copied from interface:AbstractSandboxFilesystemExecute a shell command in the environment backing this filesystem.- Specified by:
executein interfaceAbstractSandboxFilesystem- Parameters:
runtimeContext- per-call agent context; may benullwhen unavailablecommand- full shell command string to executetimeoutSeconds- maximum time in seconds to wait for the command to complete;nulluses the filesystem's default timeout- Returns:
- ExecuteResponse with combined output, exit code, and truncation flag; a
non-successful response (see
ExecuteResponse.isSuccess()) means the command did not complete successfully, sooutputmust not be parsed as normal command output
-