feat: [US-020] - Add TypeScript SDK browser lifecycle and CDP methods

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nathan Flurry 2026-03-17 06:19:12 -07:00
parent 45cc8a8383
commit 8ade8bba9d

View file

@ -30,6 +30,8 @@ import {
type AgentInstallRequest, type AgentInstallRequest,
type AgentInstallResponse, type AgentInstallResponse,
type AgentListResponse, type AgentListResponse,
type BrowserStartRequest,
type BrowserStatusResponse,
type DesktopActionResponse, type DesktopActionResponse,
type DesktopClipboardQuery, type DesktopClipboardQuery,
type DesktopClipboardResponse, type DesktopClipboardResponse,
@ -2008,6 +2010,28 @@ export class SandboxAgent {
return new DesktopStreamSession(this.connectDesktopStreamWebSocket(options)); return new DesktopStreamSession(this.connectDesktopStreamWebSocket(options));
} }
async startBrowser(request: BrowserStartRequest = {}): Promise<BrowserStatusResponse> {
return this.requestJson("POST", `${API_PREFIX}/browser/start`, {
body: request,
});
}
async stopBrowser(): Promise<BrowserStatusResponse> {
return this.requestJson("POST", `${API_PREFIX}/browser/stop`);
}
async getBrowserStatus(): Promise<BrowserStatusResponse> {
return this.requestJson("GET", `${API_PREFIX}/browser/status`);
}
getBrowserCdpUrl(options: ProcessTerminalWebSocketUrlOptions = {}): string {
return toWebSocketUrl(
this.buildUrl(`${API_PREFIX}/browser/cdp`, {
access_token: options.accessToken ?? this.token,
}),
);
}
private async getLiveConnection(agent: string): Promise<LiveAcpConnection> { private async getLiveConnection(agent: string): Promise<LiveAcpConnection> {
await this.awaitHealthy(); await this.awaitHealthy();