feat(pilot): pydantic schemas for inline origin + script PATCH
- ScriptBuilderCreateRequest gains origin ('standalone' | 'pilot_inline')
and optional ai_session_id. Handler-side validation (next task) enforces
pilot_inline ⇒ ai_session_id required + owned by caller.
- SessionSuggestedFixScriptRequest added for the new PATCH /script
endpoint (Phase 9 Task 6).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,18 +1,27 @@
|
|||||||
"""Pydantic schemas for the AI Script Builder."""
|
"""Pydantic schemas for the AI Script Builder."""
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Literal, Optional
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
class ScriptBuilderCreateRequest(BaseModel):
|
class ScriptBuilderCreateRequest(BaseModel):
|
||||||
"""Request to start a new builder session."""
|
"""Request to start (or get-or-create, for inline origin) a builder session.
|
||||||
|
|
||||||
|
When `origin='pilot_inline'`, `ai_session_id` is REQUIRED and must
|
||||||
|
reference a pilot session owned by the current user. The endpoint's
|
||||||
|
get-or-create semantics kick in: if a pilot_inline session already
|
||||||
|
exists for (user_id, ai_session_id), that row is returned instead of
|
||||||
|
creating a duplicate.
|
||||||
|
"""
|
||||||
language: str = Field(
|
language: str = Field(
|
||||||
default="powershell",
|
default="powershell",
|
||||||
pattern=r"^(powershell|bash|python)$",
|
pattern=r"^(powershell|bash|python)$",
|
||||||
description="Script language",
|
description="Script language",
|
||||||
)
|
)
|
||||||
|
origin: Literal["standalone", "pilot_inline"] = "standalone"
|
||||||
|
ai_session_id: UUID | None = None
|
||||||
|
|
||||||
|
|
||||||
class ScriptBuilderMessageRequest(BaseModel):
|
class ScriptBuilderMessageRequest(BaseModel):
|
||||||
|
|||||||
@@ -114,6 +114,17 @@ class SessionSuggestedFixOutcomeRequest(BaseModel):
|
|||||||
notes: str | None = Field(None, max_length=500)
|
notes: str | None = Field(None, max_length=500)
|
||||||
|
|
||||||
|
|
||||||
|
class SessionSuggestedFixScriptRequest(BaseModel):
|
||||||
|
"""Engineer-submitted drafted script for a suggested fix.
|
||||||
|
|
||||||
|
Called when the inline Script Builder tab's Submit action fires. The
|
||||||
|
fix must be non-terminal (still proposed/applied_partial). Setting
|
||||||
|
the script does NOT stamp applied_at — a draft is not an application.
|
||||||
|
"""
|
||||||
|
ai_drafted_script: str = Field(..., min_length=1, max_length=50_000)
|
||||||
|
ai_drafted_parameters: dict[str, Any] | None = None
|
||||||
|
|
||||||
|
|
||||||
# ── Resolution note preview ────────────────────────────────────────────────
|
# ── Resolution note preview ────────────────────────────────────────────────
|
||||||
|
|
||||||
class ResolutionNotePreviewResponse(BaseModel):
|
class ResolutionNotePreviewResponse(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user