Skill: agenticio/bot (version 2.1.0)

--- name: bot description: > The Universal Autonomous Entity Standard. A local-first framework for observable, composable agents with policy-guarded execution on ClawHub. --- # BOT: Standardized Agent Framework bot is a local-first agent framework for observable execution, composable tool use, and multi-agent orchestration. ## Safety Model - Network: Core demos do not initiate outbound network requests by default. - Execution: This release provides policy-guarded local execution, not OS-level sandbox isolation. - File System: Local memory is stored in `./.bot_memory/` by default, configurable via `BOT_MEMORY_DIR`. - Viewer: Optional local monitor binds to `127.0.0.1` only when explicitly started. - Credentials: No external API keys required for core demos. ## Included Capabilities - Single-agent reasoning core - Botfile static declaration - TUI thought visualization - Crypto identity and signing - Multi-agent coordination - Local Web thought-tree viewer - Unified local run entrypoint - Capability-aware tool registration - Policy-guarded execution layer ## Quick Start ```bash PYTHONPATH=. python3 examples/run_bot.py --mode multi --prompt "Design a safe local-first agent workflow" ``` ## Custom Roles ```bash PYTHONPATH=. python3 examples/run_bot.py --mode multi --roles "planner_bot,critic_bot,executor_bot,auditor_bot" ``` ## Single-Agent Mode ```bash PYTHONPATH=. python3 examples/run_bot.py --mode single --prompt "Summarize this task safely" ``` Then open: - http://127.0.0.1:8765

path: examples/hello_agent.py
content: from src.core.reasoning import AgentCore
from src.protocol.identity import generate_agent_id

agent_id = generate_agent_id()
agent = AgentCore(identity=agent_id)
result = agent.think("Hello World Task")
print(f"Agent ID: {agent_id}")
print(result)


path: examples/multi_agent_demo.py
content: from src.core.reasoning import AgentCore
from src.core.multi_agent import MultiAgentCoordinator
from src.web.thought_tree import serve_thought_tree

def main():
    agent_a = AgentCore(identity="planner_bot")
    agent_b = AgentCore(identity="critic_bot")
    agent_c = AgentCore(identity="executor_bot")

    coordinator = MultiAgentCoordinator([agent_a, agent_b, agent_c])

    result = coordinator.run_task("Design a safe local-first agent workflow")
    print("Multi-agent result generated.")
    print("Launching web view...")
    serve_thought_tree(result)

if __name__ == "__main__":
    main()


path: examples/policy_demo.py
content: from src.protocol.alignment import AgentAlignment
from src.tools.registry import ToolRegistry
from src.tools.policy_executor import PolicyExecutor

def local_sum(a, b):
    return a + b

def main():
    alignment = AgentAlignment(mode="strict")
    registry = ToolRegistry()
    executor = PolicyExecutor(allow_network=False)

    registry.register(
        "local_sum",
        local_sum,
        capabilities=["local_compute"],
        description="Add two numbers locally"
    )

    tool = registry.get("local_sum")
    alignment.verify_capabilities(tool["capabilities"])

    result = executor.execute(tool["func"], 2, 3)
    print("Policy demo result:", result)
    print("Registered tools:", registry.list_tools())

if __name__ == "__main__":
    main()


path: examples/run_bot.py
content: import argparse

from src.core.reasoning import AgentCore
from src.core.multi_agent import MultiAgentCoordinator
from src.web.thought_tree import serve_thought_tree

