@@ -676,6 +676,7 @@ private constructor(
676676 @JsonCreator(mode = JsonCreator .Mode .DISABLED )
677677 private constructor (
678678 private val cua: JsonField <Boolean >,
679+ private val mode: JsonField <Mode >,
679680 private val model: JsonField <Model >,
680681 private val provider: JsonField <Provider >,
681682 private val systemPrompt: JsonField <String >,
@@ -685,23 +686,32 @@ private constructor(
685686 @JsonCreator
686687 private constructor (
687688 @JsonProperty(" cua" ) @ExcludeMissing cua: JsonField <Boolean > = JsonMissing .of(),
689+ @JsonProperty(" mode" ) @ExcludeMissing mode: JsonField <Mode > = JsonMissing .of(),
688690 @JsonProperty(" model" ) @ExcludeMissing model: JsonField <Model > = JsonMissing .of(),
689691 @JsonProperty(" provider" )
690692 @ExcludeMissing
691693 provider: JsonField <Provider > = JsonMissing .of(),
692694 @JsonProperty(" systemPrompt" )
693695 @ExcludeMissing
694696 systemPrompt: JsonField <String > = JsonMissing .of(),
695- ) : this (cua, model, provider, systemPrompt, mutableMapOf ())
697+ ) : this (cua, mode, model, provider, systemPrompt, mutableMapOf ())
696698
697699 /* *
698- * Enable Computer Use Agent mode
700+ * Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence.
699701 *
700702 * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
701703 * the server responded with an unexpected value).
702704 */
703705 fun cua (): Optional <Boolean > = cua.getOptional(" cua" )
704706
707+ /* *
708+ * Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
709+ *
710+ * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if
711+ * the server responded with an unexpected value).
712+ */
713+ fun mode (): Optional <Mode > = mode.getOptional(" mode" )
714+
705715 /* *
706716 * Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
707717 *
@@ -733,6 +743,13 @@ private constructor(
733743 */
734744 @JsonProperty(" cua" ) @ExcludeMissing fun _cua (): JsonField <Boolean > = cua
735745
746+ /* *
747+ * Returns the raw JSON value of [mode].
748+ *
749+ * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type.
750+ */
751+ @JsonProperty(" mode" ) @ExcludeMissing fun _mode (): JsonField <Mode > = mode
752+
736753 /* *
737754 * Returns the raw JSON value of [model].
738755 *
@@ -779,6 +796,7 @@ private constructor(
779796 class Builder internal constructor() {
780797
781798 private var cua: JsonField <Boolean > = JsonMissing .of()
799+ private var mode: JsonField <Mode > = JsonMissing .of()
782800 private var model: JsonField <Model > = JsonMissing .of()
783801 private var provider: JsonField <Provider > = JsonMissing .of()
784802 private var systemPrompt: JsonField <String > = JsonMissing .of()
@@ -787,13 +805,14 @@ private constructor(
787805 @JvmSynthetic
788806 internal fun from (agentConfig : AgentConfig ) = apply {
789807 cua = agentConfig.cua
808+ mode = agentConfig.mode
790809 model = agentConfig.model
791810 provider = agentConfig.provider
792811 systemPrompt = agentConfig.systemPrompt
793812 additionalProperties = agentConfig.additionalProperties.toMutableMap()
794813 }
795814
796- /* * Enable Computer Use Agent mode */
815+ /* * Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence. */
797816 fun cua (cua : Boolean ) = cua(JsonField .of(cua))
798817
799818 /* *
@@ -805,6 +824,18 @@ private constructor(
805824 */
806825 fun cua (cua : JsonField <Boolean >) = apply { this .cua = cua }
807826
827+ /* * Tool mode for the agent (dom, hybrid, cua). If set, overrides cua. */
828+ fun mode (mode : Mode ) = mode(JsonField .of(mode))
829+
830+ /* *
831+ * Sets [Builder.mode] to an arbitrary JSON value.
832+ *
833+ * You should usually call [Builder.mode] with a well-typed [Mode] value instead. This
834+ * method is primarily for setting the field to an undocumented or not yet supported
835+ * value.
836+ */
837+ fun mode (mode : JsonField <Mode >) = apply { this .mode = mode }
838+
808839 /* * Model configuration object or model name string (e.g., 'openai/gpt-5-nano') */
809840 fun model (model : Model ) = model(JsonField .of(model))
810841
@@ -874,7 +905,14 @@ private constructor(
874905 * Further updates to this [Builder] will not mutate the returned instance.
875906 */
876907 fun build (): AgentConfig =
877- AgentConfig (cua, model, provider, systemPrompt, additionalProperties.toMutableMap())
908+ AgentConfig (
909+ cua,
910+ mode,
911+ model,
912+ provider,
913+ systemPrompt,
914+ additionalProperties.toMutableMap(),
915+ )
878916 }
879917
880918 private var validated: Boolean = false
@@ -885,6 +923,7 @@ private constructor(
885923 }
886924
887925 cua()
926+ mode().ifPresent { it.validate() }
888927 model().ifPresent { it.validate() }
889928 provider().ifPresent { it.validate() }
890929 systemPrompt()
@@ -908,10 +947,145 @@ private constructor(
908947 @JvmSynthetic
909948 internal fun validity (): Int =
910949 (if (cua.asKnown().isPresent) 1 else 0 ) +
950+ (mode.asKnown().getOrNull()?.validity() ? : 0 ) +
911951 (model.asKnown().getOrNull()?.validity() ? : 0 ) +
912952 (provider.asKnown().getOrNull()?.validity() ? : 0 ) +
913953 (if (systemPrompt.asKnown().isPresent) 1 else 0 )
914954
955+ /* * Tool mode for the agent (dom, hybrid, cua). If set, overrides cua. */
956+ class Mode @JsonCreator private constructor(private val value : JsonField <String >) : Enum {
957+
958+ /* *
959+ * Returns this class instance's raw value.
960+ *
961+ * This is usually only useful if this instance was deserialized from data that doesn't
962+ * match any known member, and you want to know that value. For example, if the SDK is
963+ * on an older version than the API, then the API may respond with new members that the
964+ * SDK is unaware of.
965+ */
966+ @com.fasterxml.jackson.annotation.JsonValue fun _value (): JsonField <String > = value
967+
968+ companion object {
969+
970+ @JvmField val DOM = of(" dom" )
971+
972+ @JvmField val HYBRID = of(" hybrid" )
973+
974+ @JvmField val CUA = of(" cua" )
975+
976+ @JvmStatic fun of (value : String ) = Mode (JsonField .of(value))
977+ }
978+
979+ /* * An enum containing [Mode]'s known values. */
980+ enum class Known {
981+ DOM ,
982+ HYBRID ,
983+ CUA ,
984+ }
985+
986+ /* *
987+ * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member.
988+ *
989+ * An instance of [Mode] can contain an unknown value in a couple of cases:
990+ * - It was deserialized from data that doesn't match any known member. For example, if
991+ * the SDK is on an older version than the API, then the API may respond with new
992+ * members that the SDK is unaware of.
993+ * - It was constructed with an arbitrary value using the [of] method.
994+ */
995+ enum class Value {
996+ DOM ,
997+ HYBRID ,
998+ CUA ,
999+ /* * An enum member indicating that [Mode] was instantiated with an unknown value. */
1000+ _UNKNOWN ,
1001+ }
1002+
1003+ /* *
1004+ * Returns an enum member corresponding to this class instance's value, or
1005+ * [Value._UNKNOWN] if the class was instantiated with an unknown value.
1006+ *
1007+ * Use the [known] method instead if you're certain the value is always known or if you
1008+ * want to throw for the unknown case.
1009+ */
1010+ fun value (): Value =
1011+ when (this ) {
1012+ DOM -> Value .DOM
1013+ HYBRID -> Value .HYBRID
1014+ CUA -> Value .CUA
1015+ else -> Value ._UNKNOWN
1016+ }
1017+
1018+ /* *
1019+ * Returns an enum member corresponding to this class instance's value.
1020+ *
1021+ * Use the [value] method instead if you're uncertain the value is always known and
1022+ * don't want to throw for the unknown case.
1023+ *
1024+ * @throws StagehandInvalidDataException if this class instance's value is a not a known
1025+ * member.
1026+ */
1027+ fun known (): Known =
1028+ when (this ) {
1029+ DOM -> Known .DOM
1030+ HYBRID -> Known .HYBRID
1031+ CUA -> Known .CUA
1032+ else -> throw StagehandInvalidDataException (" Unknown Mode: $value " )
1033+ }
1034+
1035+ /* *
1036+ * Returns this class instance's primitive wire representation.
1037+ *
1038+ * This differs from the [toString] method because that method is primarily for
1039+ * debugging and generally doesn't throw.
1040+ *
1041+ * @throws StagehandInvalidDataException if this class instance's value does not have
1042+ * the expected primitive type.
1043+ */
1044+ fun asString (): String =
1045+ _value ().asString().orElseThrow {
1046+ StagehandInvalidDataException (" Value is not a String" )
1047+ }
1048+
1049+ private var validated: Boolean = false
1050+
1051+ fun validate (): Mode = apply {
1052+ if (validated) {
1053+ return @apply
1054+ }
1055+
1056+ known()
1057+ validated = true
1058+ }
1059+
1060+ fun isValid (): Boolean =
1061+ try {
1062+ validate()
1063+ true
1064+ } catch (e: StagehandInvalidDataException ) {
1065+ false
1066+ }
1067+
1068+ /* *
1069+ * Returns a score indicating how many valid values are contained in this object
1070+ * recursively.
1071+ *
1072+ * Used for best match union deserialization.
1073+ */
1074+ @JvmSynthetic internal fun validity (): Int = if (value() == Value ._UNKNOWN ) 0 else 1
1075+
1076+ override fun equals (other : Any? ): Boolean {
1077+ if (this == = other) {
1078+ return true
1079+ }
1080+
1081+ return other is Mode && value == other.value
1082+ }
1083+
1084+ override fun hashCode () = value.hashCode()
1085+
1086+ override fun toString () = value.toString()
1087+ }
1088+
9151089 /* * Model configuration object or model name string (e.g., 'openai/gpt-5-nano') */
9161090 @JsonDeserialize(using = Model .Deserializer ::class )
9171091 @JsonSerialize(using = Model .Serializer ::class )
@@ -1234,20 +1408,21 @@ private constructor(
12341408
12351409 return other is AgentConfig &&
12361410 cua == other.cua &&
1411+ mode == other.mode &&
12371412 model == other.model &&
12381413 provider == other.provider &&
12391414 systemPrompt == other.systemPrompt &&
12401415 additionalProperties == other.additionalProperties
12411416 }
12421417
12431418 private val hashCode: Int by lazy {
1244- Objects .hash(cua, model, provider, systemPrompt, additionalProperties)
1419+ Objects .hash(cua, mode, model, provider, systemPrompt, additionalProperties)
12451420 }
12461421
12471422 override fun hashCode (): Int = hashCode
12481423
12491424 override fun toString () =
1250- " AgentConfig{cua=$cua , model=$model , provider=$provider , systemPrompt=$systemPrompt , additionalProperties=$additionalProperties }"
1425+ " AgentConfig{cua=$cua , mode= $mode , model=$model , provider=$provider , systemPrompt=$systemPrompt , additionalProperties=$additionalProperties }"
12511426 }
12521427
12531428 class ExecuteOptions
0 commit comments