agentkernel 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ Node.js SDK for [agentkernel](https://github.com/thrashr888/agentkernel) — run
8
8
  npm install agentkernel
9
9
  ```
10
10
 
11
- Requires Node.js 20+. Zero HTTP dependencies (uses native `fetch`).
11
+ Requires Node.js 22.13+. Zero HTTP dependencies (uses native `fetch`).
12
12
 
13
13
  ## Quick Start
14
14
 
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Browser session for orchestrating headless browsers in sandboxes.
3
+ *
4
+ * Each method generates a self-contained Python/Playwright script,
5
+ * runs it inside the sandbox, and parses the JSON result.
6
+ */
7
+ import type { AriaSnapshot, PageResult, RunOutput } from "./types.cjs";
8
+ type RunInSandboxFn = (name: string, command: string[]) => Promise<RunOutput>;
9
+ type RemoveSandboxFn = (name: string) => Promise<void>;
10
+ /** Command to install Playwright + Chromium inside the sandbox. */
11
+ export declare const BROWSER_SETUP_CMD: string[];
12
+ /**
13
+ * A sandboxed headless browser controlled from outside.
14
+ *
15
+ * The browser (Chromium via Playwright) runs inside an agentkernel sandbox.
16
+ * You call high-level methods; the SDK generates and runs scripts internally.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * await using browser = await client.browser("my-browser");
21
+ * const page = await browser.goto("https://example.com");
22
+ * console.log(page.title, page.links);
23
+ * ```
24
+ */
25
+ export declare class BrowserSession implements AsyncDisposable {
26
+ readonly name: string;
27
+ private _removed;
28
+ private _lastUrl;
29
+ private readonly _run;
30
+ private readonly _remove;
31
+ /** @internal */
32
+ constructor(name: string, runFn: RunInSandboxFn, removeFn: RemoveSandboxFn);
33
+ /** Navigate to a URL and return page data (title, text, links). */
34
+ goto(url: string): Promise<PageResult>;
35
+ /** Take a PNG screenshot. Returns a base64-encoded string. */
36
+ screenshot(url?: string): Promise<string>;
37
+ /** Run a JavaScript expression on a page and return the result. */
38
+ evaluate(expression: string, url?: string): Promise<unknown>;
39
+ /** Navigate to a URL and return an ARIA snapshot. */
40
+ open(url: string, page?: string): Promise<AriaSnapshot>;
41
+ /** Get the current ARIA snapshot without navigating. */
42
+ snapshot(page?: string): Promise<AriaSnapshot>;
43
+ /** Click an element by ref ID or CSS selector. Returns new snapshot. */
44
+ click(opts: {
45
+ ref?: string;
46
+ selector?: string;
47
+ page?: string;
48
+ }): Promise<AriaSnapshot>;
49
+ /** Fill an input by ref ID or CSS selector. Returns new snapshot. */
50
+ fill(value: string, opts: {
51
+ ref?: string;
52
+ selector?: string;
53
+ page?: string;
54
+ }): Promise<AriaSnapshot>;
55
+ /** Close a named page. */
56
+ closePage(page?: string): Promise<void>;
57
+ /** List active page names. */
58
+ listPages(): Promise<string[]>;
59
+ private _serverStarted;
60
+ private _ensureServer;
61
+ private _browserRequest;
62
+ /** Remove the sandbox. Idempotent. */
63
+ remove(): Promise<void>;
64
+ /** Auto-cleanup for `await using`. */
65
+ [Symbol.asyncDispose](): Promise<void>;
66
+ }
67
+ export {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Browser session for orchestrating headless browsers in sandboxes.
3
+ *
4
+ * Each method generates a self-contained Python/Playwright script,
5
+ * runs it inside the sandbox, and parses the JSON result.
6
+ */
7
+ import type { AriaSnapshot, PageResult, RunOutput } from "./types.js";
8
+ type RunInSandboxFn = (name: string, command: string[]) => Promise<RunOutput>;
9
+ type RemoveSandboxFn = (name: string) => Promise<void>;
10
+ /** Command to install Playwright + Chromium inside the sandbox. */
11
+ export declare const BROWSER_SETUP_CMD: string[];
12
+ /**
13
+ * A sandboxed headless browser controlled from outside.
14
+ *
15
+ * The browser (Chromium via Playwright) runs inside an agentkernel sandbox.
16
+ * You call high-level methods; the SDK generates and runs scripts internally.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * await using browser = await client.browser("my-browser");
21
+ * const page = await browser.goto("https://example.com");
22
+ * console.log(page.title, page.links);
23
+ * ```
24
+ */
25
+ export declare class BrowserSession implements AsyncDisposable {
26
+ readonly name: string;
27
+ private _removed;
28
+ private _lastUrl;
29
+ private readonly _run;
30
+ private readonly _remove;
31
+ /** @internal */
32
+ constructor(name: string, runFn: RunInSandboxFn, removeFn: RemoveSandboxFn);
33
+ /** Navigate to a URL and return page data (title, text, links). */
34
+ goto(url: string): Promise<PageResult>;
35
+ /** Take a PNG screenshot. Returns a base64-encoded string. */
36
+ screenshot(url?: string): Promise<string>;
37
+ /** Run a JavaScript expression on a page and return the result. */
38
+ evaluate(expression: string, url?: string): Promise<unknown>;
39
+ /** Navigate to a URL and return an ARIA snapshot. */
40
+ open(url: string, page?: string): Promise<AriaSnapshot>;
41
+ /** Get the current ARIA snapshot without navigating. */
42
+ snapshot(page?: string): Promise<AriaSnapshot>;
43
+ /** Click an element by ref ID or CSS selector. Returns new snapshot. */
44
+ click(opts: {
45
+ ref?: string;
46
+ selector?: string;
47
+ page?: string;
48
+ }): Promise<AriaSnapshot>;
49
+ /** Fill an input by ref ID or CSS selector. Returns new snapshot. */
50
+ fill(value: string, opts: {
51
+ ref?: string;
52
+ selector?: string;
53
+ page?: string;
54
+ }): Promise<AriaSnapshot>;
55
+ /** Close a named page. */
56
+ closePage(page?: string): Promise<void>;
57
+ /** List active page names. */
58
+ listPages(): Promise<string[]>;
59
+ private _serverStarted;
60
+ private _ensureServer;
61
+ private _browserRequest;
62
+ /** Remove the sandbox. Idempotent. */
63
+ remove(): Promise<void>;
64
+ /** Auto-cleanup for `await using`. */
65
+ [Symbol.asyncDispose](): Promise<void>;
66
+ }
67
+ export {};
@@ -0,0 +1,169 @@
1
+ import { BrowserSession } from "./browser.cjs";
2
+ import { SandboxSession } from "./sandbox.cjs";
3
+ import type { AgentKernelOptions, BatchCommand, BatchFileWriteResponse, BatchRunResponse, CreateStoreRequest, CreateObjectRequest, CreateOrchestrationRequest, CreateScheduleRequest, CreateSandboxOptions, DetachedCommand, DetachedLogsResponse, ExecOptions, ExtendTtlOptions, ExtendTtlResponse, DurableObject, DurableStore, DurableStoreCommandResponse, DurableStoreExecuteResponse, DurableStoreQueryResponse, FileReadResponse, FileWriteOptions, OrchestrationDefinition, RunOptions, RunOutput, Orchestration, SandboxInfo, Schedule, SnapshotMeta, StreamEvent, TakeSnapshotOptions } from "./types.cjs";
4
+ /**
5
+ * Client for the agentkernel HTTP API.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const client = new AgentKernel();
10
+ * const result = await client.run(["echo", "hello"]);
11
+ * console.log(result.output); // "hello\n"
12
+ * ```
13
+ */
14
+ export declare class AgentKernel {
15
+ private readonly baseUrl;
16
+ private readonly apiKey;
17
+ private readonly timeout;
18
+ constructor(opts?: AgentKernelOptions);
19
+ /** Health check. Returns "ok" if the server is running. */
20
+ health(): Promise<string>;
21
+ /** Run a command in a temporary sandbox. */
22
+ run(command: string[], opts?: RunOptions): Promise<RunOutput>;
23
+ /**
24
+ * Run a command with SSE streaming output.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * for await (const event of client.runStream(["python3", "script.py"])) {
29
+ * if (event.type === "output") process.stdout.write(String(event.data.data));
30
+ * }
31
+ * ```
32
+ */
33
+ runStream(command: string[], opts?: RunOptions): AsyncGenerator<StreamEvent>;
34
+ /** List all sandboxes. */
35
+ listSandboxes(): Promise<SandboxInfo[]>;
36
+ /** Create a new sandbox. */
37
+ createSandbox(name: string, opts?: CreateSandboxOptions): Promise<SandboxInfo>;
38
+ /** Get info about a sandbox. */
39
+ getSandbox(name: string): Promise<SandboxInfo>;
40
+ /** Get info about a sandbox by UUID. */
41
+ getSandboxByUuid(uuid: string): Promise<SandboxInfo>;
42
+ /** Remove a sandbox. */
43
+ removeSandbox(name: string): Promise<void>;
44
+ /** Run a command in an existing sandbox. */
45
+ execInSandbox(name: string, command: string[], opts?: ExecOptions): Promise<RunOutput>;
46
+ /** Read a file from a sandbox. */
47
+ readFile(name: string, path: string): Promise<FileReadResponse>;
48
+ /** Write a file to a sandbox. */
49
+ writeFile(name: string, path: string, content: string, opts?: FileWriteOptions): Promise<string>;
50
+ /** Delete a file from a sandbox. */
51
+ deleteFile(name: string, path: string): Promise<string>;
52
+ /** Get audit log entries for a sandbox. */
53
+ getSandboxLogs(name: string): Promise<Record<string, unknown>[]>;
54
+ /** Write multiple files to a sandbox in one request. */
55
+ writeFiles(name: string, files: Record<string, string>): Promise<BatchFileWriteResponse>;
56
+ /** Run multiple commands in parallel. */
57
+ batchRun(commands: BatchCommand[]): Promise<BatchRunResponse>;
58
+ /** Start a detached (background) command in a sandbox. */
59
+ execDetached(name: string, command: string[], opts?: ExecOptions): Promise<DetachedCommand>;
60
+ /** Get the status of a detached command. */
61
+ detachedStatus(name: string, cmdId: string): Promise<DetachedCommand>;
62
+ /** Get logs from a detached command. */
63
+ detachedLogs(name: string, cmdId: string, stream?: "stdout" | "stderr"): Promise<DetachedLogsResponse>;
64
+ /** Kill a detached command. */
65
+ detachedKill(name: string, cmdId: string): Promise<string>;
66
+ /** List detached commands in a sandbox. */
67
+ detachedList(name: string): Promise<DetachedCommand[]>;
68
+ /** List all orchestrations. */
69
+ listOrchestrations(): Promise<Orchestration[]>;
70
+ /** Create a new orchestration. */
71
+ createOrchestration(payload: CreateOrchestrationRequest): Promise<Orchestration>;
72
+ /** Get info about an orchestration by identifier. */
73
+ getOrchestration(id: string): Promise<Orchestration>;
74
+ /** Raise an external event for an orchestration. */
75
+ signalOrchestration(id: string, payload: Record<string, unknown>): Promise<Orchestration>;
76
+ /** Terminate an orchestration. */
77
+ terminateOrchestration(id: string, payload?: Record<string, unknown>): Promise<Orchestration>;
78
+ /** List orchestration definitions. */
79
+ listOrchestrationDefinitions(): Promise<OrchestrationDefinition[]>;
80
+ /** Register or update an orchestration definition. */
81
+ upsertOrchestrationDefinition(payload: OrchestrationDefinition): Promise<OrchestrationDefinition>;
82
+ /** Get an orchestration definition by name. */
83
+ getOrchestrationDefinition(name: string): Promise<OrchestrationDefinition>;
84
+ /** Delete an orchestration definition by name. */
85
+ deleteOrchestrationDefinition(name: string): Promise<string>;
86
+ /** List all objects. */
87
+ listObjects(): Promise<DurableObject[]>;
88
+ /** Create a new object. */
89
+ createObject(payload: CreateObjectRequest): Promise<DurableObject>;
90
+ /** Get an object by identifier. */
91
+ getObject(id: string): Promise<DurableObject>;
92
+ /** Call a method on a durable object (auto-creates/wakes if needed). */
93
+ callObject(className: string, objectId: string, method: string, args?: Record<string, unknown>): Promise<unknown>;
94
+ /** Delete a durable object by identifier. */
95
+ deleteObject(id: string): Promise<string>;
96
+ /** Partially update a durable object (storage and/or status). */
97
+ patchObject(id: string, payload: {
98
+ storage?: unknown;
99
+ status?: string;
100
+ }): Promise<DurableObject>;
101
+ /** List all schedules. */
102
+ listSchedules(): Promise<Schedule[]>;
103
+ /** Create a new schedule. */
104
+ createSchedule(payload: CreateScheduleRequest): Promise<Schedule>;
105
+ /** Get a schedule by identifier. */
106
+ getSchedule(id: string): Promise<Schedule>;
107
+ /** Delete a schedule by identifier. */
108
+ deleteSchedule(id: string): Promise<string>;
109
+ /** List all durable stores. */
110
+ listStores(): Promise<DurableStore[]>;
111
+ /** Create a durable store. */
112
+ createStore(payload: CreateStoreRequest): Promise<DurableStore>;
113
+ /** Get a durable store by identifier. */
114
+ getStore(id: string): Promise<DurableStore>;
115
+ /** Delete a durable store by identifier. */
116
+ deleteStore(id: string): Promise<string>;
117
+ /** Execute a read query against a durable store. */
118
+ queryStore(id: string, payload: Record<string, unknown>): Promise<DurableStoreQueryResponse>;
119
+ /** Execute a write statement against a durable store. */
120
+ executeStore(id: string, payload: Record<string, unknown>): Promise<DurableStoreExecuteResponse>;
121
+ /** Execute a command against a durable store (Redis-style engines). */
122
+ commandStore(id: string, payload: Record<string, unknown>): Promise<DurableStoreCommandResponse>;
123
+ /**
124
+ * Create a sandbox session with automatic cleanup.
125
+ *
126
+ * The returned SandboxSession implements AsyncDisposable,
127
+ * so it works with `await using` (TS 5.2+):
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * await using sb = await client.sandbox("test", { image: "python:3.12-alpine" });
132
+ * await sb.run(["pip", "install", "numpy"]);
133
+ * // sandbox auto-removed when scope exits
134
+ * ```
135
+ */
136
+ sandbox(name: string, opts?: CreateSandboxOptions): Promise<SandboxSession>;
137
+ /**
138
+ * Create a sandboxed browser session with automatic cleanup.
139
+ *
140
+ * Creates a sandbox with Chromium pre-installed via Playwright.
141
+ * Use `goto()`, `screenshot()`, and `evaluate()` to interact with web pages.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * await using browser = await client.browser("my-browser");
146
+ * const page = await browser.goto("https://example.com");
147
+ * console.log(page.title, page.links);
148
+ * // sandbox auto-removed when scope exits
149
+ * ```
150
+ */
151
+ browser(name: string, opts?: {
152
+ memory_mb?: number;
153
+ }): Promise<BrowserSession>;
154
+ /** Extend a sandbox's TTL. Returns the new expiry time. */
155
+ extendTtl(name: string, opts: ExtendTtlOptions): Promise<ExtendTtlResponse>;
156
+ /** List all snapshots. */
157
+ listSnapshots(): Promise<SnapshotMeta[]>;
158
+ /** Take a snapshot of a sandbox. */
159
+ takeSnapshot(opts: TakeSnapshotOptions): Promise<SnapshotMeta>;
160
+ /** Get info about a snapshot. */
161
+ getSnapshot(name: string): Promise<SnapshotMeta>;
162
+ /** Delete a snapshot. */
163
+ deleteSnapshot(name: string): Promise<void>;
164
+ /** Restore a sandbox from a snapshot. */
165
+ restoreSnapshot(name: string): Promise<SandboxInfo>;
166
+ private headers;
167
+ private fetch;
168
+ private request;
169
+ }
@@ -0,0 +1,169 @@
1
+ import { BrowserSession } from "./browser.js";
2
+ import { SandboxSession } from "./sandbox.js";
3
+ import type { AgentKernelOptions, BatchCommand, BatchFileWriteResponse, BatchRunResponse, CreateStoreRequest, CreateObjectRequest, CreateOrchestrationRequest, CreateScheduleRequest, CreateSandboxOptions, DetachedCommand, DetachedLogsResponse, ExecOptions, ExtendTtlOptions, ExtendTtlResponse, DurableObject, DurableStore, DurableStoreCommandResponse, DurableStoreExecuteResponse, DurableStoreQueryResponse, FileReadResponse, FileWriteOptions, OrchestrationDefinition, RunOptions, RunOutput, Orchestration, SandboxInfo, Schedule, SnapshotMeta, StreamEvent, TakeSnapshotOptions } from "./types.js";
4
+ /**
5
+ * Client for the agentkernel HTTP API.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const client = new AgentKernel();
10
+ * const result = await client.run(["echo", "hello"]);
11
+ * console.log(result.output); // "hello\n"
12
+ * ```
13
+ */
14
+ export declare class AgentKernel {
15
+ private readonly baseUrl;
16
+ private readonly apiKey;
17
+ private readonly timeout;
18
+ constructor(opts?: AgentKernelOptions);
19
+ /** Health check. Returns "ok" if the server is running. */
20
+ health(): Promise<string>;
21
+ /** Run a command in a temporary sandbox. */
22
+ run(command: string[], opts?: RunOptions): Promise<RunOutput>;
23
+ /**
24
+ * Run a command with SSE streaming output.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * for await (const event of client.runStream(["python3", "script.py"])) {
29
+ * if (event.type === "output") process.stdout.write(String(event.data.data));
30
+ * }
31
+ * ```
32
+ */
33
+ runStream(command: string[], opts?: RunOptions): AsyncGenerator<StreamEvent>;
34
+ /** List all sandboxes. */
35
+ listSandboxes(): Promise<SandboxInfo[]>;
36
+ /** Create a new sandbox. */
37
+ createSandbox(name: string, opts?: CreateSandboxOptions): Promise<SandboxInfo>;
38
+ /** Get info about a sandbox. */
39
+ getSandbox(name: string): Promise<SandboxInfo>;
40
+ /** Get info about a sandbox by UUID. */
41
+ getSandboxByUuid(uuid: string): Promise<SandboxInfo>;
42
+ /** Remove a sandbox. */
43
+ removeSandbox(name: string): Promise<void>;
44
+ /** Run a command in an existing sandbox. */
45
+ execInSandbox(name: string, command: string[], opts?: ExecOptions): Promise<RunOutput>;
46
+ /** Read a file from a sandbox. */
47
+ readFile(name: string, path: string): Promise<FileReadResponse>;
48
+ /** Write a file to a sandbox. */
49
+ writeFile(name: string, path: string, content: string, opts?: FileWriteOptions): Promise<string>;
50
+ /** Delete a file from a sandbox. */
51
+ deleteFile(name: string, path: string): Promise<string>;
52
+ /** Get audit log entries for a sandbox. */
53
+ getSandboxLogs(name: string): Promise<Record<string, unknown>[]>;
54
+ /** Write multiple files to a sandbox in one request. */
55
+ writeFiles(name: string, files: Record<string, string>): Promise<BatchFileWriteResponse>;
56
+ /** Run multiple commands in parallel. */
57
+ batchRun(commands: BatchCommand[]): Promise<BatchRunResponse>;
58
+ /** Start a detached (background) command in a sandbox. */
59
+ execDetached(name: string, command: string[], opts?: ExecOptions): Promise<DetachedCommand>;
60
+ /** Get the status of a detached command. */
61
+ detachedStatus(name: string, cmdId: string): Promise<DetachedCommand>;
62
+ /** Get logs from a detached command. */
63
+ detachedLogs(name: string, cmdId: string, stream?: "stdout" | "stderr"): Promise<DetachedLogsResponse>;
64
+ /** Kill a detached command. */
65
+ detachedKill(name: string, cmdId: string): Promise<string>;
66
+ /** List detached commands in a sandbox. */
67
+ detachedList(name: string): Promise<DetachedCommand[]>;
68
+ /** List all orchestrations. */
69
+ listOrchestrations(): Promise<Orchestration[]>;
70
+ /** Create a new orchestration. */
71
+ createOrchestration(payload: CreateOrchestrationRequest): Promise<Orchestration>;
72
+ /** Get info about an orchestration by identifier. */
73
+ getOrchestration(id: string): Promise<Orchestration>;
74
+ /** Raise an external event for an orchestration. */
75
+ signalOrchestration(id: string, payload: Record<string, unknown>): Promise<Orchestration>;
76
+ /** Terminate an orchestration. */
77
+ terminateOrchestration(id: string, payload?: Record<string, unknown>): Promise<Orchestration>;
78
+ /** List orchestration definitions. */
79
+ listOrchestrationDefinitions(): Promise<OrchestrationDefinition[]>;
80
+ /** Register or update an orchestration definition. */
81
+ upsertOrchestrationDefinition(payload: OrchestrationDefinition): Promise<OrchestrationDefinition>;
82
+ /** Get an orchestration definition by name. */
83
+ getOrchestrationDefinition(name: string): Promise<OrchestrationDefinition>;
84
+ /** Delete an orchestration definition by name. */
85
+ deleteOrchestrationDefinition(name: string): Promise<string>;
86
+ /** List all objects. */
87
+ listObjects(): Promise<DurableObject[]>;
88
+ /** Create a new object. */
89
+ createObject(payload: CreateObjectRequest): Promise<DurableObject>;
90
+ /** Get an object by identifier. */
91
+ getObject(id: string): Promise<DurableObject>;
92
+ /** Call a method on a durable object (auto-creates/wakes if needed). */
93
+ callObject(className: string, objectId: string, method: string, args?: Record<string, unknown>): Promise<unknown>;
94
+ /** Delete a durable object by identifier. */
95
+ deleteObject(id: string): Promise<string>;
96
+ /** Partially update a durable object (storage and/or status). */
97
+ patchObject(id: string, payload: {
98
+ storage?: unknown;
99
+ status?: string;
100
+ }): Promise<DurableObject>;
101
+ /** List all schedules. */
102
+ listSchedules(): Promise<Schedule[]>;
103
+ /** Create a new schedule. */
104
+ createSchedule(payload: CreateScheduleRequest): Promise<Schedule>;
105
+ /** Get a schedule by identifier. */
106
+ getSchedule(id: string): Promise<Schedule>;
107
+ /** Delete a schedule by identifier. */
108
+ deleteSchedule(id: string): Promise<string>;
109
+ /** List all durable stores. */
110
+ listStores(): Promise<DurableStore[]>;
111
+ /** Create a durable store. */
112
+ createStore(payload: CreateStoreRequest): Promise<DurableStore>;
113
+ /** Get a durable store by identifier. */
114
+ getStore(id: string): Promise<DurableStore>;
115
+ /** Delete a durable store by identifier. */
116
+ deleteStore(id: string): Promise<string>;
117
+ /** Execute a read query against a durable store. */
118
+ queryStore(id: string, payload: Record<string, unknown>): Promise<DurableStoreQueryResponse>;
119
+ /** Execute a write statement against a durable store. */
120
+ executeStore(id: string, payload: Record<string, unknown>): Promise<DurableStoreExecuteResponse>;
121
+ /** Execute a command against a durable store (Redis-style engines). */
122
+ commandStore(id: string, payload: Record<string, unknown>): Promise<DurableStoreCommandResponse>;
123
+ /**
124
+ * Create a sandbox session with automatic cleanup.
125
+ *
126
+ * The returned SandboxSession implements AsyncDisposable,
127
+ * so it works with `await using` (TS 5.2+):
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * await using sb = await client.sandbox("test", { image: "python:3.12-alpine" });
132
+ * await sb.run(["pip", "install", "numpy"]);
133
+ * // sandbox auto-removed when scope exits
134
+ * ```
135
+ */
136
+ sandbox(name: string, opts?: CreateSandboxOptions): Promise<SandboxSession>;
137
+ /**
138
+ * Create a sandboxed browser session with automatic cleanup.
139
+ *
140
+ * Creates a sandbox with Chromium pre-installed via Playwright.
141
+ * Use `goto()`, `screenshot()`, and `evaluate()` to interact with web pages.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * await using browser = await client.browser("my-browser");
146
+ * const page = await browser.goto("https://example.com");
147
+ * console.log(page.title, page.links);
148
+ * // sandbox auto-removed when scope exits
149
+ * ```
150
+ */
151
+ browser(name: string, opts?: {
152
+ memory_mb?: number;
153
+ }): Promise<BrowserSession>;
154
+ /** Extend a sandbox's TTL. Returns the new expiry time. */
155
+ extendTtl(name: string, opts: ExtendTtlOptions): Promise<ExtendTtlResponse>;
156
+ /** List all snapshots. */
157
+ listSnapshots(): Promise<SnapshotMeta[]>;
158
+ /** Take a snapshot of a sandbox. */
159
+ takeSnapshot(opts: TakeSnapshotOptions): Promise<SnapshotMeta>;
160
+ /** Get info about a snapshot. */
161
+ getSnapshot(name: string): Promise<SnapshotMeta>;
162
+ /** Delete a snapshot. */
163
+ deleteSnapshot(name: string): Promise<void>;
164
+ /** Restore a sandbox from a snapshot. */
165
+ restoreSnapshot(name: string): Promise<SandboxInfo>;
166
+ private headers;
167
+ private fetch;
168
+ private request;
169
+ }
@@ -0,0 +1,7 @@
1
+ import type { AgentKernelOptions } from "./types.cjs";
2
+ /** Resolve configuration from constructor args, env vars, and defaults. */
3
+ export declare function resolveConfig(opts?: AgentKernelOptions): {
4
+ baseUrl: string;
5
+ apiKey: string | undefined;
6
+ timeout: number;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { AgentKernelOptions } from "./types.js";
2
+ /** Resolve configuration from constructor args, env vars, and defaults. */
3
+ export declare function resolveConfig(opts?: AgentKernelOptions): {
4
+ baseUrl: string;
5
+ apiKey: string | undefined;
6
+ timeout: number;
7
+ };
@@ -0,0 +1,34 @@
1
+ /** Base error for all agentkernel SDK errors. */
2
+ export declare class AgentKernelError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /** 401 Unauthorized. */
6
+ export declare class AuthError extends AgentKernelError {
7
+ readonly status = 401;
8
+ constructor(message?: string);
9
+ }
10
+ /** 404 Not Found. */
11
+ export declare class NotFoundError extends AgentKernelError {
12
+ readonly status = 404;
13
+ constructor(message?: string);
14
+ }
15
+ /** 400 Bad Request. */
16
+ export declare class ValidationError extends AgentKernelError {
17
+ readonly status = 400;
18
+ constructor(message?: string);
19
+ }
20
+ /** 500 Internal Server Error. */
21
+ export declare class ServerError extends AgentKernelError {
22
+ readonly status = 500;
23
+ constructor(message?: string);
24
+ }
25
+ /** Network / connection error. */
26
+ export declare class NetworkError extends AgentKernelError {
27
+ constructor(message?: string);
28
+ }
29
+ /** SSE streaming error. */
30
+ export declare class StreamError extends AgentKernelError {
31
+ constructor(message?: string);
32
+ }
33
+ /** Map an HTTP status code + body to the appropriate error. */
34
+ export declare function errorFromStatus(status: number, body: string): AgentKernelError;
@@ -0,0 +1,34 @@
1
+ /** Base error for all agentkernel SDK errors. */
2
+ export declare class AgentKernelError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /** 401 Unauthorized. */
6
+ export declare class AuthError extends AgentKernelError {
7
+ readonly status = 401;
8
+ constructor(message?: string);
9
+ }
10
+ /** 404 Not Found. */
11
+ export declare class NotFoundError extends AgentKernelError {
12
+ readonly status = 404;
13
+ constructor(message?: string);
14
+ }
15
+ /** 400 Bad Request. */
16
+ export declare class ValidationError extends AgentKernelError {
17
+ readonly status = 400;
18
+ constructor(message?: string);
19
+ }
20
+ /** 500 Internal Server Error. */
21
+ export declare class ServerError extends AgentKernelError {
22
+ readonly status = 500;
23
+ constructor(message?: string);
24
+ }
25
+ /** Network / connection error. */
26
+ export declare class NetworkError extends AgentKernelError {
27
+ constructor(message?: string);
28
+ }
29
+ /** SSE streaming error. */
30
+ export declare class StreamError extends AgentKernelError {
31
+ constructor(message?: string);
32
+ }
33
+ /** Map an HTTP status code + body to the appropriate error. */
34
+ export declare function errorFromStatus(status: number, body: string): AgentKernelError;