"""
Mnemosyne Validator Agent

A bare FastAgent that wraps the Mnemosyne MCP server. Exists solely to
exercise the Mnemosyne MCP transport, tool registration, and round-trip
serialization — no production role.

Drive it from the CLI to confirm:
- search works against the running Mnemosyne (vector + fulltext + graph)
- get_chunk fetches full chunk text from S3
- list_libraries / list_collections / list_items return the expected shape
- get_health returns ok/degraded with the right dependency breakdown

When the Daedalus integration ships, the workspace_id parameter will be
injected by Daedalus's chat path (force-overwritten before the call leaves
Daedalus). This validator never sets it — meaning all calls go to the
GLOBAL scope (libraries with workspace_id IS NULL).
"""
from fast_agent import FastAgent

fast = FastAgent("Mnemosyne Validator", parse_cli_args=False)


@fast.agent(
    name="mnemosyne_validator",
    instruction="""You are a validator for the Mnemosyne knowledge base. Your
job is to exercise its MCP tools when asked, report what you saw, and surface
errors clearly.

You have direct access to Mnemosyne via these tools:

- search(query, library_uid?, library_type?, collection_uid?, limit?, rerank?, include_images?, search_types?)
    Hybrid retrieval. Returns ranked chunks with text_preview (~500 chars),
    chunk_uid, item_uid, item_title, library_type, score, source.
- get_chunk(chunk_uid)
    Fetch the full text of a chunk by uid (typically obtained from search).
- list_libraries(limit?, offset?)
    List libraries (uid, name, library_type, description).
- list_collections(library_uid?, limit?, offset?)
    List collections, optionally filtered by parent library.
- list_items(collection_uid?, library_uid?, limit?, offset?)
    List items (documents) with chunk_count, embedding_status, etc.
- get_health()
    Health check: {status: ok|degraded|error, checks: {neo4j, s3, embedding}}.

When the user asks "what libraries exist", call list_libraries and report.
When they ask a research question, call search and surface chunk_uid + score
+ item_title for each candidate. If they want full text, call get_chunk.
Show raw structured output, not flowery prose — this is a validation tool,
not a chat assistant.

If a tool errors, paste the error message verbatim.""",
    servers=["mnemosyne"],
)
async def mnemosyne_validator():
    pass
