agent-zero/plugins/_time_travel/api/history_diff.py
Alessandro c5ea678052 Add Time Travel workspace history
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 :-)
2026-04-27 01:27:20 +02:00

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)}