|
17 | 17 |
|
18 | 18 | from typing import TYPE_CHECKING, Any, Set, Dict, List, Tuple, Union, Optional, cast |
19 | 19 | from datetime import datetime |
20 | | -from typing_extensions import Literal, Annotated, TypeAlias, override |
| 20 | +from typing_extensions import Literal, TypeAlias, override |
21 | 21 |
|
22 | 22 | from . import environment |
23 | 23 | from .step import Step |
24 | 24 | from .tool import Tool |
25 | 25 | from .model import Model |
26 | 26 | from .usage import Usage |
27 | | -from .._utils import PropertyInfo |
28 | 27 | from .content import Content |
29 | 28 | from .._compat import PYDANTIC_V1 |
30 | 29 | from .._models import BaseModel |
|
43 | 42 | from .image_response_format import ImageResponseFormat |
44 | 43 | from .deep_research_agent_config import DeepResearchAgentConfig |
45 | 44 |
|
46 | | -__all__ = ["Interaction", "AgentConfig", "Environment", "Input", "ResponseFormat", "ResponseFormatResponseFormatList"] |
| 45 | +__all__ = [ |
| 46 | + "Interaction", |
| 47 | + "AgentConfig", |
| 48 | + "AgentConfigFindRequest", |
| 49 | + "AgentConfigFindRequestSessionConfig", |
| 50 | + "AgentConfigFindRequestSourceFile", |
| 51 | + "AgentConfigFixRequest", |
| 52 | + "AgentConfigFixRequestSessionConfig", |
| 53 | + "AgentConfigFixRequestSourceFile", |
| 54 | + "Environment", |
| 55 | + "Input", |
| 56 | + "ResponseFormat", |
| 57 | + "ResponseFormatResponseFormatList", |
| 58 | +] |
| 59 | + |
| 60 | + |
| 61 | +class AgentConfigFindRequestSessionConfig(BaseModel): |
| 62 | + """ |
| 63 | + Optional session-specific configurations to override default agent |
| 64 | + behavior. |
| 65 | + """ |
| 66 | + |
| 67 | + max_rounds: Optional[int] = None |
| 68 | + """ |
| 69 | + The maximum number of interaction rounds the agent is allowed to perform before |
| 70 | + reaching a timeout. |
| 71 | + """ |
| 72 | + |
| 73 | + pipeline_mode: Optional[Literal["scan", "verify"]] = None |
| 74 | + """The pipeline mode of a CodeMender session. |
| 75 | +
|
| 76 | + It can only be used for a find session. |
| 77 | + """ |
| 78 | + |
| 79 | + topology: Optional[str] = None |
| 80 | + """The cognitive architecture or "thinking" topology used by the agent (e.g. |
| 81 | +
|
| 82 | + "default", "deep"). |
| 83 | + """ |
| 84 | + |
| 85 | + |
| 86 | +class AgentConfigFindRequestSourceFile(BaseModel): |
| 87 | + """Content of a single file in the codebase.""" |
| 88 | + |
| 89 | + content: Optional[str] = None |
| 90 | + """The UTF-8 encoded text content of the file.""" |
| 91 | + |
| 92 | + path: Optional[str] = None |
| 93 | + """The relative path of the file from the project root.""" |
| 94 | + |
| 95 | + |
| 96 | +class AgentConfigFindRequest(BaseModel): |
| 97 | + """ |
| 98 | + Request parameters specific to FIND sessions, used for discovering |
| 99 | + vulnerabilities in a codebase. |
| 100 | + """ |
| 101 | + |
| 102 | + request: Literal["find_request"] |
| 103 | + |
| 104 | + description: Optional[str] = None |
| 105 | + """ |
| 106 | + Additional context or custom instructions provided by the user to guide the |
| 107 | + vulnerability analysis. |
| 108 | + """ |
| 109 | + |
| 110 | + finding_id: Optional[str] = None |
| 111 | + """The identifier of a specific finding to verify. |
| 112 | +
|
| 113 | + This is primarily used in VERIFY mode to focus the agent's execution-based |
| 114 | + validation on a single vulnerability. |
| 115 | + """ |
| 116 | + |
| 117 | + session_config: Optional[AgentConfigFindRequestSessionConfig] = None |
| 118 | + """Optional session-specific configurations to override default agent behavior.""" |
| 119 | + |
| 120 | + session_id: Optional[str] = None |
| 121 | + """ |
| 122 | + Parameter for grouping multiple interactions that belong to the same CodeMender |
| 123 | + session. |
| 124 | + """ |
| 125 | + |
| 126 | + source_files: Optional[List[AgentConfigFindRequestSourceFile]] = None |
| 127 | + """A list of source files to provide as context for the scan.""" |
| 128 | + |
| 129 | + |
| 130 | +class AgentConfigFixRequestSessionConfig(BaseModel): |
| 131 | + """ |
| 132 | + Optional session-specific configurations to override default agent |
| 133 | + behavior. |
| 134 | + """ |
| 135 | + |
| 136 | + max_rounds: Optional[int] = None |
| 137 | + """ |
| 138 | + The maximum number of interaction rounds the agent is allowed to perform before |
| 139 | + reaching a timeout. |
| 140 | + """ |
| 141 | + |
| 142 | + pipeline_mode: Optional[Literal["scan", "verify"]] = None |
| 143 | + """The pipeline mode of a CodeMender session. |
| 144 | +
|
| 145 | + It can only be used for a find session. |
| 146 | + """ |
| 147 | + |
| 148 | + topology: Optional[str] = None |
| 149 | + """The cognitive architecture or "thinking" topology used by the agent (e.g. |
| 150 | +
|
| 151 | + "default", "deep"). |
| 152 | + """ |
| 153 | + |
| 154 | + |
| 155 | +class AgentConfigFixRequestSourceFile(BaseModel): |
| 156 | + """Content of a single file in the codebase.""" |
| 157 | + |
| 158 | + content: Optional[str] = None |
| 159 | + """The UTF-8 encoded text content of the file.""" |
| 160 | + |
| 161 | + path: Optional[str] = None |
| 162 | + """The relative path of the file from the project root.""" |
| 163 | + |
| 164 | + |
| 165 | +class AgentConfigFixRequest(BaseModel): |
| 166 | + """ |
| 167 | + Request parameters specific to FIX sessions, used for generating and |
| 168 | + validating security patches. |
| 169 | + """ |
| 170 | + |
| 171 | + request: Literal["fix_request"] |
| 172 | + |
| 173 | + description: Optional[str] = None |
| 174 | + """ |
| 175 | + Additional context or custom instructions provided by the user to guide the |
| 176 | + patch generation process. |
| 177 | + """ |
| 178 | + |
| 179 | + finding_id: Optional[str] = None |
| 180 | + """The identifier of the specific security finding to be remediated. |
| 181 | +
|
| 182 | + This ID maps to a previously discovered vulnerability. |
| 183 | + """ |
| 184 | + |
| 185 | + session_config: Optional[AgentConfigFixRequestSessionConfig] = None |
| 186 | + """Optional session-specific configurations to override default agent behavior.""" |
| 187 | + |
| 188 | + session_id: Optional[str] = None |
| 189 | + """ |
| 190 | + Parameter for grouping multiple interactions that belong to the same CodeMender |
| 191 | + session. |
| 192 | + """ |
| 193 | + |
| 194 | + source_files: Optional[List[AgentConfigFixRequestSourceFile]] = None |
| 195 | + """A list of source files providing context for the remediation. |
| 196 | +
|
| 197 | + These files are typically the ones containing the identified vulnerability. |
| 198 | + """ |
| 199 | + |
47 | 200 |
|
48 | | -AgentConfig: TypeAlias = Annotated[ |
49 | | - Union[DynamicAgentConfig, DeepResearchAgentConfig], PropertyInfo(discriminator="type") |
| 201 | +AgentConfig: TypeAlias = Union[ |
| 202 | + DeepResearchAgentConfig, DynamicAgentConfig, AgentConfigFindRequest, AgentConfigFixRequest |
50 | 203 | ] |
51 | 204 |
|
52 | 205 | Environment: TypeAlias = Union[str, environment.Environment] |
|
0 commit comments