sync update from LAN repo (source dhk-1 @ 3e87be55)
This commit is contained in:
1 parent
ab6068a7c1
commit
42f2a26fa8
1482 files changed
+227759
-9584
No files matched your search
@@ -0,0 +1,75 @@
|
||||
"""Seed the built-in latency diagnosis agent and its read-only record skill.
|
||||
|
||||
Copied only when the target is missing. An existing directory is left as-is
|
||||
so later edits in agent management are kept. Must run before
|
||||
``_sync_legacy_agents``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from deerflow.config.paths import get_paths
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LATENCY_DIAGNOSIS_AGENT_ID = "latency-diagnosis"
|
||||
LATENCY_DIAGNOSIS_SKILL_NAME = "latency-diagnosis"
|
||||
|
||||
_ASSETS_DIR = Path(__file__).parent / "_latency_diagnosis_seed_assets"
|
||||
_AGENT_FILES: tuple[str, ...] = ("config.yaml", "SOUL.md")
|
||||
|
||||
|
||||
def _ensure_skill() -> None:
|
||||
try:
|
||||
from deerflow.skills.storage import get_or_new_skill_storage
|
||||
|
||||
public_dir = Path(get_or_new_skill_storage().get_skills_root_path()) / "public"
|
||||
public_dir.mkdir(parents=True, exist_ok=True)
|
||||
source = _ASSETS_DIR / "skills" / LATENCY_DIAGNOSIS_SKILL_NAME
|
||||
target = public_dir / LATENCY_DIAGNOSIS_SKILL_NAME
|
||||
if target.exists():
|
||||
return
|
||||
if not (source / "SKILL.md").is_file():
|
||||
logger.error("Missing latency-diagnosis skill seed at %s", source)
|
||||
return
|
||||
shutil.copytree(source, target)
|
||||
logger.info("Seeded public skill '%s'", LATENCY_DIAGNOSIS_SKILL_NAME)
|
||||
except Exception:
|
||||
logger.exception("Failed to seed latency-diagnosis skill")
|
||||
|
||||
|
||||
def _ensure_agent() -> bool:
|
||||
try:
|
||||
target = get_paths().agent_dir(LATENCY_DIAGNOSIS_AGENT_ID)
|
||||
if target.exists():
|
||||
return False
|
||||
source = _ASSETS_DIR / LATENCY_DIAGNOSIS_AGENT_ID
|
||||
if not source.is_dir():
|
||||
logger.error("Missing latency-diagnosis agent seed at %s", source)
|
||||
return False
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
for filename in _AGENT_FILES:
|
||||
asset = source / filename
|
||||
if asset.is_file():
|
||||
(target / filename).write_bytes(asset.read_bytes())
|
||||
logger.info("Seeded built-in agent '%s'", LATENCY_DIAGNOSIS_AGENT_ID)
|
||||
return True
|
||||
except Exception:
|
||||
logger.exception("Failed to seed latency-diagnosis agent")
|
||||
return False
|
||||
|
||||
|
||||
def ensure_latency_diagnosis_agent() -> bool:
|
||||
"""Seed the diagnosis agent and its record-reading skill once."""
|
||||
_ensure_skill()
|
||||
return _ensure_agent()
|
||||
|
||||
|
||||
__all__ = [
|
||||
"LATENCY_DIAGNOSIS_AGENT_ID",
|
||||
"LATENCY_DIAGNOSIS_SKILL_NAME",
|
||||
"ensure_latency_diagnosis_agent",
|
||||
]
|
||||
Reference in new issue
Block a user