Define the startup OAuth protocol for config servers (#62859)

## What changed

Add the optional `target` field to `account/gatewayOAuth/login`.
The startup protocol defines `{"kind":"configServer"}` as a target
for `--startup-oauth`, mutually exclusive with `modelProvider`.
The regular app-server login handler rejects explicit targets.

Define `StartupGatewayOAuthChangedNotification` with the target,
status, and authorization URL for the browser handoff. Export the
new types in the JSON schemas, TypeScript bindings, and Python SDK.

## Testing

Update the TUI device login regression test to expect `target: null`
when signing in to a resumed thread's saved gateway.

GitOrigin-RevId: fb3ce66a143cad9ad56c93f3ac37f8b6f1abdb0e
This commit is contained in:
arnavpatidar-OAI
2026-11-20 23:24:10 +00:00
committed by copyberry
parent beac2ef8fc
commit b392250f48
18 changed files with 360 additions and 40 deletions
+64 -33
View File
@@ -1940,23 +1940,6 @@ class GatewayOAuthCancelResponse(BaseModel):
)
class GatewayOAuthLoginParams(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
device_auth: Annotated[
bool | None,
Field(
alias="deviceAuth",
description="Select device authorization when the server advertises support for it.",
),
] = None
model_provider: Annotated[
str | None,
Field(alias="modelProvider", description="Defaults to the current provider when omitted."),
] = None
class GatewayOAuthPrompt(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
@@ -1983,6 +1966,22 @@ class GatewayOAuthStatus(Enum):
failed = "failed"
class ConfigServerGatewayOAuthTarget(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
kind: Literal["configServer"]
class GatewayOAuthTarget(RootModel[ConfigServerGatewayOAuthTarget]):
root: Annotated[
ConfigServerGatewayOAuthTarget,
Field(
description="An explicit service to authorize instead of the selected model provider."
),
]
class GcpProviderId(RootModel[Literal["gcp"]]):
root: Literal["gcp"]
@@ -3275,10 +3274,6 @@ class NonSteerableTurnKind(Enum):
compact = "compact"
class NullableGatewayOAuthLoginParams(RootModel[GatewayOAuthLoginParams | None]):
root: Annotated[GatewayOAuthLoginParams | None, Field(title="Nullable_GatewayOAuthLoginParams")]
class NullableGatewayOAuthReadParams(RootModel[GatewayOAuthReadParams | None]):
root: Annotated[GatewayOAuthReadParams | None, Field(title="Nullable_GatewayOAuthReadParams")]
@@ -5398,6 +5393,15 @@ class SpendControlLimitSnapshot(BaseModel):
used: str
class StartupGatewayOAuthChangedNotification(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
auth_url: Annotated[str, Field(alias="authUrl")]
status: GatewayOAuthStatus
target: GatewayOAuthTarget
class StrictReviewRequiredNotification(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
@@ -8275,18 +8279,6 @@ class AccountGatewayOAuthReadRequest(BaseModel):
params: GatewayOAuthReadParams | None = None
class AccountGatewayOAuthLoginRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: RequestId
method: Annotated[
Literal["account/gatewayOAuth/login"],
Field(title="Account/gatewayOAuth/loginRequestMethod"),
]
params: GatewayOAuthLoginParams | None = None
class AccountGatewayOAuthCancelRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
@@ -9210,6 +9202,29 @@ class GatewayOAuthChangedNotification(BaseModel):
status: GatewayOAuthStatus
class GatewayOAuthLoginParams(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
device_auth: Annotated[
bool | None,
Field(
alias="deviceAuth",
description="Select device authorization when the server advertises support for it.",
),
] = None
model_provider: Annotated[
str | None,
Field(alias="modelProvider", description="Defaults to the current provider when omitted."),
] = None
target: Annotated[
GatewayOAuthTarget | None,
Field(
description="Available only on `--startup-oauth`. Mutually exclusive with `modelProvider`."
),
] = None
class GatewayOAuthLoginResponse(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
@@ -9864,6 +9879,10 @@ class NewThreadModelDefaults(BaseModel):
service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
class NullableGatewayOAuthLoginParams(RootModel[GatewayOAuthLoginParams | None]):
root: Annotated[GatewayOAuthLoginParams | None, Field(title="Nullable_GatewayOAuthLoginParams")]
class OtlpHttp(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
@@ -12002,6 +12021,18 @@ class ReviewStartRequest(BaseModel):
params: ReviewStartParams
class AccountGatewayOAuthLoginRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: RequestId
method: Annotated[
Literal["account/gatewayOAuth/login"],
Field(title="Account/gatewayOAuth/loginRequestMethod"),
]
params: GatewayOAuthLoginParams | None = None
class ModelProviderConfigWriteRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,