Skip to content

Virtual File System

RTC Agent builds a complete virtual file system in the browser. AI operates on files using tools like ls, read, edit, grep, and find, just like working with a local terminal — but all data always stays within the user’s browser.

💡 Core Insight: LLMs are already very good at operating file systems. Instead of making the AI learn custom APIs, give it a file system — it can immediately ls, read, grep, and write.

DirectoryPurposeContent Source
/functions/Function documentationAuto-generated after the host app registers Functions
/scenarios/Scenario documentationMarkdown workflows provided by the business side
/scripts/Executable scriptsSaved by AI via the script tool
/AGENT.mdSystem entry pointAuto-generated template describing directory structure and tools

The virtual file system provides 7 operations covering all file interactions the AI needs:

OperationFunctionKey ParametersStatus
lsList directory contentspath (default /)✅ Available
readRead file contentspath (required), offset / limit (pagination)✅ Available
writeCreate or write to filepath, content (required), mode (optional, see below)✅ Available
editExact string replacementpath, old_string, new_string (required), replace_all✅ Available
findSearch by file namepattern (glob), path✅ Available
grepSearch by file contentpattern (regex), see parameter table below✅ Available
removeDelete filepath🔒 Internal API

⚠️ remove is an internal API of the virtual file system and is not currently exposed to AI as an RTC tool. AI cannot directly delete files.

Large files support paginated reading to avoid loading too much content at once:

ParameterTypeRequiredDescription
pathstringYesAbsolute path to the file
offsetintegerNoStarting line number (1-indexed), only provide for large files
limitintegerNoNumber of lines to read, only provide for large files

write supports three write modes controlled by the mode parameter:

ModeDescriptionReturn value
overwriteOverwrite (default); creates the file if it does not existTotal character count after write
appendAppend; content is added to the end of the fileTotal character count after write
create-newCreate only; skips writing if the file already existsExisting file character count when file exists

Perform exact string replacements in a file, similar to Claude Code’s Edit tool. You must use the read tool on the file before editing it.

ParameterTypeRequiredDescription
pathstringYesAbsolute path to the file
old_stringstringYesThe original text to replace — must exactly match the file content including indentation and whitespace
new_stringstringYesThe replacement text (must differ from old_string)
replace_allbooleanNoSet to true to replace all occurrences (default false). Required when old_string is not unique

Usage Constraints:

  • You must use the read tool on the file first, otherwise the edit will fail
  • old_string must match uniquely in the file — provide more surrounding context to make it unique, or use replace_all
  • Prefer using edit to modify existing files rather than using write to overwrite the entire file

A powerful search tool for the virtual filesystem. Supports regex, file filtering, pagination, and multiple output modes.

ParameterTypeRequiredDescription
patternstringYesRegular expression search pattern
pathstringNoFile or directory path to search in (default root /)
globstringNoGlob pattern to filter files (e.g. "*.js", "**/*.tsx")
typestringNoFile type filter (e.g. "js", "py", "go") — more efficient than glob
output_modestringNoOutput mode: "files_with_matches" (default, file paths only), "content" (matching lines with context), "count" (match counts)
-ibooleanNoCase-insensitive search
-nbooleanNoShow line numbers (requires output_mode: "content", default true)
-BintegerNoLines to show before each match (requires output_mode: "content")
-AintegerNoLines to show after each match (requires output_mode: "content")
-C / contextintegerNoLines to show before and after each match
head_limitintegerNoLimit output to first N entries (default 250, pass 0 for unlimited)
offsetintegerNoSkip first N entries before applying head_limit (default 0)
multilinebooleanNoEnable multiline mode (. matches newlines, patterns can span lines)

💡 Mode Selection Tips: Use "files_with_matches" to find files; use "content" with -n and -C to inspect matching code; use "count" to tally occurrences.

RuleDescription
Root directory/
Separator/ (forward slash)
Auto-conversionAll paths are automatically converted to absolute paths
Path traversal.. is rejected directly, without parsing
DirectoriesLogical concept, not stored separately, derived from path prefixes

File types are automatically inferred from the path prefix, no explicit specification needed:

FeatureDescription
Storage EngineIndexedDB (wrapped by Dexie.js)
Primary KeyFile path
Large FilesStored and retrieved as whole, supports paginated reading
Read BehaviorEach read queries the latest data directly, no cache layer
CapacitySubject to browser IndexedDB quota (typically hundreds of MB)

At system startup, /AGENT.md is automatically checked. If it doesn’t exist, a template file is auto-generated to describe the directory structure and available tools to the AI — ensuring the AI knows “what’s in the file system” as soon as it comes online.

ConstraintDescription
🔒 Path traversal protection.. is rejected directly
🔐 Permission controlDetermined by work mode
💾 Capacity limitsSubject to browser IndexedDB quota
🚫 No cross-origin accessFile system is fully isolated within the browser sandbox
🛡️ User edit protectionSystem files (e.g. /AGENT.md, /functions/*.md) that the user has manually edited will not be automatically overwritten by the system. The user must click “Restore Default” to regenerate them
  • Remote Tool Calling — Learn how AI calls these file operations
  • Script Engine — Learn how scripts in the /scripts/ directory are executed
  • Skill System — Learn how functions in the /functions/ directory are registered