xml-pipeline/agentserver/config/template.py
dullfig 986db2e79b Implement native tools and infrastructure
Tools (18 total):
- calculate: Safe AST-based math expression evaluator
- fetch: Async HTTP with SSRF protection
- files: Sandboxed read/write/list/delete
- shell: Command execution with blocklist
- search: Web search (SerpAPI, Google, Bing)
- keyvalue: In-memory key-value store
- librarian: exist-db XML database integration
- convert: XML↔JSON conversion + XPath extraction

Infrastructure:
- CLI with run/init/check/version commands
- Config loader for organism.yaml
- Feature detection for optional dependencies
- Optional extras in pyproject.toml

LLM:
- Fixed llm_connection.py to wrap working router

WASM:
- Documented WASM listener interface
- Stub implementation for future work

MCP:
- Reddit sentiment MCP server example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 20:25:48 -08:00

112 lines
3.8 KiB
Python

"""
Configuration templates for xml-pipeline.
Generates starter organism.yaml files.
"""
def create_organism_template(name: str = "my-organism") -> str:
"""Create a starter organism.yaml configuration."""
return f'''# {name} - xml-pipeline organism configuration
# Documentation: https://github.com/yourorg/xml-pipeline
organism:
name: {name}
version: "0.1.0"
description: "A multi-agent organism"
# =============================================================================
# LLM BACKENDS
# Configure which LLM providers to use. Agents will use these for inference.
# API keys are read from environment variables.
# =============================================================================
llm_backends:
- name: primary
provider: xai # xai, anthropic, openai, ollama
model: grok-2
api_key_env: XAI_API_KEY
priority: 0 # Lower = preferred
# Uncomment to add fallback backends:
# - name: fallback
# provider: anthropic
# model: claude-3-sonnet-20240229
# api_key_env: ANTHROPIC_API_KEY
# priority: 1
# =============================================================================
# LISTENERS
# Define agents, tools, and gateways that make up your organism.
# =============================================================================
listeners:
# -----------------------------------------------------------------------------
# Example agent - an LLM-powered assistant
# -----------------------------------------------------------------------------
- name: assistant
agent: true
description: "A helpful assistant that can use tools"
prompt: |
You are a helpful assistant. You can use tools to help users.
Always be concise and accurate.
model: grok-2 # Override default model (optional)
peers:
- calculator # Can call calculator tool
- fetcher # Can call fetch tool
allowed_tools:
- calculate
- fetch
# -----------------------------------------------------------------------------
# Example tool - calculator
# -----------------------------------------------------------------------------
- name: calculator
tool: true
description: "Evaluates mathematical expressions"
handler: agentserver.tools.calculate:calculate_handler
payload_class: agentserver.tools.calculate:CalculateRequest
# -----------------------------------------------------------------------------
# Example tool - HTTP fetcher
# -----------------------------------------------------------------------------
- name: fetcher
tool: true
description: "Fetches content from URLs"
handler: agentserver.tools.fetch:fetch_handler
payload_class: agentserver.tools.fetch:FetchRequest
# =============================================================================
# OPTIONAL: WebSocket server for remote connections
# Uncomment to enable. Requires: pip install xml-pipeline[server]
# =============================================================================
# server:
# enabled: true
# host: "127.0.0.1"
# port: 8765
# =============================================================================
# OPTIONAL: Authentication for privileged operations
# Uncomment to enable. Requires: pip install xml-pipeline[auth]
# =============================================================================
# auth:
# enabled: true
# totp_secret_env: ORGANISM_TOTP_SECRET
'''
def create_minimal_template(name: str = "simple") -> str:
"""Create a minimal organism.yaml with just one agent."""
return f'''organism:
name: {name}
llm_backends:
- name: default
provider: xai
model: grok-2
api_key_env: XAI_API_KEY
listeners:
- name: assistant
agent: true
description: "A simple assistant"
prompt: "You are a helpful assistant."
'''