Class LocalFilesystemSpec

java.lang.Object
io.agentscope.harness.agent.filesystem.spec.LocalFilesystemSpec

public class LocalFilesystemSpec extends Object
Specification for the local filesystem mode (with shell execution).

This spec produces a LocalFilesystemWithShell whose root is the agent workspace and whose shell runs directly on the host as sh -c <command>. Long-term memory (MEMORY.md, memory/) and session logs live on the same local disk.

Suitable for single-process deployments (personal assistants, CLI tools, local dev loops) where distributed sharing is not required and the agent is trusted to run host shell commands.

For distributed deployments where long-term memory must be shared across replicas, prefer RemoteFilesystemSpec (no shell) or a sandbox filesystem spec (shell via sandbox).

  • Constructor Details

    • LocalFilesystemSpec

      public LocalFilesystemSpec()
  • Method Details

    • executeTimeoutSeconds

      public LocalFilesystemSpec executeTimeoutSeconds(int seconds)
      Sets the default command execution timeout in seconds.
      Parameters:
      seconds - timeout (must be positive)
      Returns:
      this spec
    • maxOutputBytes

      public LocalFilesystemSpec maxOutputBytes(int bytes)
      Sets the maximum number of output bytes captured from any single shell command.
      Parameters:
      bytes - byte cap (must be positive)
      Returns:
      this spec
    • env

      public LocalFilesystemSpec env(String name, String value)
      Adds an environment variable that will be set for every shell command.
      Parameters:
      name - variable name
      value - variable value
      Returns:
      this spec
    • inheritEnv

      public LocalFilesystemSpec inheritEnv(boolean inherit)
      Controls whether the parent process environment is inherited by shell commands. When false (default), only variables added via env(String, String) are visible.
      Parameters:
      inherit - whether to inherit parent env
      Returns:
      this spec
    • virtualMode

      @Deprecated public LocalFilesystemSpec virtualMode(boolean virtual)
      Deprecated.
      use mode(LocalFsMode) for the full three-way selection
      Legacy: true maps to LocalFsMode.SANDBOXED, false to LocalFsMode.UNRESTRICTED. Prefer mode(LocalFsMode) so LocalFsMode.ROOTED is also reachable.
      Parameters:
      virtual - whether to enable virtual mode
      Returns:
      this spec
    • mode

      public LocalFilesystemSpec mode(LocalFsMode mode)
      Sets the path-resolution policy for the upper LocalFilesystemWithShell. Defaults to LocalFsMode.ROOTED.
      Parameters:
      mode - policy mode
      Returns:
      this spec
    • isolationScope

      public LocalFilesystemSpec isolationScope(IsolationScope scope)
      Sets the isolation scope controlling how file paths are namespaced per user, session, or agent. Defaults to IsolationScope.USER (consistent with RemoteFilesystemSpec and sandbox specs).
      Parameters:
      scope - isolation scope
      Returns:
      this spec
    • getIsolationScope

      public IsolationScope getIsolationScope()
      Returns the configured isolation scope, or null to use the default.
    • addRoot

      public LocalFilesystemSpec addRoot(Path root)
      Adds an extra host directory the agent is allowed to access by absolute path under LocalFsMode.ROOTED. null entries are ignored.
      Parameters:
      root - extra root to allow
      Returns:
      this spec
    • projectWritable

      public LocalFilesystemSpec projectWritable(boolean writable)
      Enables or disables project-writable mode. When true, the agent's file-write operations for non-workspace paths are routed to the project directory.
      Parameters:
      writable - whether non-workspace writes go to the project directory
      Returns:
      this spec
    • isProjectWritable

      public boolean isProjectWritable()
      Returns whether project-writable mode is enabled.
    • additionalRoots

      public LocalFilesystemSpec additionalRoots(Collection<Path> roots)
      Replaces the list of extra host directories. See addRoot(Path).
      Parameters:
      roots - extra roots (null clears)
      Returns:
      this spec
    • project

      public LocalFilesystemSpec project(Path project)
      Sets the user project root used as the lower layer of the resulting OverlayFilesystem. Reads of AGENTS.md, knowledge/, skills/ etc. fall back to this directory when the agent workspace does not contain them; shell execute() runs with pwd set to this directory.

      Defaults to System.getProperty("user.dir") when not set.

      Parameters:
      project - project root path
      Returns:
      this spec
    • getProject

      public Path getProject()
      Project root explicitly configured, or null to fall back to ${user.dir}.
    • getMode

      public LocalFsMode getMode()
      Currently configured path-resolution policy mode.
    • sharedLocalWorkspace

      public LocalFilesystemSpec sharedLocalWorkspace(boolean shared)
      Enables or disables the shared workspace root for non-routed paths; see the field javadoc. When enabled, the per-user namespace prefix is not applied to the upper or project layers.
      Parameters:
      shared - whether non-routed paths resolve against the shared workspace root
      Returns:
      this spec
    • getAdditionalRoots

      public List<Path> getAdditionalRoots()
      Snapshot of configured extra roots.
    • toFilesystem

      public AbstractFilesystem toFilesystem(Path workspace, NamespaceFactory localNamespaceFactory)