test-wuying-agentbay-sdk 0.13.0-beta.20251218180112 → 0.13.0-beta.20251219140420
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/dist/index.cjs +90 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +121 -44
- package/dist/index.d.ts +121 -44
- package/dist/index.mjs +90 -15
- package/dist/index.mjs.map +1 -1
- package/docs/api/common-features/basics/filesystem.md +36 -0
- package/docs/api/computer-use/computer.md +24 -24
- package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +13 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,31 @@ interface OperationResult extends ApiResponse {
|
|
|
125
125
|
/** Optional error message if the operation failed */
|
|
126
126
|
errorMessage?: string;
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Interface for process list operation responses
|
|
130
|
+
* Corresponds to Python's ProcessListResult type
|
|
131
|
+
*/
|
|
132
|
+
interface Process$1 {
|
|
133
|
+
pname: string;
|
|
134
|
+
pid: number;
|
|
135
|
+
cmdline?: string;
|
|
136
|
+
}
|
|
137
|
+
interface ProcessListResult extends OperationResult {
|
|
138
|
+
data: Process$1[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Interface for installed app list operation responses
|
|
142
|
+
* Corresponds to Python's InstalledAppListResult type
|
|
143
|
+
*/
|
|
144
|
+
interface InstalledApp$1 {
|
|
145
|
+
name: string;
|
|
146
|
+
startCmd: string;
|
|
147
|
+
stopCmd?: string;
|
|
148
|
+
workDirectory?: string;
|
|
149
|
+
}
|
|
150
|
+
interface InstalledAppListResult extends OperationResult {
|
|
151
|
+
data: InstalledApp$1[];
|
|
152
|
+
}
|
|
128
153
|
/**
|
|
129
154
|
* Interface for command execution operation responses
|
|
130
155
|
* Corresponds to Python's CommandResult type
|
|
@@ -201,7 +226,7 @@ interface CodeExecutionResult extends ApiResponse {
|
|
|
201
226
|
* Interface for boolean operation responses
|
|
202
227
|
* Corresponds to Python's BoolResult type
|
|
203
228
|
*/
|
|
204
|
-
interface BoolResult$
|
|
229
|
+
interface BoolResult$1 extends ApiResponse {
|
|
205
230
|
/** Request identifier for tracking API calls */
|
|
206
231
|
requestId: string;
|
|
207
232
|
/** Whether the operation was successful */
|
|
@@ -323,6 +348,12 @@ interface OSSDownloadResult extends ApiResponse {
|
|
|
323
348
|
/** Optional error message if the operation failed */
|
|
324
349
|
errorMessage?: string;
|
|
325
350
|
}
|
|
351
|
+
interface WindowInfo {
|
|
352
|
+
windowId: number;
|
|
353
|
+
title: string;
|
|
354
|
+
pid: number;
|
|
355
|
+
pname: string;
|
|
356
|
+
}
|
|
326
357
|
/**
|
|
327
358
|
* Interface for window list operation responses
|
|
328
359
|
* Corresponds to Python's WindowListResult type
|
|
@@ -333,10 +364,21 @@ interface WindowListResult extends ApiResponse {
|
|
|
333
364
|
/** Whether the operation was successful */
|
|
334
365
|
success: boolean;
|
|
335
366
|
/** List of windows */
|
|
336
|
-
windows:
|
|
367
|
+
windows: WindowInfo[];
|
|
337
368
|
/** Optional error message if the operation failed */
|
|
338
369
|
errorMessage?: string;
|
|
339
370
|
}
|
|
371
|
+
interface Window {
|
|
372
|
+
windowId: number;
|
|
373
|
+
title: string;
|
|
374
|
+
absoluteUpperLeftX?: number;
|
|
375
|
+
absoluteUpperLeftY?: number;
|
|
376
|
+
width?: number;
|
|
377
|
+
height?: number;
|
|
378
|
+
pid?: number;
|
|
379
|
+
pname?: string;
|
|
380
|
+
childWindows?: Window[];
|
|
381
|
+
}
|
|
340
382
|
/**
|
|
341
383
|
* Interface for window info operation responses
|
|
342
384
|
* Corresponds to Python's WindowInfoResult type
|
|
@@ -347,7 +389,7 @@ interface WindowInfoResult extends ApiResponse {
|
|
|
347
389
|
/** Whether the operation was successful */
|
|
348
390
|
success: boolean;
|
|
349
391
|
/** Window object */
|
|
350
|
-
window?:
|
|
392
|
+
window?: Window[];
|
|
351
393
|
/** Optional error message if the operation failed */
|
|
352
394
|
errorMessage?: string;
|
|
353
395
|
}
|
|
@@ -492,6 +534,32 @@ interface SessionResumeResult extends ApiResponse {
|
|
|
492
534
|
/** Current status of the session. Possible values: "RUNNING", "PAUSED", "RESUMING" */
|
|
493
535
|
status?: string;
|
|
494
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Represents the screen dimensions and DPI scaling information.
|
|
539
|
+
*
|
|
540
|
+
* @interface ScreenSize
|
|
541
|
+
* @extends OperationResult
|
|
542
|
+
*/
|
|
543
|
+
interface ScreenSize extends OperationResult {
|
|
544
|
+
/** Screen width in pixels */
|
|
545
|
+
width: number;
|
|
546
|
+
/** Screen height in pixels */
|
|
547
|
+
height: number;
|
|
548
|
+
/** DPI scaling factor (e.g., 1.0 for 100%, 1.5 for 150%, 2.0 for 200%) */
|
|
549
|
+
dpiScalingFactor: number;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Represents the current cursor position on screen.
|
|
553
|
+
*
|
|
554
|
+
* @interface CursorPosition
|
|
555
|
+
* @extends OperationResult
|
|
556
|
+
*/
|
|
557
|
+
interface CursorPosition extends OperationResult {
|
|
558
|
+
/** X coordinate in pixels (0 is left edge of screen) */
|
|
559
|
+
x: number;
|
|
560
|
+
/** Y coordinate in pixels (0 is top edge of screen) */
|
|
561
|
+
y: number;
|
|
562
|
+
}
|
|
495
563
|
|
|
496
564
|
/**
|
|
497
565
|
*/
|
|
@@ -4208,6 +4276,9 @@ declare function replaceTemplatePlaceholders(template: string, replacements: Rec
|
|
|
4208
4276
|
* Provides mouse, keyboard, and screen operations for desktop environments.
|
|
4209
4277
|
*/
|
|
4210
4278
|
|
|
4279
|
+
interface ScreenshotResult$1 extends OperationResult {
|
|
4280
|
+
data: string;
|
|
4281
|
+
}
|
|
4211
4282
|
declare enum MouseButton {
|
|
4212
4283
|
LEFT = "left",
|
|
4213
4284
|
RIGHT = "right",
|
|
@@ -4220,21 +4291,6 @@ declare enum ScrollDirection {
|
|
|
4220
4291
|
LEFT = "left",
|
|
4221
4292
|
RIGHT = "right"
|
|
4222
4293
|
}
|
|
4223
|
-
interface BoolResult$1 extends OperationResult {
|
|
4224
|
-
data?: boolean;
|
|
4225
|
-
}
|
|
4226
|
-
interface CursorPosition extends OperationResult {
|
|
4227
|
-
x: number;
|
|
4228
|
-
y: number;
|
|
4229
|
-
}
|
|
4230
|
-
interface ScreenSize extends OperationResult {
|
|
4231
|
-
width: number;
|
|
4232
|
-
height: number;
|
|
4233
|
-
dpiScalingFactor: number;
|
|
4234
|
-
}
|
|
4235
|
-
interface ScreenshotResult$1 extends OperationResult {
|
|
4236
|
-
data: string;
|
|
4237
|
-
}
|
|
4238
4294
|
interface ComputerSession {
|
|
4239
4295
|
callMcpTool(toolName: string, args: Record<string, any>): Promise<any>;
|
|
4240
4296
|
sessionId: string;
|
|
@@ -4263,7 +4319,7 @@ declare class Computer {
|
|
|
4263
4319
|
* }
|
|
4264
4320
|
* ```
|
|
4265
4321
|
*/
|
|
4266
|
-
clickMouse(x: number, y: number, button?: MouseButton | string): Promise<
|
|
4322
|
+
clickMouse(x: number, y: number, button?: MouseButton | string): Promise<OperationResult>;
|
|
4267
4323
|
/**
|
|
4268
4324
|
* Move mouse to specified coordinates.
|
|
4269
4325
|
*
|
|
@@ -4283,7 +4339,7 @@ declare class Computer {
|
|
|
4283
4339
|
* }
|
|
4284
4340
|
* ```
|
|
4285
4341
|
*/
|
|
4286
|
-
moveMouse(x: number, y: number): Promise<
|
|
4342
|
+
moveMouse(x: number, y: number): Promise<OperationResult>;
|
|
4287
4343
|
/**
|
|
4288
4344
|
* Drag mouse from one position to another.
|
|
4289
4345
|
*
|
|
@@ -4305,7 +4361,7 @@ declare class Computer {
|
|
|
4305
4361
|
* }
|
|
4306
4362
|
* ```
|
|
4307
4363
|
*/
|
|
4308
|
-
dragMouse(fromX: number, fromY: number, toX: number, toY: number, button?: MouseButton | string): Promise<
|
|
4364
|
+
dragMouse(fromX: number, fromY: number, toX: number, toY: number, button?: MouseButton | string): Promise<OperationResult>;
|
|
4309
4365
|
/**
|
|
4310
4366
|
* Scroll at specified coordinates.
|
|
4311
4367
|
*
|
|
@@ -4325,7 +4381,7 @@ declare class Computer {
|
|
|
4325
4381
|
* }
|
|
4326
4382
|
* ```
|
|
4327
4383
|
*/
|
|
4328
|
-
scroll(x: number, y: number, direction?: ScrollDirection | string, amount?: number): Promise<
|
|
4384
|
+
scroll(x: number, y: number, direction?: ScrollDirection | string, amount?: number): Promise<OperationResult>;
|
|
4329
4385
|
/**
|
|
4330
4386
|
* Input text at the current cursor position.
|
|
4331
4387
|
*
|
|
@@ -4342,7 +4398,7 @@ declare class Computer {
|
|
|
4342
4398
|
* }
|
|
4343
4399
|
* ```
|
|
4344
4400
|
*/
|
|
4345
|
-
inputText(text: string): Promise<
|
|
4401
|
+
inputText(text: string): Promise<OperationResult>;
|
|
4346
4402
|
/**
|
|
4347
4403
|
* Press one or more keys.
|
|
4348
4404
|
*
|
|
@@ -4361,7 +4417,7 @@ declare class Computer {
|
|
|
4361
4417
|
* }
|
|
4362
4418
|
* ```
|
|
4363
4419
|
*/
|
|
4364
|
-
pressKeys(keys: string[], hold?: boolean): Promise<
|
|
4420
|
+
pressKeys(keys: string[], hold?: boolean): Promise<OperationResult>;
|
|
4365
4421
|
/**
|
|
4366
4422
|
* Release previously pressed keys.
|
|
4367
4423
|
*
|
|
@@ -4379,7 +4435,7 @@ declare class Computer {
|
|
|
4379
4435
|
* }
|
|
4380
4436
|
* ```
|
|
4381
4437
|
*/
|
|
4382
|
-
releaseKeys(keys: string[]): Promise<
|
|
4438
|
+
releaseKeys(keys: string[]): Promise<OperationResult>;
|
|
4383
4439
|
/**
|
|
4384
4440
|
* Get cursor position.
|
|
4385
4441
|
*
|
|
@@ -4466,7 +4522,7 @@ declare class Computer {
|
|
|
4466
4522
|
* }
|
|
4467
4523
|
* ```
|
|
4468
4524
|
*/
|
|
4469
|
-
getActiveWindow(
|
|
4525
|
+
getActiveWindow(): Promise<WindowInfoResult>;
|
|
4470
4526
|
/**
|
|
4471
4527
|
* Activates the specified window.
|
|
4472
4528
|
*
|
|
@@ -4484,7 +4540,7 @@ declare class Computer {
|
|
|
4484
4540
|
* }
|
|
4485
4541
|
* ```
|
|
4486
4542
|
*/
|
|
4487
|
-
activateWindow(windowId: number): Promise<BoolResult$
|
|
4543
|
+
activateWindow(windowId: number): Promise<BoolResult$1>;
|
|
4488
4544
|
/**
|
|
4489
4545
|
* Closes the specified window.
|
|
4490
4546
|
*
|
|
@@ -4503,7 +4559,7 @@ declare class Computer {
|
|
|
4503
4559
|
* }
|
|
4504
4560
|
* ```
|
|
4505
4561
|
*/
|
|
4506
|
-
closeWindow(windowId: number): Promise<BoolResult$
|
|
4562
|
+
closeWindow(windowId: number): Promise<BoolResult$1>;
|
|
4507
4563
|
/**
|
|
4508
4564
|
* Maximizes the specified window.
|
|
4509
4565
|
*
|
|
@@ -4522,7 +4578,7 @@ declare class Computer {
|
|
|
4522
4578
|
* }
|
|
4523
4579
|
* ```
|
|
4524
4580
|
*/
|
|
4525
|
-
maximizeWindow(windowId: number): Promise<BoolResult$
|
|
4581
|
+
maximizeWindow(windowId: number): Promise<BoolResult$1>;
|
|
4526
4582
|
/**
|
|
4527
4583
|
* Minimizes the specified window.
|
|
4528
4584
|
*
|
|
@@ -4541,7 +4597,7 @@ declare class Computer {
|
|
|
4541
4597
|
* }
|
|
4542
4598
|
* ```
|
|
4543
4599
|
*/
|
|
4544
|
-
minimizeWindow(windowId: number): Promise<BoolResult$
|
|
4600
|
+
minimizeWindow(windowId: number): Promise<BoolResult$1>;
|
|
4545
4601
|
/**
|
|
4546
4602
|
* Restores the specified window.
|
|
4547
4603
|
*
|
|
@@ -4561,7 +4617,7 @@ declare class Computer {
|
|
|
4561
4617
|
* }
|
|
4562
4618
|
* ```
|
|
4563
4619
|
*/
|
|
4564
|
-
restoreWindow(windowId: number): Promise<BoolResult$
|
|
4620
|
+
restoreWindow(windowId: number): Promise<BoolResult$1>;
|
|
4565
4621
|
/**
|
|
4566
4622
|
* Resizes the specified window.
|
|
4567
4623
|
*
|
|
@@ -4582,7 +4638,7 @@ declare class Computer {
|
|
|
4582
4638
|
* }
|
|
4583
4639
|
* ```
|
|
4584
4640
|
*/
|
|
4585
|
-
resizeWindow(windowId: number, width: number, height: number): Promise<BoolResult$
|
|
4641
|
+
resizeWindow(windowId: number, width: number, height: number): Promise<BoolResult$1>;
|
|
4586
4642
|
/**
|
|
4587
4643
|
* Makes the specified window fullscreen.
|
|
4588
4644
|
*
|
|
@@ -4601,7 +4657,7 @@ declare class Computer {
|
|
|
4601
4657
|
* }
|
|
4602
4658
|
* ```
|
|
4603
4659
|
*/
|
|
4604
|
-
fullscreenWindow(windowId: number): Promise<BoolResult$
|
|
4660
|
+
fullscreenWindow(windowId: number): Promise<BoolResult$1>;
|
|
4605
4661
|
/**
|
|
4606
4662
|
* Toggles focus mode on or off.
|
|
4607
4663
|
*
|
|
@@ -4619,7 +4675,7 @@ declare class Computer {
|
|
|
4619
4675
|
* }
|
|
4620
4676
|
* ```
|
|
4621
4677
|
*/
|
|
4622
|
-
focusMode(on: boolean): Promise<BoolResult$
|
|
4678
|
+
focusMode(on: boolean): Promise<BoolResult$1>;
|
|
4623
4679
|
/**
|
|
4624
4680
|
* Gets the list of installed applications.
|
|
4625
4681
|
*
|
|
@@ -4639,7 +4695,7 @@ declare class Computer {
|
|
|
4639
4695
|
* }
|
|
4640
4696
|
* ```
|
|
4641
4697
|
*/
|
|
4642
|
-
getInstalledApps(startMenu?: boolean, desktop?: boolean, ignoreSystemApps?: boolean): Promise<
|
|
4698
|
+
getInstalledApps(startMenu?: boolean, desktop?: boolean, ignoreSystemApps?: boolean): Promise<InstalledAppListResult>;
|
|
4643
4699
|
/**
|
|
4644
4700
|
* Starts the specified application.
|
|
4645
4701
|
*
|
|
@@ -4659,7 +4715,7 @@ declare class Computer {
|
|
|
4659
4715
|
* }
|
|
4660
4716
|
* ```
|
|
4661
4717
|
*/
|
|
4662
|
-
startApp(startCmd: string, workDirectory?: string, activity?: string): Promise<
|
|
4718
|
+
startApp(startCmd: string, workDirectory?: string, activity?: string): Promise<ProcessListResult>;
|
|
4663
4719
|
/**
|
|
4664
4720
|
* Stops an application by process name.
|
|
4665
4721
|
*
|
|
@@ -4677,7 +4733,7 @@ declare class Computer {
|
|
|
4677
4733
|
* }
|
|
4678
4734
|
* ```
|
|
4679
4735
|
*/
|
|
4680
|
-
stopAppByPName(pname: string): Promise<
|
|
4736
|
+
stopAppByPName(pname: string): Promise<BoolResult$1>;
|
|
4681
4737
|
/**
|
|
4682
4738
|
* Stops an application by process ID.
|
|
4683
4739
|
*
|
|
@@ -4696,7 +4752,7 @@ declare class Computer {
|
|
|
4696
4752
|
* }
|
|
4697
4753
|
* ```
|
|
4698
4754
|
*/
|
|
4699
|
-
stopAppByPID(pid: number): Promise<
|
|
4755
|
+
stopAppByPID(pid: number): Promise<BoolResult$1>;
|
|
4700
4756
|
/**
|
|
4701
4757
|
* Stops an application by stop command.
|
|
4702
4758
|
*
|
|
@@ -4714,7 +4770,7 @@ declare class Computer {
|
|
|
4714
4770
|
* }
|
|
4715
4771
|
* ```
|
|
4716
4772
|
*/
|
|
4717
|
-
stopAppByCmd(cmd: string): Promise<
|
|
4773
|
+
stopAppByCmd(cmd: string): Promise<BoolResult$1>;
|
|
4718
4774
|
/**
|
|
4719
4775
|
* Lists all visible applications.
|
|
4720
4776
|
*
|
|
@@ -4731,7 +4787,7 @@ declare class Computer {
|
|
|
4731
4787
|
* }
|
|
4732
4788
|
* ```
|
|
4733
4789
|
*/
|
|
4734
|
-
listVisibleApps(): Promise<
|
|
4790
|
+
listVisibleApps(): Promise<ProcessListResult>;
|
|
4735
4791
|
}
|
|
4736
4792
|
|
|
4737
4793
|
interface ContextStatusData {
|
|
@@ -4965,7 +5021,28 @@ declare class FileSystem {
|
|
|
4965
5021
|
* }
|
|
4966
5022
|
* ```
|
|
4967
5023
|
*/
|
|
4968
|
-
createDirectory(path: string): Promise<BoolResult$
|
|
5024
|
+
createDirectory(path: string): Promise<BoolResult$1>;
|
|
5025
|
+
/**
|
|
5026
|
+
* Deletes a file at the specified path.
|
|
5027
|
+
* Corresponds to Python's delete_file() method
|
|
5028
|
+
*
|
|
5029
|
+
* @param path - Path to the file to delete.
|
|
5030
|
+
* @returns BoolResult with deletion result and requestId
|
|
5031
|
+
*
|
|
5032
|
+
* @example
|
|
5033
|
+
* ```typescript
|
|
5034
|
+
* const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
5035
|
+
* const result = await agentBay.create();
|
|
5036
|
+
* if (result.success) {
|
|
5037
|
+
* const session = result.session;
|
|
5038
|
+
* await session.fileSystem.writeFile('/tmp/to_delete.txt', 'hello');
|
|
5039
|
+
* const deleteResult = await session.fileSystem.deleteFile('/tmp/to_delete.txt');
|
|
5040
|
+
* console.log('File deleted:', deleteResult.success);
|
|
5041
|
+
* await session.delete();
|
|
5042
|
+
* }
|
|
5043
|
+
* ```
|
|
5044
|
+
*/
|
|
5045
|
+
deleteFile(path: string): Promise<BoolResult$1>;
|
|
4969
5046
|
/**
|
|
4970
5047
|
* Edits a file by replacing occurrences of oldText with newText.
|
|
4971
5048
|
* Corresponds to Python's edit_file() method
|
|
@@ -4991,7 +5068,7 @@ declare class FileSystem {
|
|
|
4991
5068
|
editFile(path: string, edits: Array<{
|
|
4992
5069
|
oldText: string;
|
|
4993
5070
|
newText: string;
|
|
4994
|
-
}>, dryRun?: boolean): Promise<BoolResult$
|
|
5071
|
+
}>, dryRun?: boolean): Promise<BoolResult$1>;
|
|
4995
5072
|
/**
|
|
4996
5073
|
* Gets information about a file or directory.
|
|
4997
5074
|
* Corresponds to Python's get_file_info() method
|
|
@@ -5072,7 +5149,7 @@ declare class FileSystem {
|
|
|
5072
5149
|
* }
|
|
5073
5150
|
* ```
|
|
5074
5151
|
*/
|
|
5075
|
-
moveFile(source: string, destination: string): Promise<BoolResult$
|
|
5152
|
+
moveFile(source: string, destination: string): Promise<BoolResult$1>;
|
|
5076
5153
|
/**
|
|
5077
5154
|
* Internal method to read a file chunk. Used for chunked file operations.
|
|
5078
5155
|
*
|
|
@@ -5242,7 +5319,7 @@ declare class FileSystem {
|
|
|
5242
5319
|
*
|
|
5243
5320
|
* @see {@link readFile}, {@link listDirectory}
|
|
5244
5321
|
*/
|
|
5245
|
-
writeFile(path: string, content: string, mode?: string): Promise<BoolResult$
|
|
5322
|
+
writeFile(path: string, content: string, mode?: string): Promise<BoolResult$1>;
|
|
5246
5323
|
/**
|
|
5247
5324
|
* Get file change information for the specified directory path
|
|
5248
5325
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -11546,6 +11546,38 @@ init_esm_shims();
|
|
|
11546
11546
|
|
|
11547
11547
|
// src/computer/computer.ts
|
|
11548
11548
|
init_esm_shims();
|
|
11549
|
+
|
|
11550
|
+
// src/utils/field-converter.ts
|
|
11551
|
+
init_esm_shims();
|
|
11552
|
+
function snakeToCamel(str) {
|
|
11553
|
+
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
11554
|
+
}
|
|
11555
|
+
__name(snakeToCamel, "snakeToCamel");
|
|
11556
|
+
function convertObjectKeys(obj) {
|
|
11557
|
+
if (obj === null || obj === void 0) {
|
|
11558
|
+
return obj;
|
|
11559
|
+
}
|
|
11560
|
+
if (Array.isArray(obj)) {
|
|
11561
|
+
return obj.map((item) => convertObjectKeys(item));
|
|
11562
|
+
}
|
|
11563
|
+
if (typeof obj === "object" && obj.constructor === Object) {
|
|
11564
|
+
const converted = {};
|
|
11565
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
11566
|
+
const camelKey = snakeToCamel(key);
|
|
11567
|
+
converted[camelKey] = convertObjectKeys(value);
|
|
11568
|
+
}
|
|
11569
|
+
return converted;
|
|
11570
|
+
}
|
|
11571
|
+
return obj;
|
|
11572
|
+
}
|
|
11573
|
+
__name(convertObjectKeys, "convertObjectKeys");
|
|
11574
|
+
function convertWindowData(rawWindow) {
|
|
11575
|
+
if (!rawWindow) return rawWindow;
|
|
11576
|
+
return convertObjectKeys(rawWindow);
|
|
11577
|
+
}
|
|
11578
|
+
__name(convertWindowData, "convertWindowData");
|
|
11579
|
+
|
|
11580
|
+
// src/computer/computer.ts
|
|
11549
11581
|
var MouseButton = /* @__PURE__ */ ((MouseButton2) => {
|
|
11550
11582
|
MouseButton2["LEFT"] = "left";
|
|
11551
11583
|
MouseButton2["RIGHT"] = "right";
|
|
@@ -12050,7 +12082,8 @@ var _Computer = class _Computer {
|
|
|
12050
12082
|
errorMessage: response.errorMessage
|
|
12051
12083
|
};
|
|
12052
12084
|
}
|
|
12053
|
-
const
|
|
12085
|
+
const rawWindows = response.data ? JSON.parse(response.data) : [];
|
|
12086
|
+
const windows = convertWindowData(rawWindows);
|
|
12054
12087
|
return {
|
|
12055
12088
|
requestId: response.requestId,
|
|
12056
12089
|
success: true,
|
|
@@ -12082,19 +12115,20 @@ var _Computer = class _Computer {
|
|
|
12082
12115
|
* }
|
|
12083
12116
|
* ```
|
|
12084
12117
|
*/
|
|
12085
|
-
async getActiveWindow(
|
|
12118
|
+
async getActiveWindow() {
|
|
12086
12119
|
try {
|
|
12087
|
-
const args = {
|
|
12120
|
+
const args = {};
|
|
12088
12121
|
const response = await this.session.callMcpTool("get_active_window", args);
|
|
12089
12122
|
if (!response.success) {
|
|
12090
12123
|
return {
|
|
12091
12124
|
requestId: response.requestId,
|
|
12092
12125
|
success: false,
|
|
12093
|
-
window:
|
|
12126
|
+
window: [],
|
|
12094
12127
|
errorMessage: response.errorMessage
|
|
12095
12128
|
};
|
|
12096
12129
|
}
|
|
12097
|
-
const
|
|
12130
|
+
const rawWindow = response.data ? JSON.parse(response.data) : null;
|
|
12131
|
+
const window = convertWindowData(rawWindow);
|
|
12098
12132
|
return {
|
|
12099
12133
|
requestId: response.requestId,
|
|
12100
12134
|
success: true,
|
|
@@ -12104,7 +12138,7 @@ var _Computer = class _Computer {
|
|
|
12104
12138
|
return {
|
|
12105
12139
|
requestId: "",
|
|
12106
12140
|
success: false,
|
|
12107
|
-
window:
|
|
12141
|
+
window: [],
|
|
12108
12142
|
errorMessage: `Failed to get active window: ${error}`
|
|
12109
12143
|
};
|
|
12110
12144
|
}
|
|
@@ -12410,7 +12444,6 @@ var _Computer = class _Computer {
|
|
|
12410
12444
|
* }
|
|
12411
12445
|
* ```
|
|
12412
12446
|
*/
|
|
12413
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12414
12447
|
async getInstalledApps(startMenu = true, desktop = false, ignoreSystemApps = true) {
|
|
12415
12448
|
try {
|
|
12416
12449
|
const args = {
|
|
@@ -12427,7 +12460,8 @@ var _Computer = class _Computer {
|
|
|
12427
12460
|
errorMessage: response.errorMessage
|
|
12428
12461
|
};
|
|
12429
12462
|
}
|
|
12430
|
-
const
|
|
12463
|
+
const rawApps = response.data ? JSON.parse(response.data) : [];
|
|
12464
|
+
const apps = convertObjectKeys(rawApps);
|
|
12431
12465
|
return {
|
|
12432
12466
|
requestId: response.requestId,
|
|
12433
12467
|
success: true,
|
|
@@ -12461,7 +12495,6 @@ var _Computer = class _Computer {
|
|
|
12461
12495
|
* }
|
|
12462
12496
|
* ```
|
|
12463
12497
|
*/
|
|
12464
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12465
12498
|
async startApp(startCmd, workDirectory = "", activity = "") {
|
|
12466
12499
|
try {
|
|
12467
12500
|
const args = { start_cmd: startCmd };
|
|
@@ -12476,7 +12509,8 @@ var _Computer = class _Computer {
|
|
|
12476
12509
|
errorMessage: response.errorMessage
|
|
12477
12510
|
};
|
|
12478
12511
|
}
|
|
12479
|
-
const
|
|
12512
|
+
const rawProcesses = response.data ? JSON.parse(response.data) : [];
|
|
12513
|
+
const processes = convertObjectKeys(rawProcesses);
|
|
12480
12514
|
return {
|
|
12481
12515
|
requestId: response.requestId,
|
|
12482
12516
|
success: true,
|
|
@@ -12508,7 +12542,6 @@ var _Computer = class _Computer {
|
|
|
12508
12542
|
* }
|
|
12509
12543
|
* ```
|
|
12510
12544
|
*/
|
|
12511
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12512
12545
|
async stopAppByPName(pname) {
|
|
12513
12546
|
try {
|
|
12514
12547
|
const args = { pname };
|
|
@@ -12544,7 +12577,6 @@ var _Computer = class _Computer {
|
|
|
12544
12577
|
* }
|
|
12545
12578
|
* ```
|
|
12546
12579
|
*/
|
|
12547
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12548
12580
|
async stopAppByPID(pid) {
|
|
12549
12581
|
try {
|
|
12550
12582
|
const args = { pid };
|
|
@@ -12579,7 +12611,6 @@ var _Computer = class _Computer {
|
|
|
12579
12611
|
* }
|
|
12580
12612
|
* ```
|
|
12581
12613
|
*/
|
|
12582
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12583
12614
|
async stopAppByCmd(cmd) {
|
|
12584
12615
|
try {
|
|
12585
12616
|
const args = { stop_cmd: cmd };
|
|
@@ -12613,7 +12644,6 @@ var _Computer = class _Computer {
|
|
|
12613
12644
|
* }
|
|
12614
12645
|
* ```
|
|
12615
12646
|
*/
|
|
12616
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12617
12647
|
async listVisibleApps() {
|
|
12618
12648
|
try {
|
|
12619
12649
|
const response = await this.session.callMcpTool("list_visible_apps", {});
|
|
@@ -12625,7 +12655,8 @@ var _Computer = class _Computer {
|
|
|
12625
12655
|
errorMessage: response.errorMessage
|
|
12626
12656
|
};
|
|
12627
12657
|
}
|
|
12628
|
-
const
|
|
12658
|
+
const rawProcesses = response.data ? JSON.parse(response.data) : [];
|
|
12659
|
+
const processes = convertObjectKeys(rawProcesses);
|
|
12629
12660
|
return {
|
|
12630
12661
|
requestId: response.requestId,
|
|
12631
12662
|
success: true,
|
|
@@ -13708,6 +13739,50 @@ var _FileSystem = class _FileSystem {
|
|
|
13708
13739
|
};
|
|
13709
13740
|
}
|
|
13710
13741
|
}
|
|
13742
|
+
/**
|
|
13743
|
+
* Deletes a file at the specified path.
|
|
13744
|
+
* Corresponds to Python's delete_file() method
|
|
13745
|
+
*
|
|
13746
|
+
* @param path - Path to the file to delete.
|
|
13747
|
+
* @returns BoolResult with deletion result and requestId
|
|
13748
|
+
*
|
|
13749
|
+
* @example
|
|
13750
|
+
* ```typescript
|
|
13751
|
+
* const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
13752
|
+
* const result = await agentBay.create();
|
|
13753
|
+
* if (result.success) {
|
|
13754
|
+
* const session = result.session;
|
|
13755
|
+
* await session.fileSystem.writeFile('/tmp/to_delete.txt', 'hello');
|
|
13756
|
+
* const deleteResult = await session.fileSystem.deleteFile('/tmp/to_delete.txt');
|
|
13757
|
+
* console.log('File deleted:', deleteResult.success);
|
|
13758
|
+
* await session.delete();
|
|
13759
|
+
* }
|
|
13760
|
+
* ```
|
|
13761
|
+
*/
|
|
13762
|
+
async deleteFile(path6) {
|
|
13763
|
+
try {
|
|
13764
|
+
const args = { path: path6 };
|
|
13765
|
+
const result = await this.session.callMcpTool("delete_file", args);
|
|
13766
|
+
if (!result.success) {
|
|
13767
|
+
return {
|
|
13768
|
+
requestId: result.requestId,
|
|
13769
|
+
success: false,
|
|
13770
|
+
errorMessage: result.errorMessage
|
|
13771
|
+
};
|
|
13772
|
+
}
|
|
13773
|
+
return {
|
|
13774
|
+
requestId: result.requestId,
|
|
13775
|
+
success: true,
|
|
13776
|
+
data: true
|
|
13777
|
+
};
|
|
13778
|
+
} catch (error) {
|
|
13779
|
+
return {
|
|
13780
|
+
requestId: "",
|
|
13781
|
+
success: false,
|
|
13782
|
+
errorMessage: `Failed to delete file: ${error}`
|
|
13783
|
+
};
|
|
13784
|
+
}
|
|
13785
|
+
}
|
|
13711
13786
|
/**
|
|
13712
13787
|
* Edits a file by replacing occurrences of oldText with newText.
|
|
13713
13788
|
* Corresponds to Python's edit_file() method
|