-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomputers.ts
More file actions
208 lines (179 loc) · 6.1 KB
/
computers.ts
File metadata and controls
208 lines (179 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as DevboxesAPI from './devboxes';
export class Computers extends APIResource {
/**
* Create a Computer and begin the boot process. The Computer will initially launch
* in the 'provisioning' state while Runloop allocates the necessary
* infrastructure. It will transition to the 'initializing' state while the booted
* Computer runs any Runloop or user defined set up scripts. Finally, the Computer
* will transition to the 'running' state when it is ready for use.
*/
create(body?: ComputerCreateParams, options?: Core.RequestOptions): Core.APIPromise<ComputerView>;
create(options?: Core.RequestOptions): Core.APIPromise<ComputerView>;
create(
body: ComputerCreateParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<ComputerView> {
if (isRequestOptions(body)) {
return this.create({}, body);
}
return this._client.post('/v1/devboxes/computers', { body, ...options });
}
/**
* Get Computer Details.
*/
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<ComputerView> {
return this._client.get(`/v1/devboxes/computers/${id}`, options);
}
/**
* Perform the specified keyboard interaction on the Computer identified by the
* given ID.
*/
keyboardInteraction(
id: string,
body: ComputerKeyboardInteractionParams,
options?: Core.RequestOptions,
): Core.APIPromise<ComputerKeyboardInteractionResponse> {
return this._client.post(`/v1/devboxes/computers/${id}/keyboard_interaction`, { body, ...options });
}
/**
* Perform the specified mouse interaction on the Computer identified by the given
* ID.
*/
mouseInteraction(
id: string,
body: ComputerMouseInteractionParams,
options?: Core.RequestOptions,
): Core.APIPromise<ComputerMouseInteractionResponse> {
return this._client.post(`/v1/devboxes/computers/${id}/mouse_interaction`, { body, ...options });
}
/**
* Perform the specified screen interaction on the Computer identified by the given
* ID.
*/
screenInteraction(
id: string,
body: ComputerScreenInteractionParams,
options?: Core.RequestOptions,
): Core.APIPromise<ComputerScreenInteractionResponse> {
return this._client.post(`/v1/devboxes/computers/${id}/screen_interaction`, { body, ...options });
}
}
/**
* A Computer represents an implementation of Anthropic Computer usage on top of
* Devboxes. It includes the tunnel to the live screen and the underlying
* DevboxView.
*/
export interface ComputerView {
/**
* The underlying devbox the computer setup is running on.
*/
devbox: DevboxesAPI.DevboxView;
/**
* The http tunnel to connect and view the live screen of the computer. You can
* control the interactivity of the browser by adding or removing 'view_only' query
* parameter. view_only=1 will allow interaction and view_only=0 will disable
* interaction.
*/
live_screen_url: string;
}
export interface ComputerKeyboardInteractionResponse {
error?: string;
latest_screenshot_base64_img?: string;
output?: string;
}
export interface ComputerMouseInteractionResponse {
error?: string;
latest_screenshot_base64_img?: string;
output?: string;
}
export interface ComputerScreenInteractionResponse {
error?: string;
latest_screenshot_base64_img?: string;
output?: string;
}
export interface ComputerCreateParams {
/**
* Customize the dimensions of the computer display.
*/
display_dimensions?: ComputerCreateParams.DisplayDimensions | null;
/**
* The name to use for the created computer.
*/
name?: string | null;
}
export namespace ComputerCreateParams {
/**
* Customize the dimensions of the computer display.
*/
export interface DisplayDimensions {
/**
* The height of the display being controlled by the model in pixels.
*/
display_height_px: number;
/**
* The width of the display being controlled by the model in pixels.
*/
display_width_px: number;
}
}
export interface ComputerKeyboardInteractionParams {
/**
* The keyboard action to perform.
*/
action: 'key' | 'type';
/**
* The text to type or the key (with optional modifier) to press.
*/
text?: string | null;
}
export interface ComputerMouseInteractionParams {
/**
* The mouse action to perform.
*/
action: 'mouse_move' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click';
/**
* The x (pixels from the left) and y (pixels from the top) coordinates for the
* mouse to move or click-drag. Required only by `action=mouse_move` or
* `action=left_click_drag`
*/
coordinate?: ComputerMouseInteractionParams.Coordinate | null;
}
export namespace ComputerMouseInteractionParams {
/**
* The x (pixels from the left) and y (pixels from the top) coordinates for the
* mouse to move or click-drag. Required only by `action=mouse_move` or
* `action=left_click_drag`
*/
export interface Coordinate {
/**
* The x coordinate (pixels from the left) for the mouse to move or click-drag.
*/
x: number;
/**
* The y coordinate (pixels from the top) for the mouse to move or click-drag.
*/
y: number;
}
}
export interface ComputerScreenInteractionParams {
/**
* The screen action to perform.
*/
action: 'screenshot' | 'cursor_position';
}
export declare namespace Computers {
export {
type ComputerView as ComputerView,
type ComputerKeyboardInteractionResponse as ComputerKeyboardInteractionResponse,
type ComputerMouseInteractionResponse as ComputerMouseInteractionResponse,
type ComputerScreenInteractionResponse as ComputerScreenInteractionResponse,
type ComputerCreateParams as ComputerCreateParams,
type ComputerKeyboardInteractionParams as ComputerKeyboardInteractionParams,
type ComputerMouseInteractionParams as ComputerMouseInteractionParams,
type ComputerScreenInteractionParams as ComputerScreenInteractionParams,
};
}