wuying-agentbay-sdk 0.1.0 → 0.4.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.
Files changed (176) hide show
  1. package/README.md +124 -61
  2. package/dist/index.cjs +6621 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.mts +2633 -0
  5. package/dist/index.d.ts +2633 -0
  6. package/dist/index.mjs +6637 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +84 -48
  9. package/dist/src/adb/adb.d.ts +0 -20
  10. package/dist/src/adb/adb.js +0 -57
  11. package/dist/src/adb/index.d.ts +0 -1
  12. package/dist/src/adb/index.js +0 -17
  13. package/dist/src/agent-bay.d.ts +0 -68
  14. package/dist/src/agent-bay.js +0 -213
  15. package/dist/src/api/client.d.ts +0 -191
  16. package/dist/src/api/client.js +0 -629
  17. package/dist/src/api/index.d.ts +0 -4
  18. package/dist/src/api/index.js +0 -26
  19. package/dist/src/api/models/CallMcpToolRequest.d.ts +0 -21
  20. package/dist/src/api/models/CallMcpToolRequest.js +0 -71
  21. package/dist/src/api/models/CallMcpToolResponse.d.ts +0 -19
  22. package/dist/src/api/models/CallMcpToolResponse.js +0 -68
  23. package/dist/src/api/models/CallMcpToolResponseBody.d.ts +0 -19
  24. package/dist/src/api/models/CallMcpToolResponseBody.js +0 -67
  25. package/dist/src/api/models/CreateMcpSessionRequest.d.ts +0 -19
  26. package/dist/src/api/models/CreateMcpSessionRequest.js +0 -67
  27. package/dist/src/api/models/CreateMcpSessionResponse.d.ts +0 -19
  28. package/dist/src/api/models/CreateMcpSessionResponse.js +0 -68
  29. package/dist/src/api/models/CreateMcpSessionResponseBody.d.ts +0 -20
  30. package/dist/src/api/models/CreateMcpSessionResponseBody.js +0 -71
  31. package/dist/src/api/models/CreateMcpSessionResponseBodyData.d.ts +0 -19
  32. package/dist/src/api/models/CreateMcpSessionResponseBodyData.js +0 -67
  33. package/dist/src/api/models/DeleteContextRequest.d.ts +0 -15
  34. package/dist/src/api/models/DeleteContextRequest.js +0 -59
  35. package/dist/src/api/models/DeleteContextResponse.d.ts +0 -19
  36. package/dist/src/api/models/DeleteContextResponse.js +0 -68
  37. package/dist/src/api/models/DeleteContextResponseBody.d.ts +0 -18
  38. package/dist/src/api/models/DeleteContextResponseBody.js +0 -65
  39. package/dist/src/api/models/GetContextRequest.d.ts +0 -16
  40. package/dist/src/api/models/GetContextRequest.js +0 -61
  41. package/dist/src/api/models/GetContextResponse.d.ts +0 -19
  42. package/dist/src/api/models/GetContextResponse.js +0 -68
  43. package/dist/src/api/models/GetContextResponseBody.d.ts +0 -20
  44. package/dist/src/api/models/GetContextResponseBody.js +0 -71
  45. package/dist/src/api/models/GetContextResponseBodyData.d.ts +0 -19
  46. package/dist/src/api/models/GetContextResponseBodyData.js +0 -67
  47. package/dist/src/api/models/GetLabelRequest.d.ts +0 -17
  48. package/dist/src/api/models/GetLabelRequest.js +0 -63
  49. package/dist/src/api/models/GetLabelResponse.d.ts +0 -19
  50. package/dist/src/api/models/GetLabelResponse.js +0 -68
  51. package/dist/src/api/models/GetLabelResponseBody.d.ts +0 -23
  52. package/dist/src/api/models/GetLabelResponseBody.js +0 -77
  53. package/dist/src/api/models/GetLabelResponseBodyData.d.ts +0 -14
  54. package/dist/src/api/models/GetLabelResponseBodyData.js +0 -57
  55. package/dist/src/api/models/GetLinkRequest.d.ts +0 -15
  56. package/dist/src/api/models/GetLinkRequest.js +0 -59
  57. package/dist/src/api/models/GetLinkResponse.d.ts +0 -19
  58. package/dist/src/api/models/GetLinkResponse.js +0 -68
  59. package/dist/src/api/models/GetLinkResponseBody.d.ts +0 -19
  60. package/dist/src/api/models/GetLinkResponseBody.js +0 -67
  61. package/dist/src/api/models/GetMcpResourceRequest.d.ts +0 -15
  62. package/dist/src/api/models/GetMcpResourceRequest.js +0 -59
  63. package/dist/src/api/models/GetMcpResourceResponse.d.ts +0 -19
  64. package/dist/src/api/models/GetMcpResourceResponse.js +0 -68
  65. package/dist/src/api/models/GetMcpResourceResponseBody.d.ts +0 -20
  66. package/dist/src/api/models/GetMcpResourceResponseBody.js +0 -71
  67. package/dist/src/api/models/GetMcpResourceResponseBodyData.d.ts +0 -17
  68. package/dist/src/api/models/GetMcpResourceResponseBodyData.js +0 -65
  69. package/dist/src/api/models/GetMcpResourceResponseBodyDataDesktopInfo.d.ts +0 -18
  70. package/dist/src/api/models/GetMcpResourceResponseBodyDataDesktopInfo.js +0 -65
  71. package/dist/src/api/models/ListContextsRequest.d.ts +0 -16
  72. package/dist/src/api/models/ListContextsRequest.js +0 -61
  73. package/dist/src/api/models/ListContextsResponse.d.ts +0 -19
  74. package/dist/src/api/models/ListContextsResponse.js +0 -68
  75. package/dist/src/api/models/ListContextsResponseBody.d.ts +0 -23
  76. package/dist/src/api/models/ListContextsResponseBody.js +0 -77
  77. package/dist/src/api/models/ListContextsResponseBodyData.d.ts +0 -19
  78. package/dist/src/api/models/ListContextsResponseBodyData.js +0 -67
  79. package/dist/src/api/models/ListSessionRequest.d.ts +0 -17
  80. package/dist/src/api/models/ListSessionRequest.js +0 -63
  81. package/dist/src/api/models/ListSessionResponse.d.ts +0 -19
  82. package/dist/src/api/models/ListSessionResponse.js +0 -68
  83. package/dist/src/api/models/ListSessionResponseBody.d.ts +0 -23
  84. package/dist/src/api/models/ListSessionResponseBody.js +0 -77
  85. package/dist/src/api/models/ListSessionResponseBodyData.d.ts +0 -14
  86. package/dist/src/api/models/ListSessionResponseBodyData.js +0 -57
  87. package/dist/src/api/models/ModifyContextRequest.d.ts +0 -16
  88. package/dist/src/api/models/ModifyContextRequest.js +0 -61
  89. package/dist/src/api/models/ModifyContextResponse.d.ts +0 -19
  90. package/dist/src/api/models/ModifyContextResponse.js +0 -68
  91. package/dist/src/api/models/ModifyContextResponseBody.d.ts +0 -18
  92. package/dist/src/api/models/ModifyContextResponseBody.js +0 -65
  93. package/dist/src/api/models/ReleaseMcpSessionRequest.d.ts +0 -15
  94. package/dist/src/api/models/ReleaseMcpSessionRequest.js +0 -59
  95. package/dist/src/api/models/ReleaseMcpSessionResponse.d.ts +0 -19
  96. package/dist/src/api/models/ReleaseMcpSessionResponse.js +0 -68
  97. package/dist/src/api/models/ReleaseMcpSessionResponseBody.d.ts +0 -18
  98. package/dist/src/api/models/ReleaseMcpSessionResponseBody.js +0 -65
  99. package/dist/src/api/models/SetLabelRequest.d.ts +0 -16
  100. package/dist/src/api/models/SetLabelRequest.js +0 -61
  101. package/dist/src/api/models/SetLabelResponse.d.ts +0 -19
  102. package/dist/src/api/models/SetLabelResponse.js +0 -68
  103. package/dist/src/api/models/SetLabelResponseBody.d.ts +0 -18
  104. package/dist/src/api/models/SetLabelResponseBody.js +0 -65
  105. package/dist/src/api/models/model.d.ts +0 -43
  106. package/dist/src/api/models/model.js +0 -89
  107. package/dist/src/application/application.d.ts +0 -88
  108. package/dist/src/application/application.js +0 -172
  109. package/dist/src/application/index.d.ts +0 -1
  110. package/dist/src/application/index.js +0 -17
  111. package/dist/src/command/command.d.ts +0 -43
  112. package/dist/src/command/command.js +0 -120
  113. package/dist/src/command/index.d.ts +0 -1
  114. package/dist/src/command/index.js +0 -17
  115. package/dist/src/config.d.ts +0 -15
  116. package/dist/src/config.js +0 -114
  117. package/dist/src/context.d.ts +0 -87
  118. package/dist/src/context.js +0 -208
  119. package/dist/src/exceptions.d.ts +0 -30
  120. package/dist/src/exceptions.js +0 -58
  121. package/dist/src/filesystem/filesystem.d.ts +0 -109
  122. package/dist/src/filesystem/filesystem.js +0 -245
  123. package/dist/src/filesystem/index.d.ts +0 -1
  124. package/dist/src/filesystem/index.js +0 -17
  125. package/dist/src/index.d.ts +0 -10
  126. package/dist/src/index.js +0 -32
  127. package/dist/src/oss/index.d.ts +0 -1
  128. package/dist/src/oss/index.js +0 -5
  129. package/dist/src/oss/oss.d.ts +0 -80
  130. package/dist/src/oss/oss.js +0 -233
  131. package/dist/src/session.d.ts +0 -99
  132. package/dist/src/session.js +0 -226
  133. package/dist/src/ui/index.d.ts +0 -1
  134. package/dist/src/ui/index.js +0 -17
  135. package/dist/src/ui/ui.d.ts +0 -95
  136. package/dist/src/ui/ui.js +0 -206
  137. package/dist/src/utils/logger.d.ts +0 -15
  138. package/dist/src/utils/logger.js +0 -48
  139. package/dist/src/window/index.d.ts +0 -1
  140. package/dist/src/window/index.js +0 -17
  141. package/dist/src/window/window.d.ts +0 -109
  142. package/dist/src/window/window.js +0 -220
  143. package/dist/tests/agent-bay.test.d.ts +0 -1
  144. package/dist/tests/agent-bay.test.js +0 -366
  145. package/dist/tests/integration/context-persistence.test.d.ts +0 -1
  146. package/dist/tests/integration/context-persistence.test.js +0 -226
  147. package/dist/tests/integration/context-session.test.d.ts +0 -1
  148. package/dist/tests/integration/context-session.test.js +0 -223
  149. package/dist/tests/integration/window-operations.test.d.ts +0 -1
  150. package/dist/tests/integration/window-operations.test.js +0 -228
  151. package/dist/tests/unit/adb.test.d.ts +0 -1
  152. package/dist/tests/unit/adb.test.js +0 -60
  153. package/dist/tests/unit/agent-bay.test.d.ts +0 -1
  154. package/dist/tests/unit/agent-bay.test.js +0 -182
  155. package/dist/tests/unit/application.test.d.ts +0 -1
  156. package/dist/tests/unit/application.test.js +0 -260
  157. package/dist/tests/unit/command.test.d.ts +0 -1
  158. package/dist/tests/unit/command.test.js +0 -252
  159. package/dist/tests/unit/context.test.d.ts +0 -1
  160. package/dist/tests/unit/context.test.js +0 -199
  161. package/dist/tests/unit/filesystem.test.d.ts +0 -1
  162. package/dist/tests/unit/filesystem.test.js +0 -493
  163. package/dist/tests/unit/oss.test.d.ts +0 -1
  164. package/dist/tests/unit/oss.test.js +0 -243
  165. package/dist/tests/unit/session-labels.test.d.ts +0 -1
  166. package/dist/tests/unit/session-labels.test.js +0 -138
  167. package/dist/tests/unit/session-params.test.d.ts +0 -1
  168. package/dist/tests/unit/session-params.test.js +0 -78
  169. package/dist/tests/unit/session.test.d.ts +0 -1
  170. package/dist/tests/unit/session.test.js +0 -204
  171. package/dist/tests/unit/ui.test.d.ts +0 -1
  172. package/dist/tests/unit/ui.test.js +0 -158
  173. package/dist/tests/unit/window.test.d.ts +0 -1
  174. package/dist/tests/unit/window.test.js +0 -331
  175. package/dist/tests/utils/test-helpers.d.ts +0 -35
  176. package/dist/tests/utils/test-helpers.js +0 -79
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./ui"), exports);
@@ -1,95 +0,0 @@
1
- import { Session } from '../session';
2
- /**
3
- * KeyCode constants for mobile device input
4
- */
5
- export declare const KeyCode: {
6
- HOME: number;
7
- BACK: number;
8
- VOLUME_UP: number;
9
- VOLUME_DOWN: number;
10
- POWER: number;
11
- MENU: number;
12
- };
13
- /**
14
- * UI handles UI operations in the AgentBay cloud environment.
15
- */
16
- export declare class UI {
17
- private session;
18
- /**
19
- * Initialize a UI object.
20
- *
21
- * @param session - The Session instance that this UI belongs to.
22
- */
23
- constructor(session: Session);
24
- /**
25
- * Helper method to call MCP tools and handle common response processing
26
- *
27
- * @param toolName - Name of the MCP tool to call
28
- * @param args - Arguments to pass to the tool
29
- * @param defaultErrorMsg - Default error message if specific error details are not available
30
- * @returns A CallMcpToolResult with the response data
31
- * @throws APIError if the call fails
32
- */
33
- private callMcpTool;
34
- /**
35
- * Retrieves all clickable UI elements within the specified timeout.
36
- *
37
- * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
38
- * @returns The content field from the API response
39
- * @throws Error if the operation fails.
40
- */
41
- getClickableUIElements(timeoutMs?: number): Promise<any>;
42
- /**
43
- * Retrieves all UI elements within the specified timeout.
44
- *
45
- * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
46
- * @returns The content field from the API response
47
- * @throws Error if the operation fails.
48
- */
49
- getAllUIElements(timeoutMs?: number): Promise<any>;
50
- /**
51
- * Sends a key press event.
52
- *
53
- * @param key - The key code to send.
54
- * @returns The content field from the API response
55
- * @throws Error if the operation fails.
56
- */
57
- sendKey(key: number): Promise<any>;
58
- /**
59
- * Inputs text into the active field.
60
- *
61
- * @param text - The text to input.
62
- * @returns The content field from the API response
63
- * @throws Error if the operation fails.
64
- */
65
- inputText(text: string): Promise<any>;
66
- /**
67
- * Performs a swipe gesture on the screen.
68
- *
69
- * @param startX - The starting X coordinate.
70
- * @param startY - The starting Y coordinate.
71
- * @param endX - The ending X coordinate.
72
- * @param endY - The ending Y coordinate.
73
- * @param durationMs - The duration of the swipe in milliseconds. Default is 300ms.
74
- * @returns The content field from the API response
75
- * @throws Error if the operation fails.
76
- */
77
- swipe(startX: number, startY: number, endX: number, endY: number, durationMs?: number): Promise<any>;
78
- /**
79
- * Clicks on the screen at the specified coordinates.
80
- *
81
- * @param x - The X coordinate.
82
- * @param y - The Y coordinate.
83
- * @param button - The mouse button to use. Default is 'left'.
84
- * @returns The content field from the API response
85
- * @throws Error if the operation fails.
86
- */
87
- click(x: number, y: number, button?: string): Promise<any>;
88
- /**
89
- * Takes a screenshot of the current screen.
90
- *
91
- * @returns The content field from the API response containing the base64 encoded screenshot
92
- * @throws Error if the operation fails.
93
- */
94
- screenshot(): Promise<any>;
95
- }
package/dist/src/ui/ui.js DELETED
@@ -1,206 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UI = exports.KeyCode = void 0;
4
- const exceptions_1 = require("../exceptions");
5
- const model_1 = require("../api/models/model");
6
- const logger_1 = require("../utils/logger");
7
- /**
8
- * KeyCode constants for mobile device input
9
- */
10
- exports.KeyCode = {
11
- HOME: 3,
12
- BACK: 4,
13
- VOLUME_UP: 24,
14
- VOLUME_DOWN: 25,
15
- POWER: 26,
16
- MENU: 82
17
- };
18
- /**
19
- * UI handles UI operations in the AgentBay cloud environment.
20
- */
21
- class UI {
22
- /**
23
- * Initialize a UI object.
24
- *
25
- * @param session - The Session instance that this UI belongs to.
26
- */
27
- constructor(session) {
28
- this.session = session;
29
- }
30
- /**
31
- * Helper method to call MCP tools and handle common response processing
32
- *
33
- * @param toolName - Name of the MCP tool to call
34
- * @param args - Arguments to pass to the tool
35
- * @param defaultErrorMsg - Default error message if specific error details are not available
36
- * @returns A CallMcpToolResult with the response data
37
- * @throws APIError if the call fails
38
- */
39
- async callMcpTool(toolName, args, defaultErrorMsg) {
40
- try {
41
- const argsJSON = JSON.stringify(args);
42
- const callToolRequest = new model_1.CallMcpToolRequest({
43
- authorization: `Bearer ${this.session.getAPIKey()}`,
44
- sessionId: this.session.getSessionId(),
45
- name: toolName,
46
- args: argsJSON
47
- });
48
- // Log API request
49
- (0, logger_1.log)(`API Call: CallMcpTool - ${toolName}`);
50
- (0, logger_1.log)(`Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`);
51
- const response = await this.session.getClient().callMcpTool(callToolRequest);
52
- // Log API response
53
- (0, logger_1.log)(`Response from CallMcpTool - ${toolName}:`, response.body);
54
- if (!response.body?.data) {
55
- throw new Error('Invalid response data format');
56
- }
57
- // Extract data from response
58
- const data = response.body.data;
59
- // Create result object
60
- const result = {
61
- data,
62
- statusCode: response.statusCode || 0,
63
- isError: false
64
- };
65
- // Check if there's an error in the response
66
- if (data.isError === true) {
67
- result.isError = true;
68
- // Try to extract the error message from the content field
69
- const contentArray = data.content;
70
- if (contentArray && contentArray.length > 0) {
71
- result.content = contentArray;
72
- // Extract error message from the first content item
73
- if (contentArray[0]?.text) {
74
- result.errorMsg = contentArray[0].text;
75
- throw new Error(contentArray[0].text);
76
- }
77
- }
78
- throw new Error(defaultErrorMsg);
79
- }
80
- // Extract content array if it exists
81
- if (Array.isArray(data.content)) {
82
- result.content = data.content;
83
- }
84
- return result;
85
- }
86
- catch (error) {
87
- (0, logger_1.logError)(`Error calling CallMcpTool - ${toolName}:`, error);
88
- throw new exceptions_1.APIError(`Failed to call ${toolName}: ${error}`);
89
- }
90
- }
91
- /**
92
- * Retrieves all clickable UI elements within the specified timeout.
93
- *
94
- * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
95
- * @returns The content field from the API response
96
- * @throws Error if the operation fails.
97
- */
98
- async getClickableUIElements(timeoutMs = 2000) {
99
- const args = {
100
- timeout_ms: timeoutMs
101
- };
102
- const result = await this.callMcpTool('get_clickable_ui_elements', args, 'Failed to get clickable UI elements');
103
- // Return the raw content field for the caller to parse
104
- return result.data.content;
105
- }
106
- /**
107
- * Retrieves all UI elements within the specified timeout.
108
- *
109
- * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
110
- * @returns The content field from the API response
111
- * @throws Error if the operation fails.
112
- */
113
- async getAllUIElements(timeoutMs = 2000) {
114
- const args = {
115
- timeout_ms: timeoutMs
116
- };
117
- const result = await this.callMcpTool('get_all_ui_elements', args, 'Failed to get all UI elements');
118
- // Return the raw content field for the caller to parse
119
- return result.data.content;
120
- }
121
- /**
122
- * Sends a key press event.
123
- *
124
- * @param key - The key code to send.
125
- * @returns The content field from the API response
126
- * @throws Error if the operation fails.
127
- */
128
- async sendKey(key) {
129
- const args = {
130
- key
131
- };
132
- const result = await this.callMcpTool('send_key', args, 'Failed to send key');
133
- // Return the raw content field for the caller to parse
134
- return result.data.content;
135
- }
136
- /**
137
- * Inputs text into the active field.
138
- *
139
- * @param text - The text to input.
140
- * @returns The content field from the API response
141
- * @throws Error if the operation fails.
142
- */
143
- async inputText(text) {
144
- const args = {
145
- text
146
- };
147
- const result = await this.callMcpTool('input_text', args, 'Failed to input text');
148
- // Return the raw content field for the caller to parse
149
- return result.data.content;
150
- }
151
- /**
152
- * Performs a swipe gesture on the screen.
153
- *
154
- * @param startX - The starting X coordinate.
155
- * @param startY - The starting Y coordinate.
156
- * @param endX - The ending X coordinate.
157
- * @param endY - The ending Y coordinate.
158
- * @param durationMs - The duration of the swipe in milliseconds. Default is 300ms.
159
- * @returns The content field from the API response
160
- * @throws Error if the operation fails.
161
- */
162
- async swipe(startX, startY, endX, endY, durationMs = 300) {
163
- const args = {
164
- start_x: startX,
165
- start_y: startY,
166
- end_x: endX,
167
- end_y: endY,
168
- duration_ms: durationMs
169
- };
170
- const result = await this.callMcpTool('swipe', args, 'Failed to perform swipe');
171
- // Return the raw content field for the caller to parse
172
- return result.data.content;
173
- }
174
- /**
175
- * Clicks on the screen at the specified coordinates.
176
- *
177
- * @param x - The X coordinate.
178
- * @param y - The Y coordinate.
179
- * @param button - The mouse button to use. Default is 'left'.
180
- * @returns The content field from the API response
181
- * @throws Error if the operation fails.
182
- */
183
- async click(x, y, button = 'left') {
184
- const args = {
185
- x,
186
- y,
187
- button
188
- };
189
- const result = await this.callMcpTool('click', args, 'Failed to click');
190
- // Return the raw content field for the caller to parse
191
- return result.data.content;
192
- }
193
- /**
194
- * Takes a screenshot of the current screen.
195
- *
196
- * @returns The content field from the API response containing the base64 encoded screenshot
197
- * @throws Error if the operation fails.
198
- */
199
- async screenshot() {
200
- const args = {};
201
- const result = await this.callMcpTool('screenshot', args, 'Failed to take screenshot');
202
- // Return the raw content field for the caller to parse
203
- return result.data.content;
204
- }
205
- }
206
- exports.UI = UI;
@@ -1,15 +0,0 @@
1
- /**
2
- * Utility functions for logging in a clean format
3
- */
4
- /**
5
- * Log a message without the log prefix and file location
6
- * @param message The message to log
7
- * @param args Optional arguments to log
8
- */
9
- export declare function log(message: string, ...args: any[]): void;
10
- /**
11
- * Log an error message
12
- * @param message The error message to log
13
- * @param error Optional error object
14
- */
15
- export declare function logError(message: string, error?: any): void;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /**
3
- * Utility functions for logging in a clean format
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.log = log;
7
- exports.logError = logError;
8
- /**
9
- * Log a message without the log prefix and file location
10
- * @param message The message to log
11
- * @param args Optional arguments to log
12
- */
13
- function log(message, ...args) {
14
- // Use process.stdout.write instead of log to avoid the prefix and newline
15
- process.stdout.write(message + '\n');
16
- // If there are additional arguments, print them on new lines with proper formatting
17
- if (args.length > 0) {
18
- for (const arg of args) {
19
- if (typeof arg === 'object') {
20
- // For objects, format them as JSON with indentation
21
- process.stdout.write(JSON.stringify(arg, null, 2) + '\n');
22
- }
23
- else {
24
- // For other types, just convert to string
25
- process.stdout.write(String(arg) + '\n');
26
- }
27
- }
28
- }
29
- }
30
- /**
31
- * Log an error message
32
- * @param message The error message to log
33
- * @param error Optional error object
34
- */
35
- function logError(message, error) {
36
- process.stderr.write(`ERROR: ${message}\n`);
37
- if (error) {
38
- if (error instanceof Error) {
39
- process.stderr.write(`${error.message}\n`);
40
- }
41
- else if (typeof error === 'object') {
42
- process.stderr.write(JSON.stringify(error, null, 2) + '\n');
43
- }
44
- else {
45
- process.stderr.write(String(error) + '\n');
46
- }
47
- }
48
- }
@@ -1 +0,0 @@
1
- export * from './window';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./window"), exports);
@@ -1,109 +0,0 @@
1
- /**
2
- * Represents a window in the system.
3
- */
4
- export interface Window {
5
- window_id: number;
6
- title: string;
7
- absolute_upper_left_x?: number;
8
- absolute_upper_left_y?: number;
9
- width?: number;
10
- height?: number;
11
- pid?: number;
12
- pname?: string;
13
- child_windows?: Window[];
14
- }
15
- /**
16
- * Handles window management operations in the AgentBay cloud environment.
17
- */
18
- export declare class WindowManager {
19
- private session;
20
- /**
21
- * Creates a new WindowManager instance.
22
- * @param session The session object that provides access to the AgentBay API.
23
- */
24
- constructor(session: {
25
- getAPIKey(): string;
26
- getClient(): any;
27
- getSessionId(): string;
28
- });
29
- /**
30
- * Helper method to call MCP tools and handle common response processing
31
- *
32
- * @param toolName - Name of the MCP tool to call
33
- * @param args - Arguments to pass to the tool
34
- * @param defaultErrorMsg - Default error message if specific error details are not available
35
- * @returns A CallMcpToolResult with the response data
36
- * @throws APIError if the call fails
37
- */
38
- private callMcpTool;
39
- /**
40
- * Lists all root windows in the system.
41
- * @returns The content field from the API response
42
- * @throws Error if the operation fails.
43
- */
44
- listRootWindows(): Promise<any>;
45
- /**
46
- * Gets the currently active window.
47
- * @returns The content field from the API response
48
- * @throws Error if the operation fails.
49
- */
50
- getActiveWindow(): Promise<any>;
51
- /**
52
- * Activates a window by ID.
53
- * @param windowId The ID of the window to activate.
54
- * @returns The content field from the API response
55
- * @throws Error if the operation fails.
56
- */
57
- activateWindow(windowId: number): Promise<any>;
58
- /**
59
- * Maximizes a window by ID.
60
- * @param windowId The ID of the window to maximize.
61
- * @returns The content field from the API response
62
- * @throws Error if the operation fails.
63
- */
64
- maximizeWindow(windowId: number): Promise<any>;
65
- /**
66
- * Minimizes a window by ID.
67
- * @param windowId The ID of the window to minimize.
68
- * @returns The content field from the API response
69
- * @throws Error if the operation fails.
70
- */
71
- minimizeWindow(windowId: number): Promise<any>;
72
- /**
73
- * Restores a window by ID.
74
- * @param windowId The ID of the window to restore.
75
- * @returns The content field from the API response
76
- * @throws Error if the operation fails.
77
- */
78
- restoreWindow(windowId: number): Promise<any>;
79
- /**
80
- * Closes a window by ID.
81
- * @param windowId The ID of the window to close.
82
- * @returns The content field from the API response
83
- * @throws Error if the operation fails.
84
- */
85
- closeWindow(windowId: number): Promise<any>;
86
- /**
87
- * Sets a window to fullscreen mode.
88
- * @param windowId The ID of the window to set to fullscreen.
89
- * @returns The content field from the API response
90
- * @throws Error if the operation fails.
91
- */
92
- fullscreenWindow(windowId: number): Promise<any>;
93
- /**
94
- * Resizes a window by ID.
95
- * @param windowId The ID of the window to resize.
96
- * @param width The new width of the window.
97
- * @param height The new height of the window.
98
- * @returns The content field from the API response
99
- * @throws Error if the operation fails.
100
- */
101
- resizeWindow(windowId: number, width: number, height: number): Promise<any>;
102
- /**
103
- * Enables or disables focus mode.
104
- * @param on Whether to enable (true) or disable (false) focus mode.
105
- * @returns The content field from the API response
106
- * @throws Error if the operation fails.
107
- */
108
- focusMode(on: boolean): Promise<any>;
109
- }