Skip to content

Commit 94837cb

Browse files
authored
Merge branch 'main' into fix/update-org-name-in-workflows
2 parents 8197587 + 3edd9cf commit 94837cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8797
-855
lines changed

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ jobs:
1919
bash ./bin/check-release-environment
2020
env:
2121
NPM_TOKEN: ${{ secrets.KERNEL_NPM_TOKEN || secrets.NPM_TOKEN }}
22+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dist
77
dist-deno
88
/*.tgz
99
.idea/
10+
.eslintcache

.release-please-manifest.json

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

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 17
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3ec96d0022acb32aa2676c2e7ae20152b899a776ccd499380c334c955b9ba071.yml
3-
openapi_spec_hash: b64c095d82185c1cd0355abea88b606f
4-
config_hash: 00ec9df250b9dc077f8d3b93a442d252
1+
configured_endpoints: 89
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-8d66dbedea5b240936b338809f272568ca84a452fc13dbda835479f2ec068b41.yml
3+
openapi_spec_hash: 7c499bfce2e996f1fff5e7791cea390e
4+
config_hash: fcc2db3ed48ab4e8d1b588d31d394a23

CHANGELOG.md

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2025 Kernel
189+
Copyright 2026 Kernel
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ const client = new Kernel({
2727
environment: 'development', // defaults to 'production'
2828
});
2929

30-
const deployment = await client.apps.deployments.create({
31-
entrypoint_rel_path: 'main.ts',
32-
file: fs.createReadStream('path/to/file'),
33-
env_vars: { OPENAI_API_KEY: 'x' },
34-
version: '1.0.0',
35-
});
30+
const browser = await client.browsers.create({ stealth: true });
3631

37-
console.log(deployment.apps);
32+
console.log(browser.session_id);
3833
```
3934

4035
### Request & Response types
@@ -50,10 +45,7 @@ const client = new Kernel({
5045
environment: 'development', // defaults to 'production'
5146
});
5247

53-
const params: Kernel.BrowserCreateParams = {
54-
invocation_id: 'REPLACE_ME',
55-
persistence: { id: 'browser-for-user-1234' },
56-
};
48+
const params: Kernel.BrowserCreateParams = { stealth: true };
5749
const browser: Kernel.BrowserCreateResponse = await client.browsers.create(params);
5850
```
5951

@@ -75,32 +67,17 @@ import Kernel, { toFile } from '@onkernel/sdk';
7567
const client = new Kernel();
7668

7769
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
78-
await client.apps.deployments.create({
79-
entrypoint_rel_path: 'src/app.py',
80-
file: fs.createReadStream('/path/to/file'),
81-
});
70+
await client.deployments.create({ file: fs.createReadStream('/path/to/file') });
8271

8372
// Or if you have the web `File` API you can pass a `File` instance:
84-
await client.apps.deployments.create({
85-
entrypoint_rel_path: 'src/app.py',
86-
file: new File(['my bytes'], 'file'),
87-
});
73+
await client.deployments.create({ file: new File(['my bytes'], 'file') });
8874

8975
// You can also pass a `fetch` `Response`:
90-
await client.apps.deployments.create({
91-
entrypoint_rel_path: 'src/app.py',
92-
file: await fetch('https://somesite/file'),
93-
});
76+
await client.deployments.create({ file: await fetch('https://somesite/file') });
9477

9578
// Finally, if none of the above are convenient, you can use our `toFile` helper:
96-
await client.apps.deployments.create({
97-
entrypoint_rel_path: 'src/app.py',
98-
file: await toFile(Buffer.from('my bytes'), 'file'),
99-
});
100-
await client.apps.deployments.create({
101-
entrypoint_rel_path: 'src/app.py',
102-
file: await toFile(new Uint8Array([0, 1, 2]), 'file'),
103-
});
79+
await client.deployments.create({ file: await toFile(Buffer.from('my bytes'), 'file') });
80+
await client.deployments.create({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
10481
```
10582

10683
## Handling errors
@@ -111,17 +88,15 @@ a subclass of `APIError` will be thrown:
11188

11289
<!-- prettier-ignore -->
11390
```ts
114-
const browser = await client.browsers
115-
.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } })
116-
.catch(async (err) => {
117-
if (err instanceof Kernel.APIError) {
118-
console.log(err.status); // 400
119-
console.log(err.name); // BadRequestError
120-
console.log(err.headers); // {server: 'nginx', ...}
121-
} else {
122-
throw err;
123-
}
124-
});
91+
const browser = await client.browsers.create({ stealth: true }).catch(async (err) => {
92+
if (err instanceof Kernel.APIError) {
93+
console.log(err.status); // 400
94+
console.log(err.name); // BadRequestError
95+
console.log(err.headers); // {server: 'nginx', ...}
96+
} else {
97+
throw err;
98+
}
99+
});
125100
```
126101

127102
Error codes are as follows:
@@ -153,7 +128,7 @@ const client = new Kernel({
153128
});
154129

155130
// Or, configure per-request:
156-
await client.browsers.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } }, {
131+
await client.browsers.create({ stealth: true }, {
157132
maxRetries: 5,
158133
});
159134
```
@@ -170,7 +145,7 @@ const client = new Kernel({
170145
});
171146

172147
// Override per-request:
173-
await client.browsers.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } }, {
148+
await client.browsers.create({ stealth: true }, {
174149
timeout: 5 * 1000,
175150
});
176151
```
@@ -179,6 +154,40 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
179154

180155
Note that requests which time out will be [retried twice by default](#retries).
181156

157+
## Auto-pagination
158+
159+
List methods in the Kernel API are paginated.
160+
You can use the `for await … of` syntax to iterate through items across all pages:
161+
162+
```ts
163+
async function fetchAllDeploymentListResponses(params) {
164+
const allDeploymentListResponses = [];
165+
// Automatically fetches more pages as needed.
166+
for await (const deploymentListResponse of client.deployments.list({
167+
app_name: 'YOUR_APP',
168+
limit: 2,
169+
})) {
170+
allDeploymentListResponses.push(deploymentListResponse);
171+
}
172+
return allDeploymentListResponses;
173+
}
174+
```
175+
176+
Alternatively, you can request a single page at a time:
177+
178+
```ts
179+
let page = await client.deployments.list({ app_name: 'YOUR_APP', limit: 2 });
180+
for (const deploymentListResponse of page.items) {
181+
console.log(deploymentListResponse);
182+
}
183+
184+
// Convenience methods are provided for manually paginating:
185+
while (page.hasNextPage()) {
186+
page = await page.getNextPage();
187+
// ...
188+
}
189+
```
190+
182191
## Advanced Usage
183192

184193
### Accessing raw Response data (e.g., headers)
@@ -193,14 +202,12 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
193202
```ts
194203
const client = new Kernel();
195204

196-
const response = await client.browsers
197-
.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } })
198-
.asResponse();
205+
const response = await client.browsers.create({ stealth: true }).asResponse();
199206
console.log(response.headers.get('X-My-Header'));
200207
console.log(response.statusText); // access the underlying Response object
201208

202209
const { data: browser, response: raw } = await client.browsers
203-
.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } })
210+
.create({ stealth: true })
204211
.withResponse();
205212
console.log(raw.headers.get('X-My-Header'));
206213
console.log(browser.session_id);
@@ -283,7 +290,7 @@ parameter. This library doesn't validate at runtime that the request matches the
283290
send will be sent as-is.
284291

285292
```ts
286-
client.apps.deployments.create({
293+
client.browsers.create({
287294
// ...
288295
// @ts-expect-error baz is not yet public
289296
baz: 'undocumented option',

0 commit comments

Comments
 (0)