Skip to content

Commit 69d69e1

Browse files
authored
Merge pull request #16 from onkernel/release-please--branches--main--changes--next
release: 0.1.0-alpha.13
2 parents ed42599 + 72e5ed1 commit 69d69e1

File tree

12 files changed

+61
-324
lines changed

12 files changed

+61
-324
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.12"
2+
".": "0.1.0-alpha.13"
33
}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-c9d64df733f286f09d2203f4e3d820ce57e8d4c629c5e2db4e2bfac91fbc1598.yml
3-
openapi_spec_hash: fa407611fc566d55f403864fbfaa6c23
4-
config_hash: 7f67c5b95af1e4b39525515240b72275
1+
configured_endpoints: 6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-19b0d17ba368f32827ee322d15a7f4ff7e1f3bbf66606fad227b3465f8ffc5ab.yml
3+
openapi_spec_hash: 4a3cb766898e8a134ef99fe6c4c87736
4+
config_hash: 4dfa4d870ce0e23e31ce33ab6a53dd21

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.1.0-alpha.13 (2025-05-20)
4+
5+
Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/onkernel/kernel-python-sdk/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)
6+
7+
### Features
8+
9+
* **api:** update via SDK Studio ([c528c7b](https://github.com/onkernel/kernel-python-sdk/commit/c528c7b45adac371fddfdc2792a435f814b03d67))
10+
311
## 0.1.0-alpha.12 (2025-05-19)
412

513
Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/onkernel/kernel-python-sdk/compare/v0.1.0-alpha.11...v0.1.0-alpha.12)

api.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# Apps
22

3-
Types:
4-
5-
```python
6-
from kernel.types import AppListResponse
7-
```
8-
9-
Methods:
10-
11-
- <code title="get /apps">client.apps.<a href="./src/kernel/resources/apps/apps.py">list</a>(\*\*<a href="src/kernel/types/app_list_params.py">params</a>) -> <a href="./src/kernel/types/app_list_response.py">AppListResponse</a></code>
12-
133
## Deployments
144

155
Types:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "kernel"
3-
version = "0.1.0-alpha.12"
3+
version = "0.1.0-alpha.13"
44
description = "The official Python library for the kernel API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/kernel/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "kernel"
4-
__version__ = "0.1.0-alpha.12" # x-release-please-version
4+
__version__ = "0.1.0-alpha.13" # x-release-please-version

src/kernel/app_framework.py

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import inspect
33
import functools
4-
from typing import Any, Dict, List, Union, TypeVar, Callable, Optional
4+
from typing import Any, Dict, List, TypeVar, Callable, Optional
55
from dataclasses import dataclass
66

77
T = TypeVar("T")
@@ -44,53 +44,58 @@ def __init__(self, name: str):
4444
# Register this app in the global registry
4545
_app_registry.register_app(self)
4646

47-
def action(self, name_or_handler: Optional[Union[str, Callable[..., Any]]] = None) -> Callable[..., Any]:
48-
"""Decorator to register an action with the app"""
49-
if name_or_handler is None:
50-
# This is the @app.action() case, which should return the decorator
51-
def decorator(f: Callable[..., Any]) -> Callable[..., Any]:
52-
return self._register_action(f.__name__, f)
53-
return decorator
54-
elif callable(name_or_handler):
55-
# This is the @app.action case (handler passed directly)
56-
return self._register_action(name_or_handler.__name__, name_or_handler)
57-
else:
58-
# This is the @app.action("name") case (name_or_handler is a string)
59-
def decorator(f: Callable[..., Any]) -> Callable[..., Any]:
60-
return self._register_action(name_or_handler, f) # name_or_handler is the name string here
61-
return decorator
47+
def action(self, name: str) -> Callable[..., Any]:
48+
"""
49+
Decorator to register an action with the app
50+
51+
Usage:
52+
@app.action("action-name")
53+
def my_handler(ctx: KernelContext):
54+
# ...
55+
56+
@app.action("action-with-payload")
57+
def my_handler(ctx: KernelContext, payload: dict):
58+
# ...
59+
"""
60+
def decorator(handler: Callable[..., Any]) -> Callable[..., Any]:
61+
return self._register_action(name, handler)
62+
return decorator
6263

6364
def _register_action(self, name: str, handler: Callable[..., Any]) -> Callable[..., Any]:
6465
"""Internal method to register an action"""
66+
# Validate handler signature
67+
sig = inspect.signature(handler)
68+
param_count = len(sig.parameters)
69+
70+
if param_count == 0:
71+
raise TypeError("Action handler must accept at least the context parameter")
72+
elif param_count > 2:
73+
raise TypeError("Action handler can only accept context and payload parameters")
74+
75+
param_names = list(sig.parameters.keys())
6576

6677
@functools.wraps(handler)
6778
def wrapper(*args: Any, **kwargs: Any) -> Any:
68-
# Determine if the original handler accepts context as first argument
69-
sig = inspect.signature(handler)
70-
param_names = list(sig.parameters.keys())
71-
param_count = len(param_names)
72-
79+
# Ensure the first argument is the context
80+
if not args or not isinstance(args[0], KernelContext):
81+
raise TypeError("First argument to action handler must be a KernelContext")
82+
83+
ctx = args[0]
84+
7385
if param_count == 1:
74-
actual_input = None
75-
# The handler only takes input
76-
if len(args) > 0: # Prioritize args if context was implicitly passed
77-
# If context (args[0]) and input (args[1]) were provided, or just input (args[0])
78-
actual_input = args[1] if len(args) > 1 else args[0]
79-
elif kwargs:
80-
# Attempt to find the single expected kwarg
81-
if param_names: # Should always be true if param_count == 1
82-
param_name = param_names[0]
83-
if param_name in kwargs:
84-
actual_input = kwargs[param_name]
85-
elif kwargs: # Fallback if name doesn't match but kwargs exist
86-
actual_input = next(iter(kwargs.values()))
87-
elif kwargs: # param_names is empty but kwargs exist (unlikely for param_count==1)
88-
actual_input = next(iter(kwargs.values()))
89-
# If no args/kwargs, actual_input remains None, handler might raise error or accept None
90-
return handler(actual_input)
91-
else: # param_count == 0 or param_count > 1
92-
# Handler takes context and input (or more), or no args
93-
return handler(*args, **kwargs)
86+
# Handler takes only context
87+
return handler(ctx)
88+
else: # param_count == 2
89+
# Handler takes context and payload
90+
if len(args) >= 2:
91+
return handler(ctx, args[1])
92+
else:
93+
# Try to find payload in kwargs
94+
payload_name = param_names[1]
95+
if payload_name in kwargs:
96+
return handler(ctx, kwargs[payload_name])
97+
else:
98+
raise TypeError(f"Missing required payload parameter '{payload_name}'")
9499

95100
action = KernelAction(name=name, handler=wrapper)
96101
self.actions[name] = action

src/kernel/resources/apps/apps.py

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,8 @@
22

33
from __future__ import annotations
44

5-
import httpx
6-
7-
from ...types import app_list_params
8-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9-
from ..._utils import maybe_transform, async_maybe_transform
105
from ..._compat import cached_property
116
from ..._resource import SyncAPIResource, AsyncAPIResource
12-
from ..._response import (
13-
to_raw_response_wrapper,
14-
to_streamed_response_wrapper,
15-
async_to_raw_response_wrapper,
16-
async_to_streamed_response_wrapper,
17-
)
187
from .deployments import (
198
DeploymentsResource,
209
AsyncDeploymentsResource,
@@ -31,8 +20,6 @@
3120
InvocationsResourceWithStreamingResponse,
3221
AsyncInvocationsResourceWithStreamingResponse,
3322
)
34-
from ..._base_client import make_request_options
35-
from ...types.app_list_response import AppListResponse
3623

3724
__all__ = ["AppsResource", "AsyncAppsResource"]
3825

@@ -65,54 +52,6 @@ def with_streaming_response(self) -> AppsResourceWithStreamingResponse:
6552
"""
6653
return AppsResourceWithStreamingResponse(self)
6754

68-
def list(
69-
self,
70-
*,
71-
app_name: str | NotGiven = NOT_GIVEN,
72-
version: str | NotGiven = NOT_GIVEN,
73-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
74-
# The extra values given here take precedence over values defined on the client or passed to this method.
75-
extra_headers: Headers | None = None,
76-
extra_query: Query | None = None,
77-
extra_body: Body | None = None,
78-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
79-
) -> AppListResponse:
80-
"""List application versions for the authenticated user.
81-
82-
Optionally filter by app
83-
name and/or version label.
84-
85-
Args:
86-
app_name: Filter results by application name.
87-
88-
version: Filter results by version label.
89-
90-
extra_headers: Send extra headers
91-
92-
extra_query: Add additional query parameters to the request
93-
94-
extra_body: Add additional JSON properties to the request
95-
96-
timeout: Override the client-level default timeout for this request, in seconds
97-
"""
98-
return self._get(
99-
"/apps",
100-
options=make_request_options(
101-
extra_headers=extra_headers,
102-
extra_query=extra_query,
103-
extra_body=extra_body,
104-
timeout=timeout,
105-
query=maybe_transform(
106-
{
107-
"app_name": app_name,
108-
"version": version,
109-
},
110-
app_list_params.AppListParams,
111-
),
112-
),
113-
cast_to=AppListResponse,
114-
)
115-
11655

11756
class AsyncAppsResource(AsyncAPIResource):
11857
@cached_property
@@ -142,63 +81,11 @@ def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse:
14281
"""
14382
return AsyncAppsResourceWithStreamingResponse(self)
14483

145-
async def list(
146-
self,
147-
*,
148-
app_name: str | NotGiven = NOT_GIVEN,
149-
version: str | NotGiven = NOT_GIVEN,
150-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
151-
# The extra values given here take precedence over values defined on the client or passed to this method.
152-
extra_headers: Headers | None = None,
153-
extra_query: Query | None = None,
154-
extra_body: Body | None = None,
155-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
156-
) -> AppListResponse:
157-
"""List application versions for the authenticated user.
158-
159-
Optionally filter by app
160-
name and/or version label.
161-
162-
Args:
163-
app_name: Filter results by application name.
164-
165-
version: Filter results by version label.
166-
167-
extra_headers: Send extra headers
168-
169-
extra_query: Add additional query parameters to the request
170-
171-
extra_body: Add additional JSON properties to the request
172-
173-
timeout: Override the client-level default timeout for this request, in seconds
174-
"""
175-
return await self._get(
176-
"/apps",
177-
options=make_request_options(
178-
extra_headers=extra_headers,
179-
extra_query=extra_query,
180-
extra_body=extra_body,
181-
timeout=timeout,
182-
query=await async_maybe_transform(
183-
{
184-
"app_name": app_name,
185-
"version": version,
186-
},
187-
app_list_params.AppListParams,
188-
),
189-
),
190-
cast_to=AppListResponse,
191-
)
192-
19384

19485
class AppsResourceWithRawResponse:
19586
def __init__(self, apps: AppsResource) -> None:
19687
self._apps = apps
19788

198-
self.list = to_raw_response_wrapper(
199-
apps.list,
200-
)
201-
20289
@cached_property
20390
def deployments(self) -> DeploymentsResourceWithRawResponse:
20491
return DeploymentsResourceWithRawResponse(self._apps.deployments)
@@ -212,10 +99,6 @@ class AsyncAppsResourceWithRawResponse:
21299
def __init__(self, apps: AsyncAppsResource) -> None:
213100
self._apps = apps
214101

215-
self.list = async_to_raw_response_wrapper(
216-
apps.list,
217-
)
218-
219102
@cached_property
220103
def deployments(self) -> AsyncDeploymentsResourceWithRawResponse:
221104
return AsyncDeploymentsResourceWithRawResponse(self._apps.deployments)
@@ -229,10 +112,6 @@ class AppsResourceWithStreamingResponse:
229112
def __init__(self, apps: AppsResource) -> None:
230113
self._apps = apps
231114

232-
self.list = to_streamed_response_wrapper(
233-
apps.list,
234-
)
235-
236115
@cached_property
237116
def deployments(self) -> DeploymentsResourceWithStreamingResponse:
238117
return DeploymentsResourceWithStreamingResponse(self._apps.deployments)
@@ -246,10 +125,6 @@ class AsyncAppsResourceWithStreamingResponse:
246125
def __init__(self, apps: AsyncAppsResource) -> None:
247126
self._apps = apps
248127

249-
self.list = async_to_streamed_response_wrapper(
250-
apps.list,
251-
)
252-
253128
@cached_property
254129
def deployments(self) -> AsyncDeploymentsResourceWithStreamingResponse:
255130
return AsyncDeploymentsResourceWithStreamingResponse(self._apps.deployments)

src/kernel/types/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import annotations
44

5-
from .app_list_params import AppListParams as AppListParams
6-
from .app_list_response import AppListResponse as AppListResponse
75
from .browser_create_params import BrowserCreateParams as BrowserCreateParams
86
from .browser_create_response import BrowserCreateResponse as BrowserCreateResponse
97
from .browser_retrieve_response import BrowserRetrieveResponse as BrowserRetrieveResponse

src/kernel/types/app_list_params.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)