@hypothesi/tauri-mcp-server 0.11.2 → 0.13.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 +2 -2
- package/dist/config.d.ts +14 -0
- package/dist/config.js +26 -0
- package/dist/driver/app-discovery.d.ts +4 -2
- package/dist/driver/app-discovery.js +23 -3
- package/dist/driver/element-picker.d.ts +1 -1
- package/dist/driver/plugin-client.d.ts +23 -1
- package/dist/driver/plugin-client.js +127 -2
- package/dist/driver/plugin-commands.d.ts +8 -4
- package/dist/driver/plugin-commands.js +71 -16
- package/dist/driver/protocol.d.ts +7 -0
- package/dist/driver/scripts/find-element.js +129 -16
- package/dist/driver/scripts/focus.js +31 -4
- package/dist/driver/scripts/html2canvas-loader.js +20 -2
- package/dist/driver/scripts/index.d.ts +2 -4
- package/dist/driver/scripts/index.js +40 -11
- package/dist/driver/scripts/interact.js +66 -5
- package/dist/driver/scripts/resolve-ref.js +101 -50
- package/dist/driver/session-manager.d.ts +39 -0
- package/dist/driver/session-manager.js +133 -13
- package/dist/driver/webview-executor.d.ts +20 -8
- package/dist/driver/webview-executor.js +159 -58
- package/dist/driver/webview-interactions.d.ts +57 -42
- package/dist/driver/webview-interactions.js +62 -40
- package/dist/manager/mobile.js +3 -2
- package/dist/monitor/logs.d.ts +14 -2
- package/dist/monitor/logs.js +37 -5
- package/dist/tools-registry.js +35 -33
- package/dist/version.d.ts +5 -0
- package/dist/version.js +16 -0
- package/package.json +1 -1
- package/dist/driver/scripts/get-styles.js +0 -47
- package/dist/driver/scripts/keyboard.js +0 -76
|
@@ -18,6 +18,14 @@ import { getResolveRefSource, RESOLVE_REF_SCRIPT_ID } from './scripts/index.js';
|
|
|
18
18
|
// ============================================================================
|
|
19
19
|
const initializedTargets = new Set();
|
|
20
20
|
const driverLogger = createMcpLogger('DRIVER');
|
|
21
|
+
const MCP_HELPER_MISSING = /__MCP__|resolveRef|resolveAll|countAll/;
|
|
22
|
+
function isHelperMissingError(message) {
|
|
23
|
+
return MCP_HELPER_MISSING.test(message) &&
|
|
24
|
+
/undefined is not an object|is not a function|Cannot read propert/.test(message);
|
|
25
|
+
}
|
|
26
|
+
function targetKeyFor(session, windowId) {
|
|
27
|
+
return `${session.host}:${session.port}:${windowId ?? 'main'}`;
|
|
28
|
+
}
|
|
21
29
|
/**
|
|
22
30
|
* Ensures the MCP server is fully initialized and ready to use.
|
|
23
31
|
* This is called automatically by all tool functions.
|
|
@@ -43,7 +51,7 @@ export async function ensureReady(windowId, appIdentifier) {
|
|
|
43
51
|
if (!session.client.isConnected()) {
|
|
44
52
|
await session.client.connect();
|
|
45
53
|
}
|
|
46
|
-
const targetKey =
|
|
54
|
+
const targetKey = targetKeyFor(session, windowId);
|
|
47
55
|
if (initializedTargets.has(targetKey)) {
|
|
48
56
|
return;
|
|
49
57
|
}
|
|
@@ -84,10 +92,11 @@ async function waitForResolveRefHelper(session, windowId) {
|
|
|
84
92
|
* @param script - JavaScript code to execute in the webview context
|
|
85
93
|
* @param windowId - Optional window label to target (defaults to "main")
|
|
86
94
|
* @param appIdentifier - Optional app identifier to target specific app
|
|
95
|
+
* @param timeoutMs - Optional timeout in milliseconds
|
|
87
96
|
* @returns Result of the script execution with window context
|
|
88
97
|
*/
|
|
89
|
-
export async function executeInWebview(script, windowId, appIdentifier) {
|
|
90
|
-
const { result } = await executeInWebviewWithContext(script, windowId, appIdentifier);
|
|
98
|
+
export async function executeInWebview(script, windowId, appIdentifier, timeoutMs) {
|
|
99
|
+
const { result } = await executeInWebviewWithContext(script, windowId, appIdentifier, timeoutMs);
|
|
91
100
|
return result;
|
|
92
101
|
}
|
|
93
102
|
/**
|
|
@@ -96,21 +105,38 @@ export async function executeInWebview(script, windowId, appIdentifier) {
|
|
|
96
105
|
* @param script - JavaScript code to execute in the webview context
|
|
97
106
|
* @param windowId - Optional window label to target (defaults to "main")
|
|
98
107
|
* @param appIdentifier - Optional app identifier to target specific app
|
|
108
|
+
* @param timeoutMs - Optional timeout in milliseconds
|
|
99
109
|
* @returns Result of the script execution with window context
|
|
100
110
|
*/
|
|
101
|
-
export async function executeInWebviewWithContext(script, windowId, appIdentifier) {
|
|
111
|
+
export async function executeInWebviewWithContext(script, windowId, appIdentifier, timeoutMs, isRetry = false) {
|
|
102
112
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
return await runInWebview(script, windowId, appIdentifier, timeoutMs);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
117
|
+
if (isRetry || !isHelperMissingError(message)) {
|
|
118
|
+
throw new Error(`WebView execution failed: ${message}`);
|
|
119
|
+
}
|
|
120
|
+
driverLogger.warn(`__MCP__ helper missing, re-injecting and retrying once: ${message}`);
|
|
106
121
|
const session = resolveTargetApp(appIdentifier);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
122
|
+
initializedTargets.delete(targetKeyFor(session, windowId));
|
|
123
|
+
await ensureReady(windowId, appIdentifier);
|
|
124
|
+
return executeInWebviewWithContext(script, windowId, appIdentifier, timeoutMs, true);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function runInWebview(script, windowId, appIdentifier, timeoutMs) {
|
|
128
|
+
// Ensure we're fully initialized
|
|
129
|
+
await ensureReady(windowId, appIdentifier);
|
|
130
|
+
// Resolve target session
|
|
131
|
+
const session = resolveTargetApp(appIdentifier);
|
|
132
|
+
const client = session.client;
|
|
133
|
+
// Send script directly - Rust handles wrapping and IPC callbacks.
|
|
134
|
+
// Use timeoutMs if provided, otherwise default 7s timeout (longer than Rust's 5s)
|
|
135
|
+
try {
|
|
110
136
|
const response = await client.sendCommand({
|
|
111
137
|
command: 'execute_js',
|
|
112
138
|
args: { script, windowLabel: windowId },
|
|
113
|
-
}, 7000);
|
|
139
|
+
}, timeoutMs ?? 7000);
|
|
114
140
|
if (!response.success) {
|
|
115
141
|
throw new Error(response.error || 'Unknown execution error');
|
|
116
142
|
}
|
|
@@ -136,7 +162,34 @@ export async function executeInWebviewWithContext(script, windowId, appIdentifie
|
|
|
136
162
|
}
|
|
137
163
|
catch (error) {
|
|
138
164
|
const message = error instanceof Error ? error.message : String(error);
|
|
139
|
-
|
|
165
|
+
// Check for transport timeout
|
|
166
|
+
if (/^Request timeout after \d+ms$/.test(message)) {
|
|
167
|
+
const probeResult = await probeBridge(session, windowId);
|
|
168
|
+
if (probeResult) {
|
|
169
|
+
throw new Error(`Bridge did not respond within ${timeoutMs ?? 7000}ms. A follow-up probe succeeded, so the bridge is alive and this ` +
|
|
170
|
+
'specific script was too slow. Raise `timeout`, or split the work across calls.');
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
throw new Error(`Bridge did not respond within ${timeoutMs ?? 7000}ms and a follow-up probe also timed out. The webview is wedged. ` +
|
|
174
|
+
'Call driver_session with action "stop" then "start". A runaway loop in a previous script is the usual cause.');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function probeBridge(session, windowId) {
|
|
181
|
+
if (!session) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const response = await session.client.sendCommand({
|
|
186
|
+
command: 'execute_js',
|
|
187
|
+
args: { script: 'return 1', windowLabel: windowId },
|
|
188
|
+
}, 2000);
|
|
189
|
+
return response.success === true;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return false;
|
|
140
193
|
}
|
|
141
194
|
}
|
|
142
195
|
/**
|
|
@@ -149,6 +202,7 @@ export async function executeInWebviewWithContext(script, windowId, appIdentifie
|
|
|
149
202
|
*/
|
|
150
203
|
export async function executeAsyncInWebview(script, windowId, timeout, appIdentifier) {
|
|
151
204
|
const resolvedTimeout = timeout ?? 5000;
|
|
205
|
+
const transportTimeout = resolvedTimeout + 2000;
|
|
152
206
|
const wrappedScript = `
|
|
153
207
|
return (async () => {
|
|
154
208
|
const timeoutPromise = new Promise((_, reject) => {
|
|
@@ -162,7 +216,7 @@ export async function executeAsyncInWebview(script, windowId, timeout, appIdenti
|
|
|
162
216
|
return await Promise.race([scriptPromise, timeoutPromise]);
|
|
163
217
|
})();
|
|
164
218
|
`;
|
|
165
|
-
return executeInWebview(wrappedScript, windowId, appIdentifier);
|
|
219
|
+
return executeInWebview(wrappedScript, windowId, appIdentifier, transportTimeout);
|
|
166
220
|
}
|
|
167
221
|
// ============================================================================
|
|
168
222
|
// Console Log Capture System
|
|
@@ -209,14 +263,12 @@ export async function initializeConsoleCapture() {
|
|
|
209
263
|
/**
|
|
210
264
|
* Retrieve captured console logs with optional filtering.
|
|
211
265
|
*
|
|
212
|
-
* @param
|
|
213
|
-
* @param since - Optional ISO timestamp to filter logs after this time
|
|
214
|
-
* @param windowId - Optional window label to target (defaults to "main")
|
|
215
|
-
* @param appIdentifier - Optional app identifier to target specific app
|
|
266
|
+
* @param options - Filtering and formatting options
|
|
216
267
|
* @returns Formatted console logs as string
|
|
217
268
|
*/
|
|
218
|
-
export async function getConsoleLogs(
|
|
219
|
-
const
|
|
269
|
+
export async function getConsoleLogs(options = {}) {
|
|
270
|
+
const { filter, since, lines = 50, windowId, appIdentifier, level, maxChars = 20000, maxCharsPerEntry = 2000 } = options;
|
|
271
|
+
const resolvedLines = lines, resolvedMaxChars = maxChars, resolvedMaxCharsPerEntry = maxCharsPerEntry, resolvedLevel = level ?? '', filterStr = filter ? filter.replace(/'/g, '\\\'') : '', levelStr = resolvedLevel;
|
|
220
272
|
const sinceStr = since || '';
|
|
221
273
|
const script = `
|
|
222
274
|
const logs = window.__MCP_CONSOLE_LOGS__ || [];
|
|
@@ -227,6 +279,10 @@ export async function getConsoleLogs(filter, since, windowId, appIdentifier) {
|
|
|
227
279
|
filtered = filtered.filter(l => l.timestamp > sinceTime);
|
|
228
280
|
}
|
|
229
281
|
|
|
282
|
+
if ('${levelStr}') {
|
|
283
|
+
filtered = filtered.filter(l => l.level === '${levelStr}');
|
|
284
|
+
}
|
|
285
|
+
|
|
230
286
|
if ('${filterStr}') {
|
|
231
287
|
try {
|
|
232
288
|
const regex = new RegExp('${filterStr}', 'i');
|
|
@@ -236,9 +292,34 @@ export async function getConsoleLogs(filter, since, windowId, appIdentifier) {
|
|
|
236
292
|
}
|
|
237
293
|
}
|
|
238
294
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
295
|
+
filtered = filtered.slice(-${resolvedLines});
|
|
296
|
+
|
|
297
|
+
var budget = ${resolvedMaxChars};
|
|
298
|
+
var dropped = 0;
|
|
299
|
+
var out = [];
|
|
300
|
+
|
|
301
|
+
for (var i = filtered.length - 1; i >= 0; i--) {
|
|
302
|
+
var entry = filtered[i],
|
|
303
|
+
excess = entry.message.length - ${resolvedMaxCharsPerEntry},
|
|
304
|
+
message = entry.message.length > ${resolvedMaxCharsPerEntry}
|
|
305
|
+
? entry.message.slice(0, ${resolvedMaxCharsPerEntry}) + '…[' + excess + ' more chars]'
|
|
306
|
+
: entry.message,
|
|
307
|
+
prefix = '[ ' + new Date(entry.timestamp).toISOString() + ' ] [ ' + entry.level.toUpperCase() + ' ] ',
|
|
308
|
+
line = prefix + message;
|
|
309
|
+
|
|
310
|
+
if (line.length > budget) { dropped = i + 1; break; }
|
|
311
|
+
budget -= line.length + 1;
|
|
312
|
+
out.unshift(line);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (dropped > 0) {
|
|
316
|
+
out.unshift(
|
|
317
|
+
'[ ' + dropped + ' older entries dropped to fit maxChars=' + ${resolvedMaxChars} +
|
|
318
|
+
'. Narrow with level, filter, or since. ]'
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return out.join('\\n');
|
|
242
323
|
`;
|
|
243
324
|
return executeInWebview(script, windowId, appIdentifier);
|
|
244
325
|
}
|
|
@@ -265,7 +346,7 @@ function parseDataUrl(dataUrl) {
|
|
|
265
346
|
/**
|
|
266
347
|
* Build screenshot result with image content and optional text context.
|
|
267
348
|
*/
|
|
268
|
-
function buildScreenshotResult(dataUrl, method, windowContext) {
|
|
349
|
+
function buildScreenshotResult(dataUrl, method, windowContext, metadata) {
|
|
269
350
|
const parsed = parseDataUrl(dataUrl);
|
|
270
351
|
if (!parsed) {
|
|
271
352
|
throw new Error(`Invalid data URL format: ${dataUrl.substring(0, 50)}...`);
|
|
@@ -279,6 +360,16 @@ function buildScreenshotResult(dataUrl, method, windowContext) {
|
|
|
279
360
|
contextText += `\n\n⚠️ ${windowContext.warning}`;
|
|
280
361
|
}
|
|
281
362
|
}
|
|
363
|
+
// Add screenshot metadata if available
|
|
364
|
+
if (metadata) {
|
|
365
|
+
const scale = metadata.cssWidth > 0 ? metadata.imageWidth / metadata.cssWidth : 0;
|
|
366
|
+
const inverseScale = scale > 0 ? (1 / scale).toFixed(1) : '1.0';
|
|
367
|
+
contextText += `\nImage is ${metadata.imageWidth}x${metadata.imageHeight} px. ` +
|
|
368
|
+
`Webview viewport is ${Math.round(metadata.cssWidth)}x${Math.round(metadata.cssHeight)} CSS px. ` +
|
|
369
|
+
`Scale ${scale.toFixed(3)}.`;
|
|
370
|
+
contextText += '\nwebview_interact x and y are CSS pixels: ' +
|
|
371
|
+
`multiply image coordinates by ${inverseScale}.`;
|
|
372
|
+
}
|
|
282
373
|
content.push({ type: 'text', text: contextText });
|
|
283
374
|
// Add the image content
|
|
284
375
|
content.push({
|
|
@@ -309,49 +400,53 @@ async function prepareHtml2canvasScript(format, quality, windowId, appIdentifier
|
|
|
309
400
|
return buildScreenshotScript(format, quality);
|
|
310
401
|
}
|
|
311
402
|
}
|
|
403
|
+
function parseNativeScreenshotPayload(rawPayload) {
|
|
404
|
+
if (typeof rawPayload === 'string') {
|
|
405
|
+
return { dataUrl: rawPayload };
|
|
406
|
+
}
|
|
407
|
+
const payload = rawPayload, dimensions = [payload.imageWidth, payload.imageHeight, payload.cssWidth, payload.cssHeight], hasMetadata = dimensions.every((value) => { return typeof value === 'number'; });
|
|
408
|
+
if (!hasMetadata) {
|
|
409
|
+
return { dataUrl: payload.dataUrl };
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
dataUrl: payload.dataUrl,
|
|
413
|
+
metadata: {
|
|
414
|
+
imageWidth: payload.imageWidth,
|
|
415
|
+
imageHeight: payload.imageHeight,
|
|
416
|
+
cssWidth: payload.cssWidth,
|
|
417
|
+
cssHeight: payload.cssHeight,
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
async function captureNativeScreenshot(options) {
|
|
422
|
+
const { format, quality, windowId, appIdentifier, maxWidth } = options;
|
|
423
|
+
await ensureReady(windowId, appIdentifier);
|
|
424
|
+
const session = resolveTargetApp(appIdentifier), args = { format, quality, windowLabel: windowId, maxWidth }, command = { command: 'capture_native_screenshot', args }, response = await session.client.sendCommand(command, 15000);
|
|
425
|
+
if (!response.success || !response.data) {
|
|
426
|
+
throw new Error(response.error || 'Native screenshot returned invalid data');
|
|
427
|
+
}
|
|
428
|
+
const { dataUrl, metadata } = parseNativeScreenshotPayload(response.data);
|
|
429
|
+
if (!dataUrl || !dataUrl.startsWith('data:image/')) {
|
|
430
|
+
throw new Error('Native screenshot returned invalid data');
|
|
431
|
+
}
|
|
432
|
+
return buildScreenshotResult(dataUrl, 'native API', response.windowContext, metadata);
|
|
433
|
+
}
|
|
312
434
|
/**
|
|
313
|
-
* Capture a screenshot of the
|
|
435
|
+
* Capture a screenshot of the visible webview viewport.
|
|
314
436
|
*
|
|
315
437
|
* @param options - Screenshot options (format, quality, windowId, appIdentifier, etc.)
|
|
316
438
|
* @returns Screenshot result with image content
|
|
317
439
|
*/
|
|
318
440
|
export async function captureScreenshot(options = {}) {
|
|
319
|
-
const { format = 'jpeg', quality = 80, windowId, appIdentifier, maxWidth } = options;
|
|
320
|
-
|
|
321
|
-
// - macOS: WKWebView takeSnapshot
|
|
322
|
-
// - Windows: WebView2 CapturePreview
|
|
323
|
-
// - Linux: Chromium/WebKit screenshot APIs
|
|
441
|
+
const { format = 'jpeg', quality = 80, windowId, appIdentifier, maxWidth, allowScreenCapture = false, } = options;
|
|
442
|
+
let nativeErrorMsg = 'Native screenshot unavailable';
|
|
324
443
|
try {
|
|
325
|
-
|
|
326
|
-
await ensureReady(windowId, appIdentifier);
|
|
327
|
-
// Resolve target session
|
|
328
|
-
const session = resolveTargetApp(appIdentifier);
|
|
329
|
-
const client = session.client;
|
|
330
|
-
// Use longer timeout (15s) for native screenshot - the Rust code waits up to 10s
|
|
331
|
-
const response = await client.sendCommand({
|
|
332
|
-
command: 'capture_native_screenshot',
|
|
333
|
-
args: {
|
|
334
|
-
format,
|
|
335
|
-
quality,
|
|
336
|
-
windowLabel: windowId,
|
|
337
|
-
maxWidth,
|
|
338
|
-
},
|
|
339
|
-
}, 15000);
|
|
340
|
-
if (!response.success || !response.data) {
|
|
341
|
-
throw new Error(response.error || 'Native screenshot returned invalid data');
|
|
342
|
-
}
|
|
343
|
-
// The native command returns a base64 data URL
|
|
344
|
-
const dataUrl = response.data;
|
|
345
|
-
if (!dataUrl || !dataUrl.startsWith('data:image/')) {
|
|
346
|
-
throw new Error('Native screenshot returned invalid data');
|
|
347
|
-
}
|
|
348
|
-
// Build response with window context
|
|
349
|
-
return buildScreenshotResult(dataUrl, 'native API', response.windowContext);
|
|
444
|
+
return await captureNativeScreenshot({ format, quality, windowId, appIdentifier, maxWidth });
|
|
350
445
|
}
|
|
351
446
|
catch (nativeError) {
|
|
352
447
|
// Log the native error for debugging, then fall back
|
|
353
|
-
|
|
354
|
-
driverLogger.error(`Native screenshot failed: ${
|
|
448
|
+
nativeErrorMsg = nativeError instanceof Error ? nativeError.message : String(nativeError);
|
|
449
|
+
driverLogger.error(`Native screenshot failed: ${nativeErrorMsg}, falling back to html2canvas`);
|
|
355
450
|
}
|
|
356
451
|
// Fallback 1: Use html2canvas library for high-quality DOM rendering
|
|
357
452
|
// Try to use the script manager to register html2canvas for persistence
|
|
@@ -422,6 +517,12 @@ export async function captureScreenshot(options = {}) {
|
|
|
422
517
|
throw new Error(`html2canvas returned invalid result: ${result?.substring(0, 100) || 'null'}`);
|
|
423
518
|
}
|
|
424
519
|
catch (html2canvasError) {
|
|
520
|
+
const html2canvasMsg = html2canvasError instanceof Error ? html2canvasError.message : 'html2canvas failed';
|
|
521
|
+
if (!allowScreenCapture) {
|
|
522
|
+
throw new Error(`Screenshot capture failed. Native API error: ${nativeErrorMsg}, ` +
|
|
523
|
+
`html2canvas error: ${html2canvasMsg}. ` +
|
|
524
|
+
'Screen Capture API fallback is disabled; set allowScreenCapture to true to request interactive permission.');
|
|
525
|
+
}
|
|
425
526
|
try {
|
|
426
527
|
// Fallback to Screen Capture API
|
|
427
528
|
const result = await executeAsyncInWebview(screenCaptureScript, windowId, 5000, appIdentifier);
|
|
@@ -433,9 +534,8 @@ export async function captureScreenshot(options = {}) {
|
|
|
433
534
|
}
|
|
434
535
|
catch (screenCaptureError) {
|
|
435
536
|
// All methods failed - throw a proper error
|
|
436
|
-
const html2canvasMsg = html2canvasError instanceof Error ? html2canvasError.message : 'html2canvas failed';
|
|
437
537
|
const screenCaptureMsg = screenCaptureError instanceof Error ? screenCaptureError.message : 'Screen Capture API failed';
|
|
438
|
-
throw new Error(
|
|
538
|
+
throw new Error(`Screenshot capture failed. Native API error: ${nativeErrorMsg}, ` +
|
|
439
539
|
`html2canvas error: ${html2canvasMsg}, ` +
|
|
440
540
|
`Screen Capture API error: ${screenCaptureMsg}`);
|
|
441
541
|
}
|
|
@@ -454,4 +554,5 @@ export const GetConsoleLogsSchema = z.object({
|
|
|
454
554
|
export const CaptureScreenshotSchema = z.object({
|
|
455
555
|
format: z.enum(['png', 'jpeg']).optional().default('jpeg').describe('Image format'),
|
|
456
556
|
quality: z.number().min(0).max(100).optional().describe('JPEG quality (0-100)'),
|
|
557
|
+
allowScreenCapture: z.boolean().optional().default(false).describe('Allow the Screen Capture API fallback, which opens an interactive OS permission prompt'),
|
|
457
558
|
});
|
|
@@ -18,9 +18,10 @@ export declare const InteractSchema: z.ZodObject<{
|
|
|
18
18
|
windowId: z.ZodOptional<z.ZodString>;
|
|
19
19
|
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
20
20
|
} & {
|
|
21
|
-
action: z.ZodEnum<["click", "double-click", "long-press", "scroll", "swipe", "focus"]>;
|
|
21
|
+
action: z.ZodEnum<["click", "double-click", "long-press", "scroll", "swipe", "focus", "hover", "right-click"]>;
|
|
22
22
|
selector: z.ZodOptional<z.ZodString>;
|
|
23
23
|
strategy: z.ZodDefault<z.ZodEnum<["css", "xpath", "text"]>>;
|
|
24
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
24
25
|
x: z.ZodOptional<z.ZodNumber>;
|
|
25
26
|
y: z.ZodOptional<z.ZodNumber>;
|
|
26
27
|
duration: z.ZodOptional<z.ZodNumber>;
|
|
@@ -31,11 +32,12 @@ export declare const InteractSchema: z.ZodObject<{
|
|
|
31
32
|
toX: z.ZodOptional<z.ZodNumber>;
|
|
32
33
|
toY: z.ZodOptional<z.ZodNumber>;
|
|
33
34
|
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
action: "swipe" | "focus" | "click" | "double-click" | "long-press" | "scroll";
|
|
35
|
+
action: "swipe" | "focus" | "click" | "double-click" | "long-press" | "scroll" | "hover" | "right-click";
|
|
35
36
|
strategy: "css" | "text" | "xpath";
|
|
36
37
|
windowId?: string | undefined;
|
|
37
38
|
appIdentifier?: string | number | undefined;
|
|
38
39
|
selector?: string | undefined;
|
|
40
|
+
nth?: number | undefined;
|
|
39
41
|
x?: number | undefined;
|
|
40
42
|
y?: number | undefined;
|
|
41
43
|
duration?: number | undefined;
|
|
@@ -46,11 +48,12 @@ export declare const InteractSchema: z.ZodObject<{
|
|
|
46
48
|
toX?: number | undefined;
|
|
47
49
|
toY?: number | undefined;
|
|
48
50
|
}, {
|
|
49
|
-
action: "swipe" | "focus" | "click" | "double-click" | "long-press" | "scroll";
|
|
51
|
+
action: "swipe" | "focus" | "click" | "double-click" | "long-press" | "scroll" | "hover" | "right-click";
|
|
50
52
|
windowId?: string | undefined;
|
|
51
53
|
appIdentifier?: string | number | undefined;
|
|
52
54
|
selector?: string | undefined;
|
|
53
55
|
strategy?: "css" | "text" | "xpath" | undefined;
|
|
56
|
+
nth?: number | undefined;
|
|
54
57
|
x?: number | undefined;
|
|
55
58
|
y?: number | undefined;
|
|
56
59
|
duration?: number | undefined;
|
|
@@ -69,19 +72,22 @@ export declare const ScreenshotSchema: z.ZodObject<{
|
|
|
69
72
|
quality: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
70
73
|
filePath: z.ZodOptional<z.ZodString>;
|
|
71
74
|
maxWidth: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
allowScreenCapture: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
72
76
|
}, "strip", z.ZodTypeAny, {
|
|
73
77
|
format: "png" | "jpeg";
|
|
74
78
|
quality: number;
|
|
79
|
+
allowScreenCapture: boolean;
|
|
75
80
|
windowId?: string | undefined;
|
|
76
81
|
appIdentifier?: string | number | undefined;
|
|
77
82
|
maxWidth?: number | undefined;
|
|
78
83
|
filePath?: string | undefined;
|
|
79
84
|
}, {
|
|
80
|
-
format?: "png" | "jpeg" | undefined;
|
|
81
|
-
quality?: number | undefined;
|
|
82
85
|
windowId?: string | undefined;
|
|
83
86
|
appIdentifier?: string | number | undefined;
|
|
87
|
+
format?: "png" | "jpeg" | undefined;
|
|
88
|
+
quality?: number | undefined;
|
|
84
89
|
maxWidth?: number | undefined;
|
|
90
|
+
allowScreenCapture?: boolean | undefined;
|
|
85
91
|
filePath?: string | undefined;
|
|
86
92
|
}>;
|
|
87
93
|
export declare const KeyboardSchema: z.ZodObject<{
|
|
@@ -91,25 +97,28 @@ export declare const KeyboardSchema: z.ZodObject<{
|
|
|
91
97
|
action: z.ZodEnum<["type", "press", "down", "up"]>;
|
|
92
98
|
selector: z.ZodOptional<z.ZodString>;
|
|
93
99
|
strategy: z.ZodDefault<z.ZodEnum<["css", "xpath", "text"]>>;
|
|
100
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
94
101
|
text: z.ZodOptional<z.ZodString>;
|
|
95
102
|
key: z.ZodOptional<z.ZodString>;
|
|
96
103
|
modifiers: z.ZodOptional<z.ZodArray<z.ZodEnum<["Control", "Alt", "Shift", "Meta"]>, "many">>;
|
|
97
104
|
}, "strip", z.ZodTypeAny, {
|
|
98
105
|
action: "type" | "press" | "down" | "up";
|
|
99
106
|
strategy: "css" | "text" | "xpath";
|
|
100
|
-
text?: string | undefined;
|
|
101
107
|
windowId?: string | undefined;
|
|
102
108
|
appIdentifier?: string | number | undefined;
|
|
109
|
+
text?: string | undefined;
|
|
103
110
|
selector?: string | undefined;
|
|
111
|
+
nth?: number | undefined;
|
|
104
112
|
key?: string | undefined;
|
|
105
113
|
modifiers?: ("Control" | "Alt" | "Shift" | "Meta")[] | undefined;
|
|
106
114
|
}, {
|
|
107
115
|
action: "type" | "press" | "down" | "up";
|
|
108
|
-
text?: string | undefined;
|
|
109
116
|
windowId?: string | undefined;
|
|
110
117
|
appIdentifier?: string | number | undefined;
|
|
118
|
+
text?: string | undefined;
|
|
111
119
|
selector?: string | undefined;
|
|
112
120
|
strategy?: "css" | "text" | "xpath" | undefined;
|
|
121
|
+
nth?: number | undefined;
|
|
113
122
|
key?: string | undefined;
|
|
114
123
|
modifiers?: ("Control" | "Alt" | "Shift" | "Meta")[] | undefined;
|
|
115
124
|
}>;
|
|
@@ -124,40 +133,17 @@ export declare const WaitForSchema: z.ZodObject<{
|
|
|
124
133
|
}, "strip", z.ZodTypeAny, {
|
|
125
134
|
value: string;
|
|
126
135
|
type: "text" | "selector" | "ipc-event";
|
|
127
|
-
strategy: "css" | "text" | "xpath";
|
|
128
136
|
timeout: number;
|
|
137
|
+
strategy: "css" | "text" | "xpath";
|
|
129
138
|
windowId?: string | undefined;
|
|
130
139
|
appIdentifier?: string | number | undefined;
|
|
131
140
|
}, {
|
|
132
141
|
value: string;
|
|
133
142
|
type: "text" | "selector" | "ipc-event";
|
|
134
|
-
windowId?: string | undefined;
|
|
135
|
-
appIdentifier?: string | number | undefined;
|
|
136
|
-
strategy?: "css" | "text" | "xpath" | undefined;
|
|
137
143
|
timeout?: number | undefined;
|
|
138
|
-
}>;
|
|
139
|
-
export declare const GetStylesSchema: z.ZodObject<{
|
|
140
|
-
windowId: z.ZodOptional<z.ZodString>;
|
|
141
|
-
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
142
|
-
} & {
|
|
143
|
-
selector: z.ZodString;
|
|
144
|
-
strategy: z.ZodDefault<z.ZodEnum<["css", "xpath", "text"]>>;
|
|
145
|
-
properties: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
146
|
-
multiple: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
147
|
-
}, "strip", z.ZodTypeAny, {
|
|
148
|
-
selector: string;
|
|
149
|
-
strategy: "css" | "text" | "xpath";
|
|
150
|
-
multiple: boolean;
|
|
151
|
-
windowId?: string | undefined;
|
|
152
|
-
appIdentifier?: string | number | undefined;
|
|
153
|
-
properties?: string[] | undefined;
|
|
154
|
-
}, {
|
|
155
|
-
selector: string;
|
|
156
144
|
windowId?: string | undefined;
|
|
157
145
|
appIdentifier?: string | number | undefined;
|
|
158
146
|
strategy?: "css" | "text" | "xpath" | undefined;
|
|
159
|
-
properties?: string[] | undefined;
|
|
160
|
-
multiple?: boolean | undefined;
|
|
161
147
|
}>;
|
|
162
148
|
export declare const ExecuteJavaScriptSchema: z.ZodObject<{
|
|
163
149
|
windowId: z.ZodOptional<z.ZodString>;
|
|
@@ -165,13 +151,16 @@ export declare const ExecuteJavaScriptSchema: z.ZodObject<{
|
|
|
165
151
|
} & {
|
|
166
152
|
script: z.ZodString;
|
|
167
153
|
args: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
154
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
168
155
|
}, "strip", z.ZodTypeAny, {
|
|
169
156
|
script: string;
|
|
157
|
+
timeout?: number | undefined;
|
|
170
158
|
windowId?: string | undefined;
|
|
171
159
|
appIdentifier?: string | number | undefined;
|
|
172
160
|
args?: unknown[] | undefined;
|
|
173
161
|
}, {
|
|
174
162
|
script: string;
|
|
163
|
+
timeout?: number | undefined;
|
|
175
164
|
windowId?: string | undefined;
|
|
176
165
|
appIdentifier?: string | number | undefined;
|
|
177
166
|
args?: unknown[] | undefined;
|
|
@@ -181,14 +170,20 @@ export declare const FocusElementSchema: z.ZodObject<{
|
|
|
181
170
|
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
182
171
|
} & {
|
|
183
172
|
selector: z.ZodString;
|
|
173
|
+
strategy: z.ZodDefault<z.ZodEnum<["css", "xpath", "text"]>>;
|
|
174
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
184
175
|
}, "strip", z.ZodTypeAny, {
|
|
185
176
|
selector: string;
|
|
177
|
+
strategy: "css" | "text" | "xpath";
|
|
186
178
|
windowId?: string | undefined;
|
|
187
179
|
appIdentifier?: string | number | undefined;
|
|
180
|
+
nth?: number | undefined;
|
|
188
181
|
}, {
|
|
189
182
|
selector: string;
|
|
190
183
|
windowId?: string | undefined;
|
|
191
184
|
appIdentifier?: string | number | undefined;
|
|
185
|
+
strategy?: "css" | "text" | "xpath" | undefined;
|
|
186
|
+
nth?: number | undefined;
|
|
192
187
|
}>;
|
|
193
188
|
export declare const FindElementSchema: z.ZodObject<{
|
|
194
189
|
windowId: z.ZodOptional<z.ZodString>;
|
|
@@ -196,16 +191,31 @@ export declare const FindElementSchema: z.ZodObject<{
|
|
|
196
191
|
} & {
|
|
197
192
|
selector: z.ZodString;
|
|
198
193
|
strategy: z.ZodDefault<z.ZodEnum<["css", "xpath", "text"]>>;
|
|
194
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
196
|
+
properties: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
197
|
+
visibleOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
198
|
+
includeHtml: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
199
199
|
}, "strip", z.ZodTypeAny, {
|
|
200
200
|
selector: string;
|
|
201
201
|
strategy: "css" | "text" | "xpath";
|
|
202
|
+
limit: number;
|
|
203
|
+
visibleOnly: boolean;
|
|
204
|
+
includeHtml: boolean;
|
|
202
205
|
windowId?: string | undefined;
|
|
203
206
|
appIdentifier?: string | number | undefined;
|
|
207
|
+
nth?: number | undefined;
|
|
208
|
+
properties?: string[] | undefined;
|
|
204
209
|
}, {
|
|
205
210
|
selector: string;
|
|
206
211
|
windowId?: string | undefined;
|
|
207
212
|
appIdentifier?: string | number | undefined;
|
|
208
213
|
strategy?: "css" | "text" | "xpath" | undefined;
|
|
214
|
+
nth?: number | undefined;
|
|
215
|
+
limit?: number | undefined;
|
|
216
|
+
properties?: string[] | undefined;
|
|
217
|
+
visibleOnly?: boolean | undefined;
|
|
218
|
+
includeHtml?: boolean | undefined;
|
|
209
219
|
}>;
|
|
210
220
|
export declare const GetConsoleLogsSchema: z.ZodObject<{
|
|
211
221
|
windowId: z.ZodOptional<z.ZodString>;
|
|
@@ -215,14 +225,14 @@ export declare const GetConsoleLogsSchema: z.ZodObject<{
|
|
|
215
225
|
since: z.ZodOptional<z.ZodString>;
|
|
216
226
|
}, "strip", z.ZodTypeAny, {
|
|
217
227
|
filter?: string | undefined;
|
|
228
|
+
since?: string | undefined;
|
|
218
229
|
windowId?: string | undefined;
|
|
219
230
|
appIdentifier?: string | number | undefined;
|
|
220
|
-
since?: string | undefined;
|
|
221
231
|
}, {
|
|
222
232
|
filter?: string | undefined;
|
|
233
|
+
since?: string | undefined;
|
|
223
234
|
windowId?: string | undefined;
|
|
224
235
|
appIdentifier?: string | number | undefined;
|
|
225
|
-
since?: string | undefined;
|
|
226
236
|
}>;
|
|
227
237
|
export declare const DomSnapshotSchema: z.ZodObject<{
|
|
228
238
|
windowId: z.ZodOptional<z.ZodString>;
|
|
@@ -248,6 +258,7 @@ export declare function interact(options: {
|
|
|
248
258
|
action: string;
|
|
249
259
|
selector?: string;
|
|
250
260
|
strategy?: string;
|
|
261
|
+
nth?: number;
|
|
251
262
|
x?: number;
|
|
252
263
|
y?: number;
|
|
253
264
|
duration?: number;
|
|
@@ -267,6 +278,7 @@ export interface ScreenshotOptions {
|
|
|
267
278
|
filePath?: string;
|
|
268
279
|
appIdentifier?: string | number;
|
|
269
280
|
maxWidth?: number;
|
|
281
|
+
allowScreenCapture?: boolean;
|
|
270
282
|
}
|
|
271
283
|
export interface ScreenshotFileResult {
|
|
272
284
|
filePath: string;
|
|
@@ -277,6 +289,7 @@ export interface KeyboardOptions {
|
|
|
277
289
|
action: string;
|
|
278
290
|
selectorOrKey?: string;
|
|
279
291
|
strategy?: string;
|
|
292
|
+
nth?: number;
|
|
280
293
|
textOrModifiers?: string | string[];
|
|
281
294
|
modifiers?: string[];
|
|
282
295
|
windowId?: string;
|
|
@@ -292,18 +305,10 @@ export interface WaitForOptions {
|
|
|
292
305
|
appIdentifier?: string | number;
|
|
293
306
|
}
|
|
294
307
|
export declare function waitFor(options: WaitForOptions): Promise<string>;
|
|
295
|
-
export interface GetStylesOptions {
|
|
296
|
-
selector: string;
|
|
297
|
-
strategy?: string;
|
|
298
|
-
properties?: string[];
|
|
299
|
-
multiple?: boolean;
|
|
300
|
-
windowId?: string;
|
|
301
|
-
appIdentifier?: string | number;
|
|
302
|
-
}
|
|
303
|
-
export declare function getStyles(options: GetStylesOptions): Promise<string>;
|
|
304
308
|
export interface ExecuteJavaScriptOptions {
|
|
305
309
|
script: string;
|
|
306
310
|
args?: unknown[];
|
|
311
|
+
timeout?: number;
|
|
307
312
|
windowId?: string;
|
|
308
313
|
appIdentifier?: string | number;
|
|
309
314
|
}
|
|
@@ -311,6 +316,7 @@ export declare function executeJavaScript(options: ExecuteJavaScriptOptions): Pr
|
|
|
311
316
|
export interface FocusElementOptions {
|
|
312
317
|
selector: string;
|
|
313
318
|
strategy?: string;
|
|
319
|
+
nth?: number;
|
|
314
320
|
windowId?: string;
|
|
315
321
|
appIdentifier?: string | number;
|
|
316
322
|
}
|
|
@@ -318,6 +324,11 @@ export declare function focusElement(options: FocusElementOptions): Promise<stri
|
|
|
318
324
|
export interface FindElementOptions {
|
|
319
325
|
selector: string;
|
|
320
326
|
strategy: string;
|
|
327
|
+
nth?: number;
|
|
328
|
+
limit?: number;
|
|
329
|
+
properties?: string[];
|
|
330
|
+
visibleOnly?: boolean;
|
|
331
|
+
includeHtml?: boolean;
|
|
321
332
|
windowId?: string;
|
|
322
333
|
appIdentifier?: string | number;
|
|
323
334
|
}
|
|
@@ -326,6 +337,10 @@ export interface FindElementOptions {
|
|
|
326
337
|
*/
|
|
327
338
|
export declare function findElement(options: FindElementOptions): Promise<string>;
|
|
328
339
|
export interface GetConsoleLogsOptions {
|
|
340
|
+
lines?: number;
|
|
341
|
+
level?: 'log' | 'debug' | 'info' | 'warn' | 'error';
|
|
342
|
+
maxChars?: number;
|
|
343
|
+
maxCharsPerEntry?: number;
|
|
329
344
|
filter?: string;
|
|
330
345
|
since?: string;
|
|
331
346
|
windowId?: string;
|