Initial commit of integrated agent system

This commit is contained in:
cillin
2026-03-30 17:46:44 +08:00
commit 0fa413380c
337 changed files with 75268 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
"""Runtime service client for lifecycle and gateway operations."""
from __future__ import annotations
import httpx
class RuntimeServiceClient:
"""Async client for the runtime-service API surface."""
def __init__(self, base_url: str = "http://localhost:8003/api/runtime"):
self.base_url = base_url.rstrip("/")
self._client: httpx.AsyncClient | None = None
async def __aenter__(self) -> "RuntimeServiceClient":
self._client = httpx.AsyncClient(base_url=self.base_url, timeout=30.0)
return self
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
if self._client:
await self._client.aclose()
async def fetch_context(self) -> dict:
response = await self._client.get("/context")
response.raise_for_status()
return response.json()
async def fetch_agents(self) -> dict:
response = await self._client.get("/agents")
response.raise_for_status()
return response.json()
async def fetch_events(self) -> dict:
response = await self._client.get("/events")
response.raise_for_status()
return response.json()
async def fetch_gateway_port(self) -> dict:
response = await self._client.get("/gateway/port")
response.raise_for_status()
return response.json()
async def start_runtime(self, config: dict) -> dict:
response = await self._client.post("/start", json=config)
response.raise_for_status()
return response.json()
async def stop_runtime(self, *, force: bool = True) -> dict:
response = await self._client.post(f"/stop?force={str(force).lower()}")
response.raise_for_status()
return response.json()
async def restart_runtime(self, config: dict) -> dict:
response = await self._client.post("/restart", json=config)
response.raise_for_status()
return response.json()
async def fetch_current_runtime(self) -> dict:
response = await self._client.get("/current")
response.raise_for_status()
return response.json()
async def get_runtime_config(self) -> dict:
response = await self._client.get("/config")
response.raise_for_status()
return response.json()
async def update_runtime_config(self, config: dict) -> dict:
response = await self._client.put("/config", json=config)
response.raise_for_status()
return response.json()