Skip to content

Plugin services can write files into Documents and your projects - #1398

Closed
hoangvu12 wants to merge 1 commit into
zeronsh:mainfrom
hoangvu12:plugin-write-file
Closed

hoangvu12 wants to merge 1 commit into
zeronsh:mainfrom
hoangvu12:plugin-write-file

Conversation

@hoangvu12

@hoangvu12 hoangvu12 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

A plugin's service can't write a file. An agent asking a design plugin to export its screens gets PNGs and HTML back as base64 in the tool result, and then has to save them itself. A 50-screen export doesn't fit in a result at all.

Now a service has zeron.write_file(path, data, { base64 }), behind a new files.write permission:

  • A relative path lands in the plugin's own folder in Documents, ~/Documents/<plugin name>/…, where the person can find it.
  • A whole path must be inside one of this device's chats' or projects' folders, the same list zeron.folders() gives.
  • Missing folders are made. A path with .., a folder that is a link leading out, and a file that is a link are refused. 64 MB at most per file. The result is { path, bytes }.

Tool calls also carry the chat's folder as call.cwd when the plugin has sessions.read and the chat is on this device, so an agent's export can go into the project it's working in.

The Allow sheet shows the new permission as "Save files in its Documents folder and your projects".

Testing

  • cargo test -p zeron-engine --lib plugins::service passes (36 tests).
  • files::tests covers relative paths into Documents, whole paths inside and outside a chat's folder, .., a folder as the target, bad base64, and on Unix a link out and a link at the file.
  • a_service_writes_files_only_in_a_chats_folder_with_files_write runs a real service: it writes a PNG from base64, is refused outside the chat folders, and is refused without the permission.
  • a_tool_call_says_its_chats_folder_with_sessions_read checks that call.cwd is set for a chat on this device, absent for a chat on another device, and absent without sessions.read.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

zeron.write_file(path, data, { base64 }) with a new "files.write"
permission: a relative path lands in ~/Documents/<plugin name>/, a whole
one must be inside one of this device's chats' or projects' folders.
Folders on the way are made; .., links out and links at the file are
refused. Tool calls also carry the chat's folder (call.cwd) when the
plugin has sessions.read, so an agent's export can go where its work is.
@hoangvu12

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1392, which groups the plugin API changes into one PR as asked. This change is its commit 009c8e3, on zeron/zgx instead of main.

@hoangvu12 hoangvu12 closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant