Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.52.0"
".": "0.53.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 112
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-4ce09d1a7546ab36f578cb27d819187eeb90c580b11834c7ff7a375aa22f9a20.yml
openapi_spec_hash: 1043ab2d699f6c828680c3352cd4cece
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-64dac369ae935b0318cd611e1735d45359a663eb55cf43fbb8b09e9dd814d7a2.yml
openapi_spec_hash: cc0c6a4e716977df4b9eab5f4658d41b
config_hash: 08d55086449943a8fec212b870061a3f
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 0.53.0 (2026-05-12)

Full Changelog: [v0.52.0...v0.53.0](https://github.com/kernel/kernel-python-sdk/compare/v0.52.0...v0.53.0)

### Features

* Add 'switch' MFA option type for generic method-switcher links ([82ae224](https://github.com/kernel/kernel-python-sdk/commit/82ae224a85a22b16e48a26a8058cc992ef772cf2))
* Add opt-in record_session flag to managed auth ([53fea1c](https://github.com/kernel/kernel-python-sdk/commit/53fea1c26cd8de2b93944bb7625c401d05362b1c))
* **api:** server-side search on GET /projects ([cacb057](https://github.com/kernel/kernel-python-sdk/commit/cacb057a5d1d3bcb26b6df1f6fe83067f936d642))
* browser_pools: add start_url config (KERNEL-1217 PR 2) ([e3f0b8d](https://github.com/kernel/kernel-python-sdk/commit/e3f0b8db4b2d05140d112317315ba1e393f385cf))
* **internal/types:** support eagerly validating pydantic iterators ([b30bc1e](https://github.com/kernel/kernel-python-sdk/commit/b30bc1e0c3493f12a3499eb037f13561dfdcaedf))
* managed-auth: surface awaiting_external_action even when fallback actions exist ([fd4ffe4](https://github.com/kernel/kernel-python-sdk/commit/fd4ffe40e037e95e93f46b7773d6a5e468c7b8fd))
* Scope name uniqueness to project for profiles, session_pools, extensions, credentials ([c510a51](https://github.com/kernel/kernel-python-sdk/commit/c510a515b3c57846f0e681638167ba87b8ee15c3))


### Bug Fixes

* **client:** add missing f-string prefix in file type error message ([fb5340d](https://github.com/kernel/kernel-python-sdk/commit/fb5340dbf9ea49393d87b5760a2efaaf932c9442))


### Chores

* **internal:** reformat pyproject.toml ([27c799b](https://github.com/kernel/kernel-python-sdk/commit/27c799be452cb66af59b79d24b3d5147a85b70f7))

## 0.52.0 (2026-04-29)

Full Changelog: [v0.51.0...v0.52.0](https://github.com/kernel/kernel-python-sdk/compare/v0.51.0...v0.52.0)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kernel"
version = "0.52.0"
version = "0.53.0"
description = "The official Python library for the kernel API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -168,7 +168,7 @@ show_error_codes = true
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ['src/kernel/_files.py', '_dev/.*.py', 'tests/.*']
exclude = ["src/kernel/_files.py", "_dev/.*.py", "tests/.*"]

strict_equality = true
implicit_reexport = true
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles
elif is_sequence_t(files):
files = [(key, await _async_transform_file(file)) for key, file in files]
else:
raise TypeError("Unexpected file type input {type(files)}, expected mapping or sequence")
raise TypeError(f"Unexpected file type input {type(files)}, expected mapping or sequence")

return files

Expand Down
80 changes: 80 additions & 0 deletions src/kernel/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
ClassVar,
Protocol,
Required,
Annotated,
ParamSpec,
TypeAlias,
TypedDict,
TypeGuard,
final,
Expand Down Expand Up @@ -79,7 +81,15 @@
from ._constants import RAW_RESPONSE_HEADER

if TYPE_CHECKING:
from pydantic import GetCoreSchemaHandler, ValidatorFunctionWrapHandler
from pydantic_core import CoreSchema, core_schema
from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema
else:
try:
from pydantic_core import CoreSchema, core_schema
except ImportError:
CoreSchema = None
core_schema = None

__all__ = ["BaseModel", "GenericModel"]

Expand Down Expand Up @@ -396,6 +406,76 @@ def model_dump_json(
)


class _EagerIterable(list[_T], Generic[_T]):
"""
Accepts any Iterable[T] input (including generators), consumes it
eagerly, and validates all items upfront.

Validation preserves the original container type where possible
(e.g. a set[T] stays a set[T]). Serialization (model_dump / JSON)
always emits a list — round-tripping through model_dump() will not
restore the original container type.
"""

@classmethod
def __get_pydantic_core_schema__(
cls,
source_type: Any,
handler: GetCoreSchemaHandler,
) -> CoreSchema:
(item_type,) = get_args(source_type) or (Any,)
item_schema: CoreSchema = handler.generate_schema(item_type)
list_of_items_schema: CoreSchema = core_schema.list_schema(item_schema)

return core_schema.no_info_wrap_validator_function(
cls._validate,
list_of_items_schema,
serialization=core_schema.plain_serializer_function_ser_schema(
cls._serialize,
info_arg=False,
),
)

@staticmethod
def _validate(v: Iterable[_T], handler: "ValidatorFunctionWrapHandler") -> Any:
original_type: type[Any] = type(v)

# Normalize to list so list_schema can validate each item
if isinstance(v, list):
items: list[_T] = v
else:
try:
items = list(v)
except TypeError as e:
raise TypeError("Value is not iterable") from e

# Validate items against the inner schema
validated: list[_T] = handler(items)

# Reconstruct original container type
if original_type is list:
return validated
# str(list) produces the list's repr, not a string built from items,
# so skip reconstruction for str and its subclasses.
if issubclass(original_type, str):
return validated
try:
return original_type(validated)
except (TypeError, ValueError):
# If the type cannot be reconstructed, just return the validated list
return validated

@staticmethod
def _serialize(v: Iterable[_T]) -> list[_T]:
"""Always serialize as a list so Pydantic's JSON encoder is happy."""
if isinstance(v, list):
return v
return list(v)


EagerIterable: TypeAlias = Annotated[Iterable[_T], _EagerIterable]


def _construct_field(value: object, field: FieldInfo, key: str) -> object:
if value is None:
return field_get_default(field)
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "kernel"
__version__ = "0.52.0" # x-release-please-version
__version__ = "0.53.0" # x-release-please-version
42 changes: 40 additions & 2 deletions src/kernel/resources/auth/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def create(
health_check_interval: int | Omit = omit,
login_url: str | Omit = omit,
proxy: connection_create_params.Proxy | Omit = omit,
record_session: bool | Omit = omit,
save_credentials: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -122,6 +123,9 @@ def create(
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
caller's org.

record_session: Whether to record browser sessions for this connection by default. Useful for
debugging. Can be overridden per-login. Defaults to false.

save_credentials: Whether to save credentials after every successful login. Defaults to true.
One-time codes (TOTP, SMS, etc.) are not saved.

Expand All @@ -144,6 +148,7 @@ def create(
"health_check_interval": health_check_interval,
"login_url": login_url,
"proxy": proxy,
"record_session": record_session,
"save_credentials": save_credentials,
},
connection_create_params.ConnectionCreateParams,
Expand Down Expand Up @@ -198,6 +203,7 @@ def update(
health_check_interval: int | Omit = omit,
login_url: str | Omit = omit,
proxy: connection_update_params.Proxy | Omit = omit,
record_session: bool | Omit = omit,
save_credentials: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -228,6 +234,8 @@ def update(
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
caller's org.

record_session: Whether to record browser sessions for this connection by default

save_credentials: Whether to save credentials after every successful login

extra_headers: Send extra headers
Expand All @@ -249,6 +257,7 @@ def update(
"health_check_interval": health_check_interval,
"login_url": login_url,
"proxy": proxy,
"record_session": record_session,
"save_credentials": save_credentials,
},
connection_update_params.ConnectionUpdateParams,
Expand Down Expand Up @@ -398,6 +407,7 @@ def login(
id: str,
*,
proxy: connection_login_params.Proxy | Omit = omit,
record_session: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -415,6 +425,9 @@ def login(
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
caller's org.

record_session: Override the connection's default for recording this login's browser session.
When omitted, the connection's record_session default is used.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -427,7 +440,13 @@ def login(
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return self._post(
path_template("/auth/connections/{id}/login", id=id),
body=maybe_transform({"proxy": proxy}, connection_login_params.ConnectionLoginParams),
body=maybe_transform(
{
"proxy": proxy,
"record_session": record_session,
},
connection_login_params.ConnectionLoginParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -529,6 +548,7 @@ async def create(
health_check_interval: int | Omit = omit,
login_url: str | Omit = omit,
proxy: connection_create_params.Proxy | Omit = omit,
record_session: bool | Omit = omit,
save_credentials: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -585,6 +605,9 @@ async def create(
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
caller's org.

record_session: Whether to record browser sessions for this connection by default. Useful for
debugging. Can be overridden per-login. Defaults to false.

save_credentials: Whether to save credentials after every successful login. Defaults to true.
One-time codes (TOTP, SMS, etc.) are not saved.

Expand All @@ -607,6 +630,7 @@ async def create(
"health_check_interval": health_check_interval,
"login_url": login_url,
"proxy": proxy,
"record_session": record_session,
"save_credentials": save_credentials,
},
connection_create_params.ConnectionCreateParams,
Expand Down Expand Up @@ -661,6 +685,7 @@ async def update(
health_check_interval: int | Omit = omit,
login_url: str | Omit = omit,
proxy: connection_update_params.Proxy | Omit = omit,
record_session: bool | Omit = omit,
save_credentials: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -691,6 +716,8 @@ async def update(
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
caller's org.

record_session: Whether to record browser sessions for this connection by default

save_credentials: Whether to save credentials after every successful login

extra_headers: Send extra headers
Expand All @@ -712,6 +739,7 @@ async def update(
"health_check_interval": health_check_interval,
"login_url": login_url,
"proxy": proxy,
"record_session": record_session,
"save_credentials": save_credentials,
},
connection_update_params.ConnectionUpdateParams,
Expand Down Expand Up @@ -861,6 +889,7 @@ async def login(
id: str,
*,
proxy: connection_login_params.Proxy | Omit = omit,
record_session: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -878,6 +907,9 @@ async def login(
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
caller's org.

record_session: Override the connection's default for recording this login's browser session.
When omitted, the connection's record_session default is used.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -890,7 +922,13 @@ async def login(
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return await self._post(
path_template("/auth/connections/{id}/login", id=id),
body=await async_maybe_transform({"proxy": proxy}, connection_login_params.ConnectionLoginParams),
body=await async_maybe_transform(
{
"proxy": proxy,
"record_session": record_session,
},
connection_login_params.ConnectionLoginParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down
Loading
Loading