cyberdesk 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Cyberdesk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # cyberdesk
2
+
3
+ [![npm version](https://badge.fury.io/js/cyberdesk.svg)](https://badge.fury.io/js/cyberdesk)
4
+
5
+ The official TypeScript SDK for Cyberdesk.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install cyberdesk
11
+ # or
12
+ yarn add cyberdesk
13
+ # or
14
+ pnpm add cyberdesk
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ First, configure the client, for example, by setting default headers for authentication. You only need to do this once.
20
+
21
+ ```typescript
22
+ import { client, setConfig } from 'cyberdesk/client'; // Import client and setConfig
23
+
24
+ // Configure the client (e.g., with an API Key)
25
+ // Adjust based on your actual authentication method
26
+ setConfig({
27
+ headers: {
28
+ 'Authorization': `Bearer YOUR_API_KEY`
29
+ }
30
+ });
31
+ ```
32
+
33
+ Then, import and call the specific API functions you need:
34
+
35
+ ```typescript
36
+ import {
37
+ postV1Desktop,
38
+ postV1DesktopIdComputerAction,
39
+ type PostV1DesktopData,
40
+ type PostV1DesktopIdComputerActionData
41
+ } from 'cyberdesk';
42
+
43
+ async function createAndInteract() {
44
+ try {
45
+ // 1. Create a new desktop
46
+ console.log('Creating desktop...');
47
+ const createResponse = await postV1Desktop({
48
+ // Pass request body parameters inside the 'data' object
49
+ data: {
50
+ timeoutMs: 10000
51
+ }
52
+ // Headers like Authorization should be set globally via setConfig (see above)
53
+ });
54
+
55
+ if (!createResponse.data) {
56
+ throw new Error('Failed to create desktop: ' + (createResponse.error?.message || 'Unknown error'));
57
+ }
58
+
59
+ const desktopId = createResponse.data.id; // Assuming the response has an ID
60
+ console.log(`Desktop created with ID: ${desktopId}`);
61
+
62
+ // 2. Perform an action (e.g., a mouse click)
63
+ console.log(`Performing action on desktop ${desktopId}...`);
64
+ const actionData: PostV1DesktopIdComputerActionData['data'] = {
65
+ type: 'click_mouse', // Example action type
66
+ x: 100,
67
+ y: 150
68
+ };
69
+
70
+ const actionResponse = await postV1DesktopIdComputerAction({
71
+ path: { id: desktopId }, // Provide path parameters
72
+ data: actionData // Provide request body data
73
+ });
74
+
75
+ if (actionResponse.error) {
76
+ throw new Error(`Action failed: ${actionResponse.error.message}`);
77
+ }
78
+
79
+ console.log('Action successful:', actionResponse.data);
80
+
81
+ } catch (error) {
82
+ console.error('Error using Cyberdesk SDK:', error);
83
+ }
84
+ }
85
+
86
+ createAndInteract();
87
+ ```
88
+
89
+ ## License
90
+
91
+ [MIT](LICENSE)
@@ -20,8 +20,9 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
20
20
  export declare const getV1DesktopId: <ThrowOnError extends boolean = false>(options: Options<GetV1DesktopIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
21
21
  id: string;
22
22
  status: "pending" | "running" | "terminated" | "error";
23
- createdAt: string;
24
- timeoutAt: string;
23
+ stream_url: string;
24
+ created_at: string;
25
+ timeout_at: string;
25
26
  }, GetV1DesktopIdError, ThrowOnError>;
26
27
  /**
27
28
  * Create a new virtual desktop instance
@@ -29,37 +30,30 @@ export declare const getV1DesktopId: <ThrowOnError extends boolean = false>(opti
29
30
  */
30
31
  export declare const postV1Desktop: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
31
32
  id: string;
32
- streamUrl: string;
33
+ status: "pending" | "running" | "terminated" | "error";
33
34
  }, PostV1DesktopError, ThrowOnError>;
34
35
  /**
35
36
  * Stop a running desktop instance
36
37
  * Stops a running desktop instance and cleans up resources
37
38
  */
38
39
  export declare const postV1DesktopIdStop: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopIdStopData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
39
- status: string;
40
- image?: string;
41
- cursorPosition?: {
42
- x?: number;
43
- y?: number;
44
- };
40
+ status: "pending" | "running" | "terminated" | "error";
45
41
  }, PostV1DesktopIdStopError, ThrowOnError>;
