feat(ai): phase 0 couche d'outils partagee (backend/tools) + tests
CI / lint (push) Successful in 57s
CI / security (push) Successful in 39s
CI / test (push) Failing after 41s
CI / build (push) Skipped
CI / e2e (push) Skipped
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
CI / lint (push) Successful in 57s
CI / security (push) Successful in 39s
CI / test (push) Failing after 41s
CI / build (push) Skipped
CI / e2e (push) Skipped
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
- backend/tools/: ToolContext, registry @tool + schemas JSON, audit ai_tool_call - Services lecture/recherche: list_vaults, list_directory, read_file, search_fulltext, list_tags - Permissions check_vault_access + resolve_safe_path, confirmation gating (two-step) - Redaction des secrets, limites de taille, audit JSONL (args sensibles resumes) - tests/test_tools.py: 30 tests (registry, contexte, execution, confirmation, audit) - ROADMAP: item #79 phase A livree (A2 partiel)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""Pydantic input/output models for the AI tool layer.
|
||||
|
||||
Input models double as JSON Schemas advertised to LLMs (via
|
||||
``model_json_schema``) and as validation for arguments received over MCP.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ListVaultsInput(BaseModel):
|
||||
"""No parameters — lists the vaults the caller can access."""
|
||||
|
||||
|
||||
class ListDirectoryInput(BaseModel):
|
||||
"""Browse a directory inside a vault."""
|
||||
|
||||
vault: str = Field(..., description="Vault name")
|
||||
path: str = Field("", description="Vault-relative directory path (empty = vault root)")
|
||||
|
||||
|
||||
class ReadFileInput(BaseModel):
|
||||
"""Read a text file's content from a vault."""
|
||||
|
||||
vault: str = Field(..., description="Vault name")
|
||||
path: str = Field(..., description="Vault-relative file path")
|
||||
|
||||
|
||||
class SearchFulltextInput(BaseModel):
|
||||
"""Full-text search across one or all accessible vaults."""
|
||||
|
||||
q: str = Field(..., min_length=1, description="Search query")
|
||||
vault: str = Field("all", description="Vault name or 'all'")
|
||||
tag: str | None = Field(None, description="Optional comma-separated tag filter")
|
||||
limit: int = Field(50, ge=1, le=200, description="Maximum number of results")
|
||||
|
||||
|
||||
class ListTagsInput(BaseModel):
|
||||
"""List tags and their occurrence counts."""
|
||||
|
||||
vault: str | None = Field(None, description="Vault name or 'all' (default: all accessible)")
|
||||
|
||||
|
||||
class ToolResult(BaseModel):
|
||||
"""Uniform result returned by :func:`backend.tools.registry.call_tool`."""
|
||||
|
||||
ok: bool = True
|
||||
data: Any = None
|
||||
error: str | None = None
|
||||
Reference in New Issue
Block a user