mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 09:28:56 +00:00
Start a permission-restricted Unix JSON socket alongside the WebUI, with file-discovered core/plugin handlers and a standard-library CLI. Reuse explicit JSON API operations for local administration and plugin workflows. Allow long operations without a default execution deadline, configure JSON and transfer limits, and keep blocking operations off the transport loop. Preserve HTTP authentication, multipart behavior, RFC, and startup/update health probes. Validation: 44 socket/adapter tests and 8 plugin compatibility tests pass; syntax, handler mapping, skill examples and DOX checks pass. Full WebUI integration was unavailable without installed framework dependencies.
27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
from pathlib import Path
|
|
|
|
from helpers import socket_handlers
|
|
|
|
|
|
class PluginInstall(socket_handlers.JsonApiHandler):
|
|
api_module = "plugins._plugin_installer.api.plugin_install"
|
|
api_class = "PluginInstall"
|
|
|
|
def validate(self, input: dict):
|
|
if input.get("action") not in ("fetch_index", "check_compatibility", "install_git", "update_plugin", "install_zip"):
|
|
raise socket_handlers.SocketError("INVALID_ARGUMENT", "Unknown installer action")
|
|
if input.get("action") == "install_zip":
|
|
path = input.get("zip_path")
|
|
if not isinstance(path, str) or not Path(path).is_absolute() or not Path(path).is_file():
|
|
raise socket_handlers.SocketError("INVALID_ARGUMENT", "zip_path must be an absolute local file path")
|
|
|
|
async def invoke(self, input: dict):
|
|
if input["action"] != "install_zip":
|
|
return await super().invoke(input)
|
|
from werkzeug.datastructures import FileStorage
|
|
from plugins._plugin_installer.helpers.install import install_uploaded_zip
|
|
|
|
# The upload helper copies the archive before extraction/cleanup, preserving the source.
|
|
with open(input["zip_path"], "rb") as source:
|
|
return install_uploaded_zip(FileStorage(source, filename=Path(input["zip_path"]).name))
|