Header image for Bitcg

Bitcg

Prompt

""" AgentOS – CapabilityDefinition ORM model. Stores stable, versioned capability definitions with their JSON Schema input/output specifications, authorization requirements, and policy flags. """ from __future__ import annotations import uuid from datetime import datetime from typing import Optional from sqlalchemy import Boolean, DateTime, Integer, String, Text, UniqueConstraint, func from sqlalchemy.dialects.postgresql import JSONB, UUID from sqlalchemy.orm import Mapped, mapped_column from core.database import Base class CapabilityDefinition(Base): __tablename__ = "capability_definitions" __table_args__ = ( UniqueConstraint("name", "version", name="uq_capability_name_version"), ) id: Mapped[uuid.UUID] = mapped_column( UUID(as_uuid=True), primary_key=True, default=uuid.uuid4 ) # ── Identity ────────────────────────────────────────────────────────────── name: Mapped[str] = mapped_column(String(100), nullable=False, index=True) version: Mapped[str] = mapped_column(String(20), nullable=False, default="1.0.0") display_name: Mapped[str] = mapped_column(String(200), nullable=False) description: Mapped[Optional[str]] = mapped_column(Text, nullable=True) # ── Schema ──────────────────────────────────────────────────────────────── # JSON Schema for the capability input payload input_schema: Mapped[dict] = mapped_column(JSONB, nullable=False) # JSON Schema for the capability output payload output_schema: Mapped[dict] = mapped_column(JSONB, nullable=False) # ── Authorization ───────────────────────────────────────────────────────── # Risk class: "low" | "medium" | "high" | "critical" risk_class: Mapped[str] = mapped_column( String(20), nullable=False, default="low" ) # Whether this capability requires explicit user approval before execution requires_approval: Mapped[bool] = mapped_column( Boolean, nullable=False, default=False ) # Allowlisted network destinations (CIDR or hostname patterns) allowed_network_destinations: Mapped[Optional[list]] = mapped_column( JSONB, nullable=True ) # Allowlisted filesystem path prefixes allowed_filesystem_paths: Mapped[Optional[list]] = mapped_column( JSONB, nullable=True ) # Allowlisted package sources allowed_package_sources: Mapped[Optional[list]] = mapped_column( JSONB, nullable=True ) # Task categories for which this capability is permitted permitted_task_categories: Mapped[Optional[list]] = mapped_column( JSONB, nullable=True ) # ── Concurrency / resource limits ───────────────────────────────────────── max_concurrent_global: Mapped[Optional[int]] = mapped_column( Integer, nullable=True ) max_concurrent_per_tenant: Mapped[Optional[int]] = mapped_column( Integer, nullable=True ) max_concurrent_per_task: Mapped[Optional[int]] = mapped_column( Integer, nullable=True ) # ── Lifecycle ───────────────────────────────────────────────────────────── is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) deprecated: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) deprecation_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True) # ── Timestamps ──────────────────────────────────────────────────────────── created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), nullable=False, server_default=func.now() ) updated_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), nullable=False, server_default=func.now(), onupdate=func.now(), ) def __repr__(self) -> str: return ( f"<CapabilityDefinition name={self.name!r} version={self.version!r}>" ) Send back the complete code with all the fixes. Fix each of the listed errors one by one, making sure to actually correct them so that there are 0 errors remaining. Keep the original imports, since the files exist. Write out every single character; do not abbreviate anything. Fix every error. There must be exactly one file. Do not write anything else; just output the complete code, and it must not contain any comments. Never, under any circumstances, use simplified, substitute, dummy, simulated, or fake code. Write the entire file as complete, unabridged, production-ready code in a single code block. It must be 100% error-free, a complete, error-free file, and must be submitted as a downloadable file. These requirements are mandatory and must be strictly adhered to. If no list of errors is provided, you must find all the errors and fix them. If there were comments in the original code, delete them. And most importantly: YOU MUST NEVER SIMPLIFY!

Answer guidance

backend/models/capability.py

Drag to resize