Skip to content

The platform for continuously improving AI agents.

1.6 KB
Raw Blame
from datetime import datetime
from typing import Literal
from uuid import UUID

from pydantic import Field

from overbae.services.mcp.contracts.common import MCPModel, ResourceLinkContract


class ContextQuery(MCPModel):
    roots: list[str] = Field(default_factory=list, max_length=32)
    kind: str | None = Field(default=None, max_length=48)
    query: str = Field(default="", max_length=255)
    offset: int = Field(default=0, ge=0)
    limit: int = Field(default=100, ge=1, le=500)
    purpose: Literal["inspection", "training", "workshop"] = "inspection"


class ContextCapture(MCPModel):
    roots: list[str] = Field(min_length=1, max_length=32)
    purpose: Literal["inspection", "training", "workshop"]
    request_key: str = Field(min_length=1, max_length=128)
    depth: int = Field(default=2, ge=0, le=4)


class ContextRefresh(MCPModel):
    pass


class ContextSummary(MCPModel):
    project: str
    generation: int
    coverage: dict[str, int]
    started_at: datetime | None
    completed_at: datetime | None
    nodes: int
    edges: int


class ContextEntity(MCPModel):
    reference: str
    label: str
    fingerprint: str
    exposure: str
    facts: dict
    observed_at: datetime


class ContextRelationship(MCPModel):
    source: str
    target: str
    relationship: str
    evidence: str


class ContextPage(MCPModel):
    graph: ContextSummary
    nodes: list[ContextEntity]
    edges: list[ContextRelationship]
    total: int
    next_offset: int | None


class ContextReceipt(MCPModel):
    id: UUID
    project: UUID
    purpose: str
    fingerprint: str
    roots: list[str]
    created_at: datetime
    resource: ResourceLinkContract