46
42
  /**
47
43
  * Perform an action on the desktop
48
44
  * Executes a computer action such as mouse clicks, keyboard input, or screenshots on the desktop
49
45
  */
50
46
  export declare const postV1DesktopIdComputerAction: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopIdComputerActionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
51
- status: string;
52
- image?: string;
53
- cursorPosition?: {
54
- x?: number;
55
- y?: number;
56
- };
47
+ output?: string;
48
+ error?: string;
49
+ base64_image?: string;
57
50
  }, PostV1DesktopIdComputerActionError, ThrowOnError>;
58
51
  /**
59
52
  * Execute a bash command on the desktop
60
53
  * Runs a bash command on the desktop and returns the command output
61
54
  */
62
55
  export declare const postV1DesktopIdBashAction: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopIdBashActionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
63
- status: string;
64
- output: string;
56
+ output?: string;
57
+ error?: string;
58
+ base64_image?: string;
65
59
  }, PostV1DesktopIdBashActionError, ThrowOnError>;
@@ -20,50 +20,81 @@ export type GetV1DesktopIdErrors = {
20
20
  * The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
21
21
  */
22
22
  400: {
23
- message: string;
24
- docs: string;
23
+ status: 'error';
24
+ /**
25
+ * Error message detailing what went wrong
26
+ */
27
+ error: string;
25
28
  };
26
29
  /**
27
30
  * Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
28
31
  */
29
32
  401: {
30
- message: string;
31
- docs: string;
33
+ status: 'error';
34
+ /**
35
+ * Error message detailing what went wrong
36
+ */
37
+ error: string;
32
38
  };
33
39
  /**
34
40
  * The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
35
41
  */
36
42
  403: {
37
- message: string;
38
- docs: string;
43
+ status: 'error';
44
+ /**
45
+ * Error message detailing what went wrong
46
+ */
47
+ error: string;
39
48
  };
40
49
  /**
41
50
  * The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
42
51
  */
43
52
  404: {
44
- message: string;
45
- docs: string;
53
+ status: 'error';
54
+ /**
55
+ * Error message detailing what went wrong
56
+ */
57
+ error: string;
46
58
  };
47
59
  /**
48
60
  * This response is sent when a request conflicts with the current state of the server.
49
61
  */
50
62
  409: {
51
- message: string;
52
- docs: string;
63
+ status: 'error';
64
+ /**
65
+ * Error message detailing what went wrong
66
+ */
67
+ error: string;
53
68
  };
54
69
  /**
55
70
  * The user has sent too many requests in a given amount of time ("rate limiting")
56
71
  */
57
72
  429: {
58
- message: string;
59
- docs: string;
73
+ status: 'error';
74
+ /**
75
+ * Error message detailing what went wrong
76
+ */
77
+ error: string;
60
78
  };
61
79
  /**
62
80
  * The server has encountered a situation it does not know how to handle.
63
81
  */
64
82
  500: {
65
- message: string;
66
- docs: string;
83
+ status: 'error';
84
+ /**
85
+ * Error message detailing what went wrong
86
+ */
87
+ error: string;
88
+ };
89
+ /**
90
+ * The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
91
+ */
92
+ 502: {
93
+ status: 'error';
94
+ /**
95
+ * Error message detailing what went wrong
96
+ */
97
+ error: string;
67
98
  };
68
99
  };
69
100
  export type GetV1DesktopIdError = GetV1DesktopIdErrors[keyof GetV1DesktopIdErrors];
