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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ jobs:
- name: Check release environment
run: |
bash ./bin/check-release-environment

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.51.0"
".": "0.52.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 112
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-a674e3c4c0063942621d1b4e7f67b72f7e240c12dd88564fe16627618ba33dd6.yml
openapi_spec_hash: 8b97c87f0dafe5fc5e5a7365f3687755
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-4ce09d1a7546ab36f578cb27d819187eeb90c580b11834c7ff7a375aa22f9a20.yml
openapi_spec_hash: 1043ab2d699f6c828680c3352cd4cece
config_hash: 08d55086449943a8fec212b870061a3f
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.52.0 (2026-04-29)

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

### Features

* profile download: 409 for empty profile + surface API errors in dashboard ([db164ab](https://github.com/kernel/kernel-node-sdk/commit/db164abb21ef046db547e13d1b9cdeab2aa1fcf4))
* support setting headers via env ([1a5897b](https://github.com/kernel/kernel-node-sdk/commit/1a5897b9f941b59622b82f1cc6244109b8c70bc6))


### Chores

* **format:** run eslint and prettier separately ([127af86](https://github.com/kernel/kernel-node-sdk/commit/127af86528c1c942c2b8b2af6c9e367f4acb832f))
* **internal:** codegen related update ([98c6a4b](https://github.com/kernel/kernel-node-sdk/commit/98c6a4b6e8cce127205f690b9f0b1d8f8ae333c9))
* prettier format browser routing example ([d530ee3](https://github.com/kernel/kernel-node-sdk/commit/d530ee341694c72f095fc12c1f417dbd5a5a7a51))


### Documentation

* print response body and clarify fetch() / Response semantics ([125c74d](https://github.com/kernel/kernel-node-sdk/commit/125c74db4b373d14b37ef898718dc2b18cf1d5ad))
* show both raw streaming and buffered curl in routing example ([47e2462](https://github.com/kernel/kernel-node-sdk/commit/47e2462511cbd04605612b4a76e692d635e3ef06))

## 0.51.0 (2026-04-25)

Full Changelog: [v0.50.0...v0.51.0](https://github.com/kernel/kernel-node-sdk/compare/v0.50.0...v0.51.0)
Expand Down
3 changes: 0 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check
import tseslint from 'typescript-eslint';
import unusedImports from 'eslint-plugin-unused-imports';
import prettier from 'eslint-plugin-prettier';

export default tseslint.config(
{
Expand All @@ -14,11 +13,9 @@ export default tseslint.config(
plugins: {
'@typescript-eslint': tseslint.plugin,
'unused-imports': unusedImports,
prettier,
},
rules: {
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'unused-imports/no-unused-imports': 'error',
'no-restricted-imports': [
'error',
Expand Down
16 changes: 14 additions & 2 deletions examples/browser-routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ async function main() {
const kernel = new Kernel();

const browser = await kernel.browsers.create({});
const response = await kernel.browsers.fetch(browser.session_id, 'https://example.com', { method: 'GET' });
console.log('status', response.status);

// Raw browser curl: streams the response. Use for large responses, when you want to stream,
// or when you want fetch() / Response semantics.
const response: Response = await kernel.browsers.fetch(browser.session_id, 'https://example.com', {
method: 'GET',
});
console.log('body', await response.text());

// Buffered browser curl: returns the full response in a JSON envelope. Use for small responses.
const buffered = await kernel.browsers.curl(browser.session_id, {
url: 'https://example.com',
method: 'GET',
});
console.log('body', buffered.body);

await kernel.browsers.deleteByID(browser.session_id);
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onkernel/sdk",
"version": "0.51.0",
"version": "0.52.0",
"description": "The official TypeScript library for the Kernel API",
"author": "Kernel <>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -38,7 +38,6 @@
"@typescript-eslint/parser": "8.31.1",
"busboy": "^1.6.0",
"eslint": "^9.39.1",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-unused-imports": "^4.1.4",
"iconv-lite": "^0.6.3",
"jest": "^29.4.0",
Expand Down
9 changes: 3 additions & 6 deletions scripts/fast-format
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ if ! [ -z "$ESLINT_FILES" ]; then
fi

echo "==> Running prettier --write"
# format things eslint didn't
PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)"
if ! [ -z "$PRETTIER_FILES" ]; then
echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \
--write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \
'!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
if ! [ -z "$FILE_LIST" ]; then
cat "$FILE_LIST" | xargs ./node_modules/.bin/prettier \
--write --cache --cache-strategy metadata --no-error-on-unmatched-pattern --ignore-unknown
fi
3 changes: 1 addition & 2 deletions scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ echo "==> Running eslint --fix"
./node_modules/.bin/eslint --fix .

echo "==> Running prettier --write"
# format things eslint didn't
./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
./node_modules/.bin/prettier --write --cache --cache-strategy metadata .
3 changes: 3 additions & 0 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -e

cd "$(dirname "$0")/.."

echo "==> Running prettier --check"
./node_modules/.bin/prettier --check .

echo "==> Running eslint"
./node_modules/.bin/eslint .

Expand Down
9 changes: 8 additions & 1 deletion scripts/utils/postprocess-files.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ async function postprocess() {

// strip out lib="dom", types="node", and types="react" references; these
// are needed at build time, but would pollute the user's TS environment
const transformed = code.replace(
let transformed = code.replace(
/^ *\/\/\/ *<reference +(lib="dom"|types="(node|react)").*?\n/gm,
// replace with same number of characters to avoid breaking source maps
(match) => ' '.repeat(match.length - 1) + '\n',
);

// TypeScript's declaration emitter collapses /** @ts-ignore */ onto the same
// line as the type declaration, which doesn't work. So we convert to // @ts-ignore
// on its own line to properly suppresses errors.
if (file.endsWith('.d.ts') || file.endsWith('.d.mts') || file.endsWith('.d.cts')) {
transformed = transformed.replace(/\/\*\* @ts-ignore\b[^*]*\*\/ /gm, '// @ts-ignore\n');
}

if (transformed !== code) {
console.error(`wrote ${path.relative(process.cwd(), file)}`);
await fs.promises.writeFile(file, transformed, 'utf8');
Expand Down
12 changes: 12 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,18 @@ export class Kernel {
});
this.#encoder = Opts.FallbackEncoder;

const customHeadersEnv = readEnv('KERNEL_CUSTOM_HEADERS');
if (customHeadersEnv) {
const parsed: Record<string, string> = {};
for (const line of customHeadersEnv.split('\n')) {
const colon = line.indexOf(':');
if (colon >= 0) {
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
}
}
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object spread silently drops non-plain-object defaultHeaders

Medium Severity

When KERNEL_CUSTOM_HEADERS is set, options.defaultHeaders is merged via object spread ({ ...parsed, ...options.defaultHeaders }). However, defaultHeaders is typed as HeadersLike, which includes Headers instances, 2D arrays, and NullableHeaders. Spreading a Headers instance produces an empty object because its entries aren't own enumerable properties, silently discarding all user-supplied default headers. A safe merge would need to go through buildHeaders or convert via Object.fromEntries.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7c1360d. Configure here.

}

this._options = options;

this.apiKey = apiKey;
Expand Down
14 changes: 6 additions & 8 deletions src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type OverloadedParameters<T> =
: T extends (...args: infer A) => unknown ? A
: never;

/* eslint-disable */
/**
* These imports attempt to get types from a parent package's dependencies.
* Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which
Expand All @@ -63,19 +62,18 @@ type OverloadedParameters<T> =
*
* [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition
*/
/** @ts-ignore For users with \@types/node */
/** @ts-ignore For users with \@types/node */ /* prettier-ignore */
type UndiciTypesRequestInit = NotAny<import('../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit>;
/** @ts-ignore For users with undici */
/** @ts-ignore For users with undici */ /* prettier-ignore */
type UndiciRequestInit = NotAny<import('../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici/index.d.ts').RequestInit>;
/** @ts-ignore For users with \@types/bun */
/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */
type BunRequestInit = globalThis.FetchRequestInit;
/** @ts-ignore For users with node-fetch@2 */
/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */
type NodeFetch2RequestInit = NotAny<import('../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit>;
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */
type NodeFetch3RequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
/** @ts-ignore For users who use Deno */
/** @ts-ignore For users who use Deno */ /* prettier-ignore */
type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
/* eslint-enable */

type RequestInits =
| NotAny<UndiciTypesRequestInit>
Expand Down
3 changes: 1 addition & 2 deletions src/resources/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export class Profiles extends APIResource {
}

/**
* Download the profile. Profiles are JSON files containing the pieces of state
* that we save.
* Returns a zstd-compressed tar file of the full user-data directory.
*/
download(idOrName: string, options?: RequestOptions): APIPromise<Response> {
return this._client.get(path`/profiles/${idOrName}/download`, {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.51.0'; // x-release-please-version
export const VERSION = '0.52.0'; // x-release-please-version
32 changes: 0 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,6 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@pkgr/core@^0.2.4":
version "0.2.4"
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.4.tgz#d897170a2b0ba51f78a099edccd968f7b103387c"
integrity sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw==

"@sinclair/typebox@^0.27.8":
version "0.27.8"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
Expand Down Expand Up @@ -1515,14 +1510,6 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

eslint-plugin-prettier@^5.4.1:
version "5.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz#99b55d7dd70047886b2222fdd853665f180b36af"
integrity sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg==
dependencies:
prettier-linter-helpers "^1.0.0"
synckit "^0.11.7"

eslint-plugin-unused-imports@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz#62ddc7446ccbf9aa7b6f1f0b00a980423cda2738"
Expand Down Expand Up @@ -1674,11 +1661,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-diff@^1.1.2:
version "1.3.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0"
integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==

fast-glob@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
Expand Down Expand Up @@ -2841,13 +2823,6 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier-linter-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
dependencies:
fast-diff "^1.1.2"

prettier@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848"
Expand Down Expand Up @@ -3144,13 +3119,6 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

synckit@^0.11.7:
version "0.11.8"
resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.8.tgz#b2aaae998a4ef47ded60773ad06e7cb821f55457"
integrity sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A==
dependencies:
"@pkgr/core" "^0.2.4"

test-exclude@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"
Expand Down
Loading