Tool API

API endpoints for managing and interacting with the Agent's tool system.

Component Management

List Components

GET /api/components
Response: {
  "components": [
    {
      "cell_name": "web_fetch",
      "class": "WebFetch",
      "commands": ["navigate", "get_screenshot"],
      "command_count": 5,
      "source_file": "components/web_fetch.py"
    }
  ]
}

Scan Components

GET /api/components/scan
Response: {
  "found": ["web_fetch", "weather"],
  "loaded": ["web_fetch"]
}

Reload Component

POST /api/components/reload
Response: { "status": "ok" }

Load Component

POST /api/components/{name}/load
Body: { "cell_name": "web_fetch" }
Response: { "status": "ok", "message": "组件 [name] 已加载" }

Unload Component

DELETE /api/components/{name}
Response: { "status": "ok", "message": "组件 [name] 已卸载" }

Discover & Load

POST /api/components/discover-and-load
Response: { "status": "ok", "message": "...", "loaded": ["web_fetch"] }

Get Rules

GET /api/components/rules
Response: {
  "rules": {
    "safe_commands": ["ls", "cat", ...],
    "dangerous_patterns": ["rm -rf", ...]
  }
}

Skill Management

List Skills

GET /api/skills
Response: {
  "skills": [
    {
      "name": "skill-name",
      "version": "1.0",
      "description": "..."
    }
  ]
}

Get Skill

GET /api/skills/{name}
Response: { "name": "...", "version": "1.0", "description": "..." }

Search Skills

POST /api/skills/search
Body: { "query": "web", "limit": 10 }
Response: { "results": [...], "total": 1 }

Install Skill

POST /api/skills/install
Content-Type: multipart/form-data
Body: archive file (field name: archive, .zip/.tar.gz)
Response: { "success": true, "name": "skill-name" }

Uninstall Skill

DELETE /api/skills/{name}
Response: { "success": true }

Refresh Index

POST /api/skills/refresh-index
Response: { "success": true, "indexed": 10 }