mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-17 04:01:13 +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 :-)
25 lines
972 B
Python
25 lines
972 B
Python
from __future__ import annotations
|
|
|
|
from helpers.api import ApiHandler, Request, Response
|
|
from plugins._time_travel.helpers.time_travel import (
|
|
TimeTravelError,
|
|
TimeTravelService,
|
|
WorkspaceRejectedError,
|
|
resolve_workspace,
|
|
)
|
|
|
|
|
|
class HistoryDiff(ApiHandler):
|
|
async def process(self, input: dict, request: Request) -> dict | Response:
|
|
context_id = str(input.get("context_id") or "").strip()
|
|
try:
|
|
workspace = resolve_workspace(context_id, context_loader=self.use_context)
|
|
return TimeTravelService(workspace).history_diff(
|
|
commit_hash=str(input.get("commit_hash") or ""),
|
|
path=str(input.get("path") or ""),
|
|
mode=str(input.get("mode") or "commit"),
|
|
)
|
|
except WorkspaceRejectedError as exc:
|
|
return {"ok": False, "locked": True, "error": str(exc)}
|
|
except TimeTravelError as exc:
|
|
return {"ok": False, "error": str(exc)}
|