chore: import upstream snapshot with attribution
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

This commit is contained in:
wehub-resource-sync
2026-07-13 13:10:45 +08:00
commit 4b6817381b
3933 changed files with 525247 additions and 0 deletions
@@ -0,0 +1,72 @@
"""Sentry issue and event investigation tools."""
from __future__ import annotations
from typing import Any
from core.tool_framework.tool_decorator import tool
from integrations.sentry import get_sentry_issue
from integrations.sentry.tools.sentry_search_issues_tool import (
_resolve_config,
_sentry_available,
_sentry_creds,
)
def _issue_details_available(sources: dict[str, dict]) -> bool:
return bool(_sentry_available(sources) and sources.get("sentry", {}).get("issue_id"))
def _issue_details_extract_params(sources: dict[str, dict]) -> dict[str, Any]:
sentry = sources["sentry"]
return {
**_sentry_creds(sentry),
"issue_id": sentry["issue_id"],
}
@tool(
name="get_sentry_issue_details",
source="sentry",
description="Fetch full details for a Sentry issue.",
use_cases=[
"Inspecting the main error group linked to an alert",
"Reviewing culprit, level, and regression details",
"Understanding whether an incident matches an existing issue",
],
requires=["organization_slug", "sentry_token", "issue_id"],
input_schema={
"type": "object",
"properties": {
"organization_slug": {"type": "string"},
"sentry_token": {"type": "string"},
"issue_id": {"type": "string"},
"sentry_url": {"type": "string", "default": ""},
"project_slug": {"type": "string", "default": ""},
},
"required": ["organization_slug", "sentry_token", "issue_id"],
},
injected_params=("organization_slug", "sentry_token", "sentry_url"),
is_available=_issue_details_available,
extract_params=_issue_details_extract_params,
surfaces=("investigation", "chat"),
)
def get_sentry_issue_details(
organization_slug: str,
sentry_token: str,
issue_id: str,
sentry_url: str = "",
project_slug: str = "",
) -> dict[str, Any]:
"""Fetch full details for a Sentry issue."""
config = _resolve_config(sentry_url, organization_slug, sentry_token, project_slug)
if config is None:
return {
"source": "sentry",
"available": False,
"error": "Sentry integration is not configured.",
"issue": {},
}
issue = get_sentry_issue(config=config, issue_id=issue_id)
return {"source": "sentry", "available": True, "issue": issue}
@@ -0,0 +1,75 @@
"""Sentry issue and event investigation tools."""
from __future__ import annotations
from typing import Any
from core.tool_framework.tool_decorator import tool
from integrations.sentry import list_sentry_issue_events as sentry_list_issue_events
from integrations.sentry.tools.sentry_search_issues_tool import (
_resolve_config,
_sentry_available,
_sentry_creds,
)
def _issue_events_available(sources: dict[str, dict]) -> bool:
return bool(_sentry_available(sources) and sources.get("sentry", {}).get("issue_id"))
def _issue_events_extract_params(sources: dict[str, dict]) -> dict[str, Any]:
sentry = sources["sentry"]
return {
**_sentry_creds(sentry),
"issue_id": sentry["issue_id"],
"limit": 10,
}
@tool(
name="list_sentry_issue_events",
source="sentry",
description="List recent events for a Sentry issue.",
use_cases=[
"Reviewing the latest stack traces attached to an issue",
"Checking whether new events appeared during an incident window",
"Comparing repeated failures grouped under the same issue",
],
requires=["organization_slug", "sentry_token", "issue_id"],
input_schema={
"type": "object",
"properties": {
"organization_slug": {"type": "string"},
"sentry_token": {"type": "string"},
"issue_id": {"type": "string"},
"sentry_url": {"type": "string", "default": ""},
"project_slug": {"type": "string", "default": ""},
"limit": {"type": "integer", "default": 10},
},
"required": ["organization_slug", "sentry_token", "issue_id"],
},
injected_params=("organization_slug", "sentry_token", "sentry_url"),
is_available=_issue_events_available,
extract_params=_issue_events_extract_params,
surfaces=("investigation", "chat"),
)
def list_sentry_issue_events(
organization_slug: str,
sentry_token: str,
issue_id: str,
sentry_url: str = "",
project_slug: str = "",
limit: int = 10,
) -> dict[str, Any]:
"""List recent events for a Sentry issue."""
config = _resolve_config(sentry_url, organization_slug, sentry_token, project_slug)
if config is None:
return {
"source": "sentry",
"available": False,
"error": "Sentry integration is not configured.",
"events": [],
}
events = sentry_list_issue_events(config=config, issue_id=issue_id, limit=limit)
return {"source": "sentry", "available": True, "events": events}
@@ -0,0 +1,164 @@
"""Sentry issue and event investigation tools."""
from __future__ import annotations
from typing import Any
import httpx
from core.tool_framework.telemetry import report_run_error
from core.tool_framework.tool_decorator import tool
from integrations.sentry import (
DEFAULT_SENTRY_ISSUE_LIMIT,
SentryConfig,
build_sentry_config,
describe_sentry_api_error,
list_sentry_issues,
sentry_config_from_env,
)
def _resolve_config(
sentry_url: str | None,
organization_slug: str | None,
sentry_token: str | None,
project_slug: str | None = None,
) -> SentryConfig | None:
env_config = sentry_config_from_env()
config = build_sentry_config(
{
"base_url": sentry_url or (env_config.base_url if env_config else ""),
"organization_slug": organization_slug
or (env_config.organization_slug if env_config else ""),
"auth_token": sentry_token or (env_config.auth_token if env_config else ""),
"project_slug": project_slug or (env_config.project_slug if env_config else ""),
}
)
if not config.organization_slug or not config.auth_token:
return None
return config
def _sentry_available(sources: dict[str, dict]) -> bool:
return bool(sources.get("sentry", {}).get("connection_verified"))
def _sentry_creds(sentry: dict[str, Any]) -> dict[str, Any]:
# The resolved ``sentry`` source dict is a ``SentryConfig`` dump, so the
# credential keys are ``auth_token`` / ``base_url`` — NOT ``sentry_token`` /
# ``sentry_url`` (the tool's public param names). Map both with safe lookups
# so a config that uses either shape works and a missing key can never raise
# a KeyError that aborts the whole gather/investigation loop.
return {
"organization_slug": sentry.get("organization_slug", ""),
"sentry_token": sentry.get("sentry_token") or sentry.get("auth_token", ""),
"sentry_url": sentry.get("sentry_url") or sentry.get("base_url") or "https://sentry.io",
"project_slug": sentry.get("project_slug", ""),
}
def _search_issues_extract_params(sources: dict[str, dict]) -> dict[str, Any]:
sentry = sources["sentry"]
return {
**_sentry_creds(sentry),
"query": sentry.get("query", ""),
"limit": sentry.get("limit", DEFAULT_SENTRY_ISSUE_LIMIT),
"stats_period": sentry.get("stats_period", ""),
}
@tool(
name="search_sentry_issues",
source="sentry",
description="Search Sentry issues related to an incident or failure signature.",
use_cases=[
"Checking whether an alert maps to a known Sentry issue",
"Finding unresolved error groups for a service or environment",
"Looking up recent crash reports that match an incident symptom",
],
requires=["organization_slug", "sentry_token"],
input_schema={
"type": "object",
"properties": {
"organization_slug": {"type": "string"},
"sentry_token": {"type": "string"},
"query": {"type": "string", "default": ""},
"sentry_url": {"type": "string", "default": ""},
"project_slug": {"type": "string", "default": ""},
"limit": {"type": "integer", "default": DEFAULT_SENTRY_ISSUE_LIMIT},
"stats_period": {"type": "string", "default": ""},
},
"required": ["organization_slug", "sentry_token"],
},
injected_params=("organization_slug", "sentry_token", "sentry_url", "project_slug"),
is_available=_sentry_available,
extract_params=_search_issues_extract_params,
surfaces=("investigation", "chat"),
)
def search_sentry_issues(
organization_slug: str,
sentry_token: str,
query: str = "",
sentry_url: str = "",
project_slug: str = "",
limit: int = DEFAULT_SENTRY_ISSUE_LIMIT,
stats_period: str = "",
) -> dict[str, Any]:
"""Search Sentry issues related to an incident or failure signature."""
config = _resolve_config(sentry_url, organization_slug, sentry_token, project_slug)
if config is None:
return {
"source": "sentry",
"available": False,
"error": "Sentry integration is not configured.",
"issues": [],
}
try:
issues = list_sentry_issues(
config=config, query=query, limit=limit, stats_period=stats_period or None
)
except httpx.HTTPStatusError as err:
report_run_error(
err,
tool_name="search_sentry_issues",
source="sentry",
component="integrations.sentry.tools.sentry_search_issues_tool",
method="list_sentry_issues",
severity="warning",
extras={
"query": query,
"organization_slug": config.organization_slug,
"project_slug": config.project_slug,
"status_code": err.response.status_code,
},
)
return {
"source": "sentry",
"available": False,
"error": describe_sentry_api_error(
err,
query=query,
project_slug=config.project_slug,
),
"issues": [],
"query": query,
}
except Exception as err:
report_run_error(
err,
tool_name="search_sentry_issues",
source="sentry",
component="integrations.sentry.tools.sentry_search_issues_tool",
method="list_sentry_issues",
extras={"query": query, "organization_slug": config.organization_slug},
)
return {
"source": "sentry",
"available": False,
"error": f"Sentry issue search failed: {err}",
"issues": [],
"query": query,
}
return {"source": "sentry", "available": True, "issues": issues, "query": query}