File size: 1,436 Bytes
287f3d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Structured output of the DevOps Agent."""

from __future__ import annotations

from pydantic import Field

from .limits import CappedListModel


def _length_hint(chars: int) -> dict[str, int]:
    """Publish a ``maxLength`` ceiling into the JSON Schema without enforcing it.



    The config files are the largest single block of output in the workflow

    (``github_actions`` alone measured 9.9K chars). Truncating a YAML or

    Dockerfile string after the fact would corrupt it, so the ceiling is shown to

    the model as guidance and never validated.

    """
    return {"maxLength": chars}


class DevopsOutput(CappedListModel):
    dockerfile: str = Field(..., json_schema_extra=_length_hint(1200))
    docker_compose: str = Field(default="", json_schema_extra=_length_hint(1600))
    ci_cd_pipeline: str = Field(default="", json_schema_extra=_length_hint(800))
    github_actions: str = Field(default="", json_schema_extra=_length_hint(2000))
    environment_variables: dict[str, str] = Field(default_factory=dict)
    deployment_strategy: str = Field(default="", json_schema_extra=_length_hint(400))
    health_checks: list[str] = Field(default_factory=list, max_length=3)
    logging: list[str] = Field(default_factory=list, max_length=2)
    monitoring: list[str] = Field(default_factory=list, max_length=2)
    secrets_management: str = Field(default="", json_schema_extra=_length_hint(400))