From 8aebfd82ba18df86bcada86ec77bfe6c3c0e6962 Mon Sep 17 00:00:00 2001 From: Rafael Date: Mon, 23 Nov 2026 10:43:35 -0500 Subject: [PATCH 1/6] Move create-github-app-token to v3.3.0 so permission inputs take effect (#17) Co-authored-by: rgarcia <72655+rgarcia@users.noreply.github.com> --- .github/workflows/actions.lock | 10 +++++----- .github/workflows/release-please.yml | 3 +-- .github/workflows/stlc-promote.yml | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index 2b0c5d00..1d9ae8a8 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -11,13 +11,13 @@ workflows: '.github/workflows/release-doctor.yml': - 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' '.github/workflows/release-please.yml': - - 'actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547' + - 'actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510' - 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' - 'pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1' '.github/workflows/semgrep.yml': [] '.github/workflows/stlc-promote.yml': - 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' - - 'actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547' + - 'actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510' '.github/workflows/stlc-sync.yml': - 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' '.github/workflows/vuln-remediation.yml': [] @@ -27,9 +27,9 @@ dependencies: commit: 'sha1-de0fac2e4500dabe0009e67214ff5f5447ce83dd' owner_id: 44036562 repo_id: 197814629 - 'actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547': - ref: 'v1.12.0' - commit: 'sha1-d72941d797fd3113feb6b93fd0dec494b13a2547' + 'actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510': + ref: 'v3.3.0' + commit: 'sha1-64ab729a6294000f5aa4a4bc0b73d1f32bc45510' owner_id: 44036562 repo_id: 642580244 'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd': diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 5afb4921..e199daea 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -24,14 +24,13 @@ jobs: steps: - name: Mint release token id: release-token - uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: app-id: ${{ secrets.ADMIN_APP_ID }} private-key: ${{ secrets.ADMIN_APP_PRIVATE_KEY }} owner: kernel repositories: kernel-python-sdk permission-contents: write - permission-issues: write permission-pull-requests: write permission-workflows: write diff --git a/.github/workflows/stlc-promote.yml b/.github/workflows/stlc-promote.yml index 3bcd88c7..9df4fd61 100644 --- a/.github/workflows/stlc-promote.yml +++ b/.github/workflows/stlc-promote.yml @@ -28,7 +28,7 @@ jobs: - name: Mint production token id: production-token - uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: app-id: ${{ secrets.ADMIN_APP_ID }} private-key: ${{ secrets.ADMIN_APP_PRIVATE_KEY }} From 37f0e8b489698bfe2d0f6047ae90fe1c852fd8b9 Mon Sep 17 00:00:00 2001 From: "kernel-internal[bot]" <260533166+kernel-internal[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:39:25 +0000 Subject: [PATCH 2/6] feat: Accept a proxy object on browser pools Stainless-Generated-From: 290ed062f6c53641e5eca83da369dfbfad6ddf15 --- src/kernel/resources/browser_pools.py | 89 +++++++++++++------ src/kernel/resources/browsers/browsers.py | 26 +++++- src/kernel/resources/deployments.py | 28 ++++++ .../resources/report_types/report_types.py | 14 +++ src/kernel/types/api_key.py | 12 ++- src/kernel/types/api_key_create_params.py | 12 ++- src/kernel/types/api_key_update_params.py | 12 ++- src/kernel/types/auth/auth_context.py | 12 ++- src/kernel/types/browser_list_params.py | 11 ++- src/kernel/types/browser_pool.py | 12 ++- .../types/browser_pool_create_params.py | 28 ++++-- .../types/browser_pool_update_params.py | 21 +++-- src/kernel/types/browser_update_params.py | 7 ++ src/kernel/types/deployment_create_params.py | 89 ++++++++++++++++++- src/kernel/types/report_type_list_params.py | 8 ++ .../types/vaults/kernel_wallet_state.py | 24 ++--- .../vaults/kernel_wallet_vault_item_spec.py | 2 +- .../kernel_wallet_vault_item_spec_param.py | 2 +- ...ssword_fill_vault_item_operation_result.py | 65 +++++++++++--- .../types/vaults/vault_payment_method.py | 4 +- .../types/workload_identity_authorization.py | 12 ++- .../workload_identity_authorization_param.py | 12 ++- tests/api_resources/test_browser_pools.py | 20 +++++ tests/api_resources/test_browsers.py | 2 + tests/api_resources/test_deployments.py | 26 ++++++ tests/api_resources/test_report_types.py | 2 + 26 files changed, 467 insertions(+), 85 deletions(-) diff --git a/src/kernel/resources/browser_pools.py b/src/kernel/resources/browser_pools.py index b03ef164..61f67193 100644 --- a/src/kernel/resources/browser_pools.py +++ b/src/kernel/resources/browser_pools.py @@ -31,6 +31,7 @@ from ..types.tags_param import TagsParam from ..types.browser_pool import BrowserPool from ..types.browser_memory_request import BrowserMemoryRequest +from ..types.browser_proxy_config_param import BrowserProxyConfigParam from ..types.browser_captcha_solver_param import BrowserCaptchaSolverParam from ..types.browser_network_config_param import BrowserNetworkConfigParam from ..types.browser_pool_acquire_response import BrowserPoolAcquireResponse @@ -77,6 +78,7 @@ def create( name: str | Omit = omit, network: BrowserNetworkConfigParam | Omit = omit, profile: browser_pool_create_params.Profile | Omit = omit, + proxy: BrowserProxyConfigParam | Omit = omit, proxy_id: str | Omit = omit, refresh_on_profile_update: bool | Omit = omit, region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] | Omit = omit, @@ -107,8 +109,9 @@ def create( exceed your limit). captcha_solver: Automatic CAPTCHA solving for browsers in this pool. Disabled by default. - Enabling it does not select a proxy: when proxy_id is omitted, browsers use - direct egress unless stealth=true. + Enabling it does not select a proxy: when proxy and proxy_id are omitted, + browsers use direct egress unless stealth=true. Set proxy.mode=default for + Kernel's default stealth proxy. chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool. Keys are Chrome enterprise policy names; values must match their expected types. @@ -142,8 +145,16 @@ def create( omitted here. Any save_changes value sent on a pool profile is silently ignored rather than rejected. - proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in - the same project as the browser session. + proxy: Proxy configuration for browsers in this pool. Cannot be combined with proxy_id. + Omit to use direct egress, or Kernel's default stealth proxy when stealth=true. + Set mode to direct to force direct egress. Set mode to default to use Kernel's + default stealth proxy when captcha_solver.enabled=true, or direct egress + otherwise. Select id or name to use that proxy. Proxy selection does not change + CAPTCHA solver behavior. + + proxy_id: Optional proxy to associate to browsers in this pool. Must reference a proxy in + the same project as the pool. Cannot be combined with proxy. Deprecated in favor + of proxy. refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so pool browsers pick up the latest profile data. When a profile is provided during @@ -161,10 +172,9 @@ def create( previous lease left them on. Accepts any URL Chromium can resolve, including chrome:// pages. - stealth: If true, enables the CAPTCHA solver and, when proxy_id is omitted, uses Kernel's - default stealth proxy. Defaults to false. Cannot be combined with - captcha_solver.enabled=false. Deprecated in favor of captcha_solver and - proxy_id. + stealth: If true, enables the CAPTCHA solver and, when proxy and proxy_id are omitted, + uses Kernel's default stealth proxy. Defaults to false. Cannot be combined with + captcha_solver.enabled=false. Deprecated in favor of captcha_solver and proxy. telemetry: Telemetry configuration applied to browsers warmed into this pool. Set enabled to true to start capture using the default set, or provide browser category @@ -214,6 +224,7 @@ def create( "name": name, "network": network, "profile": profile, + "proxy": proxy, "proxy_id": proxy_id, "refresh_on_profile_update": refresh_on_profile_update, "region": region, @@ -285,6 +296,7 @@ def update( name: str | Omit = omit, network: BrowserNetworkConfigParam | Omit = omit, profile: browser_pool_update_params.Profile | Omit = omit, + proxy: BrowserProxyConfigParam | Omit = omit, proxy_id: str | Omit = omit, refresh_on_profile_update: bool | Omit = omit, size: int | Omit = omit, @@ -313,7 +325,7 @@ def update( Args: captcha_solver: If provided, replaces whether browsers in this pool automatically solve CAPTCHAs. Enabling it on a pool with direct egress keeps direct egress unless - proxy_id or stealth=true is also set. + proxy, proxy_id, or stealth=true is also set. chrome_policy: If provided, replaces the custom Chrome enterprise policy overrides applied to all browsers in this pool. Empty object clears any previously-set policy. Keys @@ -374,8 +386,14 @@ def update( omitted here. Any save_changes value sent on a pool profile is silently ignored rather than rejected. + proxy: Proxy configuration to apply to browsers warmed after the update. Omit to leave + the current configuration unchanged. Cannot be combined with proxy_id. Set mode + to direct to switch to direct egress. Set mode to default to use Kernel's + default stealth proxy for a pool with CAPTCHA solving enabled, or direct egress + otherwise. Updating proxy does not change CAPTCHA solver behavior. + proxy_id: Empty string clears the previously-selected proxy. Omit this field to leave the - proxy unchanged. + proxy unchanged. Cannot be combined with proxy. Deprecated in favor of proxy. refresh_on_profile_update: If provided, replaces whether idle browsers are flushed when the profile the pool uses is updated. When the pool's profile reference is changed (including @@ -395,9 +413,9 @@ def update( it unchanged. stealth: If provided, replaces whether browsers launch in stealth mode. stealth=true - without proxy_id moves a pool on direct egress to Kernel's default stealth - proxy. Cannot be combined with captcha_solver.enabled=false. Deprecated in favor - of captcha_solver and proxy_id. + without proxy or proxy_id moves a pool on direct egress to Kernel's default + stealth proxy. Cannot be combined with captcha_solver.enabled=false. Deprecated + in favor of captcha_solver and proxy. telemetry: If provided, updates the pool's telemetry configuration. Omit, set to null, or set to an empty object ({}) to leave the existing configuration unchanged. Set @@ -451,6 +469,7 @@ def update( "name": name, "network": network, "profile": profile, + "proxy": proxy, "proxy_id": proxy_id, "refresh_on_profile_update": refresh_on_profile_update, "size": size, @@ -817,6 +836,7 @@ async def create( name: str | Omit = omit, network: BrowserNetworkConfigParam | Omit = omit, profile: browser_pool_create_params.Profile | Omit = omit, + proxy: BrowserProxyConfigParam | Omit = omit, proxy_id: str | Omit = omit, refresh_on_profile_update: bool | Omit = omit, region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] | Omit = omit, @@ -847,8 +867,9 @@ async def create( exceed your limit). captcha_solver: Automatic CAPTCHA solving for browsers in this pool. Disabled by default. - Enabling it does not select a proxy: when proxy_id is omitted, browsers use - direct egress unless stealth=true. + Enabling it does not select a proxy: when proxy and proxy_id are omitted, + browsers use direct egress unless stealth=true. Set proxy.mode=default for + Kernel's default stealth proxy. chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool. Keys are Chrome enterprise policy names; values must match their expected types. @@ -882,8 +903,16 @@ async def create( omitted here. Any save_changes value sent on a pool profile is silently ignored rather than rejected. - proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in - the same project as the browser session. + proxy: Proxy configuration for browsers in this pool. Cannot be combined with proxy_id. + Omit to use direct egress, or Kernel's default stealth proxy when stealth=true. + Set mode to direct to force direct egress. Set mode to default to use Kernel's + default stealth proxy when captcha_solver.enabled=true, or direct egress + otherwise. Select id or name to use that proxy. Proxy selection does not change + CAPTCHA solver behavior. + + proxy_id: Optional proxy to associate to browsers in this pool. Must reference a proxy in + the same project as the pool. Cannot be combined with proxy. Deprecated in favor + of proxy. refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so pool browsers pick up the latest profile data. When a profile is provided during @@ -901,10 +930,9 @@ async def create( previous lease left them on. Accepts any URL Chromium can resolve, including chrome:// pages. - stealth: If true, enables the CAPTCHA solver and, when proxy_id is omitted, uses Kernel's - default stealth proxy. Defaults to false. Cannot be combined with - captcha_solver.enabled=false. Deprecated in favor of captcha_solver and - proxy_id. + stealth: If true, enables the CAPTCHA solver and, when proxy and proxy_id are omitted, + uses Kernel's default stealth proxy. Defaults to false. Cannot be combined with + captcha_solver.enabled=false. Deprecated in favor of captcha_solver and proxy. telemetry: Telemetry configuration applied to browsers warmed into this pool. Set enabled to true to start capture using the default set, or provide browser category @@ -954,6 +982,7 @@ async def create( "name": name, "network": network, "profile": profile, + "proxy": proxy, "proxy_id": proxy_id, "refresh_on_profile_update": refresh_on_profile_update, "region": region, @@ -1025,6 +1054,7 @@ async def update( name: str | Omit = omit, network: BrowserNetworkConfigParam | Omit = omit, profile: browser_pool_update_params.Profile | Omit = omit, + proxy: BrowserProxyConfigParam | Omit = omit, proxy_id: str | Omit = omit, refresh_on_profile_update: bool | Omit = omit, size: int | Omit = omit, @@ -1053,7 +1083,7 @@ async def update( Args: captcha_solver: If provided, replaces whether browsers in this pool automatically solve CAPTCHAs. Enabling it on a pool with direct egress keeps direct egress unless - proxy_id or stealth=true is also set. + proxy, proxy_id, or stealth=true is also set. chrome_policy: If provided, replaces the custom Chrome enterprise policy overrides applied to all browsers in this pool. Empty object clears any previously-set policy. Keys @@ -1114,8 +1144,14 @@ async def update( omitted here. Any save_changes value sent on a pool profile is silently ignored rather than rejected. + proxy: Proxy configuration to apply to browsers warmed after the update. Omit to leave + the current configuration unchanged. Cannot be combined with proxy_id. Set mode + to direct to switch to direct egress. Set mode to default to use Kernel's + default stealth proxy for a pool with CAPTCHA solving enabled, or direct egress + otherwise. Updating proxy does not change CAPTCHA solver behavior. + proxy_id: Empty string clears the previously-selected proxy. Omit this field to leave the - proxy unchanged. + proxy unchanged. Cannot be combined with proxy. Deprecated in favor of proxy. refresh_on_profile_update: If provided, replaces whether idle browsers are flushed when the profile the pool uses is updated. When the pool's profile reference is changed (including @@ -1135,9 +1171,9 @@ async def update( it unchanged. stealth: If provided, replaces whether browsers launch in stealth mode. stealth=true - without proxy_id moves a pool on direct egress to Kernel's default stealth - proxy. Cannot be combined with captcha_solver.enabled=false. Deprecated in favor - of captcha_solver and proxy_id. + without proxy or proxy_id moves a pool on direct egress to Kernel's default + stealth proxy. Cannot be combined with captcha_solver.enabled=false. Deprecated + in favor of captcha_solver and proxy. telemetry: If provided, updates the pool's telemetry configuration. Omit, set to null, or set to an empty object ({}) to leave the existing configuration unchanged. Set @@ -1191,6 +1227,7 @@ async def update( "name": name, "network": network, "profile": profile, + "proxy": proxy, "proxy_id": proxy_id, "refresh_on_profile_update": refresh_on_profile_update, "size": size, diff --git a/src/kernel/resources/browsers/browsers.py b/src/kernel/resources/browsers/browsers.py index 425c1302..fa6a3504 100644 --- a/src/kernel/resources/browsers/browsers.py +++ b/src/kernel/resources/browsers/browsers.py @@ -469,6 +469,7 @@ def update( self, id_or_name: str, *, + captcha_solver_enabled: bool | Omit = omit, disable_default_proxy: bool | Omit = omit, location: BrowserLocationUpdateRequestParam | Omit = omit, name: Optional[str] | Omit = omit, @@ -492,6 +493,10 @@ def update( Update a browser session. Args: + captcha_solver_enabled: Enable or disable the stealth browser's CAPTCHA solver immediately, without + restarting the browser or interrupting the current page. Omit to leave the + solver unchanged. Only available for stealth browsers. + disable_default_proxy: If true, stealth browsers connect directly instead of using the default stealth proxy. Deprecated in favor of proxy.mode. @@ -554,6 +559,7 @@ def update( path_template("/browsers/{id_or_name}", id_or_name=id_or_name), body=maybe_transform( { + "captcha_solver_enabled": captcha_solver_enabled, "disable_default_proxy": disable_default_proxy, "location": location, "name": name, @@ -609,6 +615,9 @@ def list( offset: Number of results to skip. Defaults to 0. query: Search browsers by name, session ID, profile name or ID, proxy ID, or pool name. + With `status=deleted` or `status=all`, only browsers created in the last 24 + hours are searched, including active ones; use `status=active` to search all + active browsers. region: Filter sessions by geographic region. Omit to list sessions in all regions. @@ -617,7 +626,9 @@ def list( tags: Filter sessions by tag key-value pairs using deepObject style, e.g. ?tags[team]=backend&tags[env]=staging. Multiple pairs are ANDed: a session must - match every supplied pair exactly. + match every supplied pair exactly. With `status=deleted` or `status=all`, only + browsers created in the last 24 hours are matched; use `status=active` to match + all active browsers. extra_headers: Send extra headers @@ -1361,6 +1372,7 @@ async def update( self, id_or_name: str, *, + captcha_solver_enabled: bool | Omit = omit, disable_default_proxy: bool | Omit = omit, location: BrowserLocationUpdateRequestParam | Omit = omit, name: Optional[str] | Omit = omit, @@ -1384,6 +1396,10 @@ async def update( Update a browser session. Args: + captcha_solver_enabled: Enable or disable the stealth browser's CAPTCHA solver immediately, without + restarting the browser or interrupting the current page. Omit to leave the + solver unchanged. Only available for stealth browsers. + disable_default_proxy: If true, stealth browsers connect directly instead of using the default stealth proxy. Deprecated in favor of proxy.mode. @@ -1446,6 +1462,7 @@ async def update( path_template("/browsers/{id_or_name}", id_or_name=id_or_name), body=await async_maybe_transform( { + "captcha_solver_enabled": captcha_solver_enabled, "disable_default_proxy": disable_default_proxy, "location": location, "name": name, @@ -1501,6 +1518,9 @@ def list( offset: Number of results to skip. Defaults to 0. query: Search browsers by name, session ID, profile name or ID, proxy ID, or pool name. + With `status=deleted` or `status=all`, only browsers created in the last 24 + hours are searched, including active ones; use `status=active` to search all + active browsers. region: Filter sessions by geographic region. Omit to list sessions in all regions. @@ -1509,7 +1529,9 @@ def list( tags: Filter sessions by tag key-value pairs using deepObject style, e.g. ?tags[team]=backend&tags[env]=staging. Multiple pairs are ANDed: a session must - match every supplied pair exactly. + match every supplied pair exactly. With `status=deleted` or `status=all`, only + browsers created in the last 24 hours are matched; use `status=active` to match + all active browsers. extra_headers: Send extra headers diff --git a/src/kernel/resources/deployments.py b/src/kernel/resources/deployments.py index 5c2668a1..20c929f9 100644 --- a/src/kernel/resources/deployments.py +++ b/src/kernel/resources/deployments.py @@ -60,6 +60,7 @@ def create( file: FileTypes | Omit = omit, force: bool | Omit = omit, region: Literal["aws.us-east-1a"] | Omit = omit, + runtime_policy: deployment_create_params.RuntimePolicy | Omit = omit, source: deployment_create_params.Source | Omit = omit, version: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -85,6 +86,18 @@ def create( region: Region for deployment. Currently we only support "aws.us-east-1a" + runtime_policy: Permissions for each invocation's injected API key. Send this multipart field as + JSON. Requires scoped deployment enablement. The policy must stay within the + deployment's project, be a subset of the caller's permissions when the caller + has a policy, and grant container-wide invocations:write for runtime callbacks. + It cannot include api_keys:issue_beyond_expiry. Exact resource IDs must exist. + The policy outlives the deploying credential; each invocation gets a fresh key + valid for 65 minutes from issuance. When the caller has a policy, omission + grants only project-wide invocations:write for runtime callbacks. A supplied + policy must explicitly include that permission; it is never added automatically. + Callers without a policy keep an unrestricted runtime key when this field is + omitted. Scoped invokers must cover the runtime policy. + source: Source from which to fetch application code. version: Version of the application. Can be any string. @@ -106,6 +119,7 @@ def create( "file": file, "force": force, "region": region, + "runtime_policy": runtime_policy, "source": source, "version": version, }, @@ -344,6 +358,7 @@ async def create( file: FileTypes | Omit = omit, force: bool | Omit = omit, region: Literal["aws.us-east-1a"] | Omit = omit, + runtime_policy: deployment_create_params.RuntimePolicy | Omit = omit, source: deployment_create_params.Source | Omit = omit, version: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -369,6 +384,18 @@ async def create( region: Region for deployment. Currently we only support "aws.us-east-1a" + runtime_policy: Permissions for each invocation's injected API key. Send this multipart field as + JSON. Requires scoped deployment enablement. The policy must stay within the + deployment's project, be a subset of the caller's permissions when the caller + has a policy, and grant container-wide invocations:write for runtime callbacks. + It cannot include api_keys:issue_beyond_expiry. Exact resource IDs must exist. + The policy outlives the deploying credential; each invocation gets a fresh key + valid for 65 minutes from issuance. When the caller has a policy, omission + grants only project-wide invocations:write for runtime callbacks. A supplied + policy must explicitly include that permission; it is never added automatically. + Callers without a policy keep an unrestricted runtime key when this field is + omitted. Scoped invokers must cover the runtime policy. + source: Source from which to fetch application code. version: Version of the application. Can be any string. @@ -390,6 +417,7 @@ async def create( "file": file, "force": force, "region": region, + "runtime_policy": runtime_policy, "source": source, "version": version, }, diff --git a/src/kernel/resources/report_types/report_types.py b/src/kernel/resources/report_types/report_types.py index a4085924..f3740360 100644 --- a/src/kernel/resources/report_types/report_types.py +++ b/src/kernel/resources/report_types/report_types.py @@ -97,6 +97,7 @@ def list( task_id: str, limit: int | Omit = omit, offset: int | Omit = omit, + query: str | 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, @@ -116,6 +117,11 @@ def list( offset: Offset the number of report types to return. + query: What the agent wants to report, in its own words. Types are ranked by how + closely their meaning matches, most relevant first; they need not share any + words. Only this text affects the ranking, not the task. Without it, or if + ranking is unavailable, types are listed by name. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -137,6 +143,7 @@ def list( "task_id": task_id, "limit": limit, "offset": offset, + "query": query, }, report_type_list_params.ReportTypeListParams, ), @@ -211,6 +218,7 @@ def list( task_id: str, limit: int | Omit = omit, offset: int | Omit = omit, + query: str | 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, @@ -230,6 +238,11 @@ def list( offset: Offset the number of report types to return. + query: What the agent wants to report, in its own words. Types are ranked by how + closely their meaning matches, most relevant first; they need not share any + words. Only this text affects the ranking, not the task. Without it, or if + ranking is unavailable, types are listed by name. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -251,6 +264,7 @@ def list( "task_id": task_id, "limit": limit, "offset": offset, + "query": query, }, report_type_list_params.ReportTypeListParams, ), diff --git a/src/kernel/types/api_key.py b/src/kernel/types/api_key.py index ae3e56b7..a3c726e7 100644 --- a/src/kernel/types/api_key.py +++ b/src/kernel/types/api_key.py @@ -51,7 +51,17 @@ class PolicyStatementCondition(BaseModel): class PolicyStatement(BaseModel): action: str - """Permitted action, such as browsers:use or vaults:read.""" + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ resource: str """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. diff --git a/src/kernel/types/api_key_create_params.py b/src/kernel/types/api_key_create_params.py index 994df9e0..7dddcf96 100644 --- a/src/kernel/types/api_key_create_params.py +++ b/src/kernel/types/api_key_create_params.py @@ -72,7 +72,17 @@ class PolicyStatementCondition(TypedDict, total=False): class PolicyStatement(TypedDict, total=False): action: Required[str] - """Permitted action, such as browsers:use or vaults:read.""" + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ resource: Required[str] """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. diff --git a/src/kernel/types/api_key_update_params.py b/src/kernel/types/api_key_update_params.py index 82e32fca..832c716b 100644 --- a/src/kernel/types/api_key_update_params.py +++ b/src/kernel/types/api_key_update_params.py @@ -50,7 +50,17 @@ class PolicyStatementCondition(TypedDict, total=False): class PolicyStatement(TypedDict, total=False): action: Required[str] - """Permitted action, such as browsers:use or vaults:read.""" + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ resource: Required[str] """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. diff --git a/src/kernel/types/auth/auth_context.py b/src/kernel/types/auth/auth_context.py index 5abfb9ee..d3f0d09c 100644 --- a/src/kernel/types/auth/auth_context.py +++ b/src/kernel/types/auth/auth_context.py @@ -78,7 +78,17 @@ class AuthorizationEffectivePolicyStatementCondition(BaseModel): class AuthorizationEffectivePolicyStatement(BaseModel): action: str - """Permitted action, such as browsers:use or vaults:read.""" + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ resource: str """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. diff --git a/src/kernel/types/browser_list_params.py b/src/kernel/types/browser_list_params.py index 5bf673b5..54a12f7b 100644 --- a/src/kernel/types/browser_list_params.py +++ b/src/kernel/types/browser_list_params.py @@ -23,8 +23,11 @@ class BrowserListParams(TypedDict, total=False): """Number of results to skip. Defaults to 0.""" query: str - """ - Search browsers by name, session ID, profile name or ID, proxy ID, or pool name. + """Search browsers by name, session ID, profile name or ID, proxy ID, or pool name. + + With `status=deleted` or `status=all`, only browsers created in the last 24 + hours are searched, including active ones; use `status=active` to search all + active browsers. """ region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] @@ -41,5 +44,7 @@ class BrowserListParams(TypedDict, total=False): """Filter sessions by tag key-value pairs using deepObject style, e.g. ?tags[team]=backend&tags[env]=staging. Multiple pairs are ANDed: a session must - match every supplied pair exactly. + match every supplied pair exactly. With `status=deleted` or `status=all`, only + browsers created in the last 24 hours are matched; use `status=active` to match + all active browsers. """ diff --git a/src/kernel/types/browser_pool.py b/src/kernel/types/browser_pool.py index a36c510f..31e462f4 100644 --- a/src/kernel/types/browser_pool.py +++ b/src/kernel/types/browser_pool.py @@ -5,6 +5,7 @@ from typing_extensions import Literal from .._models import BaseModel +from .browser_proxy import BrowserProxy from .browser_memory import BrowserMemory from .browser_captcha_solver import BrowserCaptchaSolver from .browser_network_config import BrowserNetworkConfig @@ -99,10 +100,13 @@ class BrowserPoolConfig(BaseModel): pool profile is silently ignored rather than rejected. """ + proxy: Optional[BrowserProxy] = None + """Resolved proxy configuration for browsers in this pool.""" + proxy_id: Optional[str] = None - """Optional proxy associated to the browser session. + """ID of the proxy associated with browsers in this pool, if any. - References a proxy in the same project as the browser session. + Deprecated in favor of proxy. """ refresh_on_profile_update: Optional[bool] = None @@ -127,9 +131,9 @@ class BrowserPoolConfig(BaseModel): stealth: Optional[bool] = None """ Whether browsers in this pool use stealth mode, which is CAPTCHA solving with - Kernel's default stealth proxy unless proxy_id is set. A pool with only + Kernel's default stealth proxy unless a proxy is set. A pool with only captcha_solver enabled reports false. Deprecated in favor of captcha_solver and - proxy_id. + proxy. """ telemetry: Optional[BrowserTelemetryConfig] = None diff --git a/src/kernel/types/browser_pool_create_params.py b/src/kernel/types/browser_pool_create_params.py index 207ee70f..ccb3cac0 100644 --- a/src/kernel/types/browser_pool_create_params.py +++ b/src/kernel/types/browser_pool_create_params.py @@ -6,6 +6,7 @@ from typing_extensions import Literal, Required, TypedDict from .browser_memory_request import BrowserMemoryRequest +from .browser_proxy_config_param import BrowserProxyConfigParam from .browser_captcha_solver_param import BrowserCaptchaSolverParam from .browser_network_config_param import BrowserNetworkConfigParam from .shared_params.browser_viewport import BrowserViewport @@ -34,8 +35,9 @@ class BrowserPoolCreateParams(TypedDict, total=False): captcha_solver: BrowserCaptchaSolverParam """Automatic CAPTCHA solving for browsers in this pool. - Disabled by default. Enabling it does not select a proxy: when proxy_id is - omitted, browsers use direct egress unless stealth=true. + Disabled by default. Enabling it does not select a proxy: when proxy and + proxy_id are omitted, browsers use direct egress unless stealth=true. Set + proxy.mode=default for Kernel's default stealth proxy. """ chrome_policy: Dict[str, object] @@ -94,10 +96,21 @@ class BrowserPoolCreateParams(TypedDict, total=False): pool profile is silently ignored rather than rejected. """ + proxy: BrowserProxyConfigParam + """Proxy configuration for browsers in this pool. + + Cannot be combined with proxy_id. Omit to use direct egress, or Kernel's default + stealth proxy when stealth=true. Set mode to direct to force direct egress. Set + mode to default to use Kernel's default stealth proxy when + captcha_solver.enabled=true, or direct egress otherwise. Select id or name to + use that proxy. Proxy selection does not change CAPTCHA solver behavior. + """ + proxy_id: str - """Optional proxy to associate to the browser session. + """Optional proxy to associate to browsers in this pool. - Must reference a proxy in the same project as the browser session. + Must reference a proxy in the same project as the pool. Cannot be combined with + proxy. Deprecated in favor of proxy. """ refresh_on_profile_update: bool @@ -128,10 +141,9 @@ class BrowserPoolCreateParams(TypedDict, total=False): stealth: bool """ - If true, enables the CAPTCHA solver and, when proxy_id is omitted, uses Kernel's - default stealth proxy. Defaults to false. Cannot be combined with - captcha_solver.enabled=false. Deprecated in favor of captcha_solver and - proxy_id. + If true, enables the CAPTCHA solver and, when proxy and proxy_id are omitted, + uses Kernel's default stealth proxy. Defaults to false. Cannot be combined with + captcha_solver.enabled=false. Deprecated in favor of captcha_solver and proxy. """ telemetry: Optional[Telemetry] diff --git a/src/kernel/types/browser_pool_update_params.py b/src/kernel/types/browser_pool_update_params.py index 599333f5..b65c90d0 100644 --- a/src/kernel/types/browser_pool_update_params.py +++ b/src/kernel/types/browser_pool_update_params.py @@ -5,6 +5,7 @@ from typing import Dict, Iterable, Optional from typing_extensions import Literal, TypedDict +from .browser_proxy_config_param import BrowserProxyConfigParam from .browser_captcha_solver_param import BrowserCaptchaSolverParam from .browser_network_config_param import BrowserNetworkConfigParam from .shared_params.browser_viewport import BrowserViewport @@ -27,7 +28,7 @@ class BrowserPoolUpdateParams(TypedDict, total=False): """ If provided, replaces whether browsers in this pool automatically solve CAPTCHAs. Enabling it on a pool with direct egress keeps direct egress unless - proxy_id or stealth=true is also set. + proxy, proxy_id, or stealth=true is also set. """ chrome_policy: Dict[str, object] @@ -121,10 +122,20 @@ class BrowserPoolUpdateParams(TypedDict, total=False): pool profile is silently ignored rather than rejected. """ + proxy: BrowserProxyConfigParam + """Proxy configuration to apply to browsers warmed after the update. + + Omit to leave the current configuration unchanged. Cannot be combined with + proxy_id. Set mode to direct to switch to direct egress. Set mode to default to + use Kernel's default stealth proxy for a pool with CAPTCHA solving enabled, or + direct egress otherwise. Updating proxy does not change CAPTCHA solver behavior. + """ + proxy_id: str """Empty string clears the previously-selected proxy. - Omit this field to leave the proxy unchanged. + Omit this field to leave the proxy unchanged. Cannot be combined with proxy. + Deprecated in favor of proxy. """ refresh_on_profile_update: bool @@ -159,9 +170,9 @@ class BrowserPoolUpdateParams(TypedDict, total=False): stealth: bool """If provided, replaces whether browsers launch in stealth mode. - stealth=true without proxy_id moves a pool on direct egress to Kernel's default - stealth proxy. Cannot be combined with captcha_solver.enabled=false. Deprecated - in favor of captcha_solver and proxy_id. + stealth=true without proxy or proxy_id moves a pool on direct egress to Kernel's + default stealth proxy. Cannot be combined with captcha_solver.enabled=false. + Deprecated in favor of captcha_solver and proxy. """ telemetry: Optional[Telemetry] diff --git a/src/kernel/types/browser_update_params.py b/src/kernel/types/browser_update_params.py index 8bac0cf7..529e950b 100644 --- a/src/kernel/types/browser_update_params.py +++ b/src/kernel/types/browser_update_params.py @@ -25,6 +25,13 @@ class BrowserUpdateParams(TypedDict, total=False): + captcha_solver_enabled: bool + """ + Enable or disable the stealth browser's CAPTCHA solver immediately, without + restarting the browser or interrupting the current page. Omit to leave the + solver unchanged. Only available for stealth browsers. + """ + disable_default_proxy: bool """ If true, stealth browsers connect directly instead of using the default stealth diff --git a/src/kernel/types/deployment_create_params.py b/src/kernel/types/deployment_create_params.py index 84d3d876..ed59c7da 100644 --- a/src/kernel/types/deployment_create_params.py +++ b/src/kernel/types/deployment_create_params.py @@ -2,12 +2,19 @@ from __future__ import annotations -from typing import Dict +from typing import Dict, Iterable from typing_extensions import Literal, Required, TypedDict -from .._types import FileTypes +from .._types import FileTypes, SequenceNotStr -__all__ = ["DeploymentCreateParams", "Source", "SourceAuth"] +__all__ = [ + "DeploymentCreateParams", + "RuntimePolicy", + "RuntimePolicyStatement", + "RuntimePolicyStatementCondition", + "Source", + "SourceAuth", +] class DeploymentCreateParams(TypedDict, total=False): @@ -29,6 +36,22 @@ class DeploymentCreateParams(TypedDict, total=False): region: Literal["aws.us-east-1a"] """Region for deployment. Currently we only support "aws.us-east-1a" """ + runtime_policy: RuntimePolicy + """Permissions for each invocation's injected API key. + + Send this multipart field as JSON. Requires scoped deployment enablement. The + policy must stay within the deployment's project, be a subset of the caller's + permissions when the caller has a policy, and grant container-wide + invocations:write for runtime callbacks. It cannot include + api_keys:issue_beyond_expiry. Exact resource IDs must exist. The policy outlives + the deploying credential; each invocation gets a fresh key valid for 65 minutes + from issuance. When the caller has a policy, omission grants only project-wide + invocations:write for runtime callbacks. A supplied policy must explicitly + include that permission; it is never added automatically. Callers without a + policy keep an unrestricted runtime key when this field is omitted. Scoped + invokers must cover the runtime policy. + """ + source: Source """Source from which to fetch application code.""" @@ -36,6 +59,66 @@ class DeploymentCreateParams(TypedDict, total=False): """Version of the application. Can be any string.""" +class RuntimePolicyStatementCondition(TypedDict, total=False): + """ + A condition narrows a policy statement to requests matching its constraint: the request attribute, a comparison operator, and that operator's values. + """ + + key: Required[Literal["source_ip"]] + """Request attribute the condition constrains. + + `source_ip` restricts the statement to requests whose client address falls + inside one of `values`. + """ + + operator: Required[Literal["in"]] + """Comparison the condition applies between the request attribute and values.""" + + values: Required[SequenceNotStr[str]] + """Values the request attribute must match. + + For `source_ip`, CIDR networks: a bare address without a mask is rejected, and + so are an entry with host bits set and an IPv4 network written in IPv6 notation. + """ + + +class RuntimePolicyStatement(TypedDict, total=False): + action: Required[str] + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ + + resource: Required[str] + """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. + + Wildcards are supported. + """ + + condition: RuntimePolicyStatementCondition + """ + A condition narrows a policy statement to requests matching its constraint: the + request attribute, a comparison operator, and that operator's values. + """ + + +class RuntimePolicy(TypedDict, total=False): + """Permissions for each invocation's injected API key. + + Send this multipart field as JSON. Requires scoped deployment enablement. The policy must stay within the deployment's project, be a subset of the caller's permissions when the caller has a policy, and grant container-wide invocations:write for runtime callbacks. It cannot include api_keys:issue_beyond_expiry. Exact resource IDs must exist. The policy outlives the deploying credential; each invocation gets a fresh key valid for 65 minutes from issuance. When the caller has a policy, omission grants only project-wide invocations:write for runtime callbacks. A supplied policy must explicitly include that permission; it is never added automatically. Callers without a policy keep an unrestricted runtime key when this field is omitted. Scoped invokers must cover the runtime policy. + """ + + statements: Required[Iterable[RuntimePolicyStatement]] + """Allow statements. Every action and resource not listed is denied.""" + + class SourceAuth(TypedDict, total=False): """Authentication for private repositories.""" diff --git a/src/kernel/types/report_type_list_params.py b/src/kernel/types/report_type_list_params.py index aa46ee1f..ef7adb3a 100644 --- a/src/kernel/types/report_type_list_params.py +++ b/src/kernel/types/report_type_list_params.py @@ -16,3 +16,11 @@ class ReportTypeListParams(TypedDict, total=False): offset: int """Offset the number of report types to return.""" + + query: str + """What the agent wants to report, in its own words. + + Types are ranked by how closely their meaning matches, most relevant first; they + need not share any words. Only this text affects the ranking, not the task. + Without it, or if ranking is unavailable, types are listed by name. + """ diff --git a/src/kernel/types/vaults/kernel_wallet_state.py b/src/kernel/types/vaults/kernel_wallet_state.py index 0953b867..cc1d49a8 100644 --- a/src/kernel/types/vaults/kernel_wallet_state.py +++ b/src/kernel/types/vaults/kernel_wallet_state.py @@ -14,18 +14,18 @@ class KernelWalletState(BaseModel): status: Literal["pending_authorization", "connected", "reconnect_required", "degraded"] """connected means the wallet is usable. - It holds zero or more cards as payment methods, listed by the payment_methods - expansion, and each can pay once it reports - capabilities.single_use_card.eligible. A wallet with no cards, before its first - card or after its last is removed, is still connected. Where the wallet - advertises add_payment_method and remove_payment_method, use them to manage - cards. Otherwise the wallet enrolls one default card when created; until that - card is enrolled the wallet reports pending_authorization with the card's - card_enrollment action, or degraded when the card's enrollment outcome is - unknown and the wallet must be deleted before adding another card. - reconnect_required appears only on a wallet created before cards were payment - methods and not yet upgraded. Reads preserve its stored state until the operator - upgrade; payment and deletion requests are refused until then. + New wallets are created connected and empty. A wallet holds zero or more cards + as payment methods, added with add_payment_method, removed with + remove_payment_method and listed by the payment_methods expansion; each can pay + once it reports capabilities.single_use_card.eligible. A wallet with no cards, + before its first card or after its last is removed, is still connected. A wallet + created before cards were added with add_payment_method holds a default card, ID + card; while that card's enrollment is pending, its card_enrollment action is on + the card in the payment_methods expansion, not on the wallet. + pending_authorization, degraded and reconnect_required appear only on a wallet + created before cards were payment methods and not yet upgraded. Reads preserve + its stored state until the operator upgrade; payment and deletion requests are + refused until then. """ status_reason: Optional[str] = None diff --git a/src/kernel/types/vaults/kernel_wallet_vault_item_spec.py b/src/kernel/types/vaults/kernel_wallet_vault_item_spec.py index 3cbd225c..311a8869 100644 --- a/src/kernel/types/vaults/kernel_wallet_vault_item_spec.py +++ b/src/kernel/types/vaults/kernel_wallet_vault_item_spec.py @@ -9,7 +9,7 @@ class KernelWalletVaultItemSpec(BaseModel): """ - Cards stored with Kernel-managed credentials, each a payment method of the wallet. Each card is enrolled through a card_enrollment action: the cardholder enters the card and their email on a Kernel-hosted page. Where the wallet advertises add_payment_method, creation returns an empty connected wallet and each card is enrolled with that operation. Otherwise creation returns the wallet's default card's card_enrollment action, and the wallet connects once that card is stored. Kernel then enrolls each card for an agentic network token when the issuer supports it. The card number never reaches Kernel. The connected wallet's payment_methods expansion lists the cards; capabilities.single_use_card.eligible is false, with a network_token_* reason, until the card has a network token, and authorize returns 400 for such a card unless Kernel supports checkout delivery without a network token for that card. In that case, fill types the checkout details. Visa purchases require the cardholder to complete a spend_approval action before Kernel issues a one-time code; Mastercard purchases need no hosted approval. + Cards stored with Kernel-managed credentials, each a payment method of the wallet. Creation returns a connected wallet with no cards and no action. Add each card with the add_payment_method operation, which returns a card_enrollment action: the cardholder enters the card and their email on a Kernel-hosted page. Kernel then enrolls each card for an agentic network token when the issuer supports it. The card number never reaches Kernel. The connected wallet's payment_methods expansion lists the cards; capabilities.single_use_card.eligible is false, with a network_token_* reason, until the card has a network token, and authorize returns 400 for such a card unless Kernel supports checkout delivery without a network token for that card. In that case, fill types the checkout details. Visa purchases require the cardholder to complete a spend_approval action before Kernel issues a one-time code; Mastercard purchases need no hosted approval. """ provider: Literal["kernel"] diff --git a/src/kernel/types/vaults/kernel_wallet_vault_item_spec_param.py b/src/kernel/types/vaults/kernel_wallet_vault_item_spec_param.py index e560f119..8e535a08 100644 --- a/src/kernel/types/vaults/kernel_wallet_vault_item_spec_param.py +++ b/src/kernel/types/vaults/kernel_wallet_vault_item_spec_param.py @@ -9,7 +9,7 @@ class KernelWalletVaultItemSpecParam(TypedDict, total=False): """ - Cards stored with Kernel-managed credentials, each a payment method of the wallet. Each card is enrolled through a card_enrollment action: the cardholder enters the card and their email on a Kernel-hosted page. Where the wallet advertises add_payment_method, creation returns an empty connected wallet and each card is enrolled with that operation. Otherwise creation returns the wallet's default card's card_enrollment action, and the wallet connects once that card is stored. Kernel then enrolls each card for an agentic network token when the issuer supports it. The card number never reaches Kernel. The connected wallet's payment_methods expansion lists the cards; capabilities.single_use_card.eligible is false, with a network_token_* reason, until the card has a network token, and authorize returns 400 for such a card unless Kernel supports checkout delivery without a network token for that card. In that case, fill types the checkout details. Visa purchases require the cardholder to complete a spend_approval action before Kernel issues a one-time code; Mastercard purchases need no hosted approval. + Cards stored with Kernel-managed credentials, each a payment method of the wallet. Creation returns a connected wallet with no cards and no action. Add each card with the add_payment_method operation, which returns a card_enrollment action: the cardholder enters the card and their email on a Kernel-hosted page. Kernel then enrolls each card for an agentic network token when the issuer supports it. The card number never reaches Kernel. The connected wallet's payment_methods expansion lists the cards; capabilities.single_use_card.eligible is false, with a network_token_* reason, until the card has a network token, and authorize returns 400 for such a card unless Kernel supports checkout delivery without a network token for that card. In that case, fill types the checkout details. Visa purchases require the cardholder to complete a spend_approval action before Kernel issues a one-time code; Mastercard purchases need no hosted approval. """ provider: Required[Literal["kernel"]] diff --git a/src/kernel/types/vaults/one_password_fill_vault_item_operation_result.py b/src/kernel/types/vaults/one_password_fill_vault_item_operation_result.py index 9fa64aeb..16cbe304 100644 --- a/src/kernel/types/vaults/one_password_fill_vault_item_operation_result.py +++ b/src/kernel/types/vaults/one_password_fill_vault_item_operation_result.py @@ -18,20 +18,61 @@ class OnePasswordFillVaultItemOperationResult(BaseModel): """Kernel's outcome of the extension call. fill_submitted means the extension reported submission, not website - authentication. fill_failed means the extension returned a known failure and - includes error_code. fill_unknown means the form may have been filled or - submitted without a conclusive result; inspect the page to see the result of the - fill. + authentication; check the page. fill_failed means 1Password reported a failure, + named by error_code; with fillFailed the form may already have been filled or + submitted, so check the page. fill_unknown means the form may have been filled + or submitted without a conclusive result; inspect the page to see the result of + the fill. """ type: Literal["1pw_fill"] - error_code: Optional[Literal["fillFailed", "autosubmitFailed", "noExistingCredentials", "authenticationFailed"]] = ( - None - ) - """ - Present for fill_failed, and for fill_unknown when the extension reported - autosubmitFailed (it filled and submitted the form but could not confirm the - fill finished). These are allowlisted 1Password extension codes, never raw - errors, secrets, or page content. + error_code: Optional[str] = None + """The 1Password extension's error code, passed through unchanged. + + Present for fill_failed, and for fill_unknown when the extension reported one. + Codes 1Password adds later are returned with fill_unknown, because the form may + have been filled or submitted. Codes are short identifiers, never raw errors, + secrets, or page content. + + autosubmitFailed (fill_unknown): 1Password filled the form, saw no new page and + no removed fields for 10 seconds, and cleared what it filled. If the login has a + one-time password the site didn't ask for, the sign-in may still have worked. + The approval is still valid: do not request access again. Check the page: + continue if signed in or on a verification step; if the form is still showing, + 1Password cannot sign in to this site, so ask the user or use another sign-in + method rather than filling again. + + internal (fill_unknown): an unexpected 1Password error that may have happened + after the fill. Inspect the page. + + noActiveGrant, credentialNotFound: the approval expired or was revoked, or the + login was deleted or moved. Kernel returns the credential to + pending_authorization and drops its approval; create a new access request with + 1pw_create_access_request. + + fillFailed: 1Password couldn't complete the fill, and the form may already have + been filled or submitted. Check the page before filling again. + + websiteMismatch: the page isn't on the login's website. Navigate to the login + page and fill again. + + rateLimitExceeded: wait at least a minute before filling again. + serviceUnavailable and networkError: fill again with backoff. + + extensionUnavailable: the 1Password extension failed to start in this browser. + Create a new browser with the vault attached and fill there. + + invalidToken: 1Password rejected the access token. For a credential linked to a + 1Password account, Kernel has already refreshed the token and filled once more; + if that refresh failed, the account is now reconnect_required, so link it again + with PUT. For a credential with a stored token, replace the token with + 1pw_update_access_token, then fill again. + + integrationKeyInvalid: the 1Password connection was removed or is out of date. + Invoke 1pw_disconnect on the credential_account item, then link it again with + PUT. + + insufficientScope, permissionDenied, featureEntitlementMissing: the 1Password + account or plan doesn't allow this. Tell the user; filling again won't help. """ diff --git a/src/kernel/types/vaults/vault_payment_method.py b/src/kernel/types/vaults/vault_payment_method.py index ce2411ae..fb12a027 100644 --- a/src/kernel/types/vaults/vault_payment_method.py +++ b/src/kernel/types/vaults/vault_payment_method.py @@ -66,8 +66,8 @@ class VaultPaymentMethod(BaseModel): is_default: bool """ For Kernel wallets, true for the default card, ID card, which a Kernel card item - that omits payment_method_id selects. Wallets created with payment methods - enabled have no default card. + that omits payment_method_id selects. Only wallets created before cards were + added with add_payment_method have a default card. """ provider: str diff --git a/src/kernel/types/workload_identity_authorization.py b/src/kernel/types/workload_identity_authorization.py index cb4be438..4f8f4fe2 100644 --- a/src/kernel/types/workload_identity_authorization.py +++ b/src/kernel/types/workload_identity_authorization.py @@ -33,7 +33,17 @@ class PolicyStatementCondition(BaseModel): class PolicyStatement(BaseModel): action: str - """Permitted action, such as browsers:use or vaults:read.""" + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ resource: str """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. diff --git a/src/kernel/types/workload_identity_authorization_param.py b/src/kernel/types/workload_identity_authorization_param.py index 1227db95..c93b6c31 100644 --- a/src/kernel/types/workload_identity_authorization_param.py +++ b/src/kernel/types/workload_identity_authorization_param.py @@ -35,7 +35,17 @@ class PolicyStatementCondition(TypedDict, total=False): class PolicyStatement(TypedDict, total=False): action: Required[str] - """Permitted action, such as browsers:use or vaults:read.""" + """Permitted action, such as browsers:use or vaults:read. + + When creating an API key or replacing its policy, `*` may replace whole + components as shorthand: browsers:_ names every browsers action, _:delete every + delete action the resource can carry, and _:_ every action the resource can + carry. The stored policy lists the concrete actions, so actions added later are + not granted, and api_keys:issue_beyond_expiry must always be listed explicitly. + Partial components such as brow*:use and a bare * are rejected. Other policies, + such as workload identity rules and deployment runtime policies, accept only + exact actions. + """ resource: Required[str] """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. diff --git a/tests/api_resources/test_browser_pools.py b/tests/api_resources/test_browser_pools.py index 26704959..d7a0fa6d 100644 --- a/tests/api_resources/test_browser_pools.py +++ b/tests/api_resources/test_browser_pools.py @@ -64,6 +64,11 @@ def test_method_create_with_all_params(self, client: Kernel) -> None: "id": "id", "name": "name", }, + proxy={ + "id": "x", + "mode": "direct", + "name": "x", + }, proxy_id="proxy_id", refresh_on_profile_update=True, region="us-east", @@ -232,6 +237,11 @@ def test_method_update_with_all_params(self, client: Kernel) -> None: "id": "id", "name": "name", }, + proxy={ + "id": "x", + "mode": "direct", + "name": "x", + }, proxy_id="proxy_id", refresh_on_profile_update=True, size=10, @@ -638,6 +648,11 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) -> "id": "id", "name": "name", }, + proxy={ + "id": "x", + "mode": "direct", + "name": "x", + }, proxy_id="proxy_id", refresh_on_profile_update=True, region="us-east", @@ -806,6 +821,11 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) -> "id": "id", "name": "name", }, + proxy={ + "id": "x", + "mode": "direct", + "name": "x", + }, proxy_id="proxy_id", refresh_on_profile_update=True, size=10, diff --git a/tests/api_resources/test_browsers.py b/tests/api_resources/test_browsers.py index a0c01836..d98245cf 100644 --- a/tests/api_resources/test_browsers.py +++ b/tests/api_resources/test_browsers.py @@ -219,6 +219,7 @@ def test_method_update(self, client: Kernel) -> None: def test_method_update_with_all_params(self, client: Kernel) -> None: browser = client.browsers.update( id_or_name="htzv5orfit78e1m2biiifpbv", + captcha_solver_enabled=True, disable_default_proxy=True, location={ "locale": "en-US", @@ -835,6 +836,7 @@ async def test_method_update(self, async_client: AsyncKernel) -> None: async def test_method_update_with_all_params(self, async_client: AsyncKernel) -> None: browser = await async_client.browsers.update( id_or_name="htzv5orfit78e1m2biiifpbv", + captcha_solver_enabled=True, disable_default_proxy=True, location={ "locale": "en-US", diff --git a/tests/api_resources/test_deployments.py b/tests/api_resources/test_deployments.py index 4f619015..e5f51d37 100644 --- a/tests/api_resources/test_deployments.py +++ b/tests/api_resources/test_deployments.py @@ -37,6 +37,19 @@ def test_method_create_with_all_params(self, client: Kernel) -> None: file=b"Example data", force=False, region="aws.us-east-1a", + runtime_policy={ + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + "condition": { + "key": "source_ip", + "operator": "in", + "values": ["203.0.113.0/24"], + }, + } + ] + }, source={ "entrypoint": "src/index.ts", "ref": "main", @@ -269,6 +282,19 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) -> file=b"Example data", force=False, region="aws.us-east-1a", + runtime_policy={ + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + "condition": { + "key": "source_ip", + "operator": "in", + "values": ["203.0.113.0/24"], + }, + } + ] + }, source={ "entrypoint": "src/index.ts", "ref": "main", diff --git a/tests/api_resources/test_report_types.py b/tests/api_resources/test_report_types.py index 56cbad8e..9d869c95 100644 --- a/tests/api_resources/test_report_types.py +++ b/tests/api_resources/test_report_types.py @@ -75,6 +75,7 @@ def test_method_list_with_all_params(self, client: Kernel) -> None: task_id="task_id", limit=1, offset=0, + query="query", ) assert_matches_type(SyncOffsetPagination[ReportTypeSummary], report_type, path=["response"]) @@ -167,6 +168,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> N task_id="task_id", limit=1, offset=0, + query="query", ) assert_matches_type(AsyncOffsetPagination[ReportTypeSummary], report_type, path=["response"]) From 24bbc41ea434fbe7b3e8bf3d700a2733e750b40c Mon Sep 17 00:00:00 2001 From: "kernel-internal[bot]" <260533166+kernel-internal[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:34:36 +0000 Subject: [PATCH 3/6] feat: Let alias Kernel cards record a merchant outcome Stainless-Generated-From: 2f01624e47addcbaf46aec486398fb71adc666f2 --- src/kernel/resources/vaults/items.py | 24 +++++++++---------- ...tion_vault_item_operation_request_param.py | 12 ++++++---- .../vaults/item_perform_operation_params.py | 10 ++++---- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/kernel/resources/vaults/items.py b/src/kernel/resources/vaults/items.py index 22ed93b2..e6b533c7 100644 --- a/src/kernel/resources/vaults/items.py +++ b/src/kernel/resources/vaults/items.py @@ -681,14 +681,14 @@ def perform_operation( failure_code: Why the purchase did not succeed, for any other outcome, such as 3ds_challenge, captcha, login_required, timeout or site_error. payment_declined goes only with - DECLINED, which takes no other code. Shop Pay reports it; other providers ignore - it. + DECLINED, which takes no other code. Shop Pay reports it to Shop Pay; Kernel + cards store it with the purchase without reporting it. - order_id: The merchant's order number, for an APPROVED outcome. Shop Pay reports it; other - providers ignore it. + order_id: The merchant's order number, for an APPROVED outcome. Shop Pay reports it to + Shop Pay; Kernel cards store it with the purchase without reporting it. - order_url: The merchant's https order page, for an APPROVED outcome. Shop Pay reports it; - other providers ignore it. + order_url: The merchant's https order page, for an APPROVED outcome. Shop Pay reports it to + Shop Pay; Kernel cards store it with the purchase without reporting it. extra_headers: Send extra headers @@ -2926,14 +2926,14 @@ async def perform_operation( failure_code: Why the purchase did not succeed, for any other outcome, such as 3ds_challenge, captcha, login_required, timeout or site_error. payment_declined goes only with - DECLINED, which takes no other code. Shop Pay reports it; other providers ignore - it. + DECLINED, which takes no other code. Shop Pay reports it to Shop Pay; Kernel + cards store it with the purchase without reporting it. - order_id: The merchant's order number, for an APPROVED outcome. Shop Pay reports it; other - providers ignore it. + order_id: The merchant's order number, for an APPROVED outcome. Shop Pay reports it to + Shop Pay; Kernel cards store it with the purchase without reporting it. - order_url: The merchant's https order page, for an APPROVED outcome. Shop Pay reports it; - other providers ignore it. + order_url: The merchant's https order page, for an APPROVED outcome. Shop Pay reports it to + Shop Pay; Kernel cards store it with the purchase without reporting it. extra_headers: Send extra headers diff --git a/src/kernel/types/vaults/confirm_transaction_vault_item_operation_request_param.py b/src/kernel/types/vaults/confirm_transaction_vault_item_operation_request_param.py index a57f9e2e..a36a8c2d 100644 --- a/src/kernel/types/vaults/confirm_transaction_vault_item_operation_request_param.py +++ b/src/kernel/types/vaults/confirm_transaction_vault_item_operation_request_param.py @@ -13,7 +13,7 @@ class ConfirmTransactionVaultItemOperationRequestParam(TypedDict, total=False): """ - Report a real merchant transaction outcome for an issued Kernel Visa or Shop Pay credential. Shop Pay accepts PURCHASE, AUTHORIZATION and CAPTURE. Never infer success from filling checkout or receiving a credential. Supply the observed status, transaction type, actual amount, currency and timestamp. Unknown outcomes require manual reconciliation, not retry. Each purchase accepts one report. + Report a real merchant transaction outcome for an issued Kernel card or Shop Pay credential. Kernel alias cards record the outcome without contacting the issuer. Shop Pay accepts PURCHASE, AUTHORIZATION and CAPTURE. Never infer success from filling checkout or receiving a credential. Supply the observed status, transaction type, actual amount, currency and timestamp. Unknown outcomes require manual reconciliation, not retry. Each purchase accepts one report. """ amount: Required[int] @@ -37,18 +37,20 @@ class ConfirmTransactionVaultItemOperationRequestParam(TypedDict, total=False): """ Why the purchase did not succeed, for any other outcome, such as 3ds_challenge, captcha, login_required, timeout or site_error. payment_declined goes only with - DECLINED, which takes no other code. Shop Pay reports it; other providers ignore - it. + DECLINED, which takes no other code. Shop Pay reports it to Shop Pay; Kernel + cards store it with the purchase without reporting it. """ order_id: str """The merchant's order number, for an APPROVED outcome. - Shop Pay reports it; other providers ignore it. + Shop Pay reports it to Shop Pay; Kernel cards store it with the purchase without + reporting it. """ order_url: str """The merchant's https order page, for an APPROVED outcome. - Shop Pay reports it; other providers ignore it. + Shop Pay reports it to Shop Pay; Kernel cards store it with the purchase without + reporting it. """ diff --git a/src/kernel/types/vaults/item_perform_operation_params.py b/src/kernel/types/vaults/item_perform_operation_params.py index f151624e..df8099e8 100644 --- a/src/kernel/types/vaults/item_perform_operation_params.py +++ b/src/kernel/types/vaults/item_perform_operation_params.py @@ -82,20 +82,22 @@ class ConfirmTransactionVaultItemOperationRequest(TypedDict, total=False): """ Why the purchase did not succeed, for any other outcome, such as 3ds_challenge, captcha, login_required, timeout or site_error. payment_declined goes only with - DECLINED, which takes no other code. Shop Pay reports it; other providers ignore - it. + DECLINED, which takes no other code. Shop Pay reports it to Shop Pay; Kernel + cards store it with the purchase without reporting it. """ order_id: str """The merchant's order number, for an APPROVED outcome. - Shop Pay reports it; other providers ignore it. + Shop Pay reports it to Shop Pay; Kernel cards store it with the purchase without + reporting it. """ order_url: str """The merchant's https order page, for an APPROVED outcome. - Shop Pay reports it; other providers ignore it. + Shop Pay reports it to Shop Pay; Kernel cards store it with the purchase without + reporting it. """ From de8716f1ead3b74e8287eed4b77a23f150721e52 Mon Sep 17 00:00:00 2001 From: "kernel-internal[bot]" <260533166+kernel-internal[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:39:29 +0000 Subject: [PATCH 4/6] release: 0.155.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/kernel/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 78362658..f102a288 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.154.0" + ".": "0.155.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c2246acc..bcf34a21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [0.155.0](https://github.com/kernel/kernel-python-sdk/compare/v0.154.0...v0.155.0) (2026-11-25) + + +### Features + +* Accept a proxy object on browser pools ([37f0e8b](https://github.com/kernel/kernel-python-sdk/commit/37f0e8b489698bfe2d0f6047ae90fe1c852fd8b9)) +* Let alias Kernel cards record a merchant outcome ([24bbc41](https://github.com/kernel/kernel-python-sdk/commit/24bbc41ea434fbe7b3e8bf3d700a2733e750b40c)) + ## [0.154.0](https://github.com/kernel/kernel-python-sdk/compare/v0.153.0...v0.154.0) (2026-11-20) diff --git a/pyproject.toml b/pyproject.toml index 8be71519..0361c542 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "kernel" -version = "0.154.0" +version = "0.155.0" description = "The official Python library for the kernel API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/kernel/_version.py b/src/kernel/_version.py index e8eb495b..290c6dc2 100644 --- a/src/kernel/_version.py +++ b/src/kernel/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "kernel" -__version__ = "0.154.0" # x-release-please-version +__version__ = "0.155.0" # x-release-please-version From 133d7389f404a7a7b533a56ff1045742f79e3657 Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Wed, 25 Nov 2026 17:47:58 +0000 Subject: [PATCH 5/6] fix: send deployment source and runtime policy as JSON parts --- src/kernel/resources/deployments.py | 31 ++++++++++++++++------- tests/test_deployment_multipart.py | 38 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 tests/test_deployment_multipart.py diff --git a/src/kernel/resources/deployments.py b/src/kernel/resources/deployments.py index 20c929f9..620a9f5c 100644 --- a/src/kernel/resources/deployments.py +++ b/src/kernel/resources/deployments.py @@ -10,7 +10,7 @@ from ..types import deployment_list_params, deployment_create_params, deployment_follow_params from .._files import deepcopy_with_paths from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, omit, not_given -from .._utils import extract_files, path_template, maybe_transform, async_maybe_transform +from .._utils import transform, extract_files, path_template, async_transform, maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( @@ -22,6 +22,7 @@ from .._streaming import Stream, AsyncStream from ..pagination import SyncOffsetPagination, AsyncOffsetPagination from .._base_client import AsyncPaginator, make_request_options +from .._utils._json import openapi_dumps from ..types.deployment_list_response import DeploymentListResponse from ..types.deployment_create_response import DeploymentCreateResponse from ..types.deployment_follow_response import DeploymentFollowResponse @@ -30,6 +31,16 @@ __all__ = ["DeploymentsResource", "AsyncDeploymentsResource"] +def _extract_json_parts(body: dict[str, object], extra_body: Body | None) -> list[tuple[str, FileTypes]]: + if extra_body is not None: + body.update(cast(Mapping[str, object], extra_body)) + return [ + (name, (None, openapi_dumps(body.pop(name)), "application/json")) + for name in ("source", "runtime_policy") + if isinstance(body.get(name), dict) + ] + + class DeploymentsResource(SyncAPIResource): """Create and manage app deployments and stream deployment events.""" @@ -112,7 +123,7 @@ def create( idempotency_key: Specify a custom idempotency key for this request """ - body = deepcopy_with_paths( + body: dict[str, object] = deepcopy_with_paths( { "entrypoint_rel_path": entrypoint_rel_path, "env_vars": env_vars, @@ -125,19 +136,20 @@ def create( }, [["file"]], ) - files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) + files = extract_files(body, paths=[["file"]]) + body = transform(body, deployment_create_params.DeploymentCreateParams) + files.extend(_extract_json_parts(body, extra_body)) # It should be noted that the actual Content-Type header that will be # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( "/deployments", - body=maybe_transform(body, deployment_create_params.DeploymentCreateParams), + body=body, files=files, options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, - extra_body=extra_body, timeout=timeout, idempotency_key=idempotency_key, ), @@ -410,7 +422,7 @@ async def create( idempotency_key: Specify a custom idempotency key for this request """ - body = deepcopy_with_paths( + body: dict[str, object] = deepcopy_with_paths( { "entrypoint_rel_path": entrypoint_rel_path, "env_vars": env_vars, @@ -423,19 +435,20 @@ async def create( }, [["file"]], ) - files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) + files = extract_files(body, paths=[["file"]]) + body = await async_transform(body, deployment_create_params.DeploymentCreateParams) + files.extend(_extract_json_parts(body, extra_body)) # It should be noted that the actual Content-Type header that will be # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( "/deployments", - body=await async_maybe_transform(body, deployment_create_params.DeploymentCreateParams), + body=body, files=files, options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, - extra_body=extra_body, timeout=timeout, idempotency_key=idempotency_key, ), diff --git a/tests/test_deployment_multipart.py b/tests/test_deployment_multipart.py new file mode 100644 index 00000000..60b11c07 --- /dev/null +++ b/tests/test_deployment_multipart.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +import json +from email import policy +from email.parser import BytesParser +from email.message import EmailMessage + +import httpx +import pytest +from respx import MockRouter + +from kernel import Kernel, AsyncKernel +from kernel.types.deployment_create_params import Source, RuntimePolicy + + +@pytest.mark.parametrize("use_async", [False, True], ids=["sync", "async"]) +async def test_deployment_json_parts( + client: Kernel, async_client: AsyncKernel, respx_mock: MockRouter, use_async: bool +) -> None: + route = respx_mock.post("/deployments").mock(return_value=httpx.Response(200, json={})) + source: Source = {"type": "github", "url": "https://github.com/example/app", "ref": "main", "entrypoint": "app.py"} + runtime_policy: RuntimePolicy = {"statements": [{"action": "invocations:write", "resource": "*"}]} + if use_async: + await async_client.deployments.with_raw_response.create(source=source, runtime_policy=runtime_policy) + else: + client.deployments.with_raw_response.create(source=source, runtime_policy=runtime_policy) + + request = route.calls.last.request + message = BytesParser(EmailMessage, policy=policy.default).parsebytes( + f"Content-Type: {request.headers['Content-Type']}\r\n\r\n".encode() + request.content + ) + parts = list(message.iter_parts()) + assert len(parts) == 2 + assert all(part.get_content_type() == "application/json" and part.get_filename() is None for part in parts) + assert {part.get_param("name", header="content-disposition"): json.loads(part.get_content()) for part in parts} == { + "source": source, + "runtime_policy": runtime_policy, + } From 551353129289c8017b41e8475b6d98a9e6ef6d9b Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Wed, 25 Nov 2026 17:57:31 +0000 Subject: [PATCH 6/6] fix: keep extra_body out of deployment JSON part extraction --- src/kernel/resources/deployments.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kernel/resources/deployments.py b/src/kernel/resources/deployments.py index 620a9f5c..90512603 100644 --- a/src/kernel/resources/deployments.py +++ b/src/kernel/resources/deployments.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Dict, Mapping, cast +from typing import Any, Dict, cast from typing_extensions import Literal import httpx @@ -31,9 +31,7 @@ __all__ = ["DeploymentsResource", "AsyncDeploymentsResource"] -def _extract_json_parts(body: dict[str, object], extra_body: Body | None) -> list[tuple[str, FileTypes]]: - if extra_body is not None: - body.update(cast(Mapping[str, object], extra_body)) +def _extract_json_parts(body: dict[str, object]) -> list[tuple[str, FileTypes]]: return [ (name, (None, openapi_dumps(body.pop(name)), "application/json")) for name in ("source", "runtime_policy") @@ -138,7 +136,7 @@ def create( ) files = extract_files(body, paths=[["file"]]) body = transform(body, deployment_create_params.DeploymentCreateParams) - files.extend(_extract_json_parts(body, extra_body)) + files.extend(_extract_json_parts(body)) # It should be noted that the actual Content-Type header that will be # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- @@ -150,6 +148,7 @@ def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, + extra_body=extra_body, timeout=timeout, idempotency_key=idempotency_key, ), @@ -437,7 +436,7 @@ async def create( ) files = extract_files(body, paths=[["file"]]) body = await async_transform(body, deployment_create_params.DeploymentCreateParams) - files.extend(_extract_json_parts(body, extra_body)) + files.extend(_extract_json_parts(body)) # It should be noted that the actual Content-Type header that will be # sent to the server will contain a `boundary` parameter, e.g. # multipart/form-data; boundary=---abc-- @@ -449,6 +448,7 @@ async def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, + extra_body=extra_body, timeout=timeout, idempotency_key=idempotency_key, ),