wuying-agentbay-sdk 0.8.0 → 0.9.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/tsup/assets/esm_shims.js","../src/window/window.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;;;ACAA;AA+BO,IAAM,iBAAN,MAAM,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBzB,YAAY,SAST;AACD,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,qBAAqB,SAA2B;AACtD,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,OAAO;AACjC,aAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AAAA,IACjD,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,gCAAgC,KAAK,EAAE;AAAA,IACzD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,gBAAgB,YAAY,KAAiC;AACjE,YAAQ,KAAK,8GAAoG;AAEjH,QAAI;AACF,YAAM,OAAO;AAAA,QACX,YAAY;AAAA,MACd;AAEA,YAAM,WAAW,MAAM,KAAK,QAAQ;AAAA,QAClC;AAAA,QACA;AAAA,MACF;AAEA,UAAI,CAAC,SAAS,SAAS;AACrB,eAAO;AAAA,UACL,WAAW,SAAS;AAAA,UACpB,SAAS;AAAA,UACT,SAAS,CAAC;AAAA,UACV,cAAc,SAAS;AAAA,QACzB;AAAA,MACF;AAEA,YAAM,UAAU,SAA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AAI;AACvD,uBAAe,QAAQ,SAAS,IAAI,QAAQ,CAAC,IAAI;AAAA,MACnD;AAEA,aAAO;AAAA,QACL,WAAW,SAAS;AAAA,QACpB,SAAS;AAAA,QACT,QAAQ;AAAA,MACV;AAAA,IACF,SAAS,OAAO;AACd,aAAO;AAAA,QACL,WAAW;AAAA,QACX,SAAS;AAAA,QACT,cAAc,gCAAgC,KAAK;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;AA5nB2B;AAApB,IAAM,gBAAN;","names":[]}
@@ -0,0 +1,601 @@
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
+ // src/window/window.ts
45
+ init_cjs_shims();
46
+ var _WindowManager = class _WindowManager {
47
+ /**
48
+ * Creates a new WindowManager instance.
49
+ * @param session The session object that provides access to the AgentBay API.
50
+ */
51
+ constructor(session) {
52
+ this.session = session;
53
+ }
54
+ /**
55
+ * Helper method to parse JSON string into Window objects
56
+ * @param jsonStr - JSON string to parse
57
+ * @returns Array of Window objects or single Window object
58
+ */
59
+ parseWindowsFromJSON(jsonStr) {
60
+ try {
61
+ const parsed = JSON.parse(jsonStr);
62
+ return Array.isArray(parsed) ? parsed : [parsed];
63
+ } catch (error) {
64
+ throw new Error(`Failed to parse window data: ${error}`);
65
+ }
66
+ }
67
+ /**
68
+ * Lists all root windows in the system.
69
+ * Corresponds to Python's list_root_windows() method
70
+ *
71
+ * @param timeoutMs - The timeout in milliseconds. Default is 3000ms.
72
+ * @returns WindowListResult with windows array and requestId
73
+ *
74
+ * @deprecated Use session.computer.listRootWindows() instead.
75
+ */
76
+ async listRootWindows(timeoutMs = 3e3) {
77
+ console.warn("\u26A0\uFE0F WindowManager.listRootWindows() is deprecated. Use session.computer.listRootWindows() instead.");
78
+ try {
79
+ const args = {
80
+ timeout_ms: timeoutMs
81
+ };
82
+ const response = await this.session.callMcpTool(
83
+ "list_root_windows",
84
+ args
85
+ );
86
+ if (!response.success) {
87
+ return {
88
+ requestId: response.requestId,
89
+ success: false,
90
+ windows: [],
91
+ errorMessage: response.errorMessage
92
+ };
93
+ }
94
+ const windows = response.data ? this.parseWindowsFromJSON(response.data) : [];
95
+ return {
96
+ requestId: response.requestId,
97
+ success: true,
98
+ windows
99
+ };
100
+ } catch (error) {
101
+ return {
102
+ requestId: "",
103
+ success: false,
104
+ windows: [],
105
+ errorMessage: `Failed to list root windows: ${error}`
106
+ };
107
+ }
108
+ }
109
+ /**
110
+ * Lists all windows in the system.
111
+ * Corresponds to Python's list_all_windows() method
112
+ *
113
+ * @param timeoutMs - The timeout in milliseconds. Default is 3000ms.
114
+ * @returns WindowListResult with windows array and requestId
115
+ *
116
+ * @deprecated Use session.computer.listAllWindows() instead.
117
+ */
118
+ async listAllWindows(timeoutMs = 3e3) {
119
+ console.warn("\u26A0\uFE0F WindowManager.listAllWindows() is deprecated. Use session.computer.listAllWindows() instead.");
120
+ try {
121
+ const args = {
122
+ timeout_ms: timeoutMs
123
+ };
124
+ const response = await this.session.callMcpTool(
125
+ "list_all_windows",
126
+ args
127
+ );
128
+ if (!response.success) {
129
+ return {
130
+ requestId: response.requestId,
131
+ success: false,
132
+ windows: [],
133
+ errorMessage: response.errorMessage
134
+ };
135
+ }
136
+ const windows = response.data ? this.parseWindowsFromJSON(response.data) : [];
137
+ return {
138
+ requestId: response.requestId,
139
+ success: true,
140
+ windows
141
+ };
142
+ } catch (error) {
143
+ return {
144
+ requestId: "",
145
+ success: false,
146
+ windows: [],
147
+ errorMessage: `Failed to list all windows: ${error}`
148
+ };
149
+ }
150
+ }
151
+ /**
152
+ * Gets information about a specific window.
153
+ * Corresponds to Python's get_window_info() method
154
+ *
155
+ * @param windowId - The ID of the window to get information for.
156
+ * @returns WindowInfoResult with window information and requestId
157
+ *
158
+ * @deprecated Use session.computer.getWindowInfo() instead.
159
+ */
160
+ async getWindowInfo(windowId) {
161
+ console.warn("\u26A0\uFE0F WindowManager.getWindowInfo() is deprecated. Use session.computer.getWindowInfo() instead.");
162
+ try {
163
+ const args = {
164
+ window_id: windowId
165
+ };
166
+ const response = await this.session.callMcpTool(
167
+ "get_window_info",
168
+ args
169
+ );
170
+ if (!response.success) {
171
+ return {
172
+ requestId: response.requestId,
173
+ success: false,
174
+ errorMessage: response.errorMessage
175
+ };
176
+ }
177
+ let window = void 0;
178
+ if (response.data) {
179
+ const windows = this.parseWindowsFromJSON(response.data);
180
+ window = windows.length > 0 ? windows[0] : void 0;
181
+ }
182
+ return {
183
+ requestId: response.requestId,
184
+ success: true,
185
+ window
186
+ };
187
+ } catch (error) {
188
+ return {
189
+ requestId: "",
190
+ success: false,
191
+ errorMessage: `Failed to get window info: ${error}`
192
+ };
193
+ }
194
+ }
195
+ /**
196
+ * Activates a window by bringing it to the foreground.
197
+ * Corresponds to Python's activate_window() method
198
+ *
199
+ * @param windowId - The ID of the window to activate.
200
+ * @returns BoolResult with success status and requestId
201
+ *
202
+ * @deprecated Use session.computer.activateWindow() instead.
203
+ */
204
+ async activateWindow(windowId) {
205
+ console.warn("\u26A0\uFE0F WindowManager.activateWindow() is deprecated. Use session.computer.activateWindow() instead.");
206
+ try {
207
+ const args = {
208
+ window_id: windowId
209
+ };
210
+ const response = await this.session.callMcpTool(
211
+ "activate_window",
212
+ args
213
+ );
214
+ if (!response.success) {
215
+ return {
216
+ requestId: response.requestId,
217
+ success: false,
218
+ errorMessage: response.errorMessage
219
+ };
220
+ }
221
+ return {
222
+ requestId: response.requestId,
223
+ success: true,
224
+ data: true
225
+ };
226
+ } catch (error) {
227
+ return {
228
+ requestId: "",
229
+ success: false,
230
+ errorMessage: `Failed to activate window: ${error}`
231
+ };
232
+ }
233
+ }
234
+ /**
235
+ * Maximizes a window.
236
+ * Corresponds to Python's maximize_window() method
237
+ *
238
+ * @param windowId - The ID of the window to maximize.
239
+ * @returns BoolResult with success status and requestId
240
+ *
241
+ * @deprecated Use session.computer.maximizeWindow() instead.
242
+ */
243
+ async maximizeWindow(windowId) {
244
+ console.warn("\u26A0\uFE0F WindowManager.maximizeWindow() is deprecated. Use session.computer.maximizeWindow() instead.");
245
+ try {
246
+ const args = {
247
+ window_id: windowId
248
+ };
249
+ const response = await this.session.callMcpTool(
250
+ "maximize_window",
251
+ args
252
+ );
253
+ if (!response.success) {
254
+ return {
255
+ requestId: response.requestId,
256
+ success: false,
257
+ errorMessage: response.errorMessage
258
+ };
259
+ }
260
+ return {
261
+ requestId: response.requestId,
262
+ success: true,
263
+ data: true
264
+ };
265
+ } catch (error) {
266
+ return {
267
+ requestId: "",
268
+ success: false,
269
+ errorMessage: `Failed to maximize window: ${error}`
270
+ };
271
+ }
272
+ }
273
+ /**
274
+ * Minimizes a window.
275
+ * Corresponds to Python's minimize_window() method
276
+ *
277
+ * @param windowId - The ID of the window to minimize.
278
+ * @returns BoolResult with success status and requestId
279
+ *
280
+ * @deprecated Use session.computer.minimizeWindow() instead.
281
+ */
282
+ async minimizeWindow(windowId) {
283
+ console.warn("\u26A0\uFE0F WindowManager.minimizeWindow() is deprecated. Use session.computer.minimizeWindow() instead.");
284
+ try {
285
+ const args = {
286
+ window_id: windowId
287
+ };
288
+ const response = await this.session.callMcpTool(
289
+ "minimize_window",
290
+ args
291
+ );
292
+ if (!response.success) {
293
+ return {
294
+ requestId: response.requestId,
295
+ success: false,
296
+ errorMessage: response.errorMessage
297
+ };
298
+ }
299
+ return {
300
+ requestId: response.requestId,
301
+ success: true,
302
+ data: true
303
+ };
304
+ } catch (error) {
305
+ return {
306
+ requestId: "",
307
+ success: false,
308
+ errorMessage: `Failed to minimize window: ${error}`
309
+ };
310
+ }
311
+ }
312
+ /**
313
+ * Restores a window by ID.
314
+ * Corresponds to Python's restore_window() method
315
+ *
316
+ * @param windowId The ID of the window to restore.
317
+ * @returns BoolResult with requestId
318
+ */
319
+ async restoreWindow(windowId) {
320
+ try {
321
+ const args = {
322
+ window_id: windowId
323
+ };
324
+ const response = await this.session.callMcpTool(
325
+ "restore_window",
326
+ args
327
+ );
328
+ if (!response.success) {
329
+ return {
330
+ requestId: response.requestId,
331
+ success: false,
332
+ errorMessage: response.errorMessage
333
+ };
334
+ }
335
+ return {
336
+ requestId: response.requestId,
337
+ success: true,
338
+ data: true
339
+ };
340
+ } catch (error) {
341
+ return {
342
+ requestId: "",
343
+ success: false,
344
+ errorMessage: `Failed to restore window: ${error}`
345
+ };
346
+ }
347
+ }
348
+ /**
349
+ * Closes a window.
350
+ * Corresponds to Python's close_window() method
351
+ *
352
+ * @param windowId - The ID of the window to close.
353
+ * @returns BoolResult with success status and requestId
354
+ *
355
+ * @deprecated Use session.computer.closeWindow() instead.
356
+ */
357
+ async closeWindow(windowId) {
358
+ console.warn("\u26A0\uFE0F WindowManager.closeWindow() is deprecated. Use session.computer.closeWindow() instead.");
359
+ try {
360
+ const args = {
361
+ window_id: windowId
362
+ };
363
+ const response = await this.session.callMcpTool(
364
+ "close_window",
365
+ args
366
+ );
367
+ if (!response.success) {
368
+ return {
369
+ requestId: response.requestId,
370
+ success: false,
371
+ errorMessage: response.errorMessage
372
+ };
373
+ }
374
+ return {
375
+ requestId: response.requestId,
376
+ success: true,
377
+ data: true
378
+ };
379
+ } catch (error) {
380
+ return {
381
+ requestId: "",
382
+ success: false,
383
+ errorMessage: `Failed to close window: ${error}`
384
+ };
385
+ }
386
+ }
387
+ /**
388
+ * Sets a window to fullscreen by ID.
389
+ * Corresponds to Python's fullscreen_window() method
390
+ *
391
+ * @param windowId The ID of the window to set to fullscreen.
392
+ * @returns BoolResult with requestId
393
+ */
394
+ async fullscreenWindow(windowId) {
395
+ try {
396
+ const args = {
397
+ window_id: windowId
398
+ };
399
+ const response = await this.session.callMcpTool(
400
+ "fullscreen_window",
401
+ args
402
+ );
403
+ if (!response.success) {
404
+ return {
405
+ requestId: response.requestId,
406
+ success: false,
407
+ errorMessage: response.errorMessage
408
+ };
409
+ }
410
+ return {
411
+ requestId: response.requestId,
412
+ success: true,
413
+ data: true
414
+ };
415
+ } catch (error) {
416
+ return {
417
+ requestId: "",
418
+ success: false,
419
+ errorMessage: `Failed to make window fullscreen: ${error}`
420
+ };
421
+ }
422
+ }
423
+ /**
424
+ * Resizes a window to the specified dimensions.
425
+ * Corresponds to Python's resize_window() method
426
+ *
427
+ * @param windowId - The ID of the window to resize.
428
+ * @param width - The new width of the window.
429
+ * @param height - The new height of the window.
430
+ * @returns BoolResult with success status and requestId
431
+ *
432
+ * @deprecated Use session.computer.resizeWindow() instead.
433
+ */
434
+ async resizeWindow(windowId, width, height) {
435
+ console.warn("\u26A0\uFE0F WindowManager.resizeWindow() is deprecated. Use session.computer.resizeWindow() instead.");
436
+ try {
437
+ const args = {
438
+ window_id: windowId,
439
+ width,
440
+ height
441
+ };
442
+ const response = await this.session.callMcpTool(
443
+ "resize_window",
444
+ args
445
+ );
446
+ if (!response.success) {
447
+ return {
448
+ requestId: response.requestId,
449
+ success: false,
450
+ errorMessage: response.errorMessage
451
+ };
452
+ }
453
+ return {
454
+ requestId: response.requestId,
455
+ success: true,
456
+ data: true
457
+ };
458
+ } catch (error) {
459
+ return {
460
+ requestId: "",
461
+ success: false,
462
+ errorMessage: `Failed to resize window: ${error}`
463
+ };
464
+ }
465
+ }
466
+ /**
467
+ * Moves a window to the specified position.
468
+ * Corresponds to Python's move_window() method
469
+ *
470
+ * @param windowId - The ID of the window to move.
471
+ * @param x - The new x coordinate of the window.
472
+ * @param y - The new y coordinate of the window.
473
+ * @returns BoolResult with success status and requestId
474
+ *
475
+ * @deprecated Use session.computer.moveWindow() instead.
476
+ */
477
+ async moveWindow(windowId, x, y) {
478
+ console.warn("\u26A0\uFE0F WindowManager.moveWindow() is deprecated. Use session.computer.moveWindow() instead.");
479
+ try {
480
+ const args = {
481
+ window_id: windowId,
482
+ x,
483
+ y
484
+ };
485
+ const response = await this.session.callMcpTool(
486
+ "move_window",
487
+ args
488
+ );
489
+ if (!response.success) {
490
+ return {
491
+ requestId: response.requestId,
492
+ success: false,
493
+ errorMessage: response.errorMessage
494
+ };
495
+ }
496
+ return {
497
+ requestId: response.requestId,
498
+ success: true,
499
+ data: true
500
+ };
501
+ } catch (error) {
502
+ return {
503
+ requestId: "",
504
+ success: false,
505
+ errorMessage: `Failed to move window: ${error}`
506
+ };
507
+ }
508
+ }
509
+ /**
510
+ * Enables or disables focus mode.
511
+ * Corresponds to Python's focus_mode() method
512
+ *
513
+ * @param on Whether to enable focus mode.
514
+ * @returns BoolResult with requestId
515
+ */
516
+ async focusMode(on) {
517
+ try {
518
+ const args = {
519
+ on
520
+ };
521
+ const response = await this.session.callMcpTool(
522
+ "focus_mode",
523
+ args
524
+ );
525
+ if (!response.success) {
526
+ return {
527
+ requestId: response.requestId,
528
+ success: false,
529
+ errorMessage: response.errorMessage
530
+ };
531
+ }
532
+ return {
533
+ requestId: response.requestId,
534
+ success: true,
535
+ data: true
536
+ };
537
+ } catch (error) {
538
+ return {
539
+ requestId: "",
540
+ success: false,
541
+ errorMessage: `Failed to toggle focus mode: ${error}`
542
+ };
543
+ }
544
+ }
545
+ /**
546
+ * Gets the currently active window.
547
+ * Corresponds to Python's get_active_window() method
548
+ *
549
+ * @param timeoutMs - The timeout in milliseconds. Default is 3000ms.
550
+ * @returns WindowInfoResult with active window information and requestId
551
+ *
552
+ * @deprecated Use session.computer.getActiveWindow() instead.
553
+ */
554
+ async getActiveWindow(timeoutMs = 3e3) {
555
+ console.warn("\u26A0\uFE0F WindowManager.getActiveWindow() is deprecated. Use session.computer.getActiveWindow() instead.");
556
+ try {
557
+ const args = {
558
+ timeout_ms: timeoutMs
559
+ };
560
+ const response = await this.session.callMcpTool(
561
+ "get_active_window",
562
+ args
563
+ );
564
+ if (!response.success) {
565
+ return {
566
+ requestId: response.requestId,
567
+ success: false,
568
+ errorMessage: response.errorMessage
569
+ };
570
+ }
571
+ let activeWindow = void 0;
572
+ if (response.data) {
573
+ const windows = this.parseWindowsFromJSON(response.data);
574
+ activeWindow = windows.length > 0 ? windows[0] : void 0;
575
+ }
576
+ return {
577
+ requestId: response.requestId,
578
+ success: true,
579
+ window: activeWindow
580
+ };
581
+ } catch (error) {
582
+ return {
583
+ requestId: "",
584
+ success: false,
585
+ errorMessage: `Failed to get active window: ${error}`
586
+ };
587
+ }
588
+ }
589
+ };
590
+ __name(_WindowManager, "WindowManager");
591
+ var WindowManager = _WindowManager;
592
+
593
+
594
+
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