@midscene/core 1.2.3-beta-20260127070952.0 → 1.3.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/dist/es/agent/task-builder.mjs +2 -1
- package/dist/es/agent/task-builder.mjs.map +1 -1
- package/dist/es/agent/tasks.mjs +29 -17
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +3 -2
- package/dist/es/agent/utils.mjs.map +1 -1
- package/dist/es/ai-model/auto-glm/planning.mjs +15 -9
- package/dist/es/ai-model/auto-glm/planning.mjs.map +1 -1
- package/dist/es/ai-model/index.mjs +2 -2
- package/dist/es/ai-model/inspect.mjs +44 -4
- package/dist/es/ai-model/inspect.mjs.map +1 -1
- package/dist/es/ai-model/llm-planning.mjs +8 -2
- package/dist/es/ai-model/llm-planning.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/index.mjs +20 -2
- package/dist/es/ai-model/service-caller/index.mjs.map +1 -1
- package/dist/es/ai-model/ui-tars-planning.mjs +25 -24
- package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -1
- package/dist/es/service/index.mjs +44 -10
- package/dist/es/service/index.mjs.map +1 -1
- package/dist/es/utils.mjs +2 -2
- package/dist/lib/agent/task-builder.js +2 -1
- package/dist/lib/agent/task-builder.js.map +1 -1
- package/dist/lib/agent/tasks.js +28 -16
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/utils.js +2 -1
- package/dist/lib/agent/utils.js.map +1 -1
- package/dist/lib/ai-model/auto-glm/planning.js +14 -8
- package/dist/lib/ai-model/auto-glm/planning.js.map +1 -1
- package/dist/lib/ai-model/index.js +3 -0
- package/dist/lib/ai-model/inspect.js +43 -3
- package/dist/lib/ai-model/inspect.js.map +1 -1
- package/dist/lib/ai-model/llm-planning.js +7 -1
- package/dist/lib/ai-model/llm-planning.js.map +1 -1
- package/dist/lib/ai-model/service-caller/index.js +25 -4
- package/dist/lib/ai-model/service-caller/index.js.map +1 -1
- package/dist/lib/ai-model/ui-tars-planning.js +24 -23
- package/dist/lib/ai-model/ui-tars-planning.js.map +1 -1
- package/dist/lib/service/index.js +43 -9
- package/dist/lib/service/index.js.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/types/ai-model/index.d.ts +1 -1
- package/dist/types/ai-model/inspect.d.ts +3 -2
- package/dist/types/ai-model/service-caller/index.d.ts +5 -0
- package/dist/types/device/device-options.d.ts +68 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { callAIWithStringResponse, callAIWithObjectResponse, callAI, } from './service-caller/index';
|
|
1
|
+
export { AIResponseParseError, callAIWithStringResponse, callAIWithObjectResponse, callAI, } from './service-caller/index';
|
|
2
2
|
export { systemPromptToLocateElement } from './prompt/llm-locator';
|
|
3
3
|
export { generatePlaywrightTest, generatePlaywrightTestStream, } from './prompt/playwright-generator';
|
|
4
4
|
export { generateYamlTest, generateYamlTestStream, } from './prompt/yaml-generator';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AIElementResponse, AIUsageInfo, Rect, ServiceExtractOption, UIContext } from '../types';
|
|
1
|
+
import type { AIDataExtractionResponse, AIElementResponse, AIUsageInfo, Rect, ServiceExtractOption, UIContext } from '../types';
|
|
2
2
|
import type { IModelConfig } from '@midscene/shared/env';
|
|
3
3
|
import type { LocateResultElement } from '@midscene/shared/types';
|
|
4
4
|
import type { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources/index';
|
|
@@ -43,7 +43,8 @@ export declare function AiExtractElementInfo<T>(options: {
|
|
|
43
43
|
extractOption?: ServiceExtractOption;
|
|
44
44
|
modelConfig: IModelConfig;
|
|
45
45
|
}): Promise<{
|
|
46
|
-
parseResult:
|
|
46
|
+
parseResult: AIDataExtractionResponse<T>;
|
|
47
|
+
rawResponse: string;
|
|
47
48
|
usage: AIUsageInfo | undefined;
|
|
48
49
|
reasoning_content: string | undefined;
|
|
49
50
|
}>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { AIUsageInfo, DeepThinkOption } from '../../types';
|
|
2
2
|
import type { StreamingCallback } from '../../types';
|
|
3
|
+
export declare class AIResponseParseError extends Error {
|
|
4
|
+
usage?: AIUsageInfo;
|
|
5
|
+
rawResponse: string;
|
|
6
|
+
constructor(message: string, rawResponse: string, usage?: AIUsageInfo);
|
|
7
|
+
}
|
|
3
8
|
import { type IModelConfig, type TModelFamily } from '@midscene/shared/env';
|
|
4
9
|
import type { ChatCompletionMessageParam } from 'openai/resources/index';
|
|
5
10
|
import type { AIArgs } from '../../common';
|
|
@@ -34,6 +34,74 @@ export type AndroidDeviceOpt = {
|
|
|
34
34
|
alwaysRefreshScreenInfo?: boolean;
|
|
35
35
|
/** Minimum screenshot buffer size in bytes (default: 10240 = 10KB). Set to 0 to disable validation. */
|
|
36
36
|
minScreenshotBufferSize?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Scrcpy screenshot configuration for high-performance screen capture.
|
|
39
|
+
*
|
|
40
|
+
* Scrcpy provides 6-8x faster screenshots by streaming H.264 video from the device.
|
|
41
|
+
* When enabled, scrcpy will:
|
|
42
|
+
* 1. Start a video stream from the device on first screenshot request
|
|
43
|
+
* 2. Keep the connection alive for subsequent screenshots (16-50ms each)
|
|
44
|
+
* 3. Automatically disconnect after idle timeout to save resources
|
|
45
|
+
* 4. Fallback to standard ADB mode if unavailable
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Default configuration (enabled with auto-fallback)
|
|
50
|
+
* const device = new AndroidDevice(deviceId);
|
|
51
|
+
*
|
|
52
|
+
* // Custom configuration
|
|
53
|
+
* const device = new AndroidDevice(deviceId, {
|
|
54
|
+
* scrcpyConfig: {
|
|
55
|
+
* enabled: true,
|
|
56
|
+
* maxSize: 0, // 0 = no scaling
|
|
57
|
+
* idleTimeoutMs: 30000,
|
|
58
|
+
* videoBitRate: 8_000_000,
|
|
59
|
+
* },
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Disable scrcpy (force ADB mode)
|
|
63
|
+
* const device = new AndroidDevice(deviceId, {
|
|
64
|
+
* scrcpyConfig: { enabled: false },
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
scrcpyConfig?: {
|
|
69
|
+
/**
|
|
70
|
+
* Enable scrcpy for high-performance screenshots.
|
|
71
|
+
* @default true - Automatically enabled with fallback to ADB if unavailable
|
|
72
|
+
*/
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Maximum video dimension (width or height).
|
|
76
|
+
* Video stream will be scaled down if device resolution exceeds this value.
|
|
77
|
+
* Lower values reduce bandwidth but may affect image quality.
|
|
78
|
+
*
|
|
79
|
+
* If not specified and `screenshotResizeScale` is set, maxSize will be
|
|
80
|
+
* automatically calculated to match the target resolution.
|
|
81
|
+
*
|
|
82
|
+
* @default 0 (no scaling, use original resolution)
|
|
83
|
+
* @example
|
|
84
|
+
* // Manual control
|
|
85
|
+
* { maxSize: 1024 } // Always scale to 1024
|
|
86
|
+
*
|
|
87
|
+
* // Auto-calculated from screenshotResizeScale
|
|
88
|
+
* { screenshotResizeScale: 0.5 } // Device 1080p → scrcpy maxSize will be 1200
|
|
89
|
+
*/
|
|
90
|
+
maxSize?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Idle timeout in milliseconds before disconnecting scrcpy.
|
|
93
|
+
* Connection auto-closes after this period of inactivity to save resources.
|
|
94
|
+
* Set to 0 to disable auto-disconnect.
|
|
95
|
+
* @default 30000 (30 seconds)
|
|
96
|
+
*/
|
|
97
|
+
idleTimeoutMs?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Video bit rate for H.264 encoding in bits per second.
|
|
100
|
+
* Higher values improve quality but increase bandwidth usage.
|
|
101
|
+
* @default 2000000 (2 Mbps)
|
|
102
|
+
*/
|
|
103
|
+
videoBitRate?: number;
|
|
104
|
+
};
|
|
37
105
|
} & AndroidDeviceInputOpt;
|
|
38
106
|
/**
|
|
39
107
|
* iOS device input options
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/core",
|
|
3
3
|
"description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
6
6
|
"homepage": "https://midscenejs.com/",
|
|
7
7
|
"main": "./dist/lib/index.js",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"semver": "7.5.2",
|
|
90
90
|
"undici": "^6.0.0",
|
|
91
91
|
"zod": "3.24.3",
|
|
92
|
-
"@midscene/shared": "1.
|
|
92
|
+
"@midscene/shared": "1.3.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@rslib/core": "^0.18.3",
|