4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
65 lines
2.0 KiB
Python
65 lines
2.0 KiB
Python
"""Tools and tasks-related API methods and models."""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from integrations.tracer.tracer_client_base import TracerClientBase
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class TracerTaskResult:
|
|
"""Result from get_run_tasks."""
|
|
|
|
found: bool
|
|
total_tasks: int = 0
|
|
failed_tasks: int = 0
|
|
completed_tasks: int = 0
|
|
tasks: list[dict] | None = None
|
|
failed_task_details: list[dict] | None = None
|
|
|
|
|
|
class TracerToolsMixin(TracerClientBase):
|
|
"""Mixin for Tracer tools and tasks-related API methods."""
|
|
|
|
def get_run_tasks(self, run_id: str) -> TracerTaskResult:
|
|
"""Get tasks from /api/tools endpoint."""
|
|
data = self._get(f"/api/tools/{run_id}", {"orgId": self.org_id})
|
|
|
|
if not data.get("success") or not data.get("data"):
|
|
return TracerTaskResult(found=False)
|
|
|
|
tasks = []
|
|
failed_details = []
|
|
for row in data["data"]:
|
|
task = {
|
|
"tool_name": row.get("tool_name", ""),
|
|
"exit_code": row.get("exit_code"),
|
|
"runtime_ms": float(row.get("runtime_ms", 0) or 0),
|
|
}
|
|
tasks.append(task)
|
|
|
|
exit_code = row.get("exit_code")
|
|
if exit_code and exit_code not in ("0", "", None):
|
|
failed_details.append(
|
|
{
|
|
**task,
|
|
"tool_cmd": row.get("tool_cmd", ""),
|
|
"reason": row.get("reason"),
|
|
"explanation": row.get("explanation"),
|
|
}
|
|
)
|
|
|
|
return TracerTaskResult(
|
|
found=True,
|
|
total_tasks=len(tasks),
|
|
failed_tasks=len(failed_details),
|
|
completed_tasks=len(tasks) - len(failed_details),
|
|
tasks=tasks,
|
|
failed_task_details=failed_details,
|
|
)
|
|
|
|
def get_tools(self, trace_id: str) -> dict:
|
|
"""Fetch tools for a trace from /api/tools/[traceId]."""
|
|
params: dict[str, str] = {}
|
|
data = self._get(f"/api/tools/{trace_id}", params)
|
|
return data
|