amfs-http-server 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/PKG-INFO +1 -1
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/pyproject.toml +1 -1
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/server.py +71 -10
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/.gitignore +0 -0
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/__init__.py +0 -0
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/auth.py +0 -0
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/models.py +0 -0
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/pro_proxy.py +0 -0
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/sse.py +0 -0
- {amfs_http_server-0.3.0 → amfs_http_server-0.3.2}/src/amfs_http/tenant_middleware.py +0 -0
|
@@ -438,16 +438,6 @@ async def search_entries(
|
|
|
438
438
|
except TypeError:
|
|
439
439
|
results = mem._adapter.search(sq)
|
|
440
440
|
|
|
441
|
-
if req.query and not getattr(mem._adapter, "_has_search_tsv", False):
|
|
442
|
-
query_lower = req.query.lower()
|
|
443
|
-
results = [
|
|
444
|
-
e
|
|
445
|
-
for e in results
|
|
446
|
-
if query_lower in e.key.lower()
|
|
447
|
-
or query_lower in str(e.value).lower()
|
|
448
|
-
or query_lower in e.entity_path.lower()
|
|
449
|
-
]
|
|
450
|
-
|
|
451
441
|
return [_entry_to_response(e) for e in results]
|
|
452
442
|
|
|
453
443
|
|
|
@@ -1704,6 +1694,77 @@ async def recover_snapshot(
|
|
|
1704
1694
|
}
|
|
1705
1695
|
|
|
1706
1696
|
|
|
1697
|
+
# ──────────────────────────────────────────────────────────────────────
|
|
1698
|
+
# Rollback
|
|
1699
|
+
# ──────────────────────────────────────────────────────────────────────
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
@app.post("/api/v1/rollback")
|
|
1703
|
+
async def rollback(
|
|
1704
|
+
body: dict[str, Any],
|
|
1705
|
+
_auth: str | None = Depends(verify_api_key),
|
|
1706
|
+
) -> dict[str, Any]:
|
|
1707
|
+
"""Rollback an agent's memory to a specific event or timestamp.
|
|
1708
|
+
|
|
1709
|
+
Accepts either ``target_event_id`` (looks up the event to get its
|
|
1710
|
+
timestamp and agent) or ``target_timestamp`` + ``agent_id``.
|
|
1711
|
+
"""
|
|
1712
|
+
mem = _get_memory()
|
|
1713
|
+
target_event_id = body.get("target_event_id")
|
|
1714
|
+
target_timestamp = body.get("target_timestamp")
|
|
1715
|
+
agent_id = body.get("agent_id")
|
|
1716
|
+
|
|
1717
|
+
if target_event_id:
|
|
1718
|
+
event = mem._adapter.get_event(target_event_id, mem.namespace)
|
|
1719
|
+
if event is None and agent_id:
|
|
1720
|
+
for e in mem._adapter.list_events(agent_id, mem.namespace, limit=10000):
|
|
1721
|
+
if e.id == target_event_id:
|
|
1722
|
+
event = e
|
|
1723
|
+
break
|
|
1724
|
+
if event is None:
|
|
1725
|
+
raise HTTPException(status_code=404, detail="Event not found")
|
|
1726
|
+
timestamp = event.created_at
|
|
1727
|
+
agent_id = agent_id or event.agent_id
|
|
1728
|
+
elif target_timestamp:
|
|
1729
|
+
if not agent_id:
|
|
1730
|
+
raise HTTPException(
|
|
1731
|
+
status_code=400,
|
|
1732
|
+
detail="agent_id is required when using target_timestamp",
|
|
1733
|
+
)
|
|
1734
|
+
timestamp = datetime.fromisoformat(target_timestamp)
|
|
1735
|
+
else:
|
|
1736
|
+
raise HTTPException(
|
|
1737
|
+
status_code=400,
|
|
1738
|
+
detail="Provide target_event_id or target_timestamp",
|
|
1739
|
+
)
|
|
1740
|
+
|
|
1741
|
+
count = mem._adapter.rollback_to_timestamp(
|
|
1742
|
+
agent_id, "main", timestamp, mem.namespace,
|
|
1743
|
+
)
|
|
1744
|
+
|
|
1745
|
+
try:
|
|
1746
|
+
mem._adapter.log_event(Event(
|
|
1747
|
+
namespace=mem.namespace,
|
|
1748
|
+
agent_id=agent_id,
|
|
1749
|
+
branch="main",
|
|
1750
|
+
event_type=EventType.ROLLBACK,
|
|
1751
|
+
summary=f"Rolled back to {timestamp.isoformat()}",
|
|
1752
|
+
details={
|
|
1753
|
+
"rolled_back_to": timestamp.isoformat(),
|
|
1754
|
+
"entries_restored": count,
|
|
1755
|
+
"source_event_id": target_event_id,
|
|
1756
|
+
},
|
|
1757
|
+
))
|
|
1758
|
+
except Exception:
|
|
1759
|
+
logger.debug("Failed to log rollback event", exc_info=True)
|
|
1760
|
+
|
|
1761
|
+
return {
|
|
1762
|
+
"entries_restored": count,
|
|
1763
|
+
"rolled_back_to": timestamp.isoformat(),
|
|
1764
|
+
"agent_id": agent_id,
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
|
|
1707
1768
|
# ──────────────────────────────────────────────────────────────────────
|
|
1708
1769
|
# Agent-scoped branches & pull requests
|
|
1709
1770
|
# ──────────────────────────────────────────────────────────────────────
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|