def main():
    parser = argparse.ArgumentParser(description="Run bot in single-agent or multi-agent mode")
    parser.add_argument("--mode", choices=["single", "multi"], default="multi")
    parser.add_argument("--prompt", default="Design a safe local-first agent workflow")
    parser.add_argument("--roles", default="planner_bot,critic_bot,executor_bot")
    args = parser.parse_args()

    if args.mode == "single":
        agent = AgentCore(identity="solo_bot")
        result = {
            "prompt": args.prompt,
            "agents": [
                {
                    "agent": agent.identity,
                    "result": agent.think(args.prompt)
                }
            ],
            "thought_tree": {
                "id": "root",
                "label": "Single-Agent Task",
                "prompt": args.prompt,
                "children": [
                    {
                        "id": "agent_1",
                        "label": agent.identity,
                        "thoughts": agent.think(args.prompt).get("thought_process", []),
                        "confidence": agent.think(args.prompt).get("confidence_score", 0.0),
                        "children": []
                    }
                ]
            }
        }
    else:
        roles = [r.strip() for r in args.roles.split(",") if r.strip()]
        agents = [AgentCore(identity=role) for role in roles]
        coordinator = MultiAgentCoordinator(agents)
        result = coordinator.run_task(args.prompt)

    print("BOT run generated.")
    print("Launching web view...")
    serve_thought_tree(result)

if __name__ == "__main__":
    main()


path: install.sh
content: #!/bin/bash
set -e

echo "BOT install: local Python dependencies only."
echo "Recommended: run inside a virtual environment."
echo "Example:"
echo "  python3 -m venv .venv && source .venv/bin/activate"

pip install -r requirements.txt

echo "Install complete."


path: requirements.txt
content: pydantic>=2,<3
jsonschema>=4,<5
rich>=13,<14
cryptography>=42,<43
PyYAML>=6,<7


path: src/core/multi_agent.py
content: from typing import List, Dict, Any

class MultiAgentCoordinator:
    def __init__(self, agents: List[Any]):
        self.agents = agents

    def run_task(self, prompt: str) -> Dict[str, Any]:
        steps = []
        agent_results = []

        for idx, agent in enumerate(self.agents, start=1):
            result = agent.think(f"[Agent {idx}] {prompt}")
            agent_results.append({
                "agent": agent.identity,
                "result": result
            })
            steps.append({
                "id": f"agent_{idx}",
                "label": agent.identity,
                "thoughts": result.get("thought_process", []),
                "confidence": result.get("confidence_score", 0.0),
                "children": []
            })

        tree = {
            "id": "root",
            "label": "Multi-Agent Task",
            "prompt": prompt,
            "children": steps
        }

        return {
            "prompt": prompt,
            "agents": agent_results,
            "thought_tree": tree
        }


path: src/core/perception.py
content: class Perception:
    def analyze_text(self, text: str) -> str:
        return f"Text analysis result: {text[:50]}..."

    def analyze_image(self, image_path: str) -> str:
        return f"Image analysis placeholder for: {image_path}"


path: src/core/reasoning.py
content: from typing import List

class AgentCore:
    def __init__(self, identity: str):
        self.identity = identity

    def think(self, prompt: str) -> dict:
        # 模拟递归链式思考
        thought_process = [f"Analyzing: {prompt}", "Generating insights..."]
        return {
            "thought_process": thought_process,
            "confidence_score": 0.95,
            "action_required": False,
            "payload": {}
        }

# 可选：与 TUI 联动展示思考流
def think_with_tui(self, prompt: str, tui=None) -> dict:
    result = self.think(prompt)
    if tui:
        tui.display_thought(result["thought_process"])
    return result

def think_with_signature(self, prompt: str, crypto=None) -> dict:
    """
    生成思考结果并附带 Crypto 身份签名
    """
    result = self.think(prompt)
    if crypto:
        message = str(result).encode("utf-8")
        signature = crypto.sign(message)
        result["signature"] = signature.hex()
        result["public_key"] = crypto.serialize_public()
    return result


path: src/protocol/alignment.py
content: class AgentAlignment:
    def __init__(self, mode="strict"):
        self.mode = mode
        self.allowed_capabilities = [
            "local_compute",
            "read_memory",
            "write_memory",
            "render_local_view"
        ]

    def verify_action(self, action_intent: dict):
        if action_intent.get("requires_network") and self.mode == "strict":
            raise Exception("Network access denied by alignment policy.")
        return True

    def verify_capabilities(self, capabilities):
        for cap in capabilities:
            if cap not in self.allowed_capabilities:
                raise Exception(f"Capability denied by alignment policy: {cap}")
        return True


