|  | 
| 2 | 2 | 
 | 
| 3 | 3 | from __future__ import annotations | 
| 4 | 4 | 
 | 
| 5 |  | -from typing import List, Union, Iterable, Optional | 
|  | 5 | +from typing import Dict, List, Union, Iterable, Optional | 
| 6 | 6 | from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict | 
| 7 | 7 | 
 | 
| 8 | 8 | from .._utils import PropertyInfo | 
|  | 
| 17 | 17 |     "ToolRuleChildToolRule", | 
| 18 | 18 |     "ToolRuleInitToolRule", | 
| 19 | 19 |     "ToolRuleTerminalToolRule", | 
|  | 20 | +    "ToolRuleConditionalToolRule", | 
| 20 | 21 | ] | 
| 21 | 22 | 
 | 
| 22 | 23 | 
 | 
| @@ -246,24 +247,51 @@ class ToolRuleChildToolRule(TypedDict, total=False): | 
| 246 | 247 |     tool_name: Required[str] | 
| 247 | 248 |     """The name of the tool. Must exist in the database for the user's organization.""" | 
| 248 | 249 | 
 | 
| 249 |  | -    type: Literal["InitToolRule", "TerminalToolRule", "continue_loop", "ToolRule", "require_parent_tools"] | 
|  | 250 | +    type: Literal[ | 
|  | 251 | +        "InitToolRule", "TerminalToolRule", "continue_loop", "conditional", "ToolRule", "require_parent_tools" | 
|  | 252 | +    ] | 
| 250 | 253 |     """Type of tool rule.""" | 
| 251 | 254 | 
 | 
| 252 | 255 | 
 | 
| 253 | 256 | class ToolRuleInitToolRule(TypedDict, total=False): | 
| 254 | 257 |     tool_name: Required[str] | 
| 255 | 258 |     """The name of the tool. Must exist in the database for the user's organization.""" | 
| 256 | 259 | 
 | 
| 257 |  | -    type: Literal["InitToolRule", "TerminalToolRule", "continue_loop", "ToolRule", "require_parent_tools"] | 
|  | 260 | +    type: Literal[ | 
|  | 261 | +        "InitToolRule", "TerminalToolRule", "continue_loop", "conditional", "ToolRule", "require_parent_tools" | 
|  | 262 | +    ] | 
| 258 | 263 |     """Type of tool rule.""" | 
| 259 | 264 | 
 | 
| 260 | 265 | 
 | 
| 261 | 266 | class ToolRuleTerminalToolRule(TypedDict, total=False): | 
| 262 | 267 |     tool_name: Required[str] | 
| 263 | 268 |     """The name of the tool. Must exist in the database for the user's organization.""" | 
| 264 | 269 | 
 | 
| 265 |  | -    type: Literal["InitToolRule", "TerminalToolRule", "continue_loop", "ToolRule", "require_parent_tools"] | 
|  | 270 | +    type: Literal[ | 
|  | 271 | +        "InitToolRule", "TerminalToolRule", "continue_loop", "conditional", "ToolRule", "require_parent_tools" | 
|  | 272 | +    ] | 
|  | 273 | +    """Type of tool rule.""" | 
|  | 274 | + | 
|  | 275 | + | 
|  | 276 | +class ToolRuleConditionalToolRule(TypedDict, total=False): | 
|  | 277 | +    child_output_mapping: Required[Dict[str, str]] | 
|  | 278 | +    """The output case to check for mapping""" | 
|  | 279 | + | 
|  | 280 | +    tool_name: Required[str] | 
|  | 281 | +    """The name of the tool. Must exist in the database for the user's organization.""" | 
|  | 282 | + | 
|  | 283 | +    default_child: Optional[str] | 
|  | 284 | +    """The default child tool to be called. If None, any tool can be called.""" | 
|  | 285 | + | 
|  | 286 | +    require_output_mapping: bool | 
|  | 287 | +    """Whether to throw an error when output doesn't match any case""" | 
|  | 288 | + | 
|  | 289 | +    type: Literal[ | 
|  | 290 | +        "InitToolRule", "TerminalToolRule", "continue_loop", "conditional", "ToolRule", "require_parent_tools" | 
|  | 291 | +    ] | 
| 266 | 292 |     """Type of tool rule.""" | 
| 267 | 293 | 
 | 
| 268 | 294 | 
 | 
| 269 |  | -ToolRule: TypeAlias = Union[ToolRuleChildToolRule, ToolRuleInitToolRule, ToolRuleTerminalToolRule] | 
|  | 295 | +ToolRule: TypeAlias = Union[ | 
|  | 296 | +    ToolRuleChildToolRule, ToolRuleInitToolRule, ToolRuleTerminalToolRule, ToolRuleConditionalToolRule | 
|  | 297 | +] | 
0 commit comments