mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-10-20 11:15:50 +00:00
Give Files and Editor shared UTF-8, binary and size validation. Default text editing to 10 MiB and file transfers to 100 MiB, with a scoped settings API and no artificial transfer ceiling. Reject oversized local uploads before overwriting files and enforce Files download limits without changing Backup & Restore. Send larger Editor input and saves over HTTP while preserving conflict checks. Add coverage for independent limits, invalid settings, large text editing and upload rejection without data loss.
21 lines
1 KiB
Python
21 lines
1 KiB
Python
"""Instance-wide File Browser preferences shared by local and remote editors."""
|
|
from helpers.api import ApiHandler, Request
|
|
from helpers.file_browser import FileBrowser
|
|
from helpers import settings
|
|
|
|
|
|
class FileBrowserSettings(ApiHandler):
|
|
async def process(self, input: dict, request: Request):
|
|
delta = {}
|
|
for name, maximum in (("max_text_size_mb", 100), ("max_transfer_size_mb", None)):
|
|
if name not in input:
|
|
continue
|
|
limit = input[name]
|
|
if type(limit) is not int or limit < 1 or (maximum is not None and limit > maximum):
|
|
message = f"Enter a whole number from 1 to {maximum} MiB." if maximum else "Enter a positive whole number of MiB."
|
|
return {"ok": False, "error": message}
|
|
delta["file_browser_" + name] = limit
|
|
if not delta:
|
|
return {"ok": False, "error": "No size limit supplied."}
|
|
settings.set_settings_delta(delta, apply=False)
|
|
return {"ok": True, "limits": FileBrowser.limits()}
|