@@ -80,14 +111,18 @@ export type GetV1DesktopIdResponses = {
80
111
  * Current status of the desktop instance
81
112
  */
82
113
  status: 'pending' | 'running' | 'terminated' | 'error';
114
+ /**
115
+ * URL for the desktop stream (null if the desktop is not running)
116
+ */
117
+ stream_url: string;
83
118
  /**
84
119
  * Timestamp when the instance was created
85
120
  */
86
- createdAt: string;
121
+ created_at: string;
87
122
  /**
88
123
  * Timestamp when the instance will automatically time out
89
124
  */
90
- timeoutAt: string;
125
+ timeout_at: string;
91
126
  };
92
127
  };
93
128
  export type GetV1DesktopIdResponse = GetV1DesktopIdResponses[keyof GetV1DesktopIdResponses];
@@ -96,7 +131,7 @@ export type PostV1DesktopData = {
96
131
  /**
97
132
  * Timeout in milliseconds for the desktop session
98
133
  */
99
- timeoutMs?: number;
134
+ timeout_ms?: number;
100
135
  };
101
136
  headers: {
102
137
  /**
@@ -113,56 +148,87 @@ export type PostV1DesktopErrors = {
113
148
  * The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
114
149
  */
115
150
  400: {
116
- message: string;
117
- docs: string;
151
+ status: 'error';
152
+ /**
153
+ * Error message detailing what went wrong
154
+ */
155
+ error: string;
118
156
  };
119
157
  /**
120
158
  * Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
121
159
  */
122
160
  401: {
123
- message: string;
124
- docs: string;
161
+ status: 'error';
162
+ /**
163
+ * Error message detailing what went wrong
164
+ */
165
+ error: string;
125
166
  };
126
167
  /**
127
168
  * The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
128
169
  */
129
170
  403: {
130
- message: string;
131
- docs: string;
171
+ status: 'error';
172
+ /**
173
+ * Error message detailing what went wrong
174
+ */
175
+ error: string;
132
176
  };
133
177
  /**
134
178
  * The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
135
179
  */
136
180
  404: {
137
- message: string;
138
- docs: string;
181
+ status: 'error';
182
+ /**
183
+ * Error message detailing what went wrong
184
+ */
185
+ error: string;
139
186
  };
140
187
  /**
141
188
  * This response is sent when a request conflicts with the current state of the server.
142
189
  */
143
190
  409: {
144
- message: string;
145
- docs: string;
191
+ status: 'error';
192
+ /**
193
+ * Error message detailing what went wrong
194
+ */
195
+ error: string;
146
196
  };
147
197
  /**
148
198
  * The user has sent too many requests in a given amount of time ("rate limiting")
149
199
  */
150
200
  429: {
151
- message: string;
152
- docs: string;
201
+ status: 'error';
202
+ /**
203
+ * Error message detailing what went wrong
204
+ */
205
+ error: string;
153
206
  };
154
207
  /**
155
208
  * The server has encountered a situation it does not know how to handle.
156
209
  */
157
210
  500: {
158
- message: string;
159
- docs: string;
211
+ status: 'error';
212
+ /**
213
+ * Error message detailing what went wrong
214
+ */
215
+ error: string;
216
+ };
217
+ /**
218
+ * The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
219
+ */
220
+ 502: {
221
+ status: 'error';
222
+ /**
223
+ * Error message detailing what went wrong
224
+ */
225
+ error: string;
160
226
  };
161
227
  };
162
228
  export type PostV1DesktopError = PostV1DesktopErrors[keyof PostV1DesktopErrors];
163
229
  export type PostV1DesktopResponses = {
164
230
  /**
165
- * Desktop created successfully
231
+ * Desktop creation initiated successfully
166
232
  */
167
233
  200: {
168
234
  /**
@@ -170,9 +236,9 @@ export type PostV1DesktopResponses = {
170
236
  */
171
237
  id: string;
172
238
  /**
173
- * URL to stream the desktop via VNC
239
+ * Initial status of the desktop instance after creation request
174
240
  */
175
- streamUrl: string;
241
+ status: 'pending' | 'running' | 'terminated' | 'error';
176
242
  };
177
243
  };
178
244
  export type PostV1DesktopResponse = PostV1DesktopResponses[keyof PostV1DesktopResponses];
