chore(oss): audit the server package and resync the SDK mirrors
Split the 657-line operation service into eor, submit, and verify modules, add the AGENT_REVOKED and KEY_RETIRED codes the Backend already emits, and condense every multi-line comment. Mirror Node, Python, and Go at 2.1.0 with the deep-health 503, non-idempotent retry, rotation grace, and path-encoding fixes. Document which routes and response fields the self-hosted server does not provide. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
This commit is contained in:
1 parent
2010175a82
commit
bc6983a62e
364 files changed
+10180
-23349
No files matched your search
@@ -0,0 +1,83 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from elydora import cli
|
||||
|
||||
|
||||
AGENT_ID = "agent-1"
|
||||
AGENT_NAME = "opencode"
|
||||
PRIVATE_KEY = base64.urlsafe_b64encode(bytes([19]) * 32).rstrip(b"=").decode()
|
||||
|
||||
|
||||
def set_home(monkeypatch: pytest.MonkeyPatch, home: Path) -> None:
|
||||
monkeypatch.setenv("HOME", str(home))
|
||||
monkeypatch.setenv("USERPROFILE", str(home))
|
||||
|
||||
|
||||
def write_json(path: Path, value: Any) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(value, indent=2) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
def write_secret(path: Path, value: str) -> None:
|
||||
path.write_text(value, encoding="utf-8")
|
||||
if os.name != "nt":
|
||||
path.chmod(0o600)
|
||||
|
||||
|
||||
def write_error_log(path: Path, chunks: int = 1) -> str:
|
||||
digest = hashlib.sha256()
|
||||
block = b"opaque historical error\n" * 4096
|
||||
with path.open("wb") as file:
|
||||
for _index in range(chunks):
|
||||
file.write(block)
|
||||
digest.update(block)
|
||||
if os.name != "nt":
|
||||
path.chmod(0o600)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def stream_digest(path: Path) -> str:
|
||||
digest = hashlib.sha256()
|
||||
with path.open("rb") as file:
|
||||
while chunk := file.read(1024 * 1024):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def prepare_runtime(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
*,
|
||||
agent_name: str = AGENT_NAME,
|
||||
) -> tuple[Path, Path]:
|
||||
home = tmp_path / "home"
|
||||
root = home / ".elydora"
|
||||
agent = root / AGENT_ID
|
||||
set_home(monkeypatch, home)
|
||||
write_json(
|
||||
agent / "config.json",
|
||||
{"agent_id": AGENT_ID, "agent_name": agent_name},
|
||||
)
|
||||
return root, agent
|
||||
|
||||
|
||||
def uninstall_args(agent_name: str = AGENT_NAME) -> argparse.Namespace:
|
||||
return cli.build_parser().parse_args(
|
||||
[
|
||||
"uninstall",
|
||||
"--agent",
|
||||
agent_name,
|
||||
"--agent_id",
|
||||
AGENT_ID,
|
||||
]
|
||||
)
|
||||
Reference in new issue
Block a user