Skip to content

Commit d1006ba

Browse files
feat: Accept browser session name on all /browsers/{id_or_name} sub-resource routes
Stainless-Generated-From: 6733d316a5573aaf519a68a6ce89bf22cdf0aa72
1 parent cfa5f27 commit d1006ba

24 files changed

Lines changed: 794 additions & 349 deletions

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 145
1+
configured_endpoints: 147

api.md

Lines changed: 62 additions & 44 deletions
Large diffs are not rendered by default.

src/resources/browsers/browsers.ts

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ import {
109109
TelemetryStreamParams,
110110
TelemetryStreamResponse,
111111
} from './telemetry';
112+
import * as WebmcpAPI from './webmcp';
113+
import {
114+
InvocationFailure,
115+
InvocationResult,
116+
InvokeRequest,
117+
Tool,
118+
ToolAnnotations,
119+
ToolFrame,
120+
ToolSource,
121+
ToolsResponse,
122+
Webmcp,
123+
WebmcpInvokeToolParams,
124+
} from './webmcp';
112125
import * as FsAPI from './fs/fs';
113126
import {
114127
FCreateDirectoryParams,
@@ -147,6 +160,7 @@ export class Browsers extends APIResource {
147160
logs: LogsAPI.Logs = new LogsAPI.Logs(this._client);
148161
computer: ComputerAPI.Computer = new ComputerAPI.Computer(this._client);
149162
playwright: PlaywrightAPI.Playwright = new PlaywrightAPI.Playwright(this._client);
163+
webmcp: WebmcpAPI.Webmcp = new WebmcpAPI.Webmcp(this._client);
150164

151165
/**
152166
* Create a new browser session from within an action.
@@ -225,13 +239,14 @@ export class Browsers extends APIResource {
225239
*
226240
* @example
227241
* ```ts
228-
* const response = await client.browsers.curl('id', {
229-
* url: 'url',
230-
* });
242+
* const response = await client.browsers.curl(
243+
* 'htzv5orfit78e1m2biiifpbv',
244+
* { url: 'url' },
245+
* );
231246
* ```
232247
*/
233-
curl(id: string, body: BrowserCurlParams, options?: RequestOptions): APIPromise<BrowserCurlResponse> {
234-
return this._client.post(path`/browsers/${id}/curl`, { body, ...options });
248+
curl(idOrName: string, body: BrowserCurlParams, options?: RequestOptions): APIPromise<BrowserCurlResponse> {
249+
return this._client.post(path`/browsers/${idOrName}/curl`, { body, ...options });
235250
}
236251

237252
/**
@@ -265,19 +280,26 @@ export class Browsers extends APIResource {
265280
*
266281
* @example
267282
* ```ts
268-
* await client.browsers.loadExtensions('id', {
269-
* extensions: [
270-
* {
271-
* name: 'name',
272-
* zip_file: fs.createReadStream('path/to/file'),
273-
* },
274-
* ],
275-
* });
283+
* await client.browsers.loadExtensions(
284+
* 'htzv5orfit78e1m2biiifpbv',
285+
* {
286+
* extensions: [
287+
* {
288+
* name: 'name',
289+
* zip_file: fs.createReadStream('path/to/file'),
290+
* },
291+
* ],
292+
* },
293+
* );
276294
* ```
277295
*/
278-
loadExtensions(id: string, body: BrowserLoadExtensionsParams, options?: RequestOptions): APIPromise<void> {
296+
loadExtensions(
297+
idOrName: string,
298+
body: BrowserLoadExtensionsParams,
299+
options?: RequestOptions,
300+
): APIPromise<void> {
279301
return this._client.post(
280-
path`/browsers/${id}/extensions`,
302+
path`/browsers/${idOrName}/extensions`,
281303
multipartFormRequestOptions(
282304
{ body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]) },
283305
this._client,
@@ -1621,6 +1643,7 @@ Browsers.Process = Process;
16211643
Browsers.Logs = Logs;
16221644
Browsers.Computer = Computer;
16231645
Browsers.Playwright = Playwright;
1646+
Browsers.Webmcp = Webmcp;
16241647

16251648
export declare namespace Browsers {
16261649
export {
@@ -1775,4 +1798,17 @@ export declare namespace Browsers {
17751798
type PlaywrightExecuteResponse as PlaywrightExecuteResponse,
17761799
type PlaywrightExecuteParams as PlaywrightExecuteParams,
17771800
};
1801+
1802+
export {
1803+
Webmcp as Webmcp,
1804+
type InvocationFailure as InvocationFailure,
1805+
type InvocationResult as InvocationResult,
1806+
type InvokeRequest as InvokeRequest,
1807+
type Tool as Tool,
1808+
type ToolAnnotations as ToolAnnotations,
1809+
type ToolFrame as ToolFrame,
1810+
type ToolSource as ToolSource,
1811+
type ToolsResponse as ToolsResponse,
1812+
type WebmcpInvokeToolParams as WebmcpInvokeToolParams,
1813+
};
17781814
}

src/resources/browsers/computer.ts

Lines changed: 78 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ export class Computer extends APIResource {
1717
*
1818
* @example
1919
* ```ts
20-
* await client.browsers.computer.batch('id', {
21-
* actions: [{ type: 'click_mouse' }],
22-
* });
20+
* await client.browsers.computer.batch(
21+
* 'htzv5orfit78e1m2biiifpbv',
22+
* { actions: [{ type: 'click_mouse' }] },
23+
* );
2324
* ```
2425
*/
25-
batch(id: string, body: ComputerBatchParams, options?: RequestOptions): APIPromise<void> {
26-
return this._client.post(path`/browsers/${id}/computer/batch`, {
26+
batch(idOrName: string, body: ComputerBatchParams, options?: RequestOptions): APIPromise<void> {
27+
return this._client.post(path`/browsers/${idOrName}/computer/batch`, {
2728
body,
2829
...options,
2930
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -36,18 +37,20 @@ export class Computer extends APIResource {
3637
* @example
3738
* ```ts
3839
* const response =
39-
* await client.browsers.computer.captureScreenshot('id');
40+
* await client.browsers.computer.captureScreenshot(
41+
* 'htzv5orfit78e1m2biiifpbv',
42+
* );
4043
*
4144
* const content = await response.blob();
4245
* console.log(content);
4346
* ```
4447
*/
4548
captureScreenshot(
46-
id: string,
49+
idOrName: string,
4750
body: ComputerCaptureScreenshotParams | null | undefined = {},
4851
options?: RequestOptions,
4952
): APIPromise<Response> {
50-
return this._client.post(path`/browsers/${id}/computer/screenshot`, {
53+
return this._client.post(path`/browsers/${idOrName}/computer/screenshot`, {
5154
body,
5255
...options,
5356
headers: buildHeaders([{ Accept: 'image/png' }, options?.headers]),
@@ -60,14 +63,14 @@ export class Computer extends APIResource {
6063
*
6164
* @example
6265
* ```ts
63-
* await client.browsers.computer.clickMouse('id', {
64-
* x: 0,
65-
* y: 0,
66-
* });
66+
* await client.browsers.computer.clickMouse(
67+
* 'htzv5orfit78e1m2biiifpbv',
68+
* { x: 0, y: 0 },
69+
* );
6770
* ```
6871
*/
69-
clickMouse(id: string, body: ComputerClickMouseParams, options?: RequestOptions): APIPromise<void> {
70-
return this._client.post(path`/browsers/${id}/computer/click_mouse`, {
72+
clickMouse(idOrName: string, body: ComputerClickMouseParams, options?: RequestOptions): APIPromise<void> {
73+
return this._client.post(path`/browsers/${idOrName}/computer/click_mouse`, {
7174
body,
7275
...options,
7376
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -79,16 +82,19 @@ export class Computer extends APIResource {
7982
*
8083
* @example
8184
* ```ts
82-
* await client.browsers.computer.dragMouse('id', {
83-
* path: [
84-
* [0, 0],
85-
* [0, 0],
86-
* ],
87-
* });
85+
* await client.browsers.computer.dragMouse(
86+
* 'htzv5orfit78e1m2biiifpbv',
87+
* {
88+
* path: [
89+
* [0, 0],
90+
* [0, 0],
91+
* ],
92+
* },
93+
* );
8894
* ```
8995
*/
90-
dragMouse(id: string, body: ComputerDragMouseParams, options?: RequestOptions): APIPromise<void> {
91-
return this._client.post(path`/browsers/${id}/computer/drag_mouse`, {
96+
dragMouse(idOrName: string, body: ComputerDragMouseParams, options?: RequestOptions): APIPromise<void> {
97+
return this._client.post(path`/browsers/${idOrName}/computer/drag_mouse`, {
9298
body,
9399
...options,
94100
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -101,26 +107,28 @@ export class Computer extends APIResource {
101107
* @example
102108
* ```ts
103109
* const response =
104-
* await client.browsers.computer.getMousePosition('id');
110+
* await client.browsers.computer.getMousePosition(
111+
* 'htzv5orfit78e1m2biiifpbv',
112+
* );
105113
* ```
106114
*/
107-
getMousePosition(id: string, options?: RequestOptions): APIPromise<ComputerGetMousePositionResponse> {
108-
return this._client.post(path`/browsers/${id}/computer/get_mouse_position`, options);
115+
getMousePosition(idOrName: string, options?: RequestOptions): APIPromise<ComputerGetMousePositionResponse> {
116+
return this._client.post(path`/browsers/${idOrName}/computer/get_mouse_position`, options);
109117
}
110118

111119
/**
112120
* Move the mouse cursor to the specified coordinates on the browser instance
113121
*
114122
* @example
115123
* ```ts
116-
* await client.browsers.computer.moveMouse('id', {
117-
* x: 0,
118-
* y: 0,
119-
* });
124+
* await client.browsers.computer.moveMouse(
125+
* 'htzv5orfit78e1m2biiifpbv',
126+
* { x: 0, y: 0 },
127+
* );
120128
* ```
121129
*/
122-
moveMouse(id: string, body: ComputerMoveMouseParams, options?: RequestOptions): APIPromise<void> {
123-
return this._client.post(path`/browsers/${id}/computer/move_mouse`, {
130+
moveMouse(idOrName: string, body: ComputerMoveMouseParams, options?: RequestOptions): APIPromise<void> {
131+
return this._client.post(path`/browsers/${idOrName}/computer/move_mouse`, {
124132
body,
125133
...options,
126134
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -132,13 +140,14 @@ export class Computer extends APIResource {
132140
*
133141
* @example
134142
* ```ts
135-
* await client.browsers.computer.pressKey('id', {
136-
* keys: ['string'],
137-
* });
143+
* await client.browsers.computer.pressKey(
144+
* 'htzv5orfit78e1m2biiifpbv',
145+
* { keys: ['string'] },
146+
* );
138147
* ```
139148
*/
140-
pressKey(id: string, body: ComputerPressKeyParams, options?: RequestOptions): APIPromise<void> {
141-
return this._client.post(path`/browsers/${id}/computer/press_key`, {
149+
pressKey(idOrName: string, body: ComputerPressKeyParams, options?: RequestOptions): APIPromise<void> {
150+
return this._client.post(path`/browsers/${idOrName}/computer/press_key`, {
142151
body,
143152
...options,
144153
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -151,23 +160,28 @@ export class Computer extends APIResource {
151160
* @example
152161
* ```ts
153162
* const response =
154-
* await client.browsers.computer.readClipboard('id');
163+
* await client.browsers.computer.readClipboard(
164+
* 'htzv5orfit78e1m2biiifpbv',
165+
* );
155166
* ```
156167
*/
157-
readClipboard(id: string, options?: RequestOptions): APIPromise<ComputerReadClipboardResponse> {
158-
return this._client.post(path`/browsers/${id}/computer/clipboard/read`, options);
168+
readClipboard(idOrName: string, options?: RequestOptions): APIPromise<ComputerReadClipboardResponse> {
169+
return this._client.post(path`/browsers/${idOrName}/computer/clipboard/read`, options);
159170
}
160171

161172
/**
162173
* Scroll the mouse wheel at a position on the host computer
163174
*
164175
* @example
165176
* ```ts
166-
* await client.browsers.computer.scroll('id', { x: 0, y: 0 });
177+
* await client.browsers.computer.scroll(
178+
* 'htzv5orfit78e1m2biiifpbv',
179+
* { x: 0, y: 0 },
180+
* );
167181
* ```
168182
*/
169-
scroll(id: string, body: ComputerScrollParams, options?: RequestOptions): APIPromise<void> {
170-
return this._client.post(path`/browsers/${id}/computer/scroll`, {
183+
scroll(idOrName: string, body: ComputerScrollParams, options?: RequestOptions): APIPromise<void> {
184+
return this._client.post(path`/browsers/${idOrName}/computer/scroll`, {
171185
body,
172186
...options,
173187
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -180,31 +194,33 @@ export class Computer extends APIResource {
180194
* @example
181195
* ```ts
182196
* const response =
183-
* await client.browsers.computer.setCursorVisibility('id', {
184-
* hidden: true,
185-
* });
197+
* await client.browsers.computer.setCursorVisibility(
198+
* 'htzv5orfit78e1m2biiifpbv',
199+
* { hidden: true },
200+
* );
186201
* ```
187202
*/
188203
setCursorVisibility(
189-
id: string,
204+
idOrName: string,
190205
body: ComputerSetCursorVisibilityParams,
191206
options?: RequestOptions,
192207
): APIPromise<ComputerSetCursorVisibilityResponse> {
193-
return this._client.post(path`/browsers/${id}/computer/cursor`, { body, ...options });
208+
return this._client.post(path`/browsers/${idOrName}/computer/cursor`, { body, ...options });
194209
}
195210

196211
/**
197212
* Type text on the browser instance
198213
*
199214
* @example
200215
* ```ts
201-
* await client.browsers.computer.typeText('id', {
202-
* text: 'text',
203-
* });
216+
* await client.browsers.computer.typeText(
217+
* 'htzv5orfit78e1m2biiifpbv',
218+
* { text: 'text' },
219+
* );
204220
* ```
205221
*/
206-
typeText(id: string, body: ComputerTypeTextParams, options?: RequestOptions): APIPromise<void> {
207-
return this._client.post(path`/browsers/${id}/computer/type`, {
222+
typeText(idOrName: string, body: ComputerTypeTextParams, options?: RequestOptions): APIPromise<void> {
223+
return this._client.post(path`/browsers/${idOrName}/computer/type`, {
208224
body,
209225
...options,
210226
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
@@ -216,13 +232,18 @@ export class Computer extends APIResource {
216232
*
217233
* @example
218234
* ```ts
219-
* await client.browsers.computer.writeClipboard('id', {
220-
* text: 'text',
221-
* });
235+
* await client.browsers.computer.writeClipboard(
236+
* 'htzv5orfit78e1m2biiifpbv',
237+
* { text: 'text' },
238+
* );
222239
* ```
223240
*/
224-
writeClipboard(id: string, body: ComputerWriteClipboardParams, options?: RequestOptions): APIPromise<void> {
225-
return this._client.post(path`/browsers/${id}/computer/clipboard/write`, {
241+
writeClipboard(
242+
idOrName: string,
243+
body: ComputerWriteClipboardParams,
244+
options?: RequestOptions,
245+
): APIPromise<void> {
246+
return this._client.post(path`/browsers/${idOrName}/computer/clipboard/write`, {
226247
body,
227248
...options,
228249
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),

0 commit comments

Comments
 (0)