FileSystem

class FileSystem(root: File, cwd: File = root, val readOnly: Boolean = false, val approveChanges: Boolean = true, val deniedPatterns: List<String> = emptyList(), val protectedPatterns: List<String> = DEFAULT_PROTECTED, val contentHashes: Boolean = true, val maxReadLines: Int = 2000, val maxListResults: Int = 1000, val maxSearchResults: Int = 1000, val maxFindResults: Int = 1000, mounts: suspend () -> List<Mount> = { emptyList() }) : Capability(source)

Sandboxed file tools over one directory tree (an app workspace), with the tools, arguments and output format of Pydantic AI Harness FileSystem: read_file, write_file, edit_file, list_directory, search_files, find_files, create_directory, file_info.

Every path is resolved (symlinks included) and must stay inside root; paths matching deniedPatterns are invisible, protectedPatterns are read-only (by default .git, .env*, keys and secrets). Dotfiles are left out of listings and searches. Reads show a 12-character content hash that writes and edits can pass back as expected_hash to refuse stale changes.

Tools that change the workspace ask the user first unless approveChanges is off.

mounts adds folders outside the workspace — typically ones the user shared through the Storage Access Framework (DocumentFolder) — at /mnt/<name>, served by the same tools with the same rules. The shell cannot see them.

Parameters

cwd

where relative paths start; inside root.

Constructors

Link copied to clipboard
constructor(root: File, cwd: File = root, readOnly: Boolean = false, approveChanges: Boolean = true, deniedPatterns: List<String> = emptyList(), protectedPatterns: List<String> = DEFAULT_PROTECTED, contentHashes: Boolean = true, maxReadLines: Int = 2000, maxListResults: Int = 1000, maxSearchResults: Int = 1000, maxFindResults: Int = 1000, mounts: suspend () -> List<Mount> = { emptyList() })

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val instructions: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open suspend override fun context(): String?
Link copied to clipboard
suspend fun createDirectory(path: String): String
Link copied to clipboard
suspend fun editFile(path: String, replacements: List<Pair<String, String>>, expectedHash: String? = null): String
Link copied to clipboard
suspend fun fileInfo(path: String): String
Link copied to clipboard
suspend fun findFiles(pattern: String, path: String = "."): String
Link copied to clipboard
suspend fun listDirectory(path: String = "."): String
Link copied to clipboard
suspend fun readFile(path: String, offset: Int = 0, limit: Int = maxReadLines): String
Link copied to clipboard
suspend fun searchFiles(pattern: String, path: String = ".", includeGlob: String? = null): String
Link copied to clipboard
open suspend override fun tools(): List<AgentTool>
Link copied to clipboard
suspend fun writeFile(path: String, content: String, expectedHash: String? = null): String