88use Stagehand \Core \Concerns \SdkModel ;
99use Stagehand \Core \Contracts \BaseModel ;
1010use Stagehand \Sessions \ModelConfig ;
11+ use Stagehand \Sessions \SessionExecuteParams \AgentConfig \Mode ;
1112use Stagehand \Sessions \SessionExecuteParams \AgentConfig \Provider ;
1213
1314/**
1617 *
1718 * @phpstan-type AgentConfigShape = array{
1819 * cua?: bool|null,
20+ * mode?: null|Mode|value-of<Mode>,
1921 * model?: ModelShape|null,
2022 * provider?: null|Provider|value-of<Provider>,
2123 * systemPrompt?: string|null,
@@ -27,11 +29,19 @@ final class AgentConfig implements BaseModel
2729 use SdkModel;
2830
2931 /**
30- * Enable Computer Use Agent mode.
32+ * Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence .
3133 */
3234 #[Optional]
3335 public ?bool $ cua ;
3436
37+ /**
38+ * Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
39+ *
40+ * @var value-of<Mode>|null $mode
41+ */
42+ #[Optional(enum: Mode::class)]
43+ public ?string $ mode ;
44+
3545 /**
3646 * Model configuration object or model name string (e.g., 'openai/gpt-5-nano').
3747 *
@@ -64,18 +74,21 @@ public function __construct()
6474 *
6575 * You must use named parameters to construct any parameters with a default value.
6676 *
77+ * @param Mode|value-of<Mode>|null $mode
6778 * @param ModelShape|null $model
6879 * @param Provider|value-of<Provider>|null $provider
6980 */
7081 public static function with (
7182 ?bool $ cua = null ,
83+ Mode |string |null $ mode = null ,
7284 string |ModelConfig |array |null $ model = null ,
7385 Provider |string |null $ provider = null ,
7486 ?string $ systemPrompt = null ,
7587 ): self {
7688 $ self = new self ;
7789
7890 null !== $ cua && $ self ['cua ' ] = $ cua ;
91+ null !== $ mode && $ self ['mode ' ] = $ mode ;
7992 null !== $ model && $ self ['model ' ] = $ model ;
8093 null !== $ provider && $ self ['provider ' ] = $ provider ;
8194 null !== $ systemPrompt && $ self ['systemPrompt ' ] = $ systemPrompt ;
@@ -84,7 +97,7 @@ public static function with(
8497 }
8598
8699 /**
87- * Enable Computer Use Agent mode.
100+ * Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence .
88101 */
89102 public function withCua (bool $ cua ): self
90103 {
@@ -94,6 +107,19 @@ public function withCua(bool $cua): self
94107 return $ self ;
95108 }
96109
110+ /**
111+ * Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
112+ *
113+ * @param Mode|value-of<Mode> $mode
114+ */
115+ public function withMode (Mode |string $ mode ): self
116+ {
117+ $ self = clone $ this ;
118+ $ self ['mode ' ] = $ mode ;
119+
120+ return $ self ;
121+ }
122+
97123 /**
98124 * Model configuration object or model name string (e.g., 'openai/gpt-5-nano').
99125 *
0 commit comments