@@ -198,50 +264,81 @@ export type PostV1DesktopIdStopErrors = {
198
264
  * The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
199
265
  */
200
266
  400: {
201
- message: string;
202
- docs: string;
267
+ status: 'error';
268
+ /**
269
+ * Error message detailing what went wrong
270
+ */
271
+ error: string;
203
272
  };
204
273
  /**
205
274
  * Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
206
275
  */
207
276
  401: {
208
- message: string;
209
- docs: string;
277
+ status: 'error';
278
+ /**
279
+ * Error message detailing what went wrong
280
+ */
281
+ error: string;
210
282
  };
211
283
  /**
212
284
  * The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
213
285
  */
214
286
  403: {
215
- message: string;
216
- docs: string;
287
+ status: 'error';
288
+ /**
289
+ * Error message detailing what went wrong
290
+ */
291
+ error: string;
217
292
  };
218
293
  /**
219
294
  * The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
220
295
  */
221
296
  404: {
222
- message: string;
223
- docs: string;
297
+ status: 'error';
298
+ /**
299
+ * Error message detailing what went wrong
300
+ */
301
+ error: string;
224
302
  };
225
303
  /**
226
304
  * This response is sent when a request conflicts with the current state of the server.
227
305
  */
228
306
  409: {
229
- message: string;
230
- docs: string;
307
+ status: 'error';
308
+ /**
309
+ * Error message detailing what went wrong
310
+ */
311
+ error: string;
231
312
  };
232
313
  /**
233
314
  * The user has sent too many requests in a given amount of time ("rate limiting")
234
315
  */
235
316
  429: {
236
- message: string;
237
- docs: string;
317
+ status: 'error';
318
+ /**
319
+ * Error message detailing what went wrong
320
+ */
321
+ error: string;
238
322
  };
239
323
  /**
240
324
  * The server has encountered a situation it does not know how to handle.
241
325
  */
242
326
  500: {
243
- message: string;
244
- docs: string;
327
+ status: 'error';
328
+ /**
329
+ * Error message detailing what went wrong
330
+ */
331
+ error: string;
332
+ };
333
+ /**
334
+ * The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
335
+ */
336
+ 502: {
337
+ status: 'error';
338
+ /**
339
+ * Error message detailing what went wrong
340
+ */
341
+ error: string;
245
342
  };
246
343
  };
247
344
  export type PostV1DesktopIdStopError = PostV1DesktopIdStopErrors[keyof PostV1DesktopIdStopErrors];
@@ -251,26 +348,9 @@ export type PostV1DesktopIdStopResponses = {
251
348
  */
252
349
  200: {
253
350
  /**
254
- * Status of the operation
351
+ * Status of the desktop instance after stopping
255
352
  */
256
- status: string;
257
- /**
258
- * Base64 encoded image data (only returned for screenshot actions)
259
- */
260
- image?: string;
261
- /**
262
- * Current cursor coordinates (only returned for get_cursor_position action)
263
- */
264
- cursorPosition?: {
265
- /**
266
- * X coordinate on the screen
267
- */
268
- x?: number;
269
- /**
270
- * Y coordinate on the screen
271
- */
272
- y?: number;
273
- };
353
+ status: 'pending' | 'running' | 'terminated' | 'error';
274
354
  };
275
355
  };
276
356
  export type PostV1DesktopIdStopResponse = PostV1DesktopIdStopResponses[keyof PostV1DesktopIdStopResponses];
