@midscene/core 0.26.2 → 0.26.3-beta-20250813021342.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/ai-model.mjs +2502 -0
- package/dist/es/ai-model.mjs.map +1 -0
- package/dist/es/index.mjs +2362 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/tree.mjs +2 -0
- package/dist/es/utils.mjs +188 -0
- package/dist/es/{chunk-O3KUKF2A.js.map → utils.mjs.map} +1 -1
- package/dist/lib/ai-model.js +2581 -3
- package/dist/lib/ai-model.js.map +1 -0
- package/dist/lib/index.js +2375 -493
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/tree.js +42 -11
- package/dist/lib/tree.js.map +1 -1
- package/dist/lib/utils.js +257 -29
- package/dist/lib/utils.js.map +1 -0
- package/dist/types/ai-model.d.ts +505 -99
- package/dist/types/index.d.ts +1299 -53
- package/dist/types/tree.d.ts +11 -1
- package/dist/types/utils.d.ts +47 -33
- package/package.json +28 -12
- package/dist/es/ai-model.d.ts +0 -99
- package/dist/es/ai-model.js +0 -44
- package/dist/es/chunk-DDYIQHOA.js +0 -2883
- package/dist/es/chunk-DDYIQHOA.js.map +0 -1
- package/dist/es/chunk-O3KUKF2A.js +0 -265
- package/dist/es/index.d.ts +0 -53
- package/dist/es/index.js +0 -570
- package/dist/es/index.js.map +0 -1
- package/dist/es/llm-planning-4e0c16fe.d.ts +0 -106
- package/dist/es/tree.d.ts +0 -1
- package/dist/es/tree.js +0 -13
- package/dist/es/tree.js.map +0 -1
- package/dist/es/types-8a6be57c.d.ts +0 -577
- package/dist/es/utils.d.ts +0 -33
- package/dist/es/utils.js +0 -30
- package/dist/lib/ai-model.d.ts +0 -99
- package/dist/lib/chunk-DDYIQHOA.js +0 -2883
- package/dist/lib/chunk-DDYIQHOA.js.map +0 -1
- package/dist/lib/chunk-O3KUKF2A.js +0 -265
- package/dist/lib/chunk-O3KUKF2A.js.map +0 -1
- package/dist/lib/index.d.ts +0 -53
- package/dist/lib/llm-planning-4e0c16fe.d.ts +0 -106
- package/dist/lib/tree.d.ts +0 -1
- package/dist/lib/types-8a6be57c.d.ts +0 -577
- package/dist/lib/utils.d.ts +0 -33
- package/dist/types/llm-planning-4e0c16fe.d.ts +0 -106
- package/dist/types/types-8a6be57c.d.ts +0 -577
package/dist/types/tree.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { descriptionOfTree } from '@midscene/shared/extractor';
|
|
2
|
+
import { trimAttributes } from '@midscene/shared/extractor';
|
|
3
|
+
import { truncateText } from '@midscene/shared/extractor';
|
|
4
|
+
|
|
5
|
+
export { descriptionOfTree }
|
|
6
|
+
|
|
7
|
+
export { trimAttributes }
|
|
8
|
+
|
|
9
|
+
export { truncateText }
|
|
10
|
+
|
|
11
|
+
export { }
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,33 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
declare function
|
|
27
|
-
|
|
28
|
-
declare function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { Rect } from '@midscene/shared/types';
|
|
2
|
+
|
|
3
|
+
export declare function getTmpDir(): string | null;
|
|
4
|
+
|
|
5
|
+
export declare function getTmpFile(fileExtWithoutDot: string): string | null;
|
|
6
|
+
|
|
7
|
+
export declare function getVersion(): string;
|
|
8
|
+
|
|
9
|
+
export declare const groupedActionDumpFileExt = "web-dump.json";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* high performance, insert script before </html> in HTML file
|
|
13
|
+
* only truncate and append, no temporary file
|
|
14
|
+
*/
|
|
15
|
+
export declare function insertScriptBeforeClosingHtml(filePath: string, scriptContent: string): void;
|
|
16
|
+
|
|
17
|
+
export declare function overlapped(container: Rect, target: Rect): boolean;
|
|
18
|
+
|
|
19
|
+
export declare function replacerForPageObject(key: string, value: any): any;
|
|
20
|
+
|
|
21
|
+
declare interface ReportDumpWithAttributes {
|
|
22
|
+
dumpString: string;
|
|
23
|
+
attributes?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare function reportHTMLContent(dumpData: string | ReportDumpWithAttributes, reportPath?: string, appendReport?: boolean): string;
|
|
27
|
+
|
|
28
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
|
29
|
+
|
|
30
|
+
export declare function stringifyDumpData(data: any, indents?: number): string;
|
|
31
|
+
|
|
32
|
+
export declare function uploadTestInfoToServer({ testUrl }: {
|
|
33
|
+
testUrl: string;
|
|
34
|
+
}): void;
|
|
35
|
+
|
|
36
|
+
export declare function writeDumpReport(fileName: string, dumpData: string | ReportDumpWithAttributes, appendReport?: boolean): string | null;
|
|
37
|
+
|
|
38
|
+
export declare function writeLogFile(opts: {
|
|
39
|
+
fileName: string;
|
|
40
|
+
fileExt: string;
|
|
41
|
+
fileContent: string;
|
|
42
|
+
type: 'dump' | 'cache' | 'report' | 'tmp';
|
|
43
|
+
generateReport?: boolean;
|
|
44
|
+
appendReport?: boolean;
|
|
45
|
+
}): string | null;
|
|
46
|
+
|
|
47
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
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": "0.26.
|
|
4
|
+
"version": "0.26.3-beta-20250813021342.0",
|
|
5
5
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
6
6
|
"homepage": "https://midscenejs.com/",
|
|
7
7
|
"jsnext:source": "./src/index.ts",
|
|
8
8
|
"main": "./dist/lib/index.js",
|
|
9
9
|
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"module": "./dist/es/index.mjs",
|
|
10
11
|
"files": [
|
|
11
12
|
"dist",
|
|
12
13
|
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
|
+
"import": "./dist/es/index.mjs",
|
|
19
|
+
"require": "./dist/lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./utils": {
|
|
22
|
+
"types": "./dist/types/utils.d.ts",
|
|
23
|
+
"import": "./dist/es/utils.mjs",
|
|
24
|
+
"require": "./dist/lib/utils.js"
|
|
25
|
+
},
|
|
26
|
+
"./ai-model": {
|
|
27
|
+
"types": "./dist/types/ai-model.d.ts",
|
|
28
|
+
"import": "./dist/es/ai-model.mjs",
|
|
29
|
+
"require": "./dist/lib/ai-model.js"
|
|
30
|
+
},
|
|
31
|
+
"./tree": {
|
|
32
|
+
"types": "./dist/types/tree.d.ts",
|
|
33
|
+
"import": "./dist/es/tree.mjs",
|
|
34
|
+
"require": "./dist/lib/tree.js"
|
|
35
|
+
}
|
|
19
36
|
},
|
|
20
37
|
"typesVersions": {
|
|
21
38
|
"*": {
|
|
@@ -44,11 +61,12 @@
|
|
|
44
61
|
"langsmith": "0.3.7",
|
|
45
62
|
"openai": "4.81.0",
|
|
46
63
|
"socks-proxy-agent": "8.0.4",
|
|
47
|
-
"@midscene/recorder": "0.26.
|
|
48
|
-
"@midscene/shared": "0.26.
|
|
64
|
+
"@midscene/recorder": "0.26.3-beta-20250813021342.0",
|
|
65
|
+
"@midscene/shared": "0.26.3-beta-20250813021342.0"
|
|
49
66
|
},
|
|
50
67
|
"devDependencies": {
|
|
51
|
-
"@
|
|
68
|
+
"@microsoft/api-extractor": "^7.52.10",
|
|
69
|
+
"@rslib/core": "^0.11.2",
|
|
52
70
|
"@types/node": "^18.0.0",
|
|
53
71
|
"@types/node-fetch": "2.6.11",
|
|
54
72
|
"typescript": "^5.8.3",
|
|
@@ -64,10 +82,8 @@
|
|
|
64
82
|
"license": "MIT",
|
|
65
83
|
"scripts": {
|
|
66
84
|
"dev": "npm run build:watch",
|
|
67
|
-
"build": "
|
|
68
|
-
"build:watch": "USE_DEV_REPORT=1
|
|
69
|
-
"new": "modern new",
|
|
70
|
-
"upgrade": "modern upgrade",
|
|
85
|
+
"build": "rslib build",
|
|
86
|
+
"build:watch": "USE_DEV_REPORT=1 rslib build --watch",
|
|
71
87
|
"test": "vitest --run",
|
|
72
88
|
"test:u": "vitest --run -u",
|
|
73
89
|
"test:ai": "AITEST=true npm run test",
|
package/dist/es/ai-model.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { aD as StreamingCallback, A as AIUsageInfo, aC as StreamingCodeGenerationOptions, aF as StreamingAIResponse, Y as PlanningAction, m as MidsceneYamlFlowItem } from './types-8a6be57c.js';
|
|
2
|
-
import OpenAI from 'openai';
|
|
3
|
-
import { ChatCompletionMessageParam } from 'openai/resources';
|
|
4
|
-
export { ChatCompletionMessageParam } from 'openai/resources';
|
|
5
|
-
import { b as AIActionType, e as AIArgs } from './llm-planning-4e0c16fe.js';
|
|
6
|
-
export { a as AiAssert, g as AiExtractElementInfo, A as AiLocateElement, h as AiLocateSection, i as adaptBboxToRect, c as callAiFn, d as describeUserPage, f as elementByPositionWithElementInfo, p as plan } from './llm-planning-4e0c16fe.js';
|
|
7
|
-
import { vlLocateMode } from '@midscene/shared/env';
|
|
8
|
-
import { actionParser } from '@ui-tars/action-parser';
|
|
9
|
-
import { Size } from '@midscene/shared/types';
|
|
10
|
-
import '@midscene/shared/constants';
|
|
11
|
-
|
|
12
|
-
declare function call(messages: ChatCompletionMessageParam[], AIActionTypeValue: AIActionType, responseFormat?: OpenAI.ChatCompletionCreateParams['response_format'] | OpenAI.ResponseFormatJSONObject, options?: {
|
|
13
|
-
stream?: boolean;
|
|
14
|
-
onChunk?: StreamingCallback;
|
|
15
|
-
}): Promise<{
|
|
16
|
-
content: string;
|
|
17
|
-
usage?: AIUsageInfo;
|
|
18
|
-
isStreamed: boolean;
|
|
19
|
-
}>;
|
|
20
|
-
declare function callToGetJSONObject<T>(messages: ChatCompletionMessageParam[], AIActionTypeValue: AIActionType): Promise<{
|
|
21
|
-
content: T;
|
|
22
|
-
usage?: AIUsageInfo;
|
|
23
|
-
}>;
|
|
24
|
-
declare function callAiFnWithStringResponse<T>(msgs: AIArgs, AIActionTypeValue: AIActionType): Promise<{
|
|
25
|
-
content: string;
|
|
26
|
-
usage?: AIUsageInfo;
|
|
27
|
-
}>;
|
|
28
|
-
|
|
29
|
-
declare function systemPromptToLocateElement(vlMode: ReturnType<typeof vlLocateMode>): string;
|
|
30
|
-
|
|
31
|
-
interface ChromeRecordedEvent {
|
|
32
|
-
type: string;
|
|
33
|
-
timestamp: number;
|
|
34
|
-
url?: string;
|
|
35
|
-
title?: string;
|
|
36
|
-
elementDescription?: string;
|
|
37
|
-
value?: string;
|
|
38
|
-
pageInfo?: any;
|
|
39
|
-
elementRect?: any;
|
|
40
|
-
screenshotBefore?: string;
|
|
41
|
-
screenshotAfter?: string;
|
|
42
|
-
screenshotWithBox?: string;
|
|
43
|
-
}
|
|
44
|
-
interface YamlGenerationOptions {
|
|
45
|
-
testName?: string;
|
|
46
|
-
includeTimestamps?: boolean;
|
|
47
|
-
maxScreenshots?: number;
|
|
48
|
-
description?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Generates YAML test configuration from recorded events using AI
|
|
52
|
-
*/
|
|
53
|
-
declare const generateYamlTest: (events: ChromeRecordedEvent[], options?: YamlGenerationOptions) => Promise<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Generates YAML test configuration from recorded events using AI with streaming support
|
|
56
|
-
*/
|
|
57
|
-
declare const generateYamlTestStream: (events: ChromeRecordedEvent[], options?: YamlGenerationOptions & StreamingCodeGenerationOptions) => Promise<StreamingAIResponse>;
|
|
58
|
-
|
|
59
|
-
interface PlaywrightGenerationOptions {
|
|
60
|
-
testName?: string;
|
|
61
|
-
includeScreenshots?: boolean;
|
|
62
|
-
includeTimestamps?: boolean;
|
|
63
|
-
maxScreenshots?: number;
|
|
64
|
-
description?: string;
|
|
65
|
-
viewportSize?: {
|
|
66
|
-
width: number;
|
|
67
|
-
height: number;
|
|
68
|
-
};
|
|
69
|
-
waitForNetworkIdle?: boolean;
|
|
70
|
-
waitForNetworkIdleTimeout?: number;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Generates Playwright test code from recorded events
|
|
75
|
-
*/
|
|
76
|
-
declare const generatePlaywrightTest: (events: ChromeRecordedEvent[], options?: PlaywrightGenerationOptions) => Promise<string>;
|
|
77
|
-
/**
|
|
78
|
-
* Generates Playwright test code from recorded events with streaming support
|
|
79
|
-
*/
|
|
80
|
-
declare const generatePlaywrightTestStream: (events: ChromeRecordedEvent[], options?: PlaywrightGenerationOptions & StreamingCodeGenerationOptions) => Promise<StreamingAIResponse>;
|
|
81
|
-
|
|
82
|
-
declare function vlmPlanning(options: {
|
|
83
|
-
userInstruction: string;
|
|
84
|
-
conversationHistory: ChatCompletionMessageParam[];
|
|
85
|
-
size: {
|
|
86
|
-
width: number;
|
|
87
|
-
height: number;
|
|
88
|
-
};
|
|
89
|
-
}): Promise<{
|
|
90
|
-
actions: PlanningAction<any>[];
|
|
91
|
-
actionsFromModel: ReturnType<typeof actionParser>['parsed'];
|
|
92
|
-
action_summary: string;
|
|
93
|
-
yamlFlow?: MidsceneYamlFlowItem[];
|
|
94
|
-
usage?: AIUsageInfo;
|
|
95
|
-
rawResponse?: string;
|
|
96
|
-
}>;
|
|
97
|
-
declare function resizeImageForUiTars(imageBase64: string, size: Size): Promise<string>;
|
|
98
|
-
|
|
99
|
-
export { AIActionType, AIArgs, call as callAi, callAiFnWithStringResponse, callToGetJSONObject, generatePlaywrightTest, generatePlaywrightTestStream, generateYamlTest, generateYamlTestStream, resizeImageForUiTars, systemPromptToLocateElement, vlmPlanning };
|
package/dist/es/ai-model.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AIActionType,
|
|
3
|
-
AiAssert,
|
|
4
|
-
AiExtractElementInfo,
|
|
5
|
-
AiLocateElement,
|
|
6
|
-
AiLocateSection,
|
|
7
|
-
adaptBboxToRect,
|
|
8
|
-
call,
|
|
9
|
-
callAiFn,
|
|
10
|
-
callAiFnWithStringResponse,
|
|
11
|
-
callToGetJSONObject,
|
|
12
|
-
describeUserPage,
|
|
13
|
-
elementByPositionWithElementInfo,
|
|
14
|
-
generatePlaywrightTest,
|
|
15
|
-
generatePlaywrightTestStream,
|
|
16
|
-
generateYamlTest,
|
|
17
|
-
generateYamlTestStream,
|
|
18
|
-
plan,
|
|
19
|
-
resizeImageForUiTars,
|
|
20
|
-
systemPromptToLocateElement,
|
|
21
|
-
vlmPlanning
|
|
22
|
-
} from "./chunk-DDYIQHOA.js";
|
|
23
|
-
export {
|
|
24
|
-
AIActionType,
|
|
25
|
-
AiAssert,
|
|
26
|
-
AiExtractElementInfo,
|
|
27
|
-
AiLocateElement,
|
|
28
|
-
AiLocateSection,
|
|
29
|
-
adaptBboxToRect,
|
|
30
|
-
call as callAi,
|
|
31
|
-
callAiFn,
|
|
32
|
-
callAiFnWithStringResponse,
|
|
33
|
-
callToGetJSONObject,
|
|
34
|
-
describeUserPage,
|
|
35
|
-
elementByPositionWithElementInfo,
|
|
36
|
-
generatePlaywrightTest,
|
|
37
|
-
generatePlaywrightTestStream,
|
|
38
|
-
generateYamlTest,
|
|
39
|
-
generateYamlTestStream,
|
|
40
|
-
plan,
|
|
41
|
-
resizeImageForUiTars,
|
|
42
|
-
systemPromptToLocateElement,
|
|
43
|
-
vlmPlanning
|
|
44
|
-
};
|