@midscene/computer 1.9.7 → 1.9.8-beta-20260618014851.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.
@@ -1,243 +0,0 @@
1
- import { AbstractInterface } from '@midscene/core/device';
2
- import { Agent } from '@midscene/core/agent';
3
- import { BaseMCPServer } from '@midscene/shared/mcp';
4
- import { BaseMidsceneTools } from '@midscene/shared/mcp/base-tools';
5
- import { ComputerInputPrimitives } from '@midscene/core/device';
6
- import type { DeviceAction } from '@midscene/core';
7
- import { InitArgSpec } from '@midscene/shared/mcp/base-tools';
8
- import type { InterfaceType } from '@midscene/core';
9
- import { LaunchMCPServerOptions } from '@midscene/shared/mcp';
10
- import { LaunchMCPServerResult } from '@midscene/shared/mcp';
11
- import type { Size } from '@midscene/core';
12
- import { Tool } from '@midscene/shared/mcp';
13
- import type { ToolDefinition } from '@midscene/shared/mcp/types';
14
-
15
- declare class ComputerAgent<InterfaceType extends AbstractInterface = ComputerInterface> extends Agent<InterfaceType> {
16
- }
17
-
18
- declare class ComputerDevice implements AbstractInterface {
19
- interfaceType: InterfaceType;
20
- private options?;
21
- private displayId?;
22
- private displayGeometry?;
23
- private description?;
24
- private destroyed;
25
- private xvfbInstance?;
26
- private xvfbCleanup?;
27
- private readonly inputDriver;
28
- /**
29
- * On macOS, use AppleScript for keyboard operations by default
30
- * to avoid focus issues with system overlays (e.g. Spotlight).
31
- */
32
- private useAppleScript;
33
- /** Cached result of the elevation check; see isRunningAsAdmin(). */
34
- private adminCheckCache?;
35
- uri?: string;
36
- readonly inputPrimitives: ComputerInputPrimitives;
37
- constructor(options?: ComputerDeviceOpt);
38
- describe(): string;
39
- /**
40
- * Get all available displays
41
- */
42
- static listDisplays(): Promise<DisplayInfo[]>;
43
- connect(): Promise<void>;
44
- private healthCheck;
45
- /**
46
- * Check if the current process is running with Administrator privileges.
47
- * Uses "net session" which succeeds only when elevated.
48
- *
49
- * The result is cached because elevation cannot change during the process
50
- * lifetime, and the underlying `execSync('net session')` is a blocking
51
- * subprocess spawn that should not run on every connect / health check.
52
- */
53
- private isRunningAsAdmin;
54
- screenshotBase64(): Promise<string>;
55
- size(): Promise<Size>;
56
- private toGlobalPoint;
57
- /**
58
- * Type text via clipboard (paste)
59
- * This method:
60
- * 1. Saves the old clipboard content
61
- * 2. Writes new content to clipboard
62
- * 3. Simulates paste shortcut (Ctrl+V / Cmd+V)
63
- * 4. Restores old clipboard content
64
- */
65
- private typeViaClipboard;
66
- /**
67
- * Always use clipboard paste to input text, avoiding IME interference.
68
- * Keystroke-based input (AppleScript/libnut) goes through the active input method,
69
- * which can swallow characters or convert them when a non-English IME is active.
70
- */
71
- private smartTypeString;
72
- private selectAllAndDelete;
73
- private pressKeyboardShortcut;
74
- private resolveUntargetedScrollPoint;
75
- private moveMouseToScrollTarget;
76
- private performScroll;
77
- actionSpace(): DeviceAction<any>[];
78
- destroy(): Promise<void>;
79
- url(): Promise<string>;
80
- }
81
-
82
- declare interface ComputerDeviceOpt {
83
- displayId?: string;
84
- customActions?: DeviceAction<any>[];
85
- /**
86
- * Keyboard driver for sending key events (macOS only)
87
- * - 'applescript': Use AppleScript via osascript (default on macOS, more reliable)
88
- * - 'libnut': Use libnut's keyTap (faster but may not work with some TUI apps)
89
- */
90
- keyboardDriver?: 'applescript' | 'libnut';
91
- /**
92
- * Headless mode via Xvfb (Linux only).
93
- * - true: start Xvfb virtual display
94
- * - false/undefined: do not start Xvfb
95
- * Can also be set via MIDSCENE_COMPUTER_HEADLESS_LINUX=true environment variable.
96
- */
97
- headless?: boolean;
98
- /**
99
- * Resolution for Xvfb virtual display (default '1920x1080x24')
100
- */
101
- xvfbResolution?: string;
102
- }
103
-
104
- /**
105
- * Discriminated union describing the two ways `computer_*` tools can spawn an
106
- * agent. `mode` is filled in by `initArgSpec.adapt` based on whether `host` is
107
- * set, so callers (CLI/MCP/YAML) never have to provide it explicitly.
108
- */
109
- declare type ComputerInitArgs = ComputerLocalInitArgs | ComputerRDPInitArgs;
110
-
111
- declare type ComputerInterface = ComputerDevice | RDPDevice;
112
-
113
- /** Init args for the local desktop agent (macOS/Windows/Linux). */
114
- declare type ComputerLocalInitArgs = {
115
- mode: 'local';
116
- } & Pick<ComputerDeviceOpt, 'displayId' | 'headless'>;
117
-
118
- /**
119
- * Computer MCP Server
120
- * Provides MCP tools for computer desktop automation
121
- */
122
- export declare class ComputerMCPServer extends BaseMCPServer {
123
- constructor(toolsManager?: ComputerMidsceneTools);
124
- protected createToolsManager(): ComputerMidsceneTools;
125
- }
126
-
127
- /**
128
- * Computer-specific tools manager
129
- * Extends BaseMidsceneTools to provide desktop automation tools
130
- */
131
- declare class ComputerMidsceneTools extends BaseMidsceneTools<ComputerAgent, ComputerInitArgs> {
132
- protected getCliReportSessionName(): string;
133
- protected readonly initArgSpec: InitArgSpec<ComputerInitArgs>;
134
- protected createTemporaryDevice(): ComputerDevice;
135
- protected ensureAgent(opts?: ComputerInitArgs): Promise<ComputerAgent>;
136
- /**
137
- * Provide Computer-specific platform tools
138
- */
139
- protected preparePlatformTools(): ToolDefinition[];
140
- }
141
-
142
- /** Init args for the RDP remote-desktop agent. */
143
- declare type ComputerRDPInitArgs = {
144
- mode: 'rdp';
145
- } & RDPConnectionConfig;
146
-
147
- declare interface DisplayInfo {
148
- id: string;
149
- name: string;
150
- primary?: boolean;
151
- }
152
-
153
- /**
154
- * Create MCP kit for a specific Computer Agent
155
- */
156
- export declare function mcpKitForAgent(agent: Agent | ComputerAgent): Promise<{
157
- description: string;
158
- tools: Tool[];
159
- }>;
160
-
161
- /**
162
- * Create an MCP server launcher for a specific Computer Agent
163
- */
164
- export declare function mcpServerForAgent(agent: Agent | ComputerAgent): {
165
- launch(options?: {
166
- verbose?: boolean;
167
- }): Promise<LaunchMCPServerResult>;
168
- launchHttp(options: LaunchMCPServerOptions): Promise<LaunchMCPServerResult>;
169
- };
170
-
171
- declare interface RDPBackendClient {
172
- connect(config: RDPConnectionConfig): Promise<RDPConnectionInfo>;
173
- disconnect(): Promise<void>;
174
- screenshotBase64(): Promise<string>;
175
- size(): Promise<Size>;
176
- mouseMove(x: number, y: number): Promise<void>;
177
- mouseButton(button: RDPMouseButton, action: RDPMouseButtonAction): Promise<void>;
178
- wheel(direction: RDPScrollDirection, amount: number, x?: number, y?: number): Promise<void>;
179
- keyPress(keyName: string): Promise<void>;
180
- typeText(text: string): Promise<void>;
181
- clearInput?(): Promise<void>;
182
- }
183
-
184
- declare interface RDPConnectionConfig {
185
- host: string;
186
- port?: number;
187
- username?: string;
188
- password?: string;
189
- domain?: string;
190
- localAddress?: string;
191
- adminSession?: boolean;
192
- ignoreCertificate?: boolean;
193
- securityProtocol?: RDPSecurityProtocol;
194
- desktopWidth?: number;
195
- desktopHeight?: number;
196
- }
197
-
198
- declare interface RDPConnectionInfo {
199
- sessionId: string;
200
- size: Size;
201
- server: string;
202
- }
203
-
204
- declare class RDPDevice implements AbstractInterface {
205
- interfaceType: InterfaceType;
206
- private readonly options;
207
- private readonly backend;
208
- private connectionInfo?;
209
- private destroyed;
210
- private cursorPosition?;
211
- uri?: string;
212
- readonly inputPrimitives: ComputerInputPrimitives;
213
- constructor(options: RDPDeviceOpt);
214
- describe(): string;
215
- connect(): Promise<void>;
216
- screenshotBase64(): Promise<string>;
217
- size(): Promise<Size>;
218
- destroy(): Promise<void>;
219
- actionSpace(): DeviceAction<any>[];
220
- private assertConnected;
221
- private throwIfDestroyed;
222
- private moveToElement;
223
- private clearInput;
224
- private edgeScrollDirection;
225
- private defaultScrollDistance;
226
- private movePointer;
227
- private performWheel;
228
- }
229
-
230
- declare interface RDPDeviceOpt extends RDPConnectionConfig {
231
- backend?: RDPBackendClient;
232
- customActions?: DeviceAction<any>[];
233
- }
234
-
235
- declare type RDPMouseButton = 'left' | 'right' | 'middle';
236
-
237
- declare type RDPMouseButtonAction = 'down' | 'up' | 'click' | 'doubleClick';
238
-
239
- declare type RDPScrollDirection = 'up' | 'down' | 'left' | 'right';
240
-
241
- declare type RDPSecurityProtocol = 'auto' | 'tls' | 'nla' | 'rdp';
242
-
243
- export { }