@@ -416,79 +496,101 @@ export type PostV1DesktopIdComputerActionErrors = {
416
496
  * The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
417
497
  */
418
498
  400: {
419
- message: string;
420
- docs: string;
499
+ status: 'error';
500
+ /**
501
+ * Error message detailing what went wrong
502
+ */
503
+ error: string;
421
504
  };
422
505
  /**
423
506
  * Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
424
507
  */
425
508
  401: {
426
- message: string;
427
- docs: string;
509
+ status: 'error';
510
+ /**
511
+ * Error message detailing what went wrong
512
+ */
513
+ error: string;
428
514
  };
429
515
  /**
430
516
  * The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
431
517
  */
432
518
  403: {
433
- message: string;
434
- docs: string;
519
+ status: 'error';
520
+ /**
521
+ * Error message detailing what went wrong
522
+ */
523
+ error: string;
435
524
  };
436
525
  /**
437
526
  * The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
438
527
  */
439
528
  404: {
440
- message: string;
441
- docs: string;
529
+ status: 'error';
530
+ /**
531
+ * Error message detailing what went wrong
532
+ */
533
+ error: string;
442
534
  };
443
535
  /**
444
536
  * This response is sent when a request conflicts with the current state of the server.
445
537
  */
446
538
  409: {
447
- message: string;
448
- docs: string;
539
+ status: 'error';
540
+ /**
541
+ * Error message detailing what went wrong
542
+ */
543
+ error: string;
449
544
  };
450
545
  /**
451
546
  * The user has sent too many requests in a given amount of time ("rate limiting")
452
547
  */
453
548
  429: {
454
- message: string;
455
- docs: string;
549
+ status: 'error';
550
+ /**
551
+ * Error message detailing what went wrong
552
+ */
553
+ error: string;
456
554
  };
457
555
  /**
458
556
  * The server has encountered a situation it does not know how to handle.
459
557
  */
460
558
  500: {
461
- message: string;
462
- docs: string;
559
+ status: 'error';
560
+ /**
561
+ * Error message detailing what went wrong
562
+ */
563
+ error: string;
564
+ };
565
+ /**
566
+ * The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
567
+ */
568
+ 502: {
569
+ status: 'error';
570
+ /**
571
+ * Error message detailing what went wrong
572
+ */
573
+ error: string;
463
574
  };
464
575
  };
465
576
  export type PostV1DesktopIdComputerActionError = PostV1DesktopIdComputerActionErrors[keyof PostV1DesktopIdComputerActionErrors];
466
577
  export type PostV1DesktopIdComputerActionResponses = {
467
578
  /**
468
- * Action executed successfully
579
+ * Action executed successfully. Response may contain output or image data depending on the action.
469
580
  */
470
581
  200: {
471
582
  /**
472
- * Status of the operation
583
+ * Raw string output from the executed command (if any)
473
584
  */
474
- status: string;
585
+ output?: string;
475
586
  /**
476
- * Base64 encoded image data (only returned for screenshot actions)
587
+ * Error message if the operation failed (also indicated by non-2xx HTTP status)
477
588
  */
478
- image?: string;
589
+ error?: string;
479
590
  /**
480
- * Current cursor coordinates (only returned for get_cursor_position action)
591
+ * Base64 encoded JPEG image data (only returned for screenshot actions)
481
592
  */
482
- cursorPosition?: {
483
- /**
484
- * X coordinate on the screen
485
- */
486
- x?: number;
487
- /**
488
- * Y coordinate on the screen
489
- */
490
- y?: number;
491
- };
593
+ base64_image?: string;
492
594
  };
493
595
  };
494
596
  export type PostV1DesktopIdComputerActionResponse = PostV1DesktopIdComputerActionResponses[keyof PostV1DesktopIdComputerActionResponses];
