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