path: src/protocol/crypto_identity.py
content: from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.primitives import serialization

class CryptoIdentity:
    def __init__(self):
        self.private_key = Ed25519PrivateKey.generate()
        self.public_key = self.private_key.public_key()

    def sign(self, message: bytes) -> bytes:
        """
        使用私钥对消息签名
        """
        return self.private_key.sign(message)

    def serialize_public(self) -> str:
        """
        输出公钥 hex，用于验证身份
        """
        return self.public_key.public_bytes(
            encoding=serialization.Encoding.Raw,
            format=serialization.PublicFormat.Raw
        ).hex()


path: src/protocol/identity.py
content: import uuid

def generate_agent_id() -> str:
    return f"bot_{uuid.uuid4().hex[:8]}"


path: src/protocol/memory.py
content: import json
import os

MEMORY_PATH = os.environ.get("BOT_MEMORY_DIR", os.path.abspath(".bot_memory"))
os.makedirs(MEMORY_PATH, exist_ok=True)

def save_memory(agent_id: str, data: dict):
    path = os.path.join(MEMORY_PATH, f"{agent_id}.json")
    with open(path, "w", encoding="utf-8") as f:
        json.dump(data, f, indent=2, ensure_ascii=False)

def load_memory(agent_id: str):
    path = os.path.join(MEMORY_PATH, f"{agent_id}.json")
    if os.path.exists(path):
        with open(path, "r", encoding="utf-8") as f:
            return json.load(f)
    return {}


path: src/tools/botfile.py
content: import yaml

class Botfile:
    def __init__(self, path):
        with open(path, "r") as f:
            self.data = yaml.safe_load(f)

    def get_identity(self):
        return self.data.get("IDENTITY", "unknown_agent")

    def get_tools(self):
        return self.data.get("EQUIP", [])

    def get_permissions(self):
        return self.data.get("GRANT", []), self.data.get("DENY", [])


path: src/tools/policy_executor.py
content: class PolicyExecutor:
    """
    Policy-guarded local executor.
    This is not OS-level sandboxing. It provides local policy checks only.
    """
    def __init__(self, allow_network=False):
        self.allow_network = allow_network

    def verify_callable(self, func):
        if not callable(func):
            raise TypeError("Provided tool is not callable")
        return True

    def execute(self, func, *args, **kwargs):
        self.verify_callable(func)
        return func(*args, **kwargs)


path: src/tools/registry.py
content: class ToolRegistry:
    def __init__(self):
        self.tools = {}

    def register(self, name: str, func, capabilities=None, description=""):
        self.tools[name] = {
            "func": func,
            "capabilities": capabilities or [],
            "description": description
        }

    def get(self, name: str):
        return self.tools.get(name)

    def list_tools(self):
        return {
            name: {
                "capabilities": meta["capabilities"],
                "description": meta["description"]
            }
            for name, meta in self.tools.items()
        }


path: src/tools/tui.py
content: from rich.console import Console
from rich.panel import Panel

console = Console()

def display_thought(thought_process):
    """
    在终端展示 Agent 的 Chain of Thought
    """
    panel = Panel("\n".join(thought_process), title="Agent CoT")
    console.print(panel)

def display_tools(tools):
    """
    在终端展示当前注册的工具
    """
    panel = Panel(", ".join(tools), title="Registered Tools")
    console.print(panel)


path: src/web/thought_tree.py
content: import json
import html
from http.server import BaseHTTPRequestHandler, HTTPServer

