wuying-agentbay-sdk 0.9.4 → 0.10.0

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/README.md CHANGED
@@ -64,6 +64,7 @@ main().catch(console.error);
64
64
  - [📖 Feature Guides](https://github.com/aliyun/wuying-agentbay-sdk/tree/main/docs/guides/README.md) - Complete feature introduction
65
65
  - [🔧 TypeScript API Reference](docs/api/README.md) - Detailed API documentation
66
66
  - [💻 TypeScript Examples](docs/examples/README.md) - Complete example code
67
+ - [📋 Logging Configuration](https://github.com/aliyun/wuying-agentbay-sdk/tree/main/docs/guides/common-features/configuration/logging.md) - Configure logging levels and output
67
68
 
68
69
  ### 🆘 Need Help
69
70
  - [🔧 TypeScript API Reference](docs/api/README.md) - Local API documentation
@@ -0,0 +1,17 @@
1
+
2
+ import { createRequire } from 'module';
3
+ const require = createRequire(import.meta.url);
4
+ (function() {
5
+ if (typeof OpenApi !== 'undefined' && !OpenApi.default) {
6
+ OpenApi.default = OpenApi;
7
+ }
8
+ })();
9
+
10
+ import {
11
+ Application
12
+ } from "./chunk-BQNGKBQF.mjs";
13
+ import "./chunk-KNEDRAP6.mjs";
14
+ export {
15
+ Application
16
+ };
17
+ //# sourceMappingURL=application-KZWXH46T.mjs.map
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkX6MS7Z5Lcjs = require('./chunk-X6MS7Z5L.cjs');
4
+ require('./chunk-4IPTHWLM.cjs');
5
+
6
+
7
+ exports.Application = _chunkX6MS7Z5Lcjs.Application;
8
+ //# sourceMappingURL=application-LMA7KSRH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/application-LMA7KSRH.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,oDAAC","file":"/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/application-LMA7KSRH.cjs"}
@@ -0,0 +1,51 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res) => function __init() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ // node_modules/tsup/assets/cjs_shims.js
38
+ var init_cjs_shims = __esm({
39
+ "node_modules/tsup/assets/cjs_shims.js"() {
40
+ "use strict";
41
+ }
42
+ });
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ exports.__name = __name; exports.__require = __require; exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.init_cjs_shims = init_cjs_shims;
51
+ //# sourceMappingURL=chunk-4IPTHWLM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/chunk-4IPTHWLM.cjs","../node_modules/tsup/assets/cjs_shims.js"],"names":[],"mappings":"AAAA,6EAAI,SAAS,EAAE,MAAM,CAAC,MAAM;AAC5B,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;AACxF,IAAI,UAAU,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,QAAQ,IAAI,YAAY,EAAE,QAAQ,EAAE,OAAO,MAAM,IAAI,YAAY,EAAE,IAAI,KAAK,CAAC,CAAC,EAAE;AAC/H,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,QAAQ,IAAI,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE;AACp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,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1H,EAAE;AACF,EAAE,OAAO,EAAE;AACX,CAAC;AACD,IAAI,QAAQ,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,GAAG,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW;AAChH;AACA;AACA;AACA;AACA,EAAE,WAAW,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,EAAE,MAAM;AACjH,EAAE;AACF,CAAC,CAAC;AACF;AACA;ACpCA,IAAA,eAAA,EAAA,KAAA,CAAA;AAAA,EAAA,uCAAA,CAAA,EAAA;AAAA,IAAA,YAAA;AAAA,EAAA;AAAA,CAAA,CAAA;AD0CA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,4JAAC","file":"/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/chunk-4IPTHWLM.cjs","sourcesContent":[null,"// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"]}
@@ -0,0 +1,386 @@
1
+
2
+ import { createRequire } from 'module';
3
+ const require = createRequire(import.meta.url);
4
+ (function() {
5
+ if (typeof OpenApi !== 'undefined' && !OpenApi.default) {
6
+ OpenApi.default = OpenApi;
7
+ }
8
+ })();
9
+
10
+ import {
11
+ __name,
12
+ init_esm_shims
13
+ } from "./chunk-KNEDRAP6.mjs";
14
+
15
+ // src/application/application.ts
16
+ init_esm_shims();
17
+ var _Application = class _Application {
18
+ /**
19
+ * Initialize an Application object.
20
+ *
21
+ * @param session - The Session instance that this Application belongs to.
22
+ */
23
+ constructor(session) {
24
+ this.session = session;
25
+ }
26
+ /**
27
+ * Sanitizes error messages to remove sensitive information like API keys.
28
+ *
29
+ * @param error - The error to sanitize
30
+ * @returns The sanitized error
31
+ */
32
+ sanitizeError(error) {
33
+ if (!error) {
34
+ return error;
35
+ }
36
+ const errorString = String(error);
37
+ return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
38
+ }
39
+ /**
40
+ * Helper method to parse JSON string into objects
41
+ */
42
+ parseJSON(jsonString) {
43
+ try {
44
+ return JSON.parse(jsonString);
45
+ } catch (error) {
46
+ throw new Error(`Failed to parse JSON: ${error}`);
47
+ }
48
+ }
49
+ /**
50
+ * Get a list of installed applications.
51
+ *
52
+ * @param startMenu - Whether to include start menu applications.
53
+ * @param desktop - Whether to include desktop applications.
54
+ * @param ignoreSystemApps - Whether to ignore system applications.
55
+ * @returns A promise that resolves to the list of installed applications.
56
+ *
57
+ * @deprecated Use session.computer.getInstalledApps() for desktop or session.mobile.getInstalledApps() for mobile instead.
58
+ */
59
+ async getInstalledApps(startMenu = false, desktop = true, ignoreSystemApps = true) {
60
+ console.warn("\u26A0\uFE0F Application.getInstalledApps() is deprecated. Use session.computer.getInstalledApps() for desktop or session.mobile.getInstalledApps() for mobile instead.");
61
+ try {
62
+ const args = {
63
+ start_menu: startMenu,
64
+ desktop,
65
+ ignore_system_apps: ignoreSystemApps
66
+ };
67
+ const result = await this.session.callMcpTool("get_installed_apps", args);
68
+ if (!result.success) {
69
+ return {
70
+ requestId: result.requestId,
71
+ success: false,
72
+ data: [],
73
+ errorMessage: result.errorMessage
74
+ };
75
+ }
76
+ let apps = [];
77
+ try {
78
+ apps = this.parseJSON(result.data);
79
+ } catch (err) {
80
+ return {
81
+ requestId: result.requestId,
82
+ success: false,
83
+ data: [],
84
+ errorMessage: `Failed to parse installed apps: ${err}`
85
+ };
86
+ }
87
+ return {
88
+ requestId: result.requestId,
89
+ success: true,
90
+ data: apps
91
+ };
92
+ } catch (error) {
93
+ return {
94
+ requestId: "",
95
+ success: false,
96
+ data: [],
97
+ errorMessage: `Failed to get installed apps: ${error}`
98
+ };
99
+ }
100
+ }
101
+ /**
102
+ * Start an application.
103
+ *
104
+ * @param startCmd - The command to start the application.
105
+ * @param workDirectory - The working directory for the application.
106
+ * @param activity - The activity to start (for mobile applications).
107
+ * @returns A promise that resolves to the result of starting the application.
108
+ *
109
+ * @deprecated Use session.computer.startApp() for desktop or session.mobile.startApp() for mobile instead.
110
+ */
111
+ async startApp(startCmd, workDirectory = "", activity = "") {
112
+ console.warn("\u26A0\uFE0F Application.startApp() is deprecated. Use session.computer.startApp() for desktop or session.mobile.startApp() for mobile instead.");
113
+ try {
114
+ const args = {
115
+ start_cmd: startCmd,
116
+ work_directory: workDirectory,
117
+ activity
118
+ };
119
+ const result = await this.session.callMcpTool("start_app", args);
120
+ if (!result.success) {
121
+ return {
122
+ requestId: result.requestId,
123
+ success: false,
124
+ data: [],
125
+ errorMessage: result.errorMessage
126
+ };
127
+ }
128
+ let processes = [];
129
+ try {
130
+ processes = this.parseJSON(result.data);
131
+ } catch (err) {
132
+ return {
133
+ requestId: result.requestId,
134
+ success: false,
135
+ data: [],
136
+ errorMessage: `Failed to parse processes: ${err}`
137
+ };
138
+ }
139
+ return {
140
+ requestId: result.requestId,
141
+ success: true,
142
+ data: processes
143
+ };
144
+ } catch (error) {
145
+ return {
146
+ requestId: "",
147
+ success: false,
148
+ data: [],
149
+ errorMessage: `Failed to start app: ${error}`
150
+ };
151
+ }
152
+ }
153
+ /**
154
+ * Stop an application by process name.
155
+ *
156
+ * @param pname - The process name of the application to stop.
157
+ * @returns A promise that resolves to the result of stopping the application.
158
+ *
159
+ * @deprecated Use session.computer.stopAppByPName() for desktop or session.mobile.stopAppByPName() for mobile instead.
160
+ */
161
+ async stopAppByPName(pname) {
162
+ console.warn("\u26A0\uFE0F Application.stopAppByPName() is deprecated. Use session.computer.stopAppByPName() for desktop or session.mobile.stopAppByPName() for mobile instead.");
163
+ try {
164
+ const args = { pname };
165
+ const result = await this.session.callMcpTool("stop_app_by_pname", args);
166
+ if (!result.success) {
167
+ return {
168
+ requestId: result.requestId,
169
+ success: false,
170
+ errorMessage: result.errorMessage
171
+ };
172
+ }
173
+ return {
174
+ requestId: result.requestId,
175
+ success: true
176
+ };
177
+ } catch (error) {
178
+ return {
179
+ requestId: "",
180
+ success: false,
181
+ errorMessage: `Failed to stop app by process name: ${error}`
182
+ };
183
+ }
184
+ }
185
+ /**
186
+ * Stops an application by process ID.
187
+ * Corresponds to Python's stop_app_by_pid() method
188
+ *
189
+ * @param pid - The process ID to stop.
190
+ * @returns AppOperationResult with operation result and requestId
191
+ * @throws Error if the operation fails.
192
+ */
193
+ async stopAppByPID(pid) {
194
+ try {
195
+ const args = { pid };
196
+ const result = await this.session.callMcpTool("stop_app_by_pid", args);
197
+ if (!result.success) {
198
+ return {
199
+ requestId: result.requestId,
200
+ success: false,
201
+ errorMessage: result.errorMessage
202
+ };
203
+ }
204
+ return {
205
+ requestId: result.requestId,
206
+ success: true
207
+ };
208
+ } catch (error) {
209
+ return {
210
+ requestId: "",
211
+ success: false,
212
+ errorMessage: `Failed to stop app by process ID: ${error}`
213
+ };
214
+ }
215
+ }
216
+ /**
217
+ * Stop an application by command.
218
+ *
219
+ * @param cmd - The command to stop the application.
220
+ * @returns A promise that resolves to the result of stopping the application.
221
+ *
222
+ * @deprecated Use session.computer.stopAppByCmd() for desktop or session.mobile.stopAppByCmd() for mobile instead.
223
+ */
224
+ async stopAppByCmd(cmd) {
225
+ console.warn("\u26A0\uFE0F Application.stopAppByCmd() is deprecated. Use session.computer.stopAppByCmd() for desktop or session.mobile.stopAppByCmd() for mobile instead.");
226
+ try {
227
+ const args = { stop_cmd: cmd };
228
+ const result = await this.session.callMcpTool("stop_app_by_cmd", args);
229
+ if (!result.success) {
230
+ return {
231
+ requestId: result.requestId,
232
+ success: false,
233
+ errorMessage: result.errorMessage
234
+ };
235
+ }
236
+ return {
237
+ requestId: result.requestId,
238
+ success: true
239
+ };
240
+ } catch (error) {
241
+ return {
242
+ requestId: "",
243
+ success: false,
244
+ errorMessage: `Failed to stop app by command: ${error}`
245
+ };
246
+ }
247
+ }
248
+ /**
249
+ * Returns a list of currently visible applications.
250
+ * Corresponds to Python's list_visible_apps() method
251
+ *
252
+ * @returns ProcessListResult with visible apps and requestId
253
+ * @throws Error if the operation fails.
254
+ */
255
+ async listVisibleApps() {
256
+ try {
257
+ const result = await this.session.callMcpTool("list_visible_apps", {});
258
+ if (!result.success) {
259
+ return {
260
+ requestId: result.requestId,
261
+ success: false,
262
+ data: [],
263
+ errorMessage: result.errorMessage
264
+ };
265
+ }
266
+ let processes = [];
267
+ try {
268
+ processes = this.parseJSON(result.data);
269
+ } catch (err) {
270
+ return {
271
+ requestId: result.requestId,
272
+ success: false,
273
+ data: [],
274
+ errorMessage: `Failed to parse visible apps: ${err}`
275
+ };
276
+ }
277
+ return {
278
+ requestId: result.requestId,
279
+ success: true,
280
+ data: processes
281
+ };
282
+ } catch (error) {
283
+ return {
284
+ requestId: "",
285
+ success: false,
286
+ data: [],
287
+ errorMessage: `Failed to list visible apps: ${error}`
288
+ };
289
+ }
290
+ }
291
+ /**
292
+ * Get a list of running processes.
293
+ *
294
+ * @returns A promise that resolves to the list of running processes.
295
+ *
296
+ * @deprecated Use session.computer.getRunningProcesses() for desktop or session.mobile.getRunningProcesses() for mobile instead.
297
+ */
298
+ async getRunningProcesses() {
299
+ console.warn("\u26A0\uFE0F Application.getRunningProcesses() is deprecated. Use session.computer.getRunningProcesses() for desktop or session.mobile.getRunningProcesses() for mobile instead.");
300
+ try {
301
+ const result = await this.session.callMcpTool("list_running_processes", {});
302
+ if (!result.success) {
303
+ return {
304
+ requestId: result.requestId,
305
+ success: false,
306
+ data: [],
307
+ errorMessage: result.errorMessage
308
+ };
309
+ }
310
+ let processes = [];
311
+ try {
312
+ processes = this.parseJSON(result.data);
313
+ } catch (err) {
314
+ return {
315
+ requestId: result.requestId,
316
+ success: false,
317
+ data: [],
318
+ errorMessage: `Failed to parse running processes: ${err}`
319
+ };
320
+ }
321
+ return {
322
+ requestId: result.requestId,
323
+ success: true,
324
+ data: processes
325
+ };
326
+ } catch (error) {
327
+ return {
328
+ requestId: "",
329
+ success: false,
330
+ data: [],
331
+ errorMessage: `Failed to get running processes: ${error}`
332
+ };
333
+ }
334
+ }
335
+ /**
336
+ * Get a list of visible applications.
337
+ *
338
+ * @returns A promise that resolves to the list of visible applications.
339
+ *
340
+ * @deprecated Use session.computer.getVisibleApps() for desktop instead. This API is not available for mobile.
341
+ */
342
+ async getVisibleApps() {
343
+ console.warn("\u26A0\uFE0F Application.getVisibleApps() is deprecated. Use session.computer.getVisibleApps() for desktop instead. This API is not available for mobile.");
344
+ try {
345
+ const result = await this.session.callMcpTool("list_visible_apps", {});
346
+ if (!result.success) {
347
+ return {
348
+ requestId: result.requestId,
349
+ success: false,
350
+ data: [],
351
+ errorMessage: result.errorMessage
352
+ };
353
+ }
354
+ let apps = [];
355
+ try {
356
+ apps = this.parseJSON(result.data);
357
+ } catch (err) {
358
+ return {
359
+ requestId: result.requestId,
360
+ success: false,
361
+ data: [],
362
+ errorMessage: `Failed to parse visible apps: ${err}`
363
+ };
364
+ }
365
+ return {
366
+ requestId: result.requestId,
367
+ success: true,
368
+ data: apps
369
+ };
370
+ } catch (error) {
371
+ return {
372
+ requestId: "",
373
+ success: false,
374
+ data: [],
375
+ errorMessage: `Failed to get visible apps: ${error}`
376
+ };
377
+ }
378
+ }
379
+ };
380
+ __name(_Application, "Application");
381
+ var Application = _Application;
382
+
383
+ export {
384
+ Application
385
+ };
386
+ //# sourceMappingURL=chunk-BQNGKBQF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/application/application.ts"],"sourcesContent":["import { Client } from \"../api/client\";\nimport {\n InstalledAppListResult,\n ProcessListResult,\n AppOperationResult,\n} from \"../types/api-response\";\n\n\n/**\n * Represents an installed application\n */\nexport interface InstalledApp {\n name: string;\n start_cmd: string;\n stop_cmd?: string;\n work_directory?: string;\n}\n\n/**\n * Represents a running process\n */\nexport interface Process {\n pname: string;\n pid: number;\n cmdline?: string;\n path?: string;\n}\n\n/**\n * Handles application operations in the AgentBay cloud environment.\n * \n * @deprecated This module is deprecated. Use Computer or Mobile modules instead.\n * - For desktop applications, use session.computer\n * - For mobile applications, use session.mobile\n */\nexport class Application {\n private session: {\n getAPIKey(): string;\n getClient(): Client;\n getSessionId(): string;\n callMcpTool(toolName: string, args: any): Promise<{\n success: boolean;\n data: string;\n errorMessage: string;\n requestId: string;\n }>;\n };\n\n /**\n * Initialize an Application object.\n *\n * @param session - The Session instance that this Application belongs to.\n */\n constructor(session: {\n getAPIKey(): string;\n getClient(): Client;\n getSessionId(): string;\n callMcpTool(toolName: string, args: any): Promise<{\n success: boolean;\n data: string;\n errorMessage: string;\n requestId: string;\n }>;\n }) {\n this.session = session;\n }\n\n /**\n * Sanitizes error messages to remove sensitive information like API keys.\n *\n * @param error - The error to sanitize\n * @returns The sanitized error\n */\n private sanitizeError(error: any): any {\n if (!error) {\n return error;\n }\n\n const errorString = String(error);\n return errorString.replace(/Bearer\\s+[^\\s]+/g, \"Bearer [REDACTED]\");\n }\n\n /**\n * Helper method to parse JSON string into objects\n */\n private parseJSON<T>(jsonString: string): T {\n try {\n return JSON.parse(jsonString);\n } catch (error) {\n throw new Error(`Failed to parse JSON: ${error}`);\n }\n }\n\n /**\n * Get a list of installed applications.\n *\n * @param startMenu - Whether to include start menu applications.\n * @param desktop - Whether to include desktop applications.\n * @param ignoreSystemApps - Whether to ignore system applications.\n * @returns A promise that resolves to the list of installed applications.\n * \n * @deprecated Use session.computer.getInstalledApps() for desktop or session.mobile.getInstalledApps() for mobile instead.\n */\n async getInstalledApps(\n startMenu = false,\n desktop = true,\n ignoreSystemApps = true\n ): Promise<InstalledAppListResult> {\n console.warn('⚠️ Application.getInstalledApps() is deprecated. Use session.computer.getInstalledApps() for desktop or session.mobile.getInstalledApps() for mobile instead.');\n \n try {\n const args = {\n start_menu: startMenu,\n desktop,\n ignore_system_apps: ignoreSystemApps,\n };\n\n const result = await this.session.callMcpTool(\"get_installed_apps\", args);\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: result.errorMessage,\n };\n }\n\n let apps: InstalledApp[] = [];\n try {\n apps = this.parseJSON<InstalledApp[]>(result.data);\n } catch (err) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: `Failed to parse installed apps: ${err}`,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n data: apps,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n data: [],\n errorMessage: `Failed to get installed apps: ${error}`,\n };\n }\n }\n\n /**\n * Start an application.\n *\n * @param startCmd - The command to start the application.\n * @param workDirectory - The working directory for the application.\n * @param activity - The activity to start (for mobile applications).\n * @returns A promise that resolves to the result of starting the application.\n * \n * @deprecated Use session.computer.startApp() for desktop or session.mobile.startApp() for mobile instead.\n */\n async startApp(\n startCmd: string,\n workDirectory = \"\",\n activity = \"\"\n ): Promise<ProcessListResult> {\n console.warn('⚠️ Application.startApp() is deprecated. Use session.computer.startApp() for desktop or session.mobile.startApp() for mobile instead.');\n \n try {\n const args = {\n start_cmd: startCmd,\n work_directory: workDirectory,\n activity,\n };\n\n const result = await this.session.callMcpTool(\"start_app\", args);\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: result.errorMessage,\n };\n }\n\n let processes: Process[] = [];\n try {\n processes = this.parseJSON<Process[]>(result.data);\n } catch (err) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: `Failed to parse processes: ${err}`,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n data: processes,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n data: [],\n errorMessage: `Failed to start app: ${error}`,\n };\n }\n }\n\n /**\n * Stop an application by process name.\n *\n * @param pname - The process name of the application to stop.\n * @returns A promise that resolves to the result of stopping the application.\n * \n * @deprecated Use session.computer.stopAppByPName() for desktop or session.mobile.stopAppByPName() for mobile instead.\n */\n async stopAppByPName(pname: string): Promise<AppOperationResult> {\n console.warn('⚠️ Application.stopAppByPName() is deprecated. Use session.computer.stopAppByPName() for desktop or session.mobile.stopAppByPName() for mobile instead.');\n \n try {\n const args = { pname };\n const result = await this.session.callMcpTool(\"stop_app_by_pname\", args);\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n errorMessage: result.errorMessage,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to stop app by process name: ${error}`,\n };\n }\n }\n\n /**\n * Stops an application by process ID.\n * Corresponds to Python's stop_app_by_pid() method\n *\n * @param pid - The process ID to stop.\n * @returns AppOperationResult with operation result and requestId\n * @throws Error if the operation fails.\n */\n async stopAppByPID(pid: number): Promise<AppOperationResult> {\n try {\n const args = { pid };\n const result = await this.session.callMcpTool(\"stop_app_by_pid\", args);\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n errorMessage: result.errorMessage,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to stop app by process ID: ${error}`,\n };\n }\n }\n\n /**\n * Stop an application by command.\n *\n * @param cmd - The command to stop the application.\n * @returns A promise that resolves to the result of stopping the application.\n * \n * @deprecated Use session.computer.stopAppByCmd() for desktop or session.mobile.stopAppByCmd() for mobile instead.\n */\n async stopAppByCmd(cmd: string): Promise<AppOperationResult> {\n console.warn('⚠️ Application.stopAppByCmd() is deprecated. Use session.computer.stopAppByCmd() for desktop or session.mobile.stopAppByCmd() for mobile instead.');\n \n try {\n const args = { stop_cmd: cmd };\n const result = await this.session.callMcpTool(\"stop_app_by_cmd\", args);\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n errorMessage: result.errorMessage,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to stop app by command: ${error}`,\n };\n }\n }\n\n /**\n * Returns a list of currently visible applications.\n * Corresponds to Python's list_visible_apps() method\n *\n * @returns ProcessListResult with visible apps and requestId\n * @throws Error if the operation fails.\n */\n async listVisibleApps(): Promise<ProcessListResult> {\n try {\n const result = await this.session.callMcpTool(\"list_visible_apps\", {});\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: result.errorMessage,\n };\n }\n\n let processes: Process[] = [];\n try {\n processes = this.parseJSON<Process[]>(result.data);\n } catch (err) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: `Failed to parse visible apps: ${err}`,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n data: processes,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n data: [],\n errorMessage: `Failed to list visible apps: ${error}`,\n };\n }\n }\n\n /**\n * Get a list of running processes.\n *\n * @returns A promise that resolves to the list of running processes.\n * \n * @deprecated Use session.computer.getRunningProcesses() for desktop or session.mobile.getRunningProcesses() for mobile instead.\n */\n async getRunningProcesses(): Promise<ProcessListResult> {\n console.warn('⚠️ Application.getRunningProcesses() is deprecated. Use session.computer.getRunningProcesses() for desktop or session.mobile.getRunningProcesses() for mobile instead.');\n \n try {\n const result = await this.session.callMcpTool(\"list_running_processes\", {});\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: result.errorMessage,\n };\n }\n\n let processes: Process[] = [];\n try {\n processes = this.parseJSON<Process[]>(result.data);\n } catch (err) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: `Failed to parse running processes: ${err}`,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n data: processes,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n data: [],\n errorMessage: `Failed to get running processes: ${error}`,\n };\n }\n }\n\n /**\n * Get a list of visible applications.\n *\n * @returns A promise that resolves to the list of visible applications.\n * \n * @deprecated Use session.computer.getVisibleApps() for desktop instead. This API is not available for mobile.\n */\n async getVisibleApps(): Promise<InstalledAppListResult> {\n console.warn('⚠️ Application.getVisibleApps() is deprecated. Use session.computer.getVisibleApps() for desktop instead. This API is not available for mobile.');\n \n try {\n const result = await this.session.callMcpTool(\"list_visible_apps\", {});\n\n if (!result.success) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: result.errorMessage,\n };\n }\n\n let apps: InstalledApp[] = [];\n try {\n apps = this.parseJSON<InstalledApp[]>(result.data);\n } catch (err) {\n return {\n requestId: result.requestId,\n success: false,\n data: [],\n errorMessage: `Failed to parse visible apps: ${err}`,\n };\n }\n\n return {\n requestId: result.requestId,\n success: true,\n data: apps,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n data: [],\n errorMessage: `Failed to get visible apps: ${error}`,\n };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAmCO,IAAM,eAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBvB,YAAY,SAUT;AACD,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,cAAc,OAAiB;AACrC,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AAEA,UAAM,cAAc,OAAO,KAAK;AAChC,WAAO,YAAY,QAAQ,oBAAoB,mBAAmB;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAKQ,UAAa,YAAuB;A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;AAAA,IACF,SAAS,OAAO;AACd,aAAO;AAAA,QACL,WAAW;AAAA,QACX,SAAS;AAAA,QACT,MAAM,CAAC;AAAA,QACP,cAAc,oCAAoC,KAAK;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,iBAAkD;AACtD,YAAQ,KAAK,4JAAkJ;AAE/J,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,QAAQ,YAAY,qBAAqB,CAAC,CAAC;AAErE,UAAI,CAAC,OAAO,SAAS;AACnB,eAAO;AAAA,UACL,WAAW,OAAO;AAAA,UAClB,SAAS;AAAA,UACT,MAAM,CAAC;AAAA,UACP,cAAc,OAAO;AAAA,QACvB;AAAA,MACF;AAEA,UAAI,OAAuB,CAAC;AAC5B,UAAI;AACF,eAAO,KAAK,UAA0B,OAAO,IAAI;AAAA,MACnD,SAAS,KAAK;AACZ,eAAO;AAAA,UACL,WAAW,OAAO;AAAA,UAClB,SAAS;AAAA,UACT,MAAM,CAAC;AAAA,UACP,cAAc,iCAAiC,GAAG;AAAA,QACpD;AAAA,MACF;AAEA,aAAO;AAAA,QACL,WAAW,OAAO;AAAA,QAClB,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,IACF,SAAS,OAAO;AACd,aAAO;AAAA,QACL,WAAW;AAAA,QACX,SAAS;AAAA,QACT,MAAM,CAAC;AAAA,QACP,cAAc,+BAA+B,KAAK;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACF;AAhbyB;AAAlB,IAAM,cAAN;","names":[]}
@@ -1,48 +1,10 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
- var __esm = (fn, res) => function __init() {
15
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
- };
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
36
2
 
37
- // node_modules/tsup/assets/cjs_shims.js
38
- var init_cjs_shims = __esm({
39
- "node_modules/tsup/assets/cjs_shims.js"() {
40
- "use strict";
41
- }
42
- });
3
+
4
+ var _chunk4IPTHWLMcjs = require('./chunk-4IPTHWLM.cjs');
43
5
 
44
6
  // src/window/window.ts
45
- init_cjs_shims();
7
+ _chunk4IPTHWLMcjs.init_cjs_shims.call(void 0, );
46
8
  var _WindowManager = class _WindowManager {
47
9
  /**
48
10
  * Creates a new WindowManager instance.
@@ -587,15 +549,10 @@ var _WindowManager = class _WindowManager {
587
549
  }
588
550
  }
589
551
  };
590
- __name(_WindowManager, "WindowManager");
552
+ _chunk4IPTHWLMcjs.__name.call(void 0, _WindowManager, "WindowManager");
591
553
  var WindowManager = _WindowManager;
592
554
 
593
555
 
594
556
 
595
-
596
-
597
-
598
-
599
-
600
- exports.__name = __name; exports.__require = __require; exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.init_cjs_shims = init_cjs_shims; exports.WindowManager = WindowManager;
601
- //# sourceMappingURL=chunk-KOCCRN77.cjs.map
557
+ exports.WindowManager = WindowManager;
558
+ //# sourceMappingURL=chunk-IOVGAAJL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/chunk-IOVGAAJL.cjs","../src/window/window.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8CAAA,CAAA;AA+BO,IAAM,eAAA,EAAN,MAAM,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBzB,WAAA,CAAY,OAAA,EAST;AACD,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,oBAAA,CAAqB,OAAA,EAA2B;AACtD,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,EAAS,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA;AACjC,MAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,MAAM,EAAA,EAAI,OAAA,EAAS,CAAC,MAAM,CAAA;AAAA,IACjD,EAAA,MAAA,CAAS,KAAA,EAAO;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,6BAAA,EAAgC,KAAK,CAAA,CAAA;AACvD,IAAA;AACF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWm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MAAA;AAClC,QAAA;AACA,QAAA;AACF,MAAA;AAEuB,MAAA;AACd,QAAA;AACe,UAAA;AACX,UAAA;AACc,UAAA;AACzB,QAAA;AACF,MAAA;AAEuC,MAAA;AACpB,MAAA;AACkC,QAAA;AACF,QAAA;AACnD,MAAA;AAEO,MAAA;AACe,QAAA;AACX,QAAA;AACD,QAAA;AACV,MAAA;AACc,IAAA;AACP,MAAA;AACM,QAAA;AACF,QAAA;AAC0C,QAAA;AACrD,MAAA;AACF,IAAA;AACF,EAAA;AACF;AA5nB2B;AAApB;AD0gBqD;AACA;AACA;AACA","file":"/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/chunk-IOVGAAJL.cjs","sourcesContent":[null,"\nimport {\n WindowListResult,\n WindowInfoResult,\n BoolResult,\n} from \"../types/api-response\";\n\n\n\n/**\n * Represents a window in the system.\n */\nexport interface Window {\n window_id: number;\n title: string;\n absolute_upper_left_x?: number;\n absolute_upper_left_y?: number;\n width?: number;\n height?: number;\n pid?: number;\n pname?: string;\n child_windows?: Window[];\n}\n\n/**\n * Handles window management operations in the AgentBay cloud environment.\n * \n * @deprecated This module is deprecated. Use Computer module instead.\n * - For desktop window operations, use session.computer\n * - Window operations are not available for mobile\n */\nexport class WindowManager {\n private session: {\n getAPIKey(): string;\n getSessionId(): string;\n callMcpTool(toolName: string, args: any): Promise<{\n success: boolean;\n data: string;\n errorMessage: string;\n requestId: string;\n }>;\n };\n\n /**\n * Creates a new WindowManager instance.\n * @param session The session object that provides access to the AgentBay API.\n */\n constructor(session: {\n getAPIKey(): string;\n getSessionId(): string;\n callMcpTool(toolName: string, args: any): Promise<{\n success: boolean;\n data: string;\n errorMessage: string;\n requestId: string;\n }>;\n }) {\n this.session = session;\n }\n\n\n\n /**\n * Helper method to parse JSON string into Window objects\n * @param jsonStr - JSON string to parse\n * @returns Array of Window objects or single Window object\n */\n private parseWindowsFromJSON(jsonStr: string): Window[] {\n try {\n const parsed = JSON.parse(jsonStr);\n return Array.isArray(parsed) ? parsed : [parsed];\n } catch (error) {\n throw new Error(`Failed to parse window data: ${error}`);\n }\n }\n\n /**\n * Lists all root windows in the system.\n * Corresponds to Python's list_root_windows() method\n *\n * @param timeoutMs - The timeout in milliseconds. Default is 3000ms.\n * @returns WindowListResult with windows array and requestId\n * \n * @deprecated Use session.computer.listRootWindows() instead.\n */\n async listRootWindows(timeoutMs = 3000): Promise<WindowListResult> {\n console.warn('⚠️ WindowManager.listRootWindows() is deprecated. Use session.computer.listRootWindows() instead.');\n \n try {\n const args = {\n timeout_ms: timeoutMs,\n };\n\n const response = await this.session.callMcpTool(\n \"list_root_windows\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n windows: [],\n errorMessage: response.errorMessage,\n };\n }\n\n const windows = response.data\n ? this.parseWindowsFromJSON(response.data)\n : [];\n\n return {\n requestId: response.requestId,\n success: true,\n windows,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n windows: [],\n errorMessage: `Failed to list root windows: ${error}`,\n };\n }\n }\n\n /**\n * Lists all windows in the system.\n * Corresponds to Python's list_all_windows() method\n *\n * @param timeoutMs - The timeout in milliseconds. Default is 3000ms.\n * @returns WindowListResult with windows array and requestId\n * \n * @deprecated Use session.computer.listAllWindows() instead.\n */\n async listAllWindows(timeoutMs = 3000): Promise<WindowListResult> {\n console.warn('⚠️ WindowManager.listAllWindows() is deprecated. Use session.computer.listAllWindows() instead.');\n \n try {\n const args = {\n timeout_ms: timeoutMs,\n };\n\n const response = await this.session.callMcpTool(\n \"list_all_windows\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n windows: [],\n errorMessage: response.errorMessage,\n };\n }\n\n const windows = response.data\n ? this.parseWindowsFromJSON(response.data)\n : [];\n\n return {\n requestId: response.requestId,\n success: true,\n windows,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n windows: [],\n errorMessage: `Failed to list all windows: ${error}`,\n };\n }\n }\n\n /**\n * Gets information about a specific window.\n * Corresponds to Python's get_window_info() method\n *\n * @param windowId - The ID of the window to get information for.\n * @returns WindowInfoResult with window information and requestId\n * \n * @deprecated Use session.computer.getWindowInfo() instead.\n */\n async getWindowInfo(windowId: number): Promise<WindowInfoResult> {\n console.warn('⚠️ WindowManager.getWindowInfo() is deprecated. Use session.computer.getWindowInfo() instead.');\n \n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"get_window_info\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n let window: Window | undefined = undefined;\n if (response.data) {\n const windows = this.parseWindowsFromJSON(response.data);\n window = windows.length > 0 ? windows[0] : undefined;\n }\n\n return {\n requestId: response.requestId,\n success: true,\n window,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to get window info: ${error}`,\n };\n }\n }\n\n /**\n * Activates a window by bringing it to the foreground.\n * Corresponds to Python's activate_window() method\n *\n * @param windowId - The ID of the window to activate.\n * @returns BoolResult with success status and requestId\n * \n * @deprecated Use session.computer.activateWindow() instead.\n */\n async activateWindow(windowId: number): Promise<BoolResult> {\n console.warn('⚠️ WindowManager.activateWindow() is deprecated. Use session.computer.activateWindow() instead.');\n \n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"activate_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to activate window: ${error}`,\n };\n }\n }\n\n /**\n * Maximizes a window.\n * Corresponds to Python's maximize_window() method\n *\n * @param windowId - The ID of the window to maximize.\n * @returns BoolResult with success status and requestId\n * \n * @deprecated Use session.computer.maximizeWindow() instead.\n */\n async maximizeWindow(windowId: number): Promise<BoolResult> {\n console.warn('⚠️ WindowManager.maximizeWindow() is deprecated. Use session.computer.maximizeWindow() instead.');\n \n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"maximize_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to maximize window: ${error}`,\n };\n }\n }\n\n /**\n * Minimizes a window.\n * Corresponds to Python's minimize_window() method\n *\n * @param windowId - The ID of the window to minimize.\n * @returns BoolResult with success status and requestId\n * \n * @deprecated Use session.computer.minimizeWindow() instead.\n */\n async minimizeWindow(windowId: number): Promise<BoolResult> {\n console.warn('⚠️ WindowManager.minimizeWindow() is deprecated. Use session.computer.minimizeWindow() instead.');\n \n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"minimize_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to minimize window: ${error}`,\n };\n }\n }\n\n /**\n * Restores a window by ID.\n * Corresponds to Python's restore_window() method\n *\n * @param windowId The ID of the window to restore.\n * @returns BoolResult with requestId\n */\n async restoreWindow(windowId: number): Promise<BoolResult> {\n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"restore_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to restore window: ${error}`,\n };\n }\n }\n\n /**\n * Closes a window.\n * Corresponds to Python's close_window() method\n *\n * @param windowId - The ID of the window to close.\n * @returns BoolResult with success status and requestId\n * \n * @deprecated Use session.computer.closeWindow() instead.\n */\n async closeWindow(windowId: number): Promise<BoolResult> {\n console.warn('⚠️ WindowManager.closeWindow() is deprecated. Use session.computer.closeWindow() instead.');\n \n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"close_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to close window: ${error}`,\n };\n }\n }\n\n /**\n * Sets a window to fullscreen by ID.\n * Corresponds to Python's fullscreen_window() method\n *\n * @param windowId The ID of the window to set to fullscreen.\n * @returns BoolResult with requestId\n */\n async fullscreenWindow(windowId: number): Promise<BoolResult> {\n try {\n const args = {\n window_id: windowId,\n };\n\n const response = await this.session.callMcpTool(\n \"fullscreen_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to make window fullscreen: ${error}`,\n };\n }\n }\n\n /**\n * Resizes a window to the specified dimensions.\n * Corresponds to Python's resize_window() method\n *\n * @param windowId - The ID of the window to resize.\n * @param width - The new width of the window.\n * @param height - The new height of the window.\n * @returns BoolResult with success status and requestId\n * \n * @deprecated Use session.computer.resizeWindow() instead.\n */\n async resizeWindow(windowId: number, width: number, height: number): Promise<BoolResult> {\n console.warn('⚠️ WindowManager.resizeWindow() is deprecated. Use session.computer.resizeWindow() instead.');\n \n try {\n const args = {\n window_id: windowId,\n width,\n height,\n };\n\n const response = await this.session.callMcpTool(\n \"resize_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to resize window: ${error}`,\n };\n }\n }\n\n /**\n * Moves a window to the specified position.\n * Corresponds to Python's move_window() method\n *\n * @param windowId - The ID of the window to move.\n * @param x - The new x coordinate of the window.\n * @param y - The new y coordinate of the window.\n * @returns BoolResult with success status and requestId\n * \n * @deprecated Use session.computer.moveWindow() instead.\n */\n async moveWindow(windowId: number, x: number, y: number): Promise<BoolResult> {\n console.warn('⚠️ WindowManager.moveWindow() is deprecated. Use session.computer.moveWindow() instead.');\n \n try {\n const args = {\n window_id: windowId,\n x,\n y,\n };\n\n const response = await this.session.callMcpTool(\n \"move_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to move window: ${error}`,\n };\n }\n }\n\n /**\n * Enables or disables focus mode.\n * Corresponds to Python's focus_mode() method\n *\n * @param on Whether to enable focus mode.\n * @returns BoolResult with requestId\n */\n async focusMode(on: boolean): Promise<BoolResult> {\n try {\n const args = {\n on,\n };\n\n const response = await this.session.callMcpTool(\n \"focus_mode\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n return {\n requestId: response.requestId,\n success: true,\n data: true,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to toggle focus mode: ${error}`,\n };\n }\n }\n\n /**\n * Gets the currently active window.\n * Corresponds to Python's get_active_window() method\n *\n * @param timeoutMs - The timeout in milliseconds. Default is 3000ms.\n * @returns WindowInfoResult with active window information and requestId\n * \n * @deprecated Use session.computer.getActiveWindow() instead.\n */\n async getActiveWindow(timeoutMs = 3000): Promise<WindowInfoResult> {\n console.warn('⚠️ WindowManager.getActiveWindow() is deprecated. Use session.computer.getActiveWindow() instead.');\n \n try {\n const args = {\n timeout_ms: timeoutMs,\n };\n\n const response = await this.session.callMcpTool(\n \"get_active_window\",\n args\n );\n\n if (!response.success) {\n return {\n requestId: response.requestId,\n success: false,\n errorMessage: response.errorMessage,\n };\n }\n\n let activeWindow: Window | undefined = undefined;\n if (response.data) {\n const windows = this.parseWindowsFromJSON(response.data);\n activeWindow = windows.length > 0 ? windows[0] : undefined;\n }\n\n return {\n requestId: response.requestId,\n success: true,\n window: activeWindow,\n };\n } catch (error) {\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to get active window: ${error}`,\n };\n }\n }\n}\n"]}