### Setup and Run Tests in Development Environment (Bash) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md This script outlines the steps to set up a Python development environment for running tests. It includes creating a virtual environment, activating it, installing project dependencies from requirements files, and finally running the tests using pytest. ```bash # Create a virtual environment (recommended) python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt pip install -r requirements-dev.txt # Run tests pytest ``` -------------------------------- ### Authentication Configuration Example (YAML) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md An example of how to configure authentication settings, including JWT parameters and API key headers, within a YAML configuration file. ```yaml auth: jwt_secret_key: "your-secret-key-here" jwt_algorithm: "HS256" jwt_expiration_seconds: 3600 # 1 hour jwt_refresh_expiration_seconds: 86400 # 24 hours enable_refresh_tokens: true token_issuer: "symbiont" token_audience: "symbiont-api" api_key_header: "Authorization" ``` -------------------------------- ### Configure Symbiont Client Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Provides examples of how to configure the Symbiont client. This includes direct configuration using API key and base URL, loading configuration from a file (YAML or JSON) using `ConfigManager`, and configuring via environment variables. ```python # Direct configuration client = Client(api_key="key", base_url="http://localhost:8080/api/v1") # From config file (YAML or JSON) from symbiont.config import ConfigManager config = ConfigManager.load("config.yaml") client = Client(config=config) # From environment variables # SYMBIONT_API_KEY, SYMBIONT_BASE_URL client = Client() ``` -------------------------------- ### Install Symbiont SDK Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Installs the Symbiont Python SDK using pip. This is the first step to using the SDK in your Python environment. ```bash pip install symbiont-sdk ``` -------------------------------- ### Install Optional Dependencies for Symbiont SDK Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Provides `pip` commands to install optional dependencies for the Symbiont SDK. This includes installing the `skills` extra for SchemaPin skill signature verification and the `metrics` extra for OpenTelemetry metrics export. ```bash # For SchemaPin skill signature verification pip install symbiont-sdk[skills] # For OpenTelemetry metrics export pip install symbiont-sdk[metrics] ``` -------------------------------- ### Symbiont SDK Configuration File Example (YAML) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Provides an example of a YAML configuration file for the Symbiont SDK. This file demonstrates how to structure settings for API, authentication, database, vector, and logging. ```yaml # API Configuration api_key: "your_api_key_here" base_url: "http://localhost:8080/api/v1" timeout: 30 max_retries: 3 # Authentication Configuration auth: jwt_secret_key: "your-jwt-secret-key" jwt_algorithm: "HS256" jwt_expiration_seconds: 3600 enable_refresh_tokens: true # Database Configuration database: host: "localhost" port: 5432 database: "symbiont" username: "user" password: "password" # Vector Database Configuration vector: provider: "qdrant" host: "localhost" port: 6333 collection_name: "symbiont_vectors" vector_size: 1536 distance_metric: "cosine" # Logging Configuration logging: level: "INFO" enable_console: true enable_structured: false ``` -------------------------------- ### Authentication Configuration Example (Environment Variables) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Shows how to configure authentication settings using environment variables, following a specific naming convention for nested properties. ```bash SYMBIONT_AUTH_JWT_SECRET_KEY=your-secret-key SYMBIONT_AUTH_JWT_ALGORITHM=HS256 SYMBIONT_AUTH_JWT_EXPIRATION_SECONDS=3600 SYMBIONT_AUTH_ENABLE_REFRESH_TOKENS=true ``` -------------------------------- ### Install Symbiont Python SDK from Repository (Development) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Installs the Symbiont Python SDK directly from its GitHub repository for development purposes. This allows access to the latest features and enables direct contributions. ```bash git clone https://github.com/thirdkeyai/symbiont-sdk-python.git cd symbiont-sdk-python pip install -e . ``` -------------------------------- ### Set up Authentication with AuthManager Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Demonstrates how to initialize the `AuthManager` with a client instance to handle JWT/RBAC authentication for Symbiont SDK operations. ```python from symbiont.auth import AuthManager auth = AuthManager(client) # JWT/RBAC authentication built in ``` -------------------------------- ### Set up Development Environment (Bash) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Provides commands to set up a local development environment for the symbiont-sdk-python project. This includes cloning the repository, creating and activating a virtual environment, and installing necessary dependencies. ```bash git clone https://github.com/yourusername/symbiont-sdk-python.git cd symbiont-sdk-python python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -r requirements.txt pip install -r requirements-dev.txt ``` -------------------------------- ### Install Development Dependencies (Bash) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Command to install the necessary development dependencies for the Symbiont SDK project, typically from a requirements file. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### List Channel Adapters with client.channels Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Shows how to list available channel adapters for integrations with platforms like Slack, Teams, and Mattermost using the `client.channels` sub-client. ```python channels = client.channels.list() ``` -------------------------------- ### Configuration Management API Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/update-plan.md APIs for managing the client configuration, including setting, getting, and reloading configuration settings. ```APIDOC ## Configuration Management API ### Description Provides methods to manage the client's configuration settings. ### Methods - **configure_client(config: ClientConfig) -> Dict[str, Any]** Configures the client with the provided configuration object. - **get_configuration() -> ClientConfig** Retrieves the current client configuration. - **reload_configuration() -> Dict[str, Any]** Reloads the client configuration, typically from a configuration file. ``` -------------------------------- ### Manage Markdown Memory Persistence Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Demonstrates how to use `MarkdownMemoryStore` for file-based agent context persistence in markdown format. Covers saving, loading, listing contexts, and performing maintenance tasks like compaction. ```python from symbiont import MarkdownMemoryStore, AgentMemoryContext store = MarkdownMemoryStore("/data/memory", retention_days=30) # Save agent context store.save_context("agent-1", AgentMemoryContext( agent_id="agent-1", facts=["User prefers dark mode", "Timezone is UTC-5"], procedures=["Always greet by name"], learned_patterns=["Responds better to bullet points"], metadata={"last_session": "2026-02-15"}, )) # Load context context = store.load_context("agent-1") # List all agents with stored contexts agents = store.list_agent_contexts() # Compact old daily logs store.compact("agent-1") # Storage statistics stats = store.get_storage_stats() ``` -------------------------------- ### Manage Symbiont Agents Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Demonstrates core agent management operations including listing, creating, checking status, and retrieving metrics for agents using the Symbiont client. ```python # List agents agents = client.list_agents() # Create an agent agent = client.create_agent({ "id": "my-agent", "name": "My Agent", "tools": ["search", "summarize"], }) # Check status status = client.get_agent_status("my-agent") # Get metrics metrics = client.get_agent_metrics("my-agent") # Execute a workflow from symbiont.models import WorkflowExecutionRequest result = client.execute_workflow(WorkflowExecutionRequest( workflow_id="wf-id", parameters={"input": "process this"}, )) ``` -------------------------------- ### Integrate AgentPin for Identity Verification Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Shows how to use the `client.agentpin` module for cryptographic agent identity verification, including key generation, JWT credential issuance, and verification (online and offline). ```python # Generate P-256 keypair keys = client.agentpin.generate_key_pair() # Issue a JWT credential jwt = client.agentpin.issue_credential( private_key_pem=keys.private_key_pem, kid="key-1", issuer="https://example.com", agent_id="my-agent", capabilities=["read", "write"], ttl_secs=3600, ) # Verify credential (online) result = client.agentpin.verify_credential(jwt) # Verify credential (offline with local discovery) result = client.agentpin.verify_credential_offline(jwt, discovery_doc) # Verify with trust bundle result = client.agentpin.verify_credential_with_bundle(jwt, bundle) # Fetch discovery document doc = client.agentpin.fetch_discovery_document("example.com") # Trust management bundle = client.agentpin.create_trust_bundle() client.agentpin.save_trust_bundle(bundle, "bundle.json") bundle = client.agentpin.load_trust_bundle("bundle.json") ``` -------------------------------- ### Collect and Export Metrics using MetricsClient Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Demonstrates how to fetch runtime metrics (snapshot, scheduler, system) using `client.metrics_client`, export them to JSON format, and utilize `FileMetricsExporter` and `CompositeExporter` for local file export. It also shows how to set up periodic background collection with `MetricsCollector`. ```python from symbiont import ( MetricsClient, FileMetricsExporter, CompositeExporter, MetricsCollector, ) # Fetch metrics from runtime API (via client) snapshot = client.metrics_client.get_metrics_snapshot() scheduler = client.metrics_client.get_scheduler_metrics() system = client.metrics_client.get_system_metrics() client.metrics_client.export_metrics({"format": "json"}) # Export metrics to file (atomic JSON write) file_exporter = FileMetricsExporter(file_path="/tmp/metrics.json") file_exporter.export(snapshot) # Fan-out to multiple backends composite = CompositeExporter([file_exporter, other_exporter]) composite.export(snapshot) # Periodic background collection collector = MetricsCollector(composite, interval_seconds=60) collector.start(fetch_snapshot_fn) collector.stop() ``` -------------------------------- ### Initialize Symbiont Client Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Initializes the Symbiont client with an API key and base URL. This client is used to interact with the Symbiont agent runtime. ```python from symbiont import Client client = Client( api_key="your-api-key", base_url="http://localhost:8080/api/v1", ) ``` -------------------------------- ### Manage Channel Adapters with Symbiont SDK Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Shows the initial setup for managing channel adapters in the Symbiont SDK for Python, including registering, updating, and mapping identities for communication platforms like Slack. This requires importing necessary classes from `symbiont.channels`. ```python from symbiont import Client from symbiont.channels import ( RegisterChannelRequest, UpdateChannelRequest, AddIdentityMappingRequest ) client = Client() ``` -------------------------------- ### Configure Symbiont SDK Storage Backends (YAML) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Shows configuration examples for different storage backends for the Symbiont SDK's memory system using YAML. It includes settings for a PostgreSQL database and specifies the storage type and connection URL for a Redis backend, enabling flexible data persistence. ```yaml # In config.yml database: host: "localhost" port: 5432 database: "symbiont_memory" username: "user" password: "password" # For Redis backend memory: storage_type: "redis" redis_url: "redis://localhost:6379/1" ``` -------------------------------- ### Interact with Qdrant Vector Database Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Shows how to use the Symbiont SDK to interact with a Qdrant vector database. This includes creating a new collection with a specified dimension, adding vectors with associated metadata, and performing semantic searches using a query vector. ```python from symbiont.models import ( CollectionCreateRequest, VectorUpsertRequest, VectorSearchRequest, ) # Create a collection client.create_vector_collection(CollectionCreateRequest( name="knowledge", dimension=384, )) # Add vectors client.add_vectors(VectorUpsertRequest( collection="knowledge", vectors=[{"id": "1", "values": [...], "metadata": {"text": "content"}}], )) # Semantic search results = client.search_vectors(VectorSearchRequest( collection="knowledge", query_vector=[...], top_k=5, )) ``` -------------------------------- ### Scan and Load Agent Skills Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Illustrates the use of `SkillScanner` and `SkillLoader` for scanning agent skill definitions for security issues (using ClawHavoc rules) and loading them from specified paths. Supports configured loading paths and security scanning. ```python from symbiont import SkillScanner, SkillLoader, SkillLoaderConfig # Scan content for security issues (10 built-in ClawHavoc rules) scanner = SkillScanner() findings = scanner.scan_content(skill_content, "SKILL.md") # Detects: pipe-to-shell, wget-pipe-to-shell, env file references, # SOUL.md/memory.md tampering, eval+fetch, base64-decode-exec, rm-rf, chmod-777 # Scan an entire skill directory result = scanner.scan_skill("/path/to/skill") # Load skills from configured paths loader = SkillLoader(SkillLoaderConfig( load_paths=["/skills/verified", "/skills/community"], require_signed=False, scan_enabled=True, )) skills = loader.load_all() # Load a single skill (reads SKILL.md, parses frontmatter, scans) skill = loader.load_skill("/path/to/skill") print(skill.name, skill.signature_status, skill.scan_result) ``` -------------------------------- ### Manage MCP Servers for Tool Integration Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Illustrates how to add, connect to, list tools and resources from, get status of, and disconnect from Model Context Protocol (MCP) servers. This is useful for integrating external tools. ```python from symbiont import Client, McpServerConfig client = Client() # Add MCP server mcp_config = McpServerConfig( name="filesystem-server", command=["npx", "@modelcontextprotocol/server-filesystem", "/tmp"], env={"NODE_ENV": "production"}, timeout_seconds=30 ) client.add_mcp_server(mcp_config) # Connect to server client.connect_mcp_server("filesystem-server") # List available tools and resources tools = client.list_mcp_tools("filesystem-server") resources = client.list_mcp_resources("filesystem-server") print(f"Tools: {[tool.name for tool in tools]}") print(f"Resources: {[resource.uri for resource in resources]}") # Get connection status connection_info = client.get_mcp_server("filesystem-server") print(f"Status: {connection_info.status}") print(f"Tools count: {connection_info.tools_count}") # Disconnect when done client.disconnect_mcp_server("filesystem-server") ``` -------------------------------- ### Manage Hierarchical Memory with Memory System Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Illustrates how to interact with the hierarchical memory system. This includes storing memories with specified types and levels, searching memories based on a query, retrieving conversation context, and consolidating memory for an agent. ```python from symbiont.models import MemoryStoreRequest, MemorySearchRequest # Store a memory client.add_memory(MemoryStoreRequest( agent_id="my-agent", content="Important fact", memory_type="fact", level="long-term", )) # Search memories results = client.search_memory(MemorySearchRequest( agent_id="my-agent", query="important", limit=10, )) # Get conversation context context = client.get_conversation_context("conv-123", "my-agent") # Consolidate memory client.consolidate_memory("my-agent") ``` -------------------------------- ### Manage Scheduled Tasks with client.schedules Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Demonstrates the usage of the `client.schedules` sub-client for managing scheduled tasks. This includes creating a new scheduled task with a cron expression and parameters, listing all existing schedules, and checking the health status of the scheduler. ```python # Create a scheduled task schedule = client.schedules.create({ "agent_id": "my-agent", "cron": "0 */6 * * *", # Every 6 hours "parameters": {"task": "cleanup"}, }) # List schedules schedules = client.schedules.list() # Scheduler health health = client.schedules.get_scheduler_health() ``` -------------------------------- ### Verify Webhook Signatures Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/SKILL.md Provides methods for verifying inbound webhook signatures from various providers like GitHub, Stripe, and Slack, or custom providers using HMAC or JWT. Includes preset providers and manual configuration. ```python from symbiont import WebhookProvider, HmacVerifier, JwtVerifier # Use a provider preset (GitHub, Stripe, Slack, Custom) verifier = WebhookProvider.GITHUB.verifier(secret=b"your-secret") verifier.verify(request.headers, request.body) # Manual HMAC verifier with prefix stripping hmac = HmacVerifier( secret=b"your-secret", header_name="X-Hub-Signature-256", prefix="sha256=", ) hmac.verify(headers, body) # JWT-based webhook verification jwt_v = JwtVerifier( secret=b"your-secret", header_name="Authorization", required_issuer="expected-issuer", ) jwt_v.verify(headers, body) ``` -------------------------------- ### Initialize Symbiont Python Client Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Demonstrates various methods for initializing the Symbiont client, including using environment variables, explicit parameters, configuration objects, and configuration files. ```python from symbiont import Client, ClientConfig, AuthConfig # Initialize with environment variables (reads SYMBIONT_API_KEY, SYMBIONT_BASE_URL) client = Client() # Initialize with explicit parameters client = Client( api_key="your_api_key", base_url="http://localhost:8080/api/v1" ) # Initialize with configuration object config = ClientConfig( api_key="your_api_key", base_url="http://localhost:8080/api/v1", timeout=30, max_retries=3 ) client = Client(config=config) # Initialize from config file client = Client(config="config.yml") ``` -------------------------------- ### Agent Management Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md APIs for listing, getting status, and creating agents. ```APIDOC ## Agent Management ### Description APIs for listing, getting status, and creating agents. ### Methods - `list_agents()` - `get_agent_status(agent_id: str)` - `create_agent(agent_data: Agent)` ### Request Example ```python # Get list of all agents agents = client.list_agents() print(f"Found {len(agents)} agents: {agents}") # Get specific agent status from symbiont import AgentState status = client.get_agent_status("agent-123") print(f"Agent {status.agent_id} is {status.state}") print(f"Memory usage: {status.resource_usage.memory_bytes} bytes") print(f"CPU usage: {status.resource_usage.cpu_percent}%") # Create a new agent from symbiont import Agent agent_data = Agent( id="my-agent", name="My Assistant", description="A helpful AI assistant", system_prompt="You are a helpful assistant.", tools=["web_search", "calculator"], model="gpt-4", temperature=0.7, top_p=0.9, max_tokens=1000 ) result = client.create_agent(agent_data) print(f"Created agent: {result}") ``` ``` -------------------------------- ### Create Agent (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Illustrates the process of creating a new agent with specified configurations, including its ID, name, description, system prompt, tools, and model parameters. ```python from symbiont import Agent # Create a new agent agent_data = Agent( id="my-agent", name="My Assistant", description="A helpful AI assistant", system_prompt="You are a helpful assistant.", tools=["web_search", "calculator"], model="gpt-4", temperature=0.7, top_p=0.9, max_tokens=1000 ) result = client.create_agent(agent_data) print(f"Created agent: {result}") ``` -------------------------------- ### Initialize Symbiont Client Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Demonstrates how to initialize the Symbiont client. It can be initialized with default settings (loading from environment variables), explicit parameters like API key and base URL, or a configuration object. ```python from symbiont import Client # Initialize with environment variables client = Client() # Or initialize with explicit parameters client = Client( api_key="your_api_key", base_url="http://localhost:8080/api/v1" ) # Initialize with configuration object from symbiont import ClientConfig, AuthConfig config = ClientConfig( api_key="your_api_key", base_url="http://localhost:8080/api/v1", auth=AuthConfig(jwt_secret_key="your-secret") ) client = Client(config=config) ``` -------------------------------- ### Get Memory API Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves a specific memory using its unique identifier and the agent's ID. ```APIDOC ## GET /memories/{memory_id} ### Description Retrieves a specific memory by its ID for a given agent. ### Method GET ### Endpoint /memories/{memory_id} ### Parameters #### Path Parameters - **memory_id** (string) - Required - The unique identifier of the memory to retrieve. #### Query Parameters - **agent_id** (string) - Required - The unique identifier for the agent. ### Response #### Success Response (200) - **memory_id** (string) - The unique identifier of the memory. - **content** (object) - The content of the memory. - **memory_type** (string) - The type of the memory. - **memory_level** (string) - The level of the memory. - **agent_id** (string) - The agent associated with the memory. - **conversation_id** (string) - Optional - The conversation ID if applicable. - **importance_score** (float) - The importance score of the memory. - **timestamp** (string) - The timestamp when the memory was created or last updated. #### Response Example ```json { "memory_id": "mem-abc123xyz", "content": { "user_message": "What's the weather like?", "assistant_response": "I can help you check the weather. What's your location?", "timestamp": "2024-01-15T10:30:00Z" }, "memory_type": "CONVERSATION", "memory_level": "SHORT_TERM", "agent_id": "agent-123", "conversation_id": "conv-456", "importance_score": 0.7, "timestamp": "2024-01-15T10:31:00Z" } ``` ``` -------------------------------- ### Get Analysis Results Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves the analysis results for a given session ID, including risk score, number of findings, and details of each finding. ```APIDOC ## GET /analysis/results/{analysis_id} ### Description Retrieves the analysis results for a given session ID. ### Method GET ### Endpoint `/analysis/results/{analysis_id}` ### Parameters #### Path Parameters - **analysis_id** (string) - Required - The ID of the analysis to retrieve results for. ### Response #### Success Response (200) - **risk_score** (integer) - The overall risk score of the analysis (0-100). - **findings** (array) - A list of security findings. - **severity** (string) - The severity level of the finding (e.g., "HIGH", "MEDIUM", "LOW"). - **title** (string) - The title of the security finding. #### Response Example ```json { "risk_score": 85, "findings": [ { "severity": "HIGH", "title": "Insecure Dependency" }, { "severity": "MEDIUM", "title": "Potential SQL Injection" } ] } ``` ``` -------------------------------- ### Get Conversation Context API Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves the context of a conversation, including related memories and a summary. Useful for maintaining conversational flow and understanding. ```APIDOC ## GET /conversations/{conversation_id}/context ### Description Retrieves the context of a specific conversation, including associated memories and a summary. ### Method GET ### Endpoint /conversations/{conversation_id}/context ### Parameters #### Path Parameters - **conversation_id** (string) - Required - The unique identifier for the conversation. #### Query Parameters - **agent_id** (string) - Required - The unique identifier for the agent. ### Response #### Success Response (200) - **conversation_id** (string) - The identifier of the conversation. - **memories** (array of Memory objects) - A list of memories related to the conversation. - **summary** (string) - A summary of the conversation. #### Response Example ```json { "conversation_id": "conv-456", "memories": [ { "memory_id": "mem-abc123xyz", "content": { "user_message": "What's the weather like?", "assistant_response": "I can help you check the weather. What's your location?", "timestamp": "2024-01-15T10:30:00Z" }, "memory_type": "CONVERSATION", "memory_level": "SHORT_TERM", "agent_id": "agent-123", "conversation_id": "conv-456", "importance_score": 0.7, "timestamp": "2024-01-15T10:31:00Z" } ], "summary": "User asked about weather, assistant requested location." } ``` ``` -------------------------------- ### Get Agent Status (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Shows how to fetch the current status and resource usage of a specific agent. This helps in monitoring agent health and performance. ```python from symbiont import AgentState # Get specific agent status status = client.get_agent_status("agent-123") print(f"Agent {status.agent_id} is {status.state}") print(f"Memory usage: {status.resource_usage.memory_bytes} bytes") print(f"CPU usage: {status.resource_usage.cpu_percent}%") ``` -------------------------------- ### Symbiont SDK Python: Configuration Management Methods Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/update-plan.md Provides methods for managing client configuration, including setting, retrieving, and reloading configuration settings. These methods are essential for initializing and maintaining the SDK's operational parameters. ```python def configure_client(config: ClientConfig) -> Dict[str, Any]: """Configures the client with the provided configuration. Args: config: The ClientConfig object containing configuration settings. Returns: A dictionary representing the applied configuration. """ pass def get_configuration() -> ClientConfig: """Retrieves the current client configuration. Returns: The current ClientConfig object. """ pass def reload_configuration() -> Dict[str, Any]: """Reloads the client configuration from its source. Returns: A dictionary representing the reloaded configuration. """ pass ``` -------------------------------- ### Get Specific Vectors - Python Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves specific vectors from a collection by providing a list of their IDs. This is useful for fetching exact data points when their identifiers are known. ```python # Get specific vectors vector_ids = ["doc-001", "doc-002"] retrieved_vectors = client.get_vectors("documents", vector_ids) for vector in retrieved_vectors: print(f"Vector ID: {vector['id']}") print(f"Payload: {vector['payload']}") ``` -------------------------------- ### Submit Multiple Tools for Review in Batch (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Shows how to submit a list of tools for review using a batch process. It iterates through tools, creates review requests, and collects the resulting session objects. ```python # Submit multiple tools for review tools_to_review = [tool1, tool2, tool3] review_sessions = [] for tool in tools_to_review: request = ReviewSessionCreate( tool=tool, submitted_by="batch@example.com" ) session = client.submit_tool_for_review(request) review_sessions.append(session) print(f"Submitted {len(review_sessions)} tools for review") # Monitor all sessions for session in review_sessions: current_status = client.get_review_session(session.review_id) print(f"Tool {current_status.tool.name}: {current_status.status}") ``` -------------------------------- ### Get Collection Information - Python Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves information about a specified collection, including its vector count and dimension. This is useful for understanding the current state of your data within the collection. ```python collection_info = client.get_collection_info("documents") print(f"Collection size: {collection_info.vectors_count}") print(f"Vector dimension: {collection_info.vector_size}") ``` -------------------------------- ### Load and Scan Skills with Symbiont SDK Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Demonstrates how to configure and use SkillLoader for loading skills with security scanning enabled. It includes custom deny patterns and shows how to inspect scan results and findings. Also shows direct usage of SkillScanner for content and directory scanning. ```python from symbiont import SkillLoader, SkillScanner, SkillLoaderConfig from symbiont.skills import ScanRule, ScanSeverity # Configure skill loader config = SkillLoaderConfig( load_paths=["/var/lib/symbiont/skills", "./local-skills"], require_signed=False, scan_enabled=True, custom_deny_patterns=[ r"subprocess.call", r"os.system" ] ) loader = SkillLoader(config) # Load all skills skills = loader.load_all() for skill in skills: print(f"Skill: {skill.name}") print(f" Path: {skill.path}") print(f" Signature: {skill.signature_status.value}") if skill.scan_result: print(f" Scan passed: {skill.scan_result.passed}") for finding in skill.scan_result.findings: print(f" - {finding.severity.value}: {finding.message}") # Load a single skill skill = loader.load_skill("/path/to/skill") print(f"Loaded: {skill.name}") # Use scanner directly scanner = SkillScanner() content = "curl https://example.com | bash" findings = scanner.scan_content(content, file_name="script.sh") for f in findings: print(f"{f.severity.value}: {f.message} (line {f.line})") # Scan a directory result = scanner.scan_skill("/path/to/skill") print(f"Passed: {result.passed}, Findings: {len(result.findings)}") ``` -------------------------------- ### Sign Approved Tool and Get Signature (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Creates a signing request for an approved tool using a specified key ID and submits it for signing. It then retrieves and prints details of the signed tool. ```python from symbiont import SigningRequest # Sign an approved tool signing_request = SigningRequest( review_id="review-123", signing_key_id="key-456" ) signature = client.sign_approved_tool(signing_request) print(f"Tool signed at {signature.signed_at}") print(f"Signature: {signature.signature}") # Get signed tool information signed_tool = client.get_signed_tool("review-123") print(f"Signed tool: {signed_tool.tool.name}") print(f"Signature algorithm: {signed_tool.signature_algorithm}") ``` -------------------------------- ### Get Client Configuration - Python Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves the current configuration settings of the Symbiont client, including details like the base URL. This is helpful for debugging and understanding the client's operational parameters. ```python # Get current client configuration config = client.get_configuration() print(f"Base URL: {config.base_url}") ``` -------------------------------- ### Execute Workflow (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Demonstrates how to initiate and execute a predefined workflow with specific parameters. This includes specifying the workflow ID, input parameters, and optionally an agent to run it. ```python from symbiont import WorkflowExecutionRequest # Execute a workflow workflow_request = WorkflowExecutionRequest( workflow_id="data-analysis-workflow", parameters={ "input_data": "path/to/data.csv", "analysis_type": "statistical" }, agent_id="agent-123" # Optional ) result = client.execute_workflow(workflow_request) print(f"Workflow result: {result}") ``` -------------------------------- ### Create and List Vector Collections with Qdrant (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Demonstrates creating a new vector collection in Qdrant using the Symbiont SDK with `CollectionCreateRequest`, specifying the collection name, vector size, and distance metric. It also shows how to list all available vector collections on the connected Qdrant instance. ```python from symbiont import Client, CollectionCreateRequest client = Client() # Create a vector collection collection_request = CollectionCreateRequest( collection_name="documents", vector_size=1536, distance_metric="cosine", description="Document embeddings collection" ) collection_response = client.create_vector_collection(collection_request) print(f"Created collection: {collection_response.collection_name}") # List all collections collections = client.list_vector_collections() print(f"Available collections: {collections}") ``` -------------------------------- ### Get Collection Info and Manage Vectors with Symbiont SDK Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Demonstrates how to retrieve information about a collection, count vectors within it, and delete specific vectors using the Symbiont Python SDK. Requires an initialized Symbiont client. ```python from symbiont import Client client = Client() # Get collection info info = client.get_collection_info("documents") print(f"Vectors: {info.vectors_count}") # Count and delete vectors count = client.count_vectors("documents") client.delete_vectors("documents", ["doc-003"]) ``` ``` -------------------------------- ### Run Symbiont Python SDK Docker Container Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Demonstrates various ways to run the Symbiont Python SDK Docker container, including interactive sessions, with environment variables, running host scripts, and executing one-liners. ```bash # Run interactively with Python REPL docker run -it --rm ghcr.io/thirdkeyai/symbiont-sdk-python:latest # Run with environment variables docker run -it --rm \ -e SYMBIONT_API_KEY=your_api_key \ -e SYMBIONT_BASE_URL=http://host.docker.internal:8080/api/v1 \ ghcr.io/thirdkeyai/symbiont-sdk-python:latest # Run a Python script from host docker run --rm \ -v $(pwd):/workspace \ -w /workspace \ -e SYMBIONT_API_KEY=your_api_key \ ghcr.io/thirdkeyai/symbiont-sdk-python:latest \ python your_script.py # Execute one-liner docker run --rm \ -e SYMBIONT_API_KEY=your_api_key \ ghcr.io/thirdkeyai/symbiont-sdk-python:latest \ python -c "from symbiont import Client; print(Client().health_check())" ``` -------------------------------- ### Submit Tool for Review (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Explains how to submit a tool for review by defining its properties, schema, and provider details. This is part of the secure review process for MCP tools. ```python from symbiont import ( ReviewSessionCreate, Tool, ToolProvider, ToolSchema ) # Define a tool for review tool = Tool( name="example-calculator", description="A simple calculator tool", schema=ToolSchema( type="object", properties={ "operation": { "type": "string", "enum": ["add", "subtract", "multiply", "divide"] }, "a": {"type": "number"}, "b": {"type": "number"} }, required=["operation", "a", "b"] ), provider=ToolProvider( name="example-provider", public_key_url="https://example.com/pubkey.pem" ) ) # Submit for review review_request = ReviewSessionCreate( tool=tool, submitted_by="developer@example.com", priority="normal" ) session = client.submit_tool_for_review(review_request) print(f"Review session {session.review_id} created with status: {session.status}") ``` -------------------------------- ### Manage MCP Servers and Tools (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md This Python snippet illustrates how to manage Model Context Protocol (MCP) servers using the Symbiont SDK. It covers adding a new MCP server with its command and environment variables, connecting to it, and listing available tools and resources provided by the server. ```python from symbiont import McpServerConfig # Add MCP server mcp_config = McpServerConfig( name="filesystem-server", command=["npx", "@modelcontextprotocol/server-filesystem", "/tmp"], env={"NODE_ENV": "production"}, timeout_seconds=30 ) client.add_mcp_server(mcp_config) # Connect to server client.connect_mcp_server("filesystem-server") # List available tools and resources tools = client.list_mcp_tools("filesystem-server") resources = client.list_mcp_resources("filesystem-server") print(f"Available tools: {[tool.name for tool in tools]}") print(f"Available resources: {[resource.uri for resource in resources]}") # Get connection status connection_info = client.get_mcp_server("filesystem-server") print(f"Status: {connection_info.status}") print(f"Tools count: {connection_info.tools_count}") ``` -------------------------------- ### Configure Symbiont SDK using Environment Variables Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Lists environment variables used for configuring the Symbiont SDK. These variables allow for flexible configuration without modifying code, covering API keys, URLs, timeouts, and more. ```bash # Example of setting environment variables (not actual code execution) # SYMBIONT_API_KEY=your_api_key # SYMBIONT_BASE_URL=http://localhost:8080/api/v1 # SYMBIONT_TIMEOUT=30 # SYMBIONT_MAX_RETRIES=3 # SYMBIONT_AUTH_JWT_SECRET_KEY=your-jwt-secret-key # SYMBIONT_AUTH_JWT_ALGORITHM=HS256 # SYMBIONT_DB_HOST=localhost # SYMBIONT_DB_PORT=5432 # SYMBIONT_VECTOR_HOST=localhost # SYMBIONT_VECTOR_PORT=6333 # SYMBIONT_LOGGING_LEVEL=INFO ``` -------------------------------- ### Submit Tools for Review via Symbiont SDK Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Demonstrates how to define and submit tools for security review using the Symbiont SDK. It includes defining tool schemas, provider information, and the structure for review requests. ```python from symbiont import ( Client, ReviewSessionCreate, Tool, ToolProvider, ToolSchema, HumanReviewDecision, SigningRequest ) client = Client() # Define a tool for review tool = Tool( name="example-calculator", description="A simple calculator tool", schema=ToolSchema( type="object", properties={ "operation": {"type": "string", "enum": ["add", "subtract", "multiply", "divide"]}, "a": {"type": "number"}, "b": {"type": "number"} }, required=["operation", "a", "b"] ), provider=ToolProvider( name="example-provider", public_key_url="https://example.com/pubkey.pem" ) ) ``` -------------------------------- ### Get Context for RAG Operations (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves context items relevant to a given query for Retrieval Augmented Generation (RAG) operations. It requires a client object and a ContextQuery object specifying the query, agent ID, and maximum context items. ```python from symbiont import ContextQuery # Assuming 'client' is an initialized Symbiont client instance context_query = ContextQuery( query="How do I set up authentication?", agent_id="agent-123", max_context_items=3 ) context = client.get_context(context_query) print(f"Retrieved {len(context.context_items)} context items") print(f"Sources: {context.sources}") ``` -------------------------------- ### Run Pytest Tests (Bash) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Provides commands to execute the test suite using pytest, including options for running all tests, running with code coverage, and running specific test files. ```bash # Run all tests pytest # Run tests with coverage pytest --cov=symbiont # Run specific test file pytest tests/test_client.py ``` -------------------------------- ### Handle Symbiont SDK Errors Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Provides an example of robust error handling for Symbiont SDK operations using specific exception types. It demonstrates catching various API-related errors like AuthenticationError, NotFoundError, RateLimitError, and general APIError, as well as base SymbiontError. ```python from symbiont import ( Client, APIError, AuthenticationError, NotFoundError, RateLimitError, SymbiontError ) client = Client() try: session = client.get_review_session("non-existent") except AuthenticationError as e: print(f"Auth failed: {e}") print("Check your API key") except NotFoundError as e: print(f"Not found: {e}") print(f"Response: {e.response_text}") except RateLimitError as e: print(f"Rate limited: {e}") print("Wait before retrying") except APIError as e: print(f"API error (status {e.status_code}): {e}") except SymbiontError as e: print(f"SDK error: {e}") ``` -------------------------------- ### Create and Manage Pin Store - Python Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Creates a pin store for Trust On First Use (TOFU) key pinning. This mechanism helps in verifying the identity of an issuer on subsequent connections by pinning their public keys. ```python # TOFU key pinning pin_store = client.agentpin.create_pin_store() ``` -------------------------------- ### Collect and Export Metrics with Symbiont SDK Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Illustrates how to use MetricsCollector and FileMetricsExporter to gather and save system resource metrics. It covers creating exporter configurations, exporting snapshots, and using a CompositeExporter for multiple destinations. Also shows background collection and querying runtime metrics. ```python from symbiont import ( MetricsCollector, MetricsSnapshot, FileMetricsExporter, CompositeExporter ) from symbiont.metrics import FileExporterConfig, SystemResourceMetrics from datetime import datetime, timezone # Create file exporter file_config = FileExporterConfig(path="/var/log/symbiont/metrics.json", compact=True) file_exporter = FileMetricsExporter(file_config) # Create and export a snapshot snapshot = MetricsSnapshot( timestamp=datetime.now(timezone.utc).isoformat(), system=SystemResourceMetrics( cpu_usage_percent=45.2, memory_usage_bytes=1073741824, memory_usage_percent=50.0, disk_usage_bytes=10737418240, disk_usage_percent=25.0 ) ) file_exporter.export(snapshot) # Use composite exporter for multiple backends composite = CompositeExporter([file_exporter]) composite.export(snapshot) # Background metrics collection collector = MetricsCollector( exporter=file_exporter, interval_seconds=60 ) collector.start() # ... application runs ... collector.stop() # Query runtime metrics via API from symbiont import Client client = Client() metrics = client.metrics_client.get_metrics_snapshot() scheduler_metrics = client.metrics_client.get_scheduler_metrics() system_metrics = client.metrics_client.get_system_metrics() ``` -------------------------------- ### Perform Vector Database Operations with Qdrant Source: https://context7.com/thirdkeyai/symbiont-sdk-python/llms.txt Demonstrates creating a vector collection, adding vectors with payloads, and performing similarity searches using the Symbiont SDK's Qdrant integration. Assumes a Qdrant instance is accessible. ```python from symbiont import Client from symbiont.models import CollectionCreateRequest, VectorUpsertRequest, Point client = Client() # Create a vector collection collection_request = CollectionCreateRequest( name="documents", vector_size=1536, distance="Cosine" ) response = client.create_vector_collection(collection_request) print(f"Created: {response.collection_name}") # Add vectors to collection points = [ Point( id="doc-001", vector=[0.1, 0.2, 0.3] + [0.0] * 1533, # 1536-dim vector payload={"title": "Getting Started", "category": "docs"} ), Point( id="doc-002", vector=[0.4, 0.5, 0.6] + [0.0] * 1533, payload={"title": "API Reference", "category": "reference"} ) ] upsert_request = VectorUpsertRequest( collection_name="documents", points=points, wait=True ) result = client.add_vectors(upsert_request) print(f"Added {result.points_count} vectors") # Search for similar vectors from symbiont import VectorSearchRequest search_request = VectorSearchRequest( query="How to authenticate users", limit=5, similarity_threshold=0.7 ) results = client.search_vectors(search_request) for result in results.results: print(f"Score: {result.similarity_score}, Item: {result.item.id}") ``` -------------------------------- ### Get System and Agent Metrics (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Retrieves comprehensive system-wide metrics and agent-specific metrics. System metrics include memory usage, CPU usage, active agents, vector database items, and MCP connections. Agent metrics provide details like tasks completed, average response time, and agent uptime. ```python # Get comprehensive system metrics system_metrics = client.get_metrics() print(f"Memory usage: {system_metrics.memory_usage_percent}%") print(f"CPU usage: {system_metrics.cpu_usage_percent}%") print(f"Active agents: {system_metrics.active_agents}") print(f"Vector DB items: {system_metrics.vector_db_items}") print(f"MCP connections: {system_metrics.mcp_connections}") # Get agent-specific metrics agent_metrics = client.get_agent_metrics("agent-123") print(f"Tasks completed: {agent_metrics.tasks_completed}") print(f"Average response time: {agent_metrics.average_response_time_ms}ms") print(f"Agent uptime: {agent_metrics.uptime_seconds}s") ``` -------------------------------- ### Configure Client with New Settings (Python) Source: https://github.com/thirdkeyai/symbiont-sdk-python/blob/main/README.md Demonstrates how to reconfigure the Symbiont client with new API endpoint settings. This is useful for switching between different environments or API versions. ```python from symbiont import ClientConfig # Configure client with new settings new_config = ClientConfig(base_url="https://new-api.example.com") client.configure_client(new_config) ```