mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-17 12:31:20 +00:00
Add the _time_travel core plugin with Agent Zero-owned shadow Git snapshots, history/diff/preview/travel/revert APIs, capture hooks, and canvas plus floating window UI surfaces for /a0/usr workspaces. Wire generic file-browser mutation hooks for UI edits, update modal backdrop handling, remove the legacy _diff_viewer plugin, and replace Diff Viewer tests with focused Time Travel coverage. Inspired by Space Agent :-)
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from helpers.api import ApiHandler, Input, Output, Request, Response
|
|
|
|
|
|
from helpers.file_browser import FileBrowser
|
|
from helpers import files, runtime, extension
|
|
from api import get_work_dir_files
|
|
|
|
|
|
class DeleteWorkDirFile(ApiHandler):
|
|
async def process(self, input: Input, request: Request) -> Output:
|
|
try:
|
|
file_path = input.get("path", "")
|
|
if not file_path.startswith("/"):
|
|
file_path = f"/{file_path}"
|
|
|
|
current_path = input.get("currentPath", "")
|
|
|
|
# browser = FileBrowser()
|
|
res = await runtime.call_development_function(delete_file, file_path)
|
|
|
|
if res:
|
|
await extension.call_extensions_async(
|
|
"workdir_file_mutation_after",
|
|
agent=None,
|
|
data={
|
|
"action": "delete",
|
|
"path": file_path,
|
|
"paths": [file_path],
|
|
"current_path": current_path,
|
|
},
|
|
)
|
|
# Get updated file list
|
|
# result = browser.get_files(current_path)
|
|
result = await runtime.call_development_function(get_work_dir_files.get_files, current_path)
|
|
return {"data": result}
|
|
else:
|
|
return {"error": "File not found or could not be deleted"}
|
|
except Exception as e:
|
|
return {"error": str(e)}
|
|
|
|
|
|
async def delete_file(file_path: str):
|
|
browser = FileBrowser()
|
|
return browser.delete_file(file_path)
|