Stabilize Local Agent and workstation management v1.26.23

This commit is contained in:
A R R R Associates
2026-09-30 21:35:40 +05:30
parent 76e13aa379
commit 56098aaeb9
4 changed files with 71 additions and 12 deletions
+22 -1
View File
@@ -4,7 +4,7 @@ import io
from pathlib import Path
import zipfile
ERP_LOCAL_AGENT_VERSION = "1.26.22"
ERP_LOCAL_AGENT_VERSION = "1.26.23"
ERP_LOCAL_AGENT_NAME = "ERP Local Agent"
RUNTIME_ROOT = Path(__file__).resolve().parent / "local_agent_runtime"
_DETERMINISTIC_ZIP_TIMESTAMP = (2026, 1, 1, 0, 0, 0)
@@ -39,9 +39,30 @@ def _write_zip_bytes(dst: zipfile.ZipFile, name: str, payload: bytes) -> None:
dst.writestr(_zip_info(name), payload)
def _validate_runtime_source() -> None:
init_path = RUNTIME_ROOT / "erp_local_agent" / "__init__.py"
dashboard_path = RUNTIME_ROOT / "erp_local_agent" / "dashboard.py"
if not init_path.is_file() or not dashboard_path.is_file():
raise RuntimeError("ERP Local Agent runtime is incomplete.")
namespace: dict[str, object] = {}
exec(compile(init_path.read_text(encoding="utf-8"), str(init_path), "exec"), namespace)
runtime_version = str(namespace.get("__version__") or "").strip()
agent_name = str(namespace.get("AGENT_NAME") or "").strip()
if runtime_version != ERP_LOCAL_AGENT_VERSION:
raise RuntimeError(
f"ERP Local Agent package version mismatch: package={ERP_LOCAL_AGENT_VERSION}, runtime={runtime_version or 'missing'}."
)
if agent_name != ERP_LOCAL_AGENT_NAME:
raise RuntimeError("ERP Local Agent runtime is missing the canonical AGENT_NAME constant.")
dashboard_text = dashboard_path.read_text(encoding="utf-8")
if "from . import AGENT_NAME, __version__" not in dashboard_text:
raise RuntimeError("ERP Local Agent dashboard/runtime identity contract is inconsistent.")
def _build_zip(*, env_text: str | None, include_env: bool, include_admin_readme: bool) -> bytes:
if not RUNTIME_ROOT.exists():
raise RuntimeError(f"ERP Local Agent runtime is missing: {RUNTIME_ROOT}")
_validate_runtime_source()
buffer = io.BytesIO()
with zipfile.ZipFile(buffer, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as dst:
for path in sorted(RUNTIME_ROOT.rglob("*"), key=lambda item: item.as_posix()):