- 新增 app_metadata 模型、仓储与服务 - 将默认 edge 验证步骤改为由 app_metadata 驱动生成 - 新增 chat_session / chat_message 会话层模型与 chat service - 新增 demo chat API,支持会话创建、消息发送、任务确认 - 新增最小 Web Demo 页面,形成聊天式演示入口 - 增强任务报告,补充 audit_summary 与更细粒度 task_metrics - 增强 edge-agent 执行器:tcp_probe、日志时间范围过滤、进程指标与更灵活健康检查 - 更新 README 与当前进度总结,MVP 进度推进到约 94%
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import time
|
|
from typing import Any
|
|
|
|
import httpx
|
|
|
|
|
|
class HttpHealthCheckExecutor:
|
|
def execute(self, params: dict[str, Any]) -> tuple[bool, str, dict[str, Any], dict[str, Any]]:
|
|
url = params["url"]
|
|
method = str(params.get("method", "GET")).upper()
|
|
timeout_ms = int(params.get("timeout_ms", 3000))
|
|
expected_status = params.get("expected_status", 200)
|
|
body_contains = params.get("body_contains")
|
|
headers = params.get("headers", {})
|
|
started_at = time.perf_counter()
|
|
with httpx.Client(timeout=timeout_ms / 1000.0) as client:
|
|
response = client.request(method, url, headers=headers)
|
|
latency_ms = max(int((time.perf_counter() - started_at) * 1000), 0)
|
|
success = response.status_code == int(expected_status)
|
|
if success and body_contains is not None:
|
|
success = str(body_contains) in response.text
|
|
message = f"{response.status_code} {response.reason_phrase}"
|
|
data: dict[str, Any] = {
|
|
"status_code": response.status_code,
|
|
"latency_ms": latency_ms,
|
|
"method": method,
|
|
"expected_status": int(expected_status),
|
|
}
|
|
evidence = {
|
|
"response_body": response.text,
|
|
}
|
|
try:
|
|
evidence["response_json"] = json.loads(response.text)
|
|
except Exception:
|
|
pass
|
|
return success, message, data, evidence
|