@@ -519,66 +621,101 @@ export type PostV1DesktopIdBashActionErrors = {
519
621
  * The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
520
622
  */
521
623
  400: {
522
- message: string;
523
- docs: string;
624
+ status: 'error';
625
+ /**
626
+ * Error message detailing what went wrong
627
+ */
628
+ error: string;
524
629
  };
525
630
  /**
526
631
  * Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
527
632
  */
528
633
  401: {
529
- message: string;
530
- docs: string;
634
+ status: 'error';
635
+ /**
636
+ * Error message detailing what went wrong
637
+ */
638
+ error: string;
531
639
  };
532
640
  /**
533
641
  * The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
534
642
  */
535
643
  403: {
536
- message: string;
537
- docs: string;
644
+ status: 'error';
645
+ /**
646
+ * Error message detailing what went wrong
647
+ */
648
+ error: string;
538
649
  };
539
650
  /**
540
651
  * The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
541
652
  */
542
653
  404: {
543
- message: string;
544
- docs: string;
654
+ status: 'error';
655
+ /**
656
+ * Error message detailing what went wrong
657
+ */
658
+ error: string;
545
659
  };
546
660
  /**
547
661
  * This response is sent when a request conflicts with the current state of the server.
548
662
  */
549
663
  409: {
550
- message: string;
551
- docs: string;
664
+ status: 'error';
665
+ /**
666
+ * Error message detailing what went wrong
667
+ */
668
+ error: string;
552
669
  };
553
670
  /**
554
671
  * The user has sent too many requests in a given amount of time ("rate limiting")
555
672
  */
556
673
  429: {
557
- message: string;
558
- docs: string;
674
+ status: 'error';
675
+ /**
676
+ * Error message detailing what went wrong
677
+ */
678
+ error: string;
559
679
  };
560
680
  /**
561
681
  * The server has encountered a situation it does not know how to handle.
562
682
  */
563
683
  500: {
564
- message: string;
565
- docs: string;
684
+ status: 'error';
685
+ /**
686
+ * Error message detailing what went wrong
687
+ */
688
+ error: string;
689
+ };
690
+ /**
691
+ * The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
692
+ */
693
+ 502: {
694
+ status: 'error';
695
+ /**
696
+ * Error message detailing what went wrong
697
+ */
698
+ error: string;
566
699
  };
567
700
  };
568
701
  export type PostV1DesktopIdBashActionError = PostV1DesktopIdBashActionErrors[keyof PostV1DesktopIdBashActionErrors];
569
702
  export type PostV1DesktopIdBashActionResponses = {
570
703
  /**
571
- * Command executed successfully
704
+ * Command executed successfully. Response contains command output.
572
705
  */
573
706
  200: {
574
707
  /**
575
- * Status of the bash command execution
708
+ * Raw string output from the executed command (if any)
709
+ */
710
+ output?: string;
711
+ /**
712
+ * Error message if the operation failed (also indicated by non-2xx HTTP status)
576
713
  */
577
- status: string;
714
+ error?: string;
578
715
  /**
579
- * Output from the bash command execution
716
+ * Base64 encoded JPEG image data (only returned for screenshot actions)
580
717
  */
581
- output: string;
718
+ base64_image?: string;
582
719
  };
583
720
  };
584
721
  export type PostV1DesktopIdBashActionResponse = PostV1DesktopIdBashActionResponses[keyof PostV1DesktopIdBashActionResponses];
@@ -0,0 +1,34 @@
1
+ import { createClient, type Options as ClientOptions } from '@hey-api/client-fetch';
2
+ import * as apiMethods from './client/sdk.gen';
3
+ export * from './client/types.gen';
4
+ import { type GetV1DesktopIdData, type PostV1DesktopData, type PostV1DesktopIdStopData, type PostV1DesktopIdComputerActionData, type PostV1DesktopIdBashActionData } from './client/types.gen';
5
+ type FetchFn = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
6
+ /**
7
+ * Configuration options for the Cyberdesk SDK client.
8
+ */
9
+ export interface CyberdeskClientOptions {
10
+ /** Your Cyberdesk API Key */
11
+ apiKey: string;
12
+ /** Optional: Override the base URL for the API. Defaults to Cyberdesk production API. */
13
+ baseUrl?: string;
14
+ /** Optional: Provide a custom fetch implementation. */
15
+ fetch?: FetchFn;
16
+ /** Optional: Provide additional default options for the underlying client (e.g., timeout, keepalive). */
17
+ clientOptions?: Partial<ClientOptions>;
18
+ }
19
+ export type CyberdeskSdk = {
20
+ getV1DesktopId: (opts: Omit<GetV1DesktopIdData, 'headers' | 'url'>) => ReturnType<typeof apiMethods.getV1DesktopId>;
21
+ postV1Desktop: (opts: Omit<PostV1DesktopData, 'headers' | 'url'>) => ReturnType<typeof apiMethods.postV1Desktop>;
22
+ postV1DesktopIdStop: (opts: Omit<PostV1DesktopIdStopData, 'headers' | 'url'>) => ReturnType<typeof apiMethods.postV1DesktopIdStop>;
23
+ postV1DesktopIdComputerAction: (opts: Omit<PostV1DesktopIdComputerActionData, 'headers' | 'url'>) => ReturnType<typeof apiMethods.postV1DesktopIdComputerAction>;
24
+ postV1DesktopIdBashAction: (opts: Omit<PostV1DesktopIdBashActionData, 'headers' | 'url'>) => ReturnType<typeof apiMethods.postV1DesktopIdBashAction>;
25
+ };
26
+ /**
27
+ * Creates a Cyberdesk SDK instance configured with your API key.
28
+ *
29
+ * @param options - Configuration options including the API key.
30
+ * @returns An SDK instance with methods ready to be called.
31
+ */
32
+ export declare function createCyberdeskClient(options: CyberdeskClientOptions): CyberdeskSdk;
33
+ export { createClient };
34
+ export * as rawApiMethods from './client/sdk.gen';
package/dist/index.js ADDED
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /// <reference lib="dom" />
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
37
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.rawApiMethods = exports.createClient = void 0;
41
+ exports.createCyberdeskClient = createCyberdeskClient;
42
+ const client_fetch_1 = require("@hey-api/client-fetch");
43
+ Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_fetch_1.createClient; } });
44
+ const apiMethods = __importStar(require("./client/sdk.gen")); // Import the generated methods
45
+ // Re-export all types from types.gen for user convenience
46
+ __exportStar(require("./client/types.gen"), exports);
47
+ const DEFAULT_BASE_URL = 'https://api.cyberdesk.io'; // Replace if needed
48
+ /**
49
+ * Creates a Cyberdesk SDK instance configured with your API key.
50
+ *
51
+ * @param options - Configuration options including the API key.
52
+ * @returns An SDK instance with methods ready to be called.
53
+ */
54
+ function createCyberdeskClient(options) {
55
+ const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch, clientOptions = {} } = options;
56
+ if (!apiKey) {
57
+ throw new Error('Cyberdesk SDK requires an `apiKey` to be provided.');
58
+ }
59
+ // Ensure baseUrl is string | undefined before use
60
+ const finalBaseUrl = baseUrl;
61
+ // Prepare headers, merging defaults with any provided in clientOptions
62
+ const mergedHeaders = Object.assign({ 'x-api-key': apiKey, 'Content-Type': 'application/json' }, (clientOptions.headers || {}));
63
+ // Construct the final options for createClient explicitly
64
+ const finalClientOptions = Object.assign({
65
+ // Set base URL
66
+ baseUrl: finalBaseUrl,
67
+ // Set merged headers
68
+ headers: mergedHeaders }, (customFetch && { fetch: customFetch }));
69
+ // Pass the inferred options object directly
70
+ const configuredClient = (0, client_fetch_1.createClient)(finalClientOptions);
71
+ // Return an object where each method is pre-configured with the client instance
72
+ return {
73
+ getV1DesktopId: (opts) => apiMethods.getV1DesktopId(Object.assign(Object.assign({}, opts), { client: configuredClient,
74
+ // Merge client headers with potentially provided headers from opts
75
+ headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
76
+ postV1Desktop: (opts) => apiMethods.postV1Desktop(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
77
+ postV1DesktopIdStop: (opts) => apiMethods.postV1DesktopIdStop(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
78
+ postV1DesktopIdComputerAction: (opts) => apiMethods.postV1DesktopIdComputerAction(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
79
+ postV1DesktopIdBashAction: (opts) => apiMethods.postV1DesktopIdBashAction(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
80
+ // Add bindings for other generated methods here following the same pattern
81
+ };
82
+ }
83
+ // Optional: Export the underlying api methods if needed, though usually accessed via the sdk instance
84
+ exports.rawApiMethods = __importStar(require("./client/sdk.gen"));
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "cyberdesk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "The official TypeScript SDK for Cyberdesk",
5
- "main": "dist/client/index.js",
6
- "types": "dist/client/index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
9
  "LICENSE",