aOperations (sTool = "fs") When the prompt starts with {, the Agent decodes the JSON and looks for aOperations. Each operation has this basic structure:
{ "aOperations": [ { "sBase": "app|web|core", "sPath": "data/test.txt", "sMode": "overwrite|append|replace|read", "sContent": "...", // for overwrite/append "sSearch": "...", // for replace "sReplace": "..." // for replace } ]
} Supported filesystem modes:
overwrite – ignore old content and write sContent.append – keep old content and append sContent.replace – str_replace(sSearch, sReplace, oldContent) and write back.read – read-only; returns sContent in the result without calling WriteFile().data/test.txt (app base){ "aOperations": [ { "sBase": "app", "sPath": "data/test.txt", "sMode": "overwrite", "sContent": "Hello from TypeStack Magic after update" } ]
} The result includes iNewLength for the new file length.
{ "aOperations": [ { "sBase": "app", "sPath": "data/agent/agent-selftest.log", "sMode": "append", "sContent": "[SELFTEST] App layer OK at 2025-12-04 23:59:59\\n" } ]
} If the file does not exist, it is treated as empty and created.
{ "aOperations": [ { "sBase": "web", "sPath": "data/agent/agent-web-selftest.txt", "sMode": "overwrite", "sContent": "Hello from TypeStack Magic on web base" } ]
} The Agent resolves the web base via DOCUMENT_ROOT or public_html/private_html under the application root and writes there.
{ "aOperations": [ { "sBase": "app", "sPath": "data/agent/agent-selftest.log", "sMode": "append", "sContent": "[SELFTEST] Combined operation started\\n" }, { "sBase": "app", "sPath": "data/agent/fs-selftest-app.txt", "sMode": "overwrite", "sContent": "App base OK" }, { "sBase": "web", "sPath": "data/agent/fs-selftest-web.txt", "sMode": "overwrite", "sContent": "Web base OK" }, { "sBase": "app", "sPath": "data/agent/agent-selftest.log", "sMode": "append", "sContent": "[SELFTEST] Combined operation finished\\n" } ]
} The response contains four entries in aOpResults, one for each operation, each with its own bSuccess flag and debug output.
data/test.txt{ "aOperations": [ { "sBase": "app", "sPath": "data/test.txt", "sMode": "replace", "sSearch": "Hoi Open AI :)", "sReplace": "Hello from TypeStack Magic after replace" } ]
} Internally this becomes:
str_replace("Hoi Open AI :)", "Hello from TypeStack Magic after replace", $sOldContent); The modified content is written back via WriteFile(), and the new length is reported in iNewLength.
sMode = "read"){ "aOperations": [ { "sBase": "app", "sPath": "data/test.txt", "sMode": "read" } ]
} The result includes:
sMode, sBase, sPath, resolved sFullPath.sContent with the current file content.aDebug with read details and content length. Read mode respects the same base rules as other operations (app, web, core).