Skip to content

Agent Zero AI framework

Handle forks in update-check version payload

Jan Tomášeke13ed04f6cc2
diff --git a/python/helpers/git.py b/python/helpers/git.py
index da0e80183..e590aef73 100644
--- a/python/helpers/git.py
+++ b/python/helpers/git.py
@@ -74,6 +74,23 @@ def get_version():
return "unknown"
+def is_official_agent_zero_repo() -> bool:
+ """Return True when origin points to agent0ai/agent-zero."""
+ try:
+ repo = Repo(files.get_base_dir())
+ if not repo.remotes:
+ return False
+
+ remote_url = strip_auth_from_url(repo.remotes.origin.url).lower().rstrip("/")
+
+ if remote_url.endswith(".git"):
+ remote_url = remote_url[:-4]
+
+ return remote_url.endswith("github.com/agent0ai/agent-zero") or remote_url.endswith("github.com:agent0ai/agent-zero")
+ except Exception:
+ return False
+
+
def clone_repo(url: str, dest: str, token: str | None = None):
"""Clone a git repository. Uses http.extraHeader for token auth (never stored in URL/config)."""
cmd = ['git']
@@ -158,4 +175,4 @@ def get_repo_status(repo_path: str) -> dict:
"last_commit": last_commit
}
except Exception as e:
- return {"is_git_repo": False, "error": str(e)}
\ No newline at end of file
+ return {"is_git_repo": False, "error": str(e)}
diff --git a/python/helpers/update_check.py b/python/helpers/update_check.py
index ce083e1c9..d093be3d7 100644
--- a/python/helpers/update_check.py
+++ b/python/helpers/update_check.py
@@ -1,15 +1,19 @@
from python.helpers import git, runtime
import hashlib
+
async def check_version():
import httpx
current_version = git.get_version()
+ if not git.is_official_agent_zero_repo():
+ current_version = "fork"
+
anonymized_id = hashlib.sha256(runtime.get_persistent_id().encode()).hexdigest()[:20]
-
+
url = "https://api.agent-zero.ai/a0-update-check"
payload = {"current_version": current_version, "anonymized_id": anonymized_id}
async with httpx.AsyncClient() as client:
response = await client.post(url, json=payload)
version = response.json()
- return version
\ No newline at end of file
+ return version