diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml
index 120241d9..994e6250 100644
--- a/.github/workflows/publish-pypi.yml
+++ b/.github/workflows/publish-pypi.yml
@@ -1,6 +1,6 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
-# You can run this workflow by navigating to https://www.github.com/onkernel/kernel-python-sdk/actions/workflows/publish-pypi.yml
+# You can run this workflow by navigating to https://www.github.com/kernel/kernel-python-sdk/actions/workflows/publish-pypi.yml
name: Publish PyPI
on:
workflow_dispatch:
diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml
index 5e7787d0..ba1be2c7 100644
--- a/.github/workflows/release-doctor.yml
+++ b/.github/workflows/release-doctor.yml
@@ -9,7 +9,7 @@ jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
- if: github.repository == 'onkernel/kernel-python-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
+ if: github.repository == 'kernel/kernel-python-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
steps:
- uses: actions/checkout@v4
diff --git a/.stats.yml b/.stats.yml
index 434275ee..e7a094fa 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 89
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-8d66dbedea5b240936b338809f272568ca84a452fc13dbda835479f2ec068b41.yml
-openapi_spec_hash: 7c499bfce2e996f1fff5e7791cea390e
-config_hash: fcc2db3ed48ab4e8d1b588d31d394a23
+configured_endpoints: 90
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-6a44c851ec955b997558a8524eb641355ff3097474f40772b8ea2fef5bee4134.yml
+openapi_spec_hash: 155ee005a1b43e1c11e843de91e9f509
+config_hash: 6cbbf855a29bc675f35ddb1106ea9083
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8130e5f..c6725062 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,25 +1,21 @@
# Changelog
-## 0.25.0 (2026-01-07)
+## 0.25.0 (2026-01-14)
-Full Changelog: [v0.24.0...v0.25.0](https://github.com/onkernel/kernel-python-sdk/compare/v0.24.0...v0.25.0)
+Full Changelog: [v0.24.0...v0.25.0](https://github.com/kernel/kernel-python-sdk/compare/v0.24.0...v0.25.0)
### Features
-* **api:** add health check endpoint for proxies ([105801c](https://github.com/onkernel/kernel-python-sdk/commit/105801ca8028df379b2f79a8a5bd4c4e9f43c3cc))
-* **auth:** add auto_login credential flow ([e941d0f](https://github.com/onkernel/kernel-python-sdk/commit/e941d0fb0a62cb8a1aad2424577c825bd6764df4))
-* Enhance AuthAgentInvocation with step and last activity tracking ([99b8057](https://github.com/onkernel/kernel-python-sdk/commit/99b80574482322b22a5bd1ce79762471330f4945))
-
-
-### Bug Fixes
-
-* use async_to_httpx_files in patch method ([b103991](https://github.com/onkernel/kernel-python-sdk/commit/b1039911a4b2b47df0087821aae2cb0ddc374de2))
+* add MFA options to agent authentication workflow ([b8a377e](https://github.com/kernel/kernel-python-sdk/commit/b8a377e8b82197133f72bc50564f8638d5058240))
+* add WebSocket process attach and PTY support ([9b5dffc](https://github.com/kernel/kernel-python-sdk/commit/9b5dffc744cc1014258e5ad77954e20ae48c1fcc))
+* **api:** manual updates ([0ca37b5](https://github.com/kernel/kernel-python-sdk/commit/0ca37b5edfdca051b6f41892b0d31ccb4ef999c6))
+* **api:** update production repos ([55ded86](https://github.com/kernel/kernel-python-sdk/commit/55ded8610ecc5357b0409a1a3eb3cac4a799ea70))
+* **client:** add support for binary request streaming ([1e748c8](https://github.com/kernel/kernel-python-sdk/commit/1e748c8fc21381cc55dcfc3fca4a067c5b6bd3ba))
### Chores
-* **internal:** add `--fix` argument to lint script ([73e0e46](https://github.com/onkernel/kernel-python-sdk/commit/73e0e4621186edb18b05514b14a638d62a0e5d14))
-* **internal:** codegen related update ([6f18d40](https://github.com/onkernel/kernel-python-sdk/commit/6f18d40b0f1f98b0f50ffb64b7fe858aaefb872f))
+* sync repo ([8427a8c](https://github.com/kernel/kernel-python-sdk/commit/8427a8cb60cfe8a286bd631b109e9b2a70bb72ac))
## 0.24.0 (2025-12-17)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f05c930b..9cb624fb 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -62,7 +62,7 @@ If you’d like to use the repository from source, you can either install from g
To install via git:
```sh
-$ pip install git+ssh://git@github.com/onkernel/kernel-python-sdk.git
+$ pip install git+ssh://git@github.com/kernel/kernel-python-sdk.git
```
Alternatively, you can build from source and install the wheel file:
@@ -120,7 +120,7 @@ the changes aren't made through the automated pipeline, you may want to make rel
### Publish with a GitHub workflow
-You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/onkernel/kernel-python-sdk/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
+You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/kernel/kernel-python-sdk/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
### Publish manually
diff --git a/README.md b/README.md
index 6d1dd19b..2826e5cd 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainless.com/).
## Documentation
-The REST API documentation can be found on [docs.onkernel.com](https://docs.onkernel.com). The full API of this library can be found in [api.md](api.md).
+The REST API documentation can be found on [docs.kernel.com](https://docs.kernel.com). The full API of this library can be found in [api.md](api.md).
## Installation
@@ -363,9 +363,9 @@ browser = response.parse() # get the object that `browsers.create()` would have
print(browser.session_id)
```
-These methods return an [`APIResponse`](https://github.com/onkernel/kernel-python-sdk/tree/main/src/kernel/_response.py) object.
+These methods return an [`APIResponse`](https://github.com/kernel/kernel-python-sdk/tree/main/src/kernel/_response.py) object.
-The async client returns an [`AsyncAPIResponse`](https://github.com/onkernel/kernel-python-sdk/tree/main/src/kernel/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
+The async client returns an [`AsyncAPIResponse`](https://github.com/kernel/kernel-python-sdk/tree/main/src/kernel/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
#### `.with_streaming_response`
@@ -471,7 +471,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
-We are keen for your feedback; please open an [issue](https://www.github.com/onkernel/kernel-python-sdk/issues) with questions, bugs, or suggestions.
+We are keen for your feedback; please open an [issue](https://www.github.com/kernel/kernel-python-sdk/issues) with questions, bugs, or suggestions.
### Determining the installed version
diff --git a/api.md b/api.md
index db5f2dfb..f975c67a 100644
--- a/api.md
+++ b/api.md
@@ -154,6 +154,7 @@ Types:
from kernel.types.browsers import (
ProcessExecResponse,
ProcessKillResponse,
+ ProcessResizeResponse,
ProcessSpawnResponse,
ProcessStatusResponse,
ProcessStdinResponse,
@@ -165,6 +166,7 @@ Methods:
- client.browsers.process.exec(id, \*\*params) -> ProcessExecResponse
- client.browsers.process.kill(process_id, \*, id, \*\*params) -> ProcessKillResponse
+- client.browsers.process.resize(process_id, \*, id, \*\*params) -> ProcessResizeResponse
- client.browsers.process.spawn(id, \*\*params) -> ProcessSpawnResponse
- client.browsers.process.status(process_id, \*, id) -> ProcessStatusResponse
- client.browsers.process.stdin(process_id, \*, id, \*\*params) -> ProcessStdinResponse
diff --git a/pyproject.toml b/pyproject.toml
index 716de1f1..011e9f05 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -37,8 +37,8 @@ classifiers = [
]
[project.urls]
-Homepage = "https://github.com/onkernel/kernel-python-sdk"
-Repository = "https://github.com/onkernel/kernel-python-sdk"
+Homepage = "https://github.com/kernel/kernel-python-sdk"
+Repository = "https://github.com/kernel/kernel-python-sdk"
[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]
@@ -126,7 +126,7 @@ path = "README.md"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# replace relative links with absolute links
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
-replacement = '[\1](https://github.com/onkernel/kernel-python-sdk/tree/main/\g<2>)'
+replacement = '[\1](https://github.com/kernel/kernel-python-sdk/tree/main/\g<2>)'
[tool.pytest.ini_options]
testpaths = ["tests"]
diff --git a/src/kernel/_base_client.py b/src/kernel/_base_client.py
index 787be54c..07809c5b 100644
--- a/src/kernel/_base_client.py
+++ b/src/kernel/_base_client.py
@@ -9,6 +9,7 @@
import inspect
import logging
import platform
+import warnings
import email.utils
from types import TracebackType
from random import random
@@ -51,9 +52,11 @@
ResponseT,
AnyMapping,
PostParser,
+ BinaryTypes,
RequestFiles,
HttpxSendArgs,
RequestOptions,
+ AsyncBinaryTypes,
HttpxRequestFiles,
ModelBuilderProtocol,
not_given,
@@ -477,8 +480,19 @@ def _build_request(
retries_taken: int = 0,
) -> httpx.Request:
if log.isEnabledFor(logging.DEBUG):
- log.debug("Request options: %s", model_dump(options, exclude_unset=True))
-
+ log.debug(
+ "Request options: %s",
+ model_dump(
+ options,
+ exclude_unset=True,
+ # Pydantic v1 can't dump every type we support in content, so we exclude it for now.
+ exclude={
+ "content",
+ }
+ if PYDANTIC_V1
+ else {},
+ ),
+ )
kwargs: dict[str, Any] = {}
json_data = options.json_data
@@ -532,7 +546,13 @@ def _build_request(
is_body_allowed = options.method.lower() != "get"
if is_body_allowed:
- if isinstance(json_data, bytes):
+ if options.content is not None and json_data is not None:
+ raise TypeError("Passing both `content` and `json_data` is not supported")
+ if options.content is not None and files is not None:
+ raise TypeError("Passing both `content` and `files` is not supported")
+ if options.content is not None:
+ kwargs["content"] = options.content
+ elif isinstance(json_data, bytes):
kwargs["content"] = json_data
else:
kwargs["json"] = json_data if is_given(json_data) else None
@@ -1194,6 +1214,7 @@ def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: Literal[False] = False,
@@ -1206,6 +1227,7 @@ def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: Literal[True],
@@ -1219,6 +1241,7 @@ def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: bool,
@@ -1231,13 +1254,25 @@ def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: bool = False,
stream_cls: type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if files is not None and content is not None:
+ raise TypeError("Passing both `files` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
opts = FinalRequestOptions.construct(
- method="post", url=path, json_data=body, files=to_httpx_files(files), **options
+ method="post", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
)
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
@@ -1247,11 +1282,23 @@ def patch(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
) -> ResponseT:
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if files is not None and content is not None:
+ raise TypeError("Passing both `files` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
opts = FinalRequestOptions.construct(
- method="patch", url=path, json_data=body, files=to_httpx_files(files), **options
+ method="patch", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
)
return self.request(cast_to, opts)
@@ -1261,11 +1308,23 @@ def put(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
) -> ResponseT:
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if files is not None and content is not None:
+ raise TypeError("Passing both `files` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
opts = FinalRequestOptions.construct(
- method="put", url=path, json_data=body, files=to_httpx_files(files), **options
+ method="put", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
)
return self.request(cast_to, opts)
@@ -1275,9 +1334,19 @@ def delete(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: BinaryTypes | None = None,
options: RequestOptions = {},
) -> ResponseT:
- opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options)
return self.request(cast_to, opts)
def get_api_list(
@@ -1717,6 +1786,7 @@ async def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
stream: Literal[False] = False,
@@ -1729,6 +1799,7 @@ async def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
stream: Literal[True],
@@ -1742,6 +1813,7 @@ async def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
stream: bool,
@@ -1754,13 +1826,25 @@ async def post(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
stream: bool = False,
stream_cls: type[_AsyncStreamT] | None = None,
) -> ResponseT | _AsyncStreamT:
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if files is not None and content is not None:
+ raise TypeError("Passing both `files` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
opts = FinalRequestOptions.construct(
- method="post", url=path, json_data=body, files=await async_to_httpx_files(files), **options
+ method="post", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options
)
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
@@ -1770,11 +1854,28 @@ async def patch(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
) -> ResponseT:
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if files is not None and content is not None:
+ raise TypeError("Passing both `files` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
opts = FinalRequestOptions.construct(
- method="patch", url=path, json_data=body, files=await async_to_httpx_files(files), **options
+ method="patch",
+ url=path,
+ json_data=body,
+ content=content,
+ files=await async_to_httpx_files(files),
+ **options,
)
return await self.request(cast_to, opts)
@@ -1784,11 +1885,23 @@ async def put(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
files: RequestFiles | None = None,
options: RequestOptions = {},
) -> ResponseT:
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if files is not None and content is not None:
+ raise TypeError("Passing both `files` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
opts = FinalRequestOptions.construct(
- method="put", url=path, json_data=body, files=await async_to_httpx_files(files), **options
+ method="put", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options
)
return await self.request(cast_to, opts)
@@ -1798,9 +1911,19 @@ async def delete(
*,
cast_to: Type[ResponseT],
body: Body | None = None,
+ content: AsyncBinaryTypes | None = None,
options: RequestOptions = {},
) -> ResponseT:
- opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
+ if body is not None and content is not None:
+ raise TypeError("Passing both `body` and `content` is not supported")
+ if isinstance(body, bytes):
+ warnings.warn(
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
+ "Please pass raw bytes via the `content` parameter instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options)
return await self.request(cast_to, opts)
def get_api_list(
diff --git a/src/kernel/_files.py b/src/kernel/_files.py
index 9a6dd194..bbef8bfb 100644
--- a/src/kernel/_files.py
+++ b/src/kernel/_files.py
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
if not is_file_content(obj):
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
raise RuntimeError(
- f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/onkernel/kernel-python-sdk/tree/main#file-uploads"
+ f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/kernel/kernel-python-sdk/tree/main#file-uploads"
) from None
diff --git a/src/kernel/_models.py b/src/kernel/_models.py
index ca9500b2..29070e05 100644
--- a/src/kernel/_models.py
+++ b/src/kernel/_models.py
@@ -3,7 +3,20 @@
import os
import inspect
import weakref
-from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
+from typing import (
+ IO,
+ TYPE_CHECKING,
+ Any,
+ Type,
+ Union,
+ Generic,
+ TypeVar,
+ Callable,
+ Iterable,
+ Optional,
+ AsyncIterable,
+ cast,
+)
from datetime import date, datetime
from typing_extensions import (
List,
@@ -787,6 +800,7 @@ class FinalRequestOptionsInput(TypedDict, total=False):
timeout: float | Timeout | None
files: HttpxRequestFiles | None
idempotency_key: str
+ content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None]
json_data: Body
extra_json: AnyMapping
follow_redirects: bool
@@ -805,6 +819,7 @@ class FinalRequestOptions(pydantic.BaseModel):
post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
follow_redirects: Union[bool, None] = None
+ content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None
# It should be noted that we cannot use `json` here as that would override
# a BaseModel method in an incompatible fashion.
json_data: Union[Body, None] = None
diff --git a/src/kernel/_types.py b/src/kernel/_types.py
index 275ffbbc..28254f95 100644
--- a/src/kernel/_types.py
+++ b/src/kernel/_types.py
@@ -13,9 +13,11 @@
Mapping,
TypeVar,
Callable,
+ Iterable,
Iterator,
Optional,
Sequence,
+ AsyncIterable,
)
from typing_extensions import (
Set,
@@ -56,6 +58,13 @@
else:
Base64FileInput = Union[IO[bytes], PathLike]
FileContent = Union[IO[bytes], bytes, PathLike] # PathLike is not subscriptable in Python 3.8.
+
+
+# Used for sending raw binary data / streaming data in request bodies
+# e.g. for file uploads without multipart encoding
+BinaryTypes = Union[bytes, bytearray, IO[bytes], Iterable[bytes]]
+AsyncBinaryTypes = Union[bytes, bytearray, IO[bytes], AsyncIterable[bytes]]
+
FileTypes = Union[
# file (or bytes)
FileContent,
diff --git a/src/kernel/resources/agents/agents.py b/src/kernel/resources/agents/agents.py
index b7bb580c..6999bd58 100644
--- a/src/kernel/resources/agents/agents.py
+++ b/src/kernel/resources/agents/agents.py
@@ -27,7 +27,7 @@ def with_raw_response(self) -> AgentsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AgentsResourceWithRawResponse(self)
@@ -36,7 +36,7 @@ def with_streaming_response(self) -> AgentsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AgentsResourceWithStreamingResponse(self)
@@ -52,7 +52,7 @@ def with_raw_response(self) -> AsyncAgentsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncAgentsResourceWithRawResponse(self)
@@ -61,7 +61,7 @@ def with_streaming_response(self) -> AsyncAgentsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncAgentsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/agents/auth/auth.py b/src/kernel/resources/agents/auth/auth.py
index f4a02767..4a541f73 100644
--- a/src/kernel/resources/agents/auth/auth.py
+++ b/src/kernel/resources/agents/auth/auth.py
@@ -41,7 +41,7 @@ def with_raw_response(self) -> AuthResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AuthResourceWithRawResponse(self)
@@ -50,7 +50,7 @@ def with_streaming_response(self) -> AuthResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AuthResourceWithStreamingResponse(self)
@@ -262,7 +262,7 @@ def with_raw_response(self) -> AsyncAuthResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncAuthResourceWithRawResponse(self)
@@ -271,7 +271,7 @@ def with_streaming_response(self) -> AsyncAuthResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncAuthResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/agents/auth/invocations.py b/src/kernel/resources/agents/auth/invocations.py
index 34ab614d..fcd5e3a6 100644
--- a/src/kernel/resources/agents/auth/invocations.py
+++ b/src/kernel/resources/agents/auth/invocations.py
@@ -3,7 +3,7 @@
from __future__ import annotations
from typing import Dict
-from typing_extensions import overload
+from typing_extensions import Literal, overload
import httpx
@@ -34,7 +34,7 @@ def with_raw_response(self) -> InvocationsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return InvocationsResourceWithRawResponse(self)
@@ -43,7 +43,7 @@ def with_streaming_response(self) -> InvocationsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return InvocationsResourceWithStreamingResponse(self)
@@ -233,13 +233,46 @@ def submit(
"""
...
- @required_args(["field_values"], ["sso_button"])
+ @overload
+ def submit(
+ self,
+ invocation_id: str,
+ *,
+ selected_mfa_type: Literal["sms", "call", "email", "totp", "push", "security_key"],
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
+ ) -> AgentAuthSubmitResponse:
+ """Submits field values for the discovered login form.
+
+ Returns immediately after
+ submission is accepted. Poll the invocation endpoint to track progress and get
+ results.
+
+ Args:
+ selected_mfa_type: The MFA delivery method type
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
+
+ @required_args(["field_values"], ["sso_button"], ["selected_mfa_type"])
def submit(
self,
invocation_id: str,
*,
field_values: Dict[str, str] | Omit = omit,
sso_button: str | Omit = omit,
+ selected_mfa_type: Literal["sms", "call", "email", "totp", "push", "security_key"] | 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,
@@ -255,6 +288,7 @@ def submit(
{
"field_values": field_values,
"sso_button": sso_button,
+ "selected_mfa_type": selected_mfa_type,
},
invocation_submit_params.InvocationSubmitParams,
),
@@ -272,7 +306,7 @@ def with_raw_response(self) -> AsyncInvocationsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncInvocationsResourceWithRawResponse(self)
@@ -281,7 +315,7 @@ def with_streaming_response(self) -> AsyncInvocationsResourceWithStreamingRespon
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncInvocationsResourceWithStreamingResponse(self)
@@ -471,13 +505,46 @@ async def submit(
"""
...
- @required_args(["field_values"], ["sso_button"])
+ @overload
+ async def submit(
+ self,
+ invocation_id: str,
+ *,
+ selected_mfa_type: Literal["sms", "call", "email", "totp", "push", "security_key"],
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
+ ) -> AgentAuthSubmitResponse:
+ """Submits field values for the discovered login form.
+
+ Returns immediately after
+ submission is accepted. Poll the invocation endpoint to track progress and get
+ results.
+
+ Args:
+ selected_mfa_type: The MFA delivery method type
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
+
+ @required_args(["field_values"], ["sso_button"], ["selected_mfa_type"])
async def submit(
self,
invocation_id: str,
*,
field_values: Dict[str, str] | Omit = omit,
sso_button: str | Omit = omit,
+ selected_mfa_type: Literal["sms", "call", "email", "totp", "push", "security_key"] | 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,
@@ -493,6 +560,7 @@ async def submit(
{
"field_values": field_values,
"sso_button": sso_button,
+ "selected_mfa_type": selected_mfa_type,
},
invocation_submit_params.InvocationSubmitParams,
),
diff --git a/src/kernel/resources/apps.py b/src/kernel/resources/apps.py
index b803299d..0443e73a 100644
--- a/src/kernel/resources/apps.py
+++ b/src/kernel/resources/apps.py
@@ -29,7 +29,7 @@ def with_raw_response(self) -> AppsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AppsResourceWithRawResponse(self)
@@ -38,7 +38,7 @@ def with_streaming_response(self) -> AppsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AppsResourceWithStreamingResponse(self)
@@ -106,7 +106,7 @@ def with_raw_response(self) -> AsyncAppsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncAppsResourceWithRawResponse(self)
@@ -115,7 +115,7 @@ def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncAppsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browser_pools.py b/src/kernel/resources/browser_pools.py
index 8c480ed5..5a4bf61b 100644
--- a/src/kernel/resources/browser_pools.py
+++ b/src/kernel/resources/browser_pools.py
@@ -41,7 +41,7 @@ def with_raw_response(self) -> BrowserPoolsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return BrowserPoolsResourceWithRawResponse(self)
@@ -50,7 +50,7 @@ def with_streaming_response(self) -> BrowserPoolsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return BrowserPoolsResourceWithStreamingResponse(self)
@@ -475,7 +475,7 @@ def with_raw_response(self) -> AsyncBrowserPoolsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncBrowserPoolsResourceWithRawResponse(self)
@@ -484,7 +484,7 @@ def with_streaming_response(self) -> AsyncBrowserPoolsResourceWithStreamingRespo
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncBrowserPoolsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browsers/browsers.py b/src/kernel/resources/browsers/browsers.py
index cbd17736..8050a7dc 100644
--- a/src/kernel/resources/browsers/browsers.py
+++ b/src/kernel/resources/browsers/browsers.py
@@ -115,7 +115,7 @@ def with_raw_response(self) -> BrowsersResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return BrowsersResourceWithRawResponse(self)
@@ -124,7 +124,7 @@ def with_streaming_response(self) -> BrowsersResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return BrowsersResourceWithStreamingResponse(self)
@@ -460,7 +460,7 @@ def with_raw_response(self) -> AsyncBrowsersResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncBrowsersResourceWithRawResponse(self)
@@ -469,7 +469,7 @@ def with_streaming_response(self) -> AsyncBrowsersResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncBrowsersResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browsers/computer.py b/src/kernel/resources/browsers/computer.py
index 87d377fd..c23dd3db 100644
--- a/src/kernel/resources/browsers/computer.py
+++ b/src/kernel/resources/browsers/computer.py
@@ -48,7 +48,7 @@ def with_raw_response(self) -> ComputerResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return ComputerResourceWithRawResponse(self)
@@ -57,7 +57,7 @@ def with_streaming_response(self) -> ComputerResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return ComputerResourceWithStreamingResponse(self)
@@ -486,7 +486,7 @@ def with_raw_response(self) -> AsyncComputerResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncComputerResourceWithRawResponse(self)
@@ -495,7 +495,7 @@ def with_streaming_response(self) -> AsyncComputerResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncComputerResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browsers/fs/fs.py b/src/kernel/resources/browsers/fs/fs.py
index ff0cc48a..3501a2a6 100644
--- a/src/kernel/resources/browsers/fs/fs.py
+++ b/src/kernel/resources/browsers/fs/fs.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import os
from typing import Mapping, Iterable, cast
import httpx
@@ -15,7 +16,20 @@
AsyncWatchResourceWithStreamingResponse,
)
from ...._files import read_file_content, async_read_file_content
-from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, FileContent, omit, not_given
+from ...._types import (
+ Body,
+ Omit,
+ Query,
+ Headers,
+ NoneType,
+ NotGiven,
+ FileTypes,
+ BinaryTypes,
+ FileContent,
+ AsyncBinaryTypes,
+ omit,
+ not_given,
+)
from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -65,7 +79,7 @@ def with_raw_response(self) -> FsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return FsResourceWithRawResponse(self)
@@ -74,7 +88,7 @@ def with_streaming_response(self) -> FsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return FsResourceWithStreamingResponse(self)
@@ -562,7 +576,7 @@ def upload_zip(
def write_file(
self,
id: str,
- contents: FileContent,
+ contents: FileContent | BinaryTypes,
*,
path: str,
mode: str | Omit = omit,
@@ -595,7 +609,7 @@ def write_file(
extra_headers["Content-Type"] = "application/octet-stream"
return self._put(
f"/browsers/{id}/fs/write_file",
- body=read_file_content(contents),
+ content=read_file_content(contents) if isinstance(contents, os.PathLike) else contents,
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -624,7 +638,7 @@ def with_raw_response(self) -> AsyncFsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncFsResourceWithRawResponse(self)
@@ -633,7 +647,7 @@ def with_streaming_response(self) -> AsyncFsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncFsResourceWithStreamingResponse(self)
@@ -1121,7 +1135,7 @@ async def upload_zip(
async def write_file(
self,
id: str,
- contents: FileContent,
+ contents: FileContent | AsyncBinaryTypes,
*,
path: str,
mode: str | Omit = omit,
@@ -1154,7 +1168,7 @@ async def write_file(
extra_headers["Content-Type"] = "application/octet-stream"
return await self._put(
f"/browsers/{id}/fs/write_file",
- body=await async_read_file_content(contents),
+ content=await async_read_file_content(contents) if isinstance(contents, os.PathLike) else contents,
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
diff --git a/src/kernel/resources/browsers/fs/watch.py b/src/kernel/resources/browsers/fs/watch.py
index ad26f2ae..2a5c1e30 100644
--- a/src/kernel/resources/browsers/fs/watch.py
+++ b/src/kernel/resources/browsers/fs/watch.py
@@ -30,7 +30,7 @@ def with_raw_response(self) -> WatchResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return WatchResourceWithRawResponse(self)
@@ -39,7 +39,7 @@ def with_streaming_response(self) -> WatchResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return WatchResourceWithStreamingResponse(self)
@@ -173,7 +173,7 @@ def with_raw_response(self) -> AsyncWatchResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncWatchResourceWithRawResponse(self)
@@ -182,7 +182,7 @@ def with_streaming_response(self) -> AsyncWatchResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncWatchResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browsers/logs.py b/src/kernel/resources/browsers/logs.py
index 1fd291d4..ab97a70d 100644
--- a/src/kernel/resources/browsers/logs.py
+++ b/src/kernel/resources/browsers/logs.py
@@ -31,7 +31,7 @@ def with_raw_response(self) -> LogsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return LogsResourceWithRawResponse(self)
@@ -40,7 +40,7 @@ def with_streaming_response(self) -> LogsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return LogsResourceWithStreamingResponse(self)
@@ -108,7 +108,7 @@ def with_raw_response(self) -> AsyncLogsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncLogsResourceWithRawResponse(self)
@@ -117,7 +117,7 @@ def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncLogsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browsers/playwright.py b/src/kernel/resources/browsers/playwright.py
index c168a4a7..5c47e3bf 100644
--- a/src/kernel/resources/browsers/playwright.py
+++ b/src/kernel/resources/browsers/playwright.py
@@ -28,7 +28,7 @@ def with_raw_response(self) -> PlaywrightResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return PlaywrightResourceWithRawResponse(self)
@@ -37,7 +37,7 @@ def with_streaming_response(self) -> PlaywrightResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return PlaywrightResourceWithStreamingResponse(self)
@@ -102,7 +102,7 @@ def with_raw_response(self) -> AsyncPlaywrightResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncPlaywrightResourceWithRawResponse(self)
@@ -111,7 +111,7 @@ def with_streaming_response(self) -> AsyncPlaywrightResourceWithStreamingRespons
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncPlaywrightResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/browsers/process.py b/src/kernel/resources/browsers/process.py
index 2bdaeebe..9932f40c 100644
--- a/src/kernel/resources/browsers/process.py
+++ b/src/kernel/resources/browsers/process.py
@@ -19,11 +19,18 @@
)
from ..._streaming import Stream, AsyncStream
from ..._base_client import make_request_options
-from ...types.browsers import process_exec_params, process_kill_params, process_spawn_params, process_stdin_params
+from ...types.browsers import (
+ process_exec_params,
+ process_kill_params,
+ process_spawn_params,
+ process_stdin_params,
+ process_resize_params,
+)
from ...types.browsers.process_exec_response import ProcessExecResponse
from ...types.browsers.process_kill_response import ProcessKillResponse
from ...types.browsers.process_spawn_response import ProcessSpawnResponse
from ...types.browsers.process_stdin_response import ProcessStdinResponse
+from ...types.browsers.process_resize_response import ProcessResizeResponse
from ...types.browsers.process_status_response import ProcessStatusResponse
from ...types.browsers.process_stdout_stream_response import ProcessStdoutStreamResponse
@@ -37,7 +44,7 @@ def with_raw_response(self) -> ProcessResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return ProcessResourceWithRawResponse(self)
@@ -46,7 +53,7 @@ def with_streaming_response(self) -> ProcessResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return ProcessResourceWithStreamingResponse(self)
@@ -156,16 +163,68 @@ def kill(
cast_to=ProcessKillResponse,
)
+ def resize(
+ self,
+ process_id: str,
+ *,
+ id: str,
+ cols: int,
+ rows: int,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
+ ) -> ProcessResizeResponse:
+ """
+ Resize a PTY-backed process terminal
+
+ Args:
+ cols: New terminal columns.
+
+ rows: New terminal rows.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ if not process_id:
+ raise ValueError(f"Expected a non-empty value for `process_id` but received {process_id!r}")
+ return self._post(
+ f"/browsers/{id}/process/{process_id}/resize",
+ body=maybe_transform(
+ {
+ "cols": cols,
+ "rows": rows,
+ },
+ process_resize_params.ProcessResizeParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=ProcessResizeResponse,
+ )
+
def spawn(
self,
id: str,
*,
command: str,
+ allocate_tty: bool | Omit = omit,
args: SequenceNotStr[str] | Omit = omit,
as_root: bool | Omit = omit,
as_user: Optional[str] | Omit = omit,
+ cols: int | Omit = omit,
cwd: Optional[str] | Omit = omit,
env: Dict[str, str] | Omit = omit,
+ rows: int | Omit = omit,
timeout_sec: Optional[int] | 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.
@@ -180,16 +239,22 @@ def spawn(
Args:
command: Executable or shell command to run.
+ allocate_tty: Allocate a pseudo-terminal (PTY) for interactive shells.
+
args: Command arguments.
as_root: Run the process with root privileges.
as_user: Run the process as this user.
+ cols: Initial terminal columns. Only used when allocate_tty is true.
+
cwd: Working directory (absolute path) to run the command in.
env: Environment variables to set for the process.
+ rows: Initial terminal rows. Only used when allocate_tty is true.
+
timeout_sec: Maximum execution time in seconds.
extra_headers: Send extra headers
@@ -207,11 +272,14 @@ def spawn(
body=maybe_transform(
{
"command": command,
+ "allocate_tty": allocate_tty,
"args": args,
"as_root": as_root,
"as_user": as_user,
+ "cols": cols,
"cwd": cwd,
"env": env,
+ "rows": rows,
"timeout_sec": timeout_sec,
},
process_spawn_params.ProcessSpawnParams,
@@ -345,7 +413,7 @@ def with_raw_response(self) -> AsyncProcessResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncProcessResourceWithRawResponse(self)
@@ -354,7 +422,7 @@ def with_streaming_response(self) -> AsyncProcessResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncProcessResourceWithStreamingResponse(self)
@@ -464,16 +532,68 @@ async def kill(
cast_to=ProcessKillResponse,
)
+ async def resize(
+ self,
+ process_id: str,
+ *,
+ id: str,
+ cols: int,
+ rows: int,
+ # 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
+ ) -> ProcessResizeResponse:
+ """
+ Resize a PTY-backed process terminal
+
+ Args:
+ cols: New terminal columns.
+
+ rows: New terminal rows.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ if not process_id:
+ raise ValueError(f"Expected a non-empty value for `process_id` but received {process_id!r}")
+ return await self._post(
+ f"/browsers/{id}/process/{process_id}/resize",
+ body=await async_maybe_transform(
+ {
+ "cols": cols,
+ "rows": rows,
+ },
+ process_resize_params.ProcessResizeParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=ProcessResizeResponse,
+ )
+
async def spawn(
self,
id: str,
*,
command: str,
+ allocate_tty: bool | Omit = omit,
args: SequenceNotStr[str] | Omit = omit,
as_root: bool | Omit = omit,
as_user: Optional[str] | Omit = omit,
+ cols: int | Omit = omit,
cwd: Optional[str] | Omit = omit,
env: Dict[str, str] | Omit = omit,
+ rows: int | Omit = omit,
timeout_sec: Optional[int] | 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.
@@ -488,16 +608,22 @@ async def spawn(
Args:
command: Executable or shell command to run.
+ allocate_tty: Allocate a pseudo-terminal (PTY) for interactive shells.
+
args: Command arguments.
as_root: Run the process with root privileges.
as_user: Run the process as this user.
+ cols: Initial terminal columns. Only used when allocate_tty is true.
+
cwd: Working directory (absolute path) to run the command in.
env: Environment variables to set for the process.
+ rows: Initial terminal rows. Only used when allocate_tty is true.
+
timeout_sec: Maximum execution time in seconds.
extra_headers: Send extra headers
@@ -515,11 +641,14 @@ async def spawn(
body=await async_maybe_transform(
{
"command": command,
+ "allocate_tty": allocate_tty,
"args": args,
"as_root": as_root,
"as_user": as_user,
+ "cols": cols,
"cwd": cwd,
"env": env,
+ "rows": rows,
"timeout_sec": timeout_sec,
},
process_spawn_params.ProcessSpawnParams,
@@ -656,6 +785,9 @@ def __init__(self, process: ProcessResource) -> None:
self.kill = to_raw_response_wrapper(
process.kill,
)
+ self.resize = to_raw_response_wrapper(
+ process.resize,
+ )
self.spawn = to_raw_response_wrapper(
process.spawn,
)
@@ -680,6 +812,9 @@ def __init__(self, process: AsyncProcessResource) -> None:
self.kill = async_to_raw_response_wrapper(
process.kill,
)
+ self.resize = async_to_raw_response_wrapper(
+ process.resize,
+ )
self.spawn = async_to_raw_response_wrapper(
process.spawn,
)
@@ -704,6 +839,9 @@ def __init__(self, process: ProcessResource) -> None:
self.kill = to_streamed_response_wrapper(
process.kill,
)
+ self.resize = to_streamed_response_wrapper(
+ process.resize,
+ )
self.spawn = to_streamed_response_wrapper(
process.spawn,
)
@@ -728,6 +866,9 @@ def __init__(self, process: AsyncProcessResource) -> None:
self.kill = async_to_streamed_response_wrapper(
process.kill,
)
+ self.resize = async_to_streamed_response_wrapper(
+ process.resize,
+ )
self.spawn = async_to_streamed_response_wrapper(
process.spawn,
)
diff --git a/src/kernel/resources/browsers/replays.py b/src/kernel/resources/browsers/replays.py
index 9f15554a..8a1d1996 100644
--- a/src/kernel/resources/browsers/replays.py
+++ b/src/kernel/resources/browsers/replays.py
@@ -37,7 +37,7 @@ def with_raw_response(self) -> ReplaysResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return ReplaysResourceWithRawResponse(self)
@@ -46,7 +46,7 @@ def with_streaming_response(self) -> ReplaysResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return ReplaysResourceWithStreamingResponse(self)
@@ -211,7 +211,7 @@ def with_raw_response(self) -> AsyncReplaysResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncReplaysResourceWithRawResponse(self)
@@ -220,7 +220,7 @@ def with_streaming_response(self) -> AsyncReplaysResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncReplaysResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/credentials.py b/src/kernel/resources/credentials.py
index 85e0c8a0..30e72e84 100644
--- a/src/kernel/resources/credentials.py
+++ b/src/kernel/resources/credentials.py
@@ -32,7 +32,7 @@ def with_raw_response(self) -> CredentialsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return CredentialsResourceWithRawResponse(self)
@@ -41,7 +41,7 @@ def with_streaming_response(self) -> CredentialsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return CredentialsResourceWithStreamingResponse(self)
@@ -327,7 +327,7 @@ def with_raw_response(self) -> AsyncCredentialsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncCredentialsResourceWithRawResponse(self)
@@ -336,7 +336,7 @@ def with_streaming_response(self) -> AsyncCredentialsResourceWithStreamingRespon
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncCredentialsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/deployments.py b/src/kernel/resources/deployments.py
index bdc200f1..f924531c 100644
--- a/src/kernel/resources/deployments.py
+++ b/src/kernel/resources/deployments.py
@@ -36,7 +36,7 @@ def with_raw_response(self) -> DeploymentsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return DeploymentsResourceWithRawResponse(self)
@@ -45,7 +45,7 @@ def with_streaming_response(self) -> DeploymentsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return DeploymentsResourceWithStreamingResponse(self)
@@ -259,7 +259,7 @@ def with_raw_response(self) -> AsyncDeploymentsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncDeploymentsResourceWithRawResponse(self)
@@ -268,7 +268,7 @@ def with_streaming_response(self) -> AsyncDeploymentsResourceWithStreamingRespon
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncDeploymentsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/extensions.py b/src/kernel/resources/extensions.py
index 2f868716..69497b1f 100644
--- a/src/kernel/resources/extensions.py
+++ b/src/kernel/resources/extensions.py
@@ -40,7 +40,7 @@ def with_raw_response(self) -> ExtensionsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return ExtensionsResourceWithRawResponse(self)
@@ -49,7 +49,7 @@ def with_streaming_response(self) -> ExtensionsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return ExtensionsResourceWithStreamingResponse(self)
@@ -247,7 +247,7 @@ def with_raw_response(self) -> AsyncExtensionsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncExtensionsResourceWithRawResponse(self)
@@ -256,7 +256,7 @@ def with_streaming_response(self) -> AsyncExtensionsResourceWithStreamingRespons
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncExtensionsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/invocations.py b/src/kernel/resources/invocations.py
index fa808dd0..3b812d45 100644
--- a/src/kernel/resources/invocations.py
+++ b/src/kernel/resources/invocations.py
@@ -37,7 +37,7 @@ def with_raw_response(self) -> InvocationsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return InvocationsResourceWithRawResponse(self)
@@ -46,7 +46,7 @@ def with_streaming_response(self) -> InvocationsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return InvocationsResourceWithStreamingResponse(self)
@@ -355,7 +355,7 @@ def with_raw_response(self) -> AsyncInvocationsResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncInvocationsResourceWithRawResponse(self)
@@ -364,7 +364,7 @@ def with_streaming_response(self) -> AsyncInvocationsResourceWithStreamingRespon
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncInvocationsResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/profiles.py b/src/kernel/resources/profiles.py
index 8d51da38..86064d52 100644
--- a/src/kernel/resources/profiles.py
+++ b/src/kernel/resources/profiles.py
@@ -37,7 +37,7 @@ def with_raw_response(self) -> ProfilesResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return ProfilesResourceWithRawResponse(self)
@@ -46,7 +46,7 @@ def with_streaming_response(self) -> ProfilesResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return ProfilesResourceWithStreamingResponse(self)
@@ -215,7 +215,7 @@ def with_raw_response(self) -> AsyncProfilesResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncProfilesResourceWithRawResponse(self)
@@ -224,7 +224,7 @@ def with_streaming_response(self) -> AsyncProfilesResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncProfilesResourceWithStreamingResponse(self)
diff --git a/src/kernel/resources/proxies.py b/src/kernel/resources/proxies.py
index 4908ab79..6574a256 100644
--- a/src/kernel/resources/proxies.py
+++ b/src/kernel/resources/proxies.py
@@ -33,7 +33,7 @@ def with_raw_response(self) -> ProxiesResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return ProxiesResourceWithRawResponse(self)
@@ -42,7 +42,7 @@ def with_streaming_response(self) -> ProxiesResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return ProxiesResourceWithStreamingResponse(self)
@@ -226,7 +226,7 @@ def with_raw_response(self) -> AsyncProxiesResourceWithRawResponse:
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers
"""
return AsyncProxiesResourceWithRawResponse(self)
@@ -235,7 +235,7 @@ def with_streaming_response(self) -> AsyncProxiesResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
- For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response
+ For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response
"""
return AsyncProxiesResourceWithStreamingResponse(self)
diff --git a/src/kernel/types/agents/agent_auth_invocation_response.py b/src/kernel/types/agents/agent_auth_invocation_response.py
index 42b54a4c..2731290e 100644
--- a/src/kernel/types/agents/agent_auth_invocation_response.py
+++ b/src/kernel/types/agents/agent_auth_invocation_response.py
@@ -7,7 +7,23 @@
from ..._models import BaseModel
from .discovered_field import DiscoveredField
-__all__ = ["AgentAuthInvocationResponse", "PendingSSOButton"]
+__all__ = ["AgentAuthInvocationResponse", "MfaOption", "PendingSSOButton"]
+
+
+class MfaOption(BaseModel):
+ """An MFA method option for verification"""
+
+ label: str
+ """The visible option text"""
+
+ type: Literal["sms", "call", "email", "totp", "push", "security_key"]
+ """The MFA delivery method type"""
+
+ description: Optional[str] = None
+ """Additional instructions from the site"""
+
+ target: Optional[str] = None
+ """The masked destination (phone/email) if shown"""
class PendingSSOButton(BaseModel):
@@ -63,6 +79,12 @@ class AgentAuthInvocationResponse(BaseModel):
live_view_url: Optional[str] = None
"""Browser live view URL for debugging the invocation"""
+ mfa_options: Optional[List[MfaOption]] = None
+ """
+ MFA method options to choose from (present when step=awaiting_input and MFA
+ selection is required)
+ """
+
pending_fields: Optional[List[DiscoveredField]] = None
"""Fields currently awaiting input (present when step=awaiting_input)"""
diff --git a/src/kernel/types/agents/auth/invocation_submit_params.py b/src/kernel/types/agents/auth/invocation_submit_params.py
index ad9f9c18..7a9c5aca 100644
--- a/src/kernel/types/agents/auth/invocation_submit_params.py
+++ b/src/kernel/types/agents/auth/invocation_submit_params.py
@@ -3,9 +3,9 @@
from __future__ import annotations
from typing import Dict, Union
-from typing_extensions import Required, TypeAlias, TypedDict
+from typing_extensions import Literal, Required, TypeAlias, TypedDict
-__all__ = ["InvocationSubmitParams", "Variant0", "Variant1"]
+__all__ = ["InvocationSubmitParams", "Variant0", "Variant1", "Variant2"]
class Variant0(TypedDict, total=False):
@@ -18,4 +18,9 @@ class Variant1(TypedDict, total=False):
"""Selector of SSO button to click"""
-InvocationSubmitParams: TypeAlias = Union[Variant0, Variant1]
+class Variant2(TypedDict, total=False):
+ selected_mfa_type: Required[Literal["sms", "call", "email", "totp", "push", "security_key"]]
+ """The MFA delivery method type"""
+
+
+InvocationSubmitParams: TypeAlias = Union[Variant0, Variant1, Variant2]
diff --git a/src/kernel/types/browsers/__init__.py b/src/kernel/types/browsers/__init__.py
index 546fdc64..e6b2eca3 100644
--- a/src/kernel/types/browsers/__init__.py
+++ b/src/kernel/types/browsers/__init__.py
@@ -21,10 +21,12 @@
from .f_list_files_response import FListFilesResponse as FListFilesResponse
from .process_exec_response import ProcessExecResponse as ProcessExecResponse
from .process_kill_response import ProcessKillResponse as ProcessKillResponse
+from .process_resize_params import ProcessResizeParams as ProcessResizeParams
from .replay_start_response import ReplayStartResponse as ReplayStartResponse
from .computer_scroll_params import ComputerScrollParams as ComputerScrollParams
from .process_spawn_response import ProcessSpawnResponse as ProcessSpawnResponse
from .process_stdin_response import ProcessStdinResponse as ProcessStdinResponse
+from .process_resize_response import ProcessResizeResponse as ProcessResizeResponse
from .process_status_response import ProcessStatusResponse as ProcessStatusResponse
from .computer_press_key_params import ComputerPressKeyParams as ComputerPressKeyParams
from .computer_type_text_params import ComputerTypeTextParams as ComputerTypeTextParams
diff --git a/src/kernel/types/browsers/process_resize_params.py b/src/kernel/types/browsers/process_resize_params.py
new file mode 100644
index 00000000..4fdb8ad5
--- /dev/null
+++ b/src/kernel/types/browsers/process_resize_params.py
@@ -0,0 +1,17 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["ProcessResizeParams"]
+
+
+class ProcessResizeParams(TypedDict, total=False):
+ id: Required[str]
+
+ cols: Required[int]
+ """New terminal columns."""
+
+ rows: Required[int]
+ """New terminal rows."""
diff --git a/src/kernel/types/browsers/process_resize_response.py b/src/kernel/types/browsers/process_resize_response.py
new file mode 100644
index 00000000..6997517d
--- /dev/null
+++ b/src/kernel/types/browsers/process_resize_response.py
@@ -0,0 +1,12 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from ..._models import BaseModel
+
+__all__ = ["ProcessResizeResponse"]
+
+
+class ProcessResizeResponse(BaseModel):
+ """Generic OK response."""
+
+ ok: bool
+ """Indicates success."""
diff --git a/src/kernel/types/browsers/process_spawn_params.py b/src/kernel/types/browsers/process_spawn_params.py
index 8e901cb0..78d57a2d 100644
--- a/src/kernel/types/browsers/process_spawn_params.py
+++ b/src/kernel/types/browsers/process_spawn_params.py
@@ -14,6 +14,9 @@ class ProcessSpawnParams(TypedDict, total=False):
command: Required[str]
"""Executable or shell command to run."""
+ allocate_tty: bool
+ """Allocate a pseudo-terminal (PTY) for interactive shells."""
+
args: SequenceNotStr[str]
"""Command arguments."""
@@ -23,11 +26,17 @@ class ProcessSpawnParams(TypedDict, total=False):
as_user: Optional[str]
"""Run the process as this user."""
+ cols: int
+ """Initial terminal columns. Only used when allocate_tty is true."""
+
cwd: Optional[str]
"""Working directory (absolute path) to run the command in."""
env: Dict[str, str]
"""Environment variables to set for the process."""
+ rows: int
+ """Initial terminal rows. Only used when allocate_tty is true."""
+
timeout_sec: Optional[int]
"""Maximum execution time in seconds."""
diff --git a/tests/api_resources/agents/auth/test_invocations.py b/tests/api_resources/agents/auth/test_invocations.py
index 1bae66da..6d70dfac 100644
--- a/tests/api_resources/agents/auth/test_invocations.py
+++ b/tests/api_resources/agents/auth/test_invocations.py
@@ -255,6 +255,52 @@ def test_path_params_submit_overload_2(self, client: Kernel) -> None:
sso_button="xpath=//button[contains(text(), 'Continue with Google')]",
)
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_method_submit_overload_3(self, client: Kernel) -> None:
+ invocation = client.agents.auth.invocations.submit(
+ invocation_id="invocation_id",
+ selected_mfa_type="sms",
+ )
+ assert_matches_type(AgentAuthSubmitResponse, invocation, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_raw_response_submit_overload_3(self, client: Kernel) -> None:
+ response = client.agents.auth.invocations.with_raw_response.submit(
+ invocation_id="invocation_id",
+ selected_mfa_type="sms",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ invocation = response.parse()
+ assert_matches_type(AgentAuthSubmitResponse, invocation, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_streaming_response_submit_overload_3(self, client: Kernel) -> None:
+ with client.agents.auth.invocations.with_streaming_response.submit(
+ invocation_id="invocation_id",
+ selected_mfa_type="sms",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ invocation = response.parse()
+ assert_matches_type(AgentAuthSubmitResponse, invocation, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_path_params_submit_overload_3(self, client: Kernel) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `invocation_id` but received ''"):
+ client.agents.auth.invocations.with_raw_response.submit(
+ invocation_id="",
+ selected_mfa_type="sms",
+ )
+
class TestAsyncInvocations:
parametrize = pytest.mark.parametrize(
@@ -495,3 +541,49 @@ async def test_path_params_submit_overload_2(self, async_client: AsyncKernel) ->
invocation_id="",
sso_button="xpath=//button[contains(text(), 'Continue with Google')]",
)
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_method_submit_overload_3(self, async_client: AsyncKernel) -> None:
+ invocation = await async_client.agents.auth.invocations.submit(
+ invocation_id="invocation_id",
+ selected_mfa_type="sms",
+ )
+ assert_matches_type(AgentAuthSubmitResponse, invocation, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_raw_response_submit_overload_3(self, async_client: AsyncKernel) -> None:
+ response = await async_client.agents.auth.invocations.with_raw_response.submit(
+ invocation_id="invocation_id",
+ selected_mfa_type="sms",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ invocation = await response.parse()
+ assert_matches_type(AgentAuthSubmitResponse, invocation, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_streaming_response_submit_overload_3(self, async_client: AsyncKernel) -> None:
+ async with async_client.agents.auth.invocations.with_streaming_response.submit(
+ invocation_id="invocation_id",
+ selected_mfa_type="sms",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ invocation = await response.parse()
+ assert_matches_type(AgentAuthSubmitResponse, invocation, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_path_params_submit_overload_3(self, async_client: AsyncKernel) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `invocation_id` but received ''"):
+ await async_client.agents.auth.invocations.with_raw_response.submit(
+ invocation_id="",
+ selected_mfa_type="sms",
+ )
diff --git a/tests/api_resources/browsers/test_process.py b/tests/api_resources/browsers/test_process.py
index 69977621..3c645fa4 100644
--- a/tests/api_resources/browsers/test_process.py
+++ b/tests/api_resources/browsers/test_process.py
@@ -14,6 +14,7 @@
ProcessKillResponse,
ProcessSpawnResponse,
ProcessStdinResponse,
+ ProcessResizeResponse,
ProcessStatusResponse,
)
@@ -141,6 +142,68 @@ def test_path_params_kill(self, client: Kernel) -> None:
signal="TERM",
)
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_method_resize(self, client: Kernel) -> None:
+ process = client.browsers.process.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="id",
+ cols=1,
+ rows=1,
+ )
+ assert_matches_type(ProcessResizeResponse, process, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_raw_response_resize(self, client: Kernel) -> None:
+ response = client.browsers.process.with_raw_response.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="id",
+ cols=1,
+ rows=1,
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ process = response.parse()
+ assert_matches_type(ProcessResizeResponse, process, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_streaming_response_resize(self, client: Kernel) -> None:
+ with client.browsers.process.with_streaming_response.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="id",
+ cols=1,
+ rows=1,
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ process = response.parse()
+ assert_matches_type(ProcessResizeResponse, process, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ def test_path_params_resize(self, client: Kernel) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.browsers.process.with_raw_response.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="",
+ cols=1,
+ rows=1,
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `process_id` but received ''"):
+ client.browsers.process.with_raw_response.resize(
+ process_id="",
+ id="id",
+ cols=1,
+ rows=1,
+ )
+
@pytest.mark.skip(reason="Prism tests are disabled")
@parametrize
def test_method_spawn(self, client: Kernel) -> None:
@@ -156,11 +219,14 @@ def test_method_spawn_with_all_params(self, client: Kernel) -> None:
process = client.browsers.process.spawn(
id="id",
command="command",
+ allocate_tty=True,
args=["string"],
as_root=True,
as_user="as_user",
+ cols=1,
cwd="/J!",
env={"foo": "string"},
+ rows=1,
timeout_sec=0,
)
assert_matches_type(ProcessSpawnResponse, process, path=["response"])
@@ -486,6 +552,68 @@ async def test_path_params_kill(self, async_client: AsyncKernel) -> None:
signal="TERM",
)
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_method_resize(self, async_client: AsyncKernel) -> None:
+ process = await async_client.browsers.process.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="id",
+ cols=1,
+ rows=1,
+ )
+ assert_matches_type(ProcessResizeResponse, process, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_raw_response_resize(self, async_client: AsyncKernel) -> None:
+ response = await async_client.browsers.process.with_raw_response.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="id",
+ cols=1,
+ rows=1,
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ process = await response.parse()
+ assert_matches_type(ProcessResizeResponse, process, path=["response"])
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_streaming_response_resize(self, async_client: AsyncKernel) -> None:
+ async with async_client.browsers.process.with_streaming_response.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="id",
+ cols=1,
+ rows=1,
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ process = await response.parse()
+ assert_matches_type(ProcessResizeResponse, process, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip(reason="Prism tests are disabled")
+ @parametrize
+ async def test_path_params_resize(self, async_client: AsyncKernel) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.browsers.process.with_raw_response.resize(
+ process_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ id="",
+ cols=1,
+ rows=1,
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `process_id` but received ''"):
+ await async_client.browsers.process.with_raw_response.resize(
+ process_id="",
+ id="id",
+ cols=1,
+ rows=1,
+ )
+
@pytest.mark.skip(reason="Prism tests are disabled")
@parametrize
async def test_method_spawn(self, async_client: AsyncKernel) -> None:
@@ -501,11 +629,14 @@ async def test_method_spawn_with_all_params(self, async_client: AsyncKernel) ->
process = await async_client.browsers.process.spawn(
id="id",
command="command",
+ allocate_tty=True,
args=["string"],
as_root=True,
as_user="as_user",
+ cols=1,
cwd="/J!",
env={"foo": "string"},
+ rows=1,
timeout_sec=0,
)
assert_matches_type(ProcessSpawnResponse, process, path=["response"])
diff --git a/tests/test_client.py b/tests/test_client.py
index 6425811f..6f4213a5 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -8,10 +8,11 @@
import json
import asyncio
import inspect
+import dataclasses
import tracemalloc
-from typing import Any, Union, cast
+from typing import Any, Union, TypeVar, Callable, Iterable, Iterator, Optional, Coroutine, cast
from unittest import mock
-from typing_extensions import Literal
+from typing_extensions import Literal, AsyncIterator, override
import httpx
import pytest
@@ -36,6 +37,7 @@
from .utils import update_env
+T = TypeVar("T")
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
api_key = "My API Key"
@@ -50,6 +52,57 @@ def _low_retry_timeout(*_args: Any, **_kwargs: Any) -> float:
return 0.1
+def mirror_request_content(request: httpx.Request) -> httpx.Response:
+ return httpx.Response(200, content=request.content)
+
+
+# note: we can't use the httpx.MockTransport class as it consumes the request
+# body itself, which means we can't test that the body is read lazily
+class MockTransport(httpx.BaseTransport, httpx.AsyncBaseTransport):
+ def __init__(
+ self,
+ handler: Callable[[httpx.Request], httpx.Response]
+ | Callable[[httpx.Request], Coroutine[Any, Any, httpx.Response]],
+ ) -> None:
+ self.handler = handler
+
+ @override
+ def handle_request(
+ self,
+ request: httpx.Request,
+ ) -> httpx.Response:
+ assert not inspect.iscoroutinefunction(self.handler), "handler must not be a coroutine function"
+ assert inspect.isfunction(self.handler), "handler must be a function"
+ return self.handler(request)
+
+ @override
+ async def handle_async_request(
+ self,
+ request: httpx.Request,
+ ) -> httpx.Response:
+ assert inspect.iscoroutinefunction(self.handler), "handler must be a coroutine function"
+ return await self.handler(request)
+
+
+@dataclasses.dataclass
+class Counter:
+ value: int = 0
+
+
+def _make_sync_iterator(iterable: Iterable[T], counter: Optional[Counter] = None) -> Iterator[T]:
+ for item in iterable:
+ if counter:
+ counter.value += 1
+ yield item
+
+
+async def _make_async_iterator(iterable: Iterable[T], counter: Optional[Counter] = None) -> AsyncIterator[T]:
+ for item in iterable:
+ if counter:
+ counter.value += 1
+ yield item
+
+
def _get_open_connections(client: Kernel | AsyncKernel) -> int:
transport = client._client._transport
assert isinstance(transport, httpx.HTTPTransport) or isinstance(transport, httpx.AsyncHTTPTransport)
@@ -500,6 +553,70 @@ def test_multipart_repeating_array(self, client: Kernel) -> None:
b"",
]
+ @pytest.mark.respx(base_url=base_url)
+ def test_binary_content_upload(self, respx_mock: MockRouter, client: Kernel) -> None:
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
+
+ file_content = b"Hello, this is a test file."
+
+ response = client.post(
+ "/upload",
+ content=file_content,
+ cast_to=httpx.Response,
+ options={"headers": {"Content-Type": "application/octet-stream"}},
+ )
+
+ assert response.status_code == 200
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
+ assert response.content == file_content
+
+ def test_binary_content_upload_with_iterator(self) -> None:
+ file_content = b"Hello, this is a test file."
+ counter = Counter()
+ iterator = _make_sync_iterator([file_content], counter=counter)
+
+ def mock_handler(request: httpx.Request) -> httpx.Response:
+ assert counter.value == 0, "the request body should not have been read"
+ return httpx.Response(200, content=request.read())
+
+ with Kernel(
+ base_url=base_url,
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.Client(transport=MockTransport(handler=mock_handler)),
+ ) as client:
+ response = client.post(
+ "/upload",
+ content=iterator,
+ cast_to=httpx.Response,
+ options={"headers": {"Content-Type": "application/octet-stream"}},
+ )
+
+ assert response.status_code == 200
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
+ assert response.content == file_content
+ assert counter.value == 1
+
+ @pytest.mark.respx(base_url=base_url)
+ def test_binary_content_upload_with_body_is_deprecated(self, respx_mock: MockRouter, client: Kernel) -> None:
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
+
+ file_content = b"Hello, this is a test file."
+
+ with pytest.deprecated_call(
+ match="Passing raw bytes as `body` is deprecated and will be removed in a future version. Please pass raw bytes via the `content` parameter instead."
+ ):
+ response = client.post(
+ "/upload",
+ body=file_content,
+ cast_to=httpx.Response,
+ options={"headers": {"Content-Type": "application/octet-stream"}},
+ )
+
+ assert response.status_code == 200
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
+ assert response.content == file_content
+
@pytest.mark.respx(base_url=base_url)
def test_basic_union_response(self, respx_mock: MockRouter, client: Kernel) -> None:
class Model1(BaseModel):
@@ -1331,6 +1448,72 @@ def test_multipart_repeating_array(self, async_client: AsyncKernel) -> None:
b"",
]
+ @pytest.mark.respx(base_url=base_url)
+ async def test_binary_content_upload(self, respx_mock: MockRouter, async_client: AsyncKernel) -> None:
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
+
+ file_content = b"Hello, this is a test file."
+
+ response = await async_client.post(
+ "/upload",
+ content=file_content,
+ cast_to=httpx.Response,
+ options={"headers": {"Content-Type": "application/octet-stream"}},
+ )
+
+ assert response.status_code == 200
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
+ assert response.content == file_content
+
+ async def test_binary_content_upload_with_asynciterator(self) -> None:
+ file_content = b"Hello, this is a test file."
+ counter = Counter()
+ iterator = _make_async_iterator([file_content], counter=counter)
+
+ async def mock_handler(request: httpx.Request) -> httpx.Response:
+ assert counter.value == 0, "the request body should not have been read"
+ return httpx.Response(200, content=await request.aread())
+
+ async with AsyncKernel(
+ base_url=base_url,
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.AsyncClient(transport=MockTransport(handler=mock_handler)),
+ ) as client:
+ response = await client.post(
+ "/upload",
+ content=iterator,
+ cast_to=httpx.Response,
+ options={"headers": {"Content-Type": "application/octet-stream"}},
+ )
+
+ assert response.status_code == 200
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
+ assert response.content == file_content
+ assert counter.value == 1
+
+ @pytest.mark.respx(base_url=base_url)
+ async def test_binary_content_upload_with_body_is_deprecated(
+ self, respx_mock: MockRouter, async_client: AsyncKernel
+ ) -> None:
+ respx_mock.post("/upload").mock(side_effect=mirror_request_content)
+
+ file_content = b"Hello, this is a test file."
+
+ with pytest.deprecated_call(
+ match="Passing raw bytes as `body` is deprecated and will be removed in a future version. Please pass raw bytes via the `content` parameter instead."
+ ):
+ response = await async_client.post(
+ "/upload",
+ body=file_content,
+ cast_to=httpx.Response,
+ options={"headers": {"Content-Type": "application/octet-stream"}},
+ )
+
+ assert response.status_code == 200
+ assert response.request.headers["Content-Type"] == "application/octet-stream"
+ assert response.content == file_content
+
@pytest.mark.respx(base_url=base_url)
async def test_basic_union_response(self, respx_mock: MockRouter, async_client: AsyncKernel) -> None:
class Model1(BaseModel):