{
  "schemaVersion": "agent9-managed-tool-package-v1",
  "name": "managed_auto_oncall_clinic",
  "version": 33,
  "description": "Clinic-backed read-only evidence Tool for a bounded batch of ticket-bound TiDB Cloud and TiCDC metadata, selected current configuration, metrics, TopSQL, Slow Query, Data Proxy system-observability SQL, logs, and activities. Configuration uses Clinic first and DevOps CloudConfig only as a fallback; credentials remain inside its isolated Tool Sandbox.",
  "parameters": {
    "type": "object",
    "additionalProperties": false,
    "required": ["issueKey", "orgId", "queries"],
    "properties": {
      "issueKey": {
        "type": "string",
        "pattern": "^(ST|TCID)-[0-9]+$"
      },
      "orgId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128
      },
      "queries": {
        "type": "array",
        "minItems": 1,
        "maxItems": 12,
        "description": "One bounded Evidence acquisition batch. The Tool executes independent entries with a concurrency limit of six and preserves one result or safe error per queryId.",
        "items": {
          "type": "object",
          "additionalProperties": false,
          "required": ["clusterId", "queryId", "operation"],
          "properties": {
            "clusterId": { "type": "string", "minLength": 1, "maxLength": 128 },
            "queryId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "description": "Stable semantic objective id, unique within this batch. Reuse it only in a later correction batch for the same objective."
            },
            "changefeedDisplayId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$",
              "description": "TiCDC architecture evidence only. Exact business-facing changefeed display ID from the ticket or runner-owned context."
            },
            "operation": {
              "enum": [
                "cluster_detail", "components", "metrics_query", "metrics_query_range",
                "topsql", "sql_query", "slow_query", "logs_query_range", "activities",
                "ticdc_changefeeds_list", "ticdc_changefeed_architecture_evidence", "configuration"
              ]
            },
            "configKeys": {
              "type": "array",
              "minItems": 1,
              "maxItems": 16,
              "description": "Configuration only. Put every requested key in this one array as an object such as {\"component\":\"pd\",\"key\":\"schedule.max-snapshot-count\"}; never pass strings, include the component in key, split keys across Tool calls, or call CloudConfig yourself. The helper queries Clinic first and falls back internally to CloudConfig for rejected or missing keys. No mutation is available.",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": ["component", "key"],
                "properties": {
                  "component": { "enum": ["pd", "tikv", "tidb", "tidb_variable"] },
                  "key": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$" }
                }
              }
            },
            "query": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192,
              "description": "PromQL or Loki query. For a backward-compatible sql_query call only, the Tool normalizes query to sql when sql is absent; never send both fields."
            },
            "sql": {
              "type": "string",
              "minLength": 1,
              "maxLength": 12000,
              "description": "Single read-only, date-partition-bounded Data Proxy SQL statement. Data Proxy validates supported logical tables; exact unqualified statements is normalized to clinic_data_proxy.statements."
            },
            "start": { "type": "integer" },
            "end": { "type": "integer" },
            "time": { "type": "integer" },
            "step": { "type": "integer", "minimum": 15, "maximum": 3600 },
            "limit": { "type": "integer", "minimum": 1, "maximum": 500 },
            "timeoutSeconds": { "type": "integer", "minimum": 1, "maximum": 120 },
            "includeSqlText": {
              "type": "boolean",
              "description": "TopSQL/Slow Query result projection. Defaults to false for broad lists and true for Digest-selected detail. Use true for bounded target-SQL matching or a load-bearing candidate detail; broad workload/latency lists need only Digests and metrics."
            },
            "digest": { "type": "string", "pattern": "^[a-fA-F0-9]{6,64}$" },
            "planDigest": { "type": "string", "pattern": "^[a-fA-F0-9]{6,64}$" },
            "component": { "enum": ["tidb", "tikv"] },
            "instance": {
              "type": "string",
              "minLength": 3,
              "maxLength": 300,
              "pattern": "^(?:[A-Za-z0-9][A-Za-z0-9._-]*:[0-9]{1,5}|Ti(?:DB|KV)-[0-9]+)$"
            },
            "rankBy": {
              "enum": [
                "cpu_ms", "exec_count", "avg_latency_ms", "read_keys", "write_keys",
                "logical_read_bytes", "logical_write_bytes", "network_in_bytes", "network_out_bytes"
              ]
            },
            "measures": {
              "type": "array",
              "maxItems": 4,
              "items": {
                "enum": [
                  "cpu_ms", "exec_count", "avg_latency_ms", "read_keys", "write_keys",
                  "logical_read_bytes", "logical_write_bytes", "network_in_bytes", "network_out_bytes"
                ]
              }
            },
            "orderBy": {
              "enum": ["query_time", "memory_max", "process_time", "wait_time", "backoff_time", "total_keys"]
            },
            "desc": { "type": "boolean" },
            "direction": { "enum": ["forward", "backward"] },
            "markers": {
              "type": "array",
              "maxItems": 8,
              "items": { "type": "string", "minLength": 1, "maxLength": 64 }
            },
            "detailLevel": {
              "enum": ["summary", "events"],
              "description": "Logs only. summary returns bounded counts and timestamps; events additionally returns allowlisted typed event groups without raw log lines."
            },
            "catalog": { "type": "string", "minLength": 1, "maxLength": 128 },
            "activityType": { "type": "string", "minLength": 1, "maxLength": 128 },
            "name": { "type": "string", "minLength": 1, "maxLength": 128 },
            "severity": { "type": "integer" }
          }
        }
      }
    }
  },
  "effect": "read",
  "entrypoint": "index.mjs",
  "secretEnv": ["CLINIC_API_KEY", "DEVOPS_API_TOKEN"],
  "timeoutMs": 120000,
  "maxOutputBytes": 1048576,
  "network": {
    "mode": "restricted",
    "allowedHosts": ["clinic.pingcap.com", "prod.devops.pingcap.com"]
  },
  "egress": []
}