HTML_TEMPLATE = """
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>BOT Thought Tree</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
    body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0; padding: 24px; background: #0b1020; color: #e5e7eb; }
    .wrap { max-width: 1180px; margin: 0 auto; }
    .hero { background: linear-gradient(135deg, #111827, #172554); border: 1px solid #243056; border-radius: 20px; padding: 24px; margin-bottom: 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
    .hero h1 { margin: 0 0 8px 0; font-size: 32px; }
    .muted { color: #94a3b8; }
    .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
    .stat { background: #121933; border: 1px solid #243056; border-radius: 16px; padding: 16px; }
    .stat .label { color: #94a3b8; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
    .stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
    .card { background: #121933; border: 1px solid #243056; border-radius: 16px; padding: 20px; margin-bottom: 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
    h2, h3 { margin-top: 0; }
    .node { margin-left: 18px; padding-left: 16px; border-left: 2px solid #334155; margin-top: 14px; }
    .pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #1d4ed8; color: white; font-size: 12px; margin-left: 8px; }
    ul { margin-top: 8px; }
    pre { background: #0f172a; border-radius: 10px; padding: 14px; overflow-x: auto; border: 1px solid #243056; }
  </style>
</head>
<body>
  <div class="wrap">
    <div class="hero">
      <h1>BOT Monitor</h1>
      <div class="muted">Prompt: __PROMPT__</div>
      <div class="stats">
        <div class="stat">
          <div class="label">Mode</div>
          <div class="value">__MODE__</div>
        </div>
        <div class="stat">
          <div class="label">Agents</div>
          <div class="value">__AGENT_COUNT__</div>
        </div>
        <div class="stat">
          <div class="label">Viewer</div>
          <div class="value">Local</div>
        </div>
      </div>
    </div>

    <div class="card">
      <h2>Tree View</h2>
      __TREE_HTML__
    </div>

    <div class="card">
      <h2>Raw JSON</h2>
      <pre>__RAW_JSON__</pre>
    </div>
  </div>
</body>
</html>
"""

def render_node(node):
    label = html.escape(str(node.get("label", "unknown")))
    confidence = node.get("confidence", None)
    thoughts = node.get("thoughts", [])
    children = node.get("children", [])

    confidence_html = ""
    if confidence is not None:
        confidence_html = f'<span class="pill">confidence: {confidence}</span>'

    thoughts_html = ""
    if thoughts:
        items = "".join(f"<li>{html.escape(str(t))}</li>" for t in thoughts)
        thoughts_html = f"<ul>{items}</ul>"

    children_html = ""
    if children:
        children_html = "".join(render_node(child) for child in children)

    return f'''
    <div class="node">
      <h3>{label}{confidence_html}</h3>
      {thoughts_html}
      {children_html}
    </div>
    '''

class ThoughtTreeHandler(BaseHTTPRequestHandler):
    data = {}

    def do_GET(self):
        if self.path not in ("/", "/index.html"):
            self.send_response(404)
            self.end_headers()
            self.wfile.write(b"Not Found")
            return

        prompt = html.escape(str(self.data.get("prompt", "")))
        tree = self.data.get("thought_tree", {})
        agents = self.data.get("agents", [])
        mode = "Multi-Agent" if len(agents) > 1 else "Single-Agent"
        tree_html = render_node(tree) if tree else "<p>No tree data</p>"
        raw_json = html.escape(json.dumps(self.data, indent=2, ensure_ascii=False))

        page_html = (
            HTML_TEMPLATE
            .replace("__PROMPT__", prompt)
            .replace("__MODE__", mode)
            .replace("__AGENT_COUNT__", str(len(agents)))
            .replace("__TREE_HTML__", tree_html)
            .replace("__RAW_JSON__", raw_json)
        )
        page = page_html.encode("utf-8")

        self.send_response(200)
        self.send_header("Content-Type", "text/html; charset=utf-8")
        self.send_header("Content-Length", str(len(page)))
        self.end_headers()
        self.wfile.write(page)

def serve_thought_tree(data, host="127.0.0.1", port=8765):
    ThoughtTreeHandler.data = data
    server = HTTPServer((host, port), ThoughtTreeHandler)
    print(f"BOT monitor running at http://{host}:{port}")
    print("Press Ctrl+C to stop.")
    server.serve_forever()


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)