@aiscene/core 1.1.1
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/es/agent/agent.mjs +753 -0
- package/dist/es/agent/agent.mjs.map +1 -0
- package/dist/es/agent/common.mjs +0 -0
- package/dist/es/agent/execution-session.mjs +41 -0
- package/dist/es/agent/execution-session.mjs.map +1 -0
- package/dist/es/agent/index.mjs +6 -0
- package/dist/es/agent/task-builder.mjs +332 -0
- package/dist/es/agent/task-builder.mjs.map +1 -0
- package/dist/es/agent/task-cache.mjs +214 -0
- package/dist/es/agent/task-cache.mjs.map +1 -0
- package/dist/es/agent/tasks.mjs +423 -0
- package/dist/es/agent/tasks.mjs.map +1 -0
- package/dist/es/agent/ui-utils.mjs +91 -0
- package/dist/es/agent/ui-utils.mjs.map +1 -0
- package/dist/es/agent/utils.mjs +169 -0
- package/dist/es/agent/utils.mjs.map +1 -0
- package/dist/es/ai-model/auto-glm/actions.mjs +239 -0
- package/dist/es/ai-model/auto-glm/actions.mjs.map +1 -0
- package/dist/es/ai-model/auto-glm/index.mjs +6 -0
- package/dist/es/ai-model/auto-glm/parser.mjs +239 -0
- package/dist/es/ai-model/auto-glm/parser.mjs.map +1 -0
- package/dist/es/ai-model/auto-glm/planning.mjs +71 -0
- package/dist/es/ai-model/auto-glm/planning.mjs.map +1 -0
- package/dist/es/ai-model/auto-glm/prompt.mjs +222 -0
- package/dist/es/ai-model/auto-glm/prompt.mjs.map +1 -0
- package/dist/es/ai-model/auto-glm/util.mjs +9 -0
- package/dist/es/ai-model/auto-glm/util.mjs.map +1 -0
- package/dist/es/ai-model/connectivity.mjs +138 -0
- package/dist/es/ai-model/connectivity.mjs.map +1 -0
- package/dist/es/ai-model/conversation-history.mjs +195 -0
- package/dist/es/ai-model/conversation-history.mjs.map +1 -0
- package/dist/es/ai-model/index.mjs +12 -0
- package/dist/es/ai-model/inspect.mjs +397 -0
- package/dist/es/ai-model/inspect.mjs.map +1 -0
- package/dist/es/ai-model/llm-planning.mjs +233 -0
- package/dist/es/ai-model/llm-planning.mjs.map +1 -0
- package/dist/es/ai-model/prompt/common.mjs +7 -0
- package/dist/es/ai-model/prompt/common.mjs.map +1 -0
- package/dist/es/ai-model/prompt/describe.mjs +66 -0
- package/dist/es/ai-model/prompt/describe.mjs.map +1 -0
- package/dist/es/ai-model/prompt/extraction.mjs +131 -0
- package/dist/es/ai-model/prompt/extraction.mjs.map +1 -0
- package/dist/es/ai-model/prompt/llm-locator.mjs +51 -0
- package/dist/es/ai-model/prompt/llm-locator.mjs.map +1 -0
- package/dist/es/ai-model/prompt/llm-planning.mjs +568 -0
- package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -0
- package/dist/es/ai-model/prompt/llm-section-locator.mjs +44 -0
- package/dist/es/ai-model/prompt/llm-section-locator.mjs.map +1 -0
- package/dist/es/ai-model/prompt/order-sensitive-judge.mjs +35 -0
- package/dist/es/ai-model/prompt/order-sensitive-judge.mjs.map +1 -0
- package/dist/es/ai-model/prompt/playwright-generator.mjs +117 -0
- package/dist/es/ai-model/prompt/playwright-generator.mjs.map +1 -0
- package/dist/es/ai-model/prompt/ui-tars-planning.mjs +36 -0
- package/dist/es/ai-model/prompt/ui-tars-planning.mjs.map +1 -0
- package/dist/es/ai-model/prompt/util.mjs +59 -0
- package/dist/es/ai-model/prompt/util.mjs.map +1 -0
- package/dist/es/ai-model/prompt/yaml-generator.mjs +203 -0
- package/dist/es/ai-model/prompt/yaml-generator.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/codex-app-server.mjs +575 -0
- package/dist/es/ai-model/service-caller/codex-app-server.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/image-detail.mjs +6 -0
- package/dist/es/ai-model/service-caller/image-detail.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/index.mjs +475 -0
- package/dist/es/ai-model/service-caller/index.mjs.map +1 -0
- package/dist/es/ai-model/ui-tars-planning.mjs +249 -0
- package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -0
- package/dist/es/common.mjs +371 -0
- package/dist/es/common.mjs.map +1 -0
- package/dist/es/device/device-options.mjs +0 -0
- package/dist/es/device/index.mjs +341 -0
- package/dist/es/device/index.mjs.map +1 -0
- package/dist/es/dump/html-utils.mjs +292 -0
- package/dist/es/dump/html-utils.mjs.map +1 -0
- package/dist/es/dump/index.mjs +3 -0
- package/dist/es/dump/screenshot-restoration.mjs +32 -0
- package/dist/es/dump/screenshot-restoration.mjs.map +1 -0
- package/dist/es/dump/screenshot-store.mjs +126 -0
- package/dist/es/dump/screenshot-store.mjs.map +1 -0
- package/dist/es/index.mjs +19 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/report-cli.mjs +151 -0
- package/dist/es/report-cli.mjs.map +1 -0
- package/dist/es/report-generator.mjs +205 -0
- package/dist/es/report-generator.mjs.map +1 -0
- package/dist/es/report-markdown.mjs +218 -0
- package/dist/es/report-markdown.mjs.map +1 -0
- package/dist/es/report.mjs +270 -0
- package/dist/es/report.mjs.map +1 -0
- package/dist/es/screenshot-item.mjs +122 -0
- package/dist/es/screenshot-item.mjs.map +1 -0
- package/dist/es/service/index.mjs +274 -0
- package/dist/es/service/index.mjs.map +1 -0
- package/dist/es/service/utils.mjs +15 -0
- package/dist/es/service/utils.mjs.map +1 -0
- package/dist/es/skill/index.mjs +38 -0
- package/dist/es/skill/index.mjs.map +1 -0
- package/dist/es/task-runner.mjs +263 -0
- package/dist/es/task-runner.mjs.map +1 -0
- package/dist/es/task-timing.mjs +12 -0
- package/dist/es/task-timing.mjs.map +1 -0
- package/dist/es/tree.mjs +13 -0
- package/dist/es/tree.mjs.map +1 -0
- package/dist/es/types.mjs +204 -0
- package/dist/es/types.mjs.map +1 -0
- package/dist/es/utils.mjs +234 -0
- package/dist/es/utils.mjs.map +1 -0
- package/dist/es/yaml/builder.mjs +13 -0
- package/dist/es/yaml/builder.mjs.map +1 -0
- package/dist/es/yaml/index.mjs +4 -0
- package/dist/es/yaml/player.mjs +442 -0
- package/dist/es/yaml/player.mjs.map +1 -0
- package/dist/es/yaml/utils.mjs +102 -0
- package/dist/es/yaml/utils.mjs.map +1 -0
- package/dist/es/yaml.mjs +0 -0
- package/dist/lib/agent/agent.js +801 -0
- package/dist/lib/agent/agent.js.map +1 -0
- package/dist/lib/agent/common.js +5 -0
- package/dist/lib/agent/execution-session.js +75 -0
- package/dist/lib/agent/execution-session.js.map +1 -0
- package/dist/lib/agent/index.js +78 -0
- package/dist/lib/agent/index.js.map +1 -0
- package/dist/lib/agent/task-builder.js +369 -0
- package/dist/lib/agent/task-builder.js.map +1 -0
- package/dist/lib/agent/task-cache.js +266 -0
- package/dist/lib/agent/task-cache.js.map +1 -0
- package/dist/lib/agent/tasks.js +466 -0
- package/dist/lib/agent/tasks.js.map +1 -0
- package/dist/lib/agent/ui-utils.js +143 -0
- package/dist/lib/agent/ui-utils.js.map +1 -0
- package/dist/lib/agent/utils.js +240 -0
- package/dist/lib/agent/utils.js.map +1 -0
- package/dist/lib/ai-model/auto-glm/actions.js +273 -0
- package/dist/lib/ai-model/auto-glm/actions.js.map +1 -0
- package/dist/lib/ai-model/auto-glm/index.js +66 -0
- package/dist/lib/ai-model/auto-glm/index.js.map +1 -0
- package/dist/lib/ai-model/auto-glm/parser.js +282 -0
- package/dist/lib/ai-model/auto-glm/parser.js.map +1 -0
- package/dist/lib/ai-model/auto-glm/planning.js +105 -0
- package/dist/lib/ai-model/auto-glm/planning.js.map +1 -0
- package/dist/lib/ai-model/auto-glm/prompt.js +259 -0
- package/dist/lib/ai-model/auto-glm/prompt.js.map +1 -0
- package/dist/lib/ai-model/auto-glm/util.js +46 -0
- package/dist/lib/ai-model/auto-glm/util.js.map +1 -0
- package/dist/lib/ai-model/connectivity.js +182 -0
- package/dist/lib/ai-model/connectivity.js.map +1 -0
- package/dist/lib/ai-model/conversation-history.js +229 -0
- package/dist/lib/ai-model/conversation-history.js.map +1 -0
- package/dist/lib/ai-model/index.js +129 -0
- package/dist/lib/ai-model/index.js.map +1 -0
- package/dist/lib/ai-model/inspect.js +443 -0
- package/dist/lib/ai-model/inspect.js.map +1 -0
- package/dist/lib/ai-model/llm-planning.js +270 -0
- package/dist/lib/ai-model/llm-planning.js.map +1 -0
- package/dist/lib/ai-model/prompt/common.js +41 -0
- package/dist/lib/ai-model/prompt/common.js.map +1 -0
- package/dist/lib/ai-model/prompt/describe.js +100 -0
- package/dist/lib/ai-model/prompt/describe.js.map +1 -0
- package/dist/lib/ai-model/prompt/extraction.js +171 -0
- package/dist/lib/ai-model/prompt/extraction.js.map +1 -0
- package/dist/lib/ai-model/prompt/llm-locator.js +88 -0
- package/dist/lib/ai-model/prompt/llm-locator.js.map +1 -0
- package/dist/lib/ai-model/prompt/llm-planning.js +605 -0
- package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -0
- package/dist/lib/ai-model/prompt/llm-section-locator.js +81 -0
- package/dist/lib/ai-model/prompt/llm-section-locator.js.map +1 -0
- package/dist/lib/ai-model/prompt/order-sensitive-judge.js +72 -0
- package/dist/lib/ai-model/prompt/order-sensitive-judge.js.map +1 -0
- package/dist/lib/ai-model/prompt/playwright-generator.js +178 -0
- package/dist/lib/ai-model/prompt/playwright-generator.js.map +1 -0
- package/dist/lib/ai-model/prompt/ui-tars-planning.js +73 -0
- package/dist/lib/ai-model/prompt/ui-tars-planning.js.map +1 -0
- package/dist/lib/ai-model/prompt/util.js +105 -0
- package/dist/lib/ai-model/prompt/util.js.map +1 -0
- package/dist/lib/ai-model/prompt/yaml-generator.js +264 -0
- package/dist/lib/ai-model/prompt/yaml-generator.js.map +1 -0
- package/dist/lib/ai-model/service-caller/codex-app-server.js +624 -0
- package/dist/lib/ai-model/service-caller/codex-app-server.js.map +1 -0
- package/dist/lib/ai-model/service-caller/image-detail.js +40 -0
- package/dist/lib/ai-model/service-caller/image-detail.js.map +1 -0
- package/dist/lib/ai-model/service-caller/index.js +540 -0
- package/dist/lib/ai-model/service-caller/index.js.map +1 -0
- package/dist/lib/ai-model/ui-tars-planning.js +283 -0
- package/dist/lib/ai-model/ui-tars-planning.js.map +1 -0
- package/dist/lib/common.js +480 -0
- package/dist/lib/common.js.map +1 -0
- package/dist/lib/device/device-options.js +20 -0
- package/dist/lib/device/device-options.js.map +1 -0
- package/dist/lib/device/index.js +468 -0
- package/dist/lib/device/index.js.map +1 -0
- package/dist/lib/dump/html-utils.js +368 -0
- package/dist/lib/dump/html-utils.js.map +1 -0
- package/dist/lib/dump/index.js +60 -0
- package/dist/lib/dump/index.js.map +1 -0
- package/dist/lib/dump/screenshot-restoration.js +66 -0
- package/dist/lib/dump/screenshot-restoration.js.map +1 -0
- package/dist/lib/dump/screenshot-store.js +166 -0
- package/dist/lib/dump/screenshot-store.js.map +1 -0
- package/dist/lib/index.js +186 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/report-cli.js +191 -0
- package/dist/lib/report-cli.js.map +1 -0
- package/dist/lib/report-generator.js +246 -0
- package/dist/lib/report-generator.js.map +1 -0
- package/dist/lib/report-markdown.js +255 -0
- package/dist/lib/report-markdown.js.map +1 -0
- package/dist/lib/report.js +316 -0
- package/dist/lib/report.js.map +1 -0
- package/dist/lib/screenshot-item.js +156 -0
- package/dist/lib/screenshot-item.js.map +1 -0
- package/dist/lib/service/index.js +308 -0
- package/dist/lib/service/index.js.map +1 -0
- package/dist/lib/service/utils.js +49 -0
- package/dist/lib/service/utils.js.map +1 -0
- package/dist/lib/skill/index.js +72 -0
- package/dist/lib/skill/index.js.map +1 -0
- package/dist/lib/task-runner.js +300 -0
- package/dist/lib/task-runner.js.map +1 -0
- package/dist/lib/task-timing.js +46 -0
- package/dist/lib/task-timing.js.map +1 -0
- package/dist/lib/tree.js +53 -0
- package/dist/lib/tree.js.map +1 -0
- package/dist/lib/types.js +300 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.js +316 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/yaml/builder.js +57 -0
- package/dist/lib/yaml/builder.js.map +1 -0
- package/dist/lib/yaml/index.js +81 -0
- package/dist/lib/yaml/index.js.map +1 -0
- package/dist/lib/yaml/player.js +476 -0
- package/dist/lib/yaml/player.js.map +1 -0
- package/dist/lib/yaml/utils.js +155 -0
- package/dist/lib/yaml/utils.js.map +1 -0
- package/dist/lib/yaml.js +20 -0
- package/dist/lib/yaml.js.map +1 -0
- package/dist/types/agent/agent.d.ts +216 -0
- package/dist/types/agent/common.d.ts +0 -0
- package/dist/types/agent/execution-session.d.ts +36 -0
- package/dist/types/agent/index.d.ts +9 -0
- package/dist/types/agent/task-builder.d.ts +34 -0
- package/dist/types/agent/task-cache.d.ts +49 -0
- package/dist/types/agent/tasks.d.ts +69 -0
- package/dist/types/agent/ui-utils.d.ts +14 -0
- package/dist/types/agent/utils.d.ts +25 -0
- package/dist/types/ai-model/auto-glm/actions.d.ts +78 -0
- package/dist/types/ai-model/auto-glm/index.d.ts +6 -0
- package/dist/types/ai-model/auto-glm/parser.d.ts +18 -0
- package/dist/types/ai-model/auto-glm/planning.d.ts +12 -0
- package/dist/types/ai-model/auto-glm/prompt.d.ts +27 -0
- package/dist/types/ai-model/auto-glm/util.d.ts +13 -0
- package/dist/types/ai-model/connectivity.d.ts +20 -0
- package/dist/types/ai-model/conversation-history.d.ts +105 -0
- package/dist/types/ai-model/index.d.ts +16 -0
- package/dist/types/ai-model/inspect.d.ts +67 -0
- package/dist/types/ai-model/llm-planning.d.ts +19 -0
- package/dist/types/ai-model/prompt/common.d.ts +2 -0
- package/dist/types/ai-model/prompt/describe.d.ts +1 -0
- package/dist/types/ai-model/prompt/extraction.d.ts +7 -0
- package/dist/types/ai-model/prompt/llm-locator.d.ts +3 -0
- package/dist/types/ai-model/prompt/llm-planning.d.ts +10 -0
- package/dist/types/ai-model/prompt/llm-section-locator.d.ts +3 -0
- package/dist/types/ai-model/prompt/order-sensitive-judge.d.ts +2 -0
- package/dist/types/ai-model/prompt/playwright-generator.d.ts +26 -0
- package/dist/types/ai-model/prompt/ui-tars-planning.d.ts +2 -0
- package/dist/types/ai-model/prompt/util.d.ts +33 -0
- package/dist/types/ai-model/prompt/yaml-generator.d.ts +102 -0
- package/dist/types/ai-model/service-caller/codex-app-server.d.ts +42 -0
- package/dist/types/ai-model/service-caller/image-detail.d.ts +2 -0
- package/dist/types/ai-model/service-caller/index.d.ts +49 -0
- package/dist/types/ai-model/ui-tars-planning.d.ts +72 -0
- package/dist/types/common.d.ts +288 -0
- package/dist/types/device/device-options.d.ts +145 -0
- package/dist/types/device/index.d.ts +2528 -0
- package/dist/types/dump/html-utils.d.ts +75 -0
- package/dist/types/dump/index.d.ts +5 -0
- package/dist/types/dump/screenshot-restoration.d.ts +8 -0
- package/dist/types/dump/screenshot-store.d.ts +49 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/report-cli.d.ts +36 -0
- package/dist/types/report-generator.d.ts +81 -0
- package/dist/types/report-markdown.d.ts +24 -0
- package/dist/types/report.d.ts +52 -0
- package/dist/types/screenshot-item.d.ts +67 -0
- package/dist/types/service/index.d.ts +24 -0
- package/dist/types/service/utils.d.ts +2 -0
- package/dist/types/skill/index.d.ts +25 -0
- package/dist/types/task-runner.d.ts +50 -0
- package/dist/types/task-timing.d.ts +8 -0
- package/dist/types/tree.d.ts +4 -0
- package/dist/types/types.d.ts +681 -0
- package/dist/types/utils.d.ts +45 -0
- package/dist/types/yaml/builder.d.ts +2 -0
- package/dist/types/yaml/index.d.ts +4 -0
- package/dist/types/yaml/player.d.ts +34 -0
- package/dist/types/yaml/utils.d.ts +9 -0
- package/dist/types/yaml.d.ts +215 -0
- package/package.json +111 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const escapeContent: (html: string) => string;
|
|
2
|
+
export declare const unescapeContent: (html: string) => string;
|
|
3
|
+
/** Chunk size for streaming file operations (64KB) */
|
|
4
|
+
export declare const STREAMING_CHUNK_SIZE: number;
|
|
5
|
+
/**
|
|
6
|
+
* Callback for processing matched tags during streaming.
|
|
7
|
+
* @param content - The content between open and close tags
|
|
8
|
+
* @returns true to stop scanning, false to continue
|
|
9
|
+
*/
|
|
10
|
+
type TagMatchCallback = (content: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Stream through a file and find tags matching the pattern.
|
|
13
|
+
* Memory usage: O(chunk_size + tag_size), not O(file_size).
|
|
14
|
+
*
|
|
15
|
+
* @param filePath - Absolute path to the file
|
|
16
|
+
* @param openTag - Opening tag to search for
|
|
17
|
+
* @param closeTag - Closing tag
|
|
18
|
+
* @param onMatch - Callback for each matched tag content
|
|
19
|
+
*/
|
|
20
|
+
export declare function streamScanTags(filePath: string, openTag: string, closeTag: string, onMatch: TagMatchCallback): void;
|
|
21
|
+
/**
|
|
22
|
+
* Synchronously extract a specific image's base64 data from an HTML file by its id.
|
|
23
|
+
* Uses streaming to avoid loading the entire file into memory.
|
|
24
|
+
*
|
|
25
|
+
* @param htmlPath - Absolute path to the HTML file
|
|
26
|
+
* @param imageId - The id of the image to extract
|
|
27
|
+
* @returns The base64 data string, or null if not found
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractImageByIdSync(htmlPath: string, imageId: string): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Stream image script tags from source file directly to output file.
|
|
32
|
+
* Memory usage: O(single_image_size), not O(all_images_size).
|
|
33
|
+
*
|
|
34
|
+
* @param srcFilePath - Source HTML file path
|
|
35
|
+
* @param destFilePath - Destination file path to append to
|
|
36
|
+
*/
|
|
37
|
+
export declare function streamImageScriptsToFile(srcFilePath: string, destFilePath: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Extract the LAST dump script content from HTML file using streaming.
|
|
40
|
+
* Memory usage: O(dump_size), not O(file_size).
|
|
41
|
+
*
|
|
42
|
+
* @param filePath - Absolute path to the HTML file
|
|
43
|
+
* @returns The dump script content (trimmed), or empty string if not found
|
|
44
|
+
*/
|
|
45
|
+
export declare function extractLastDumpScriptSync(filePath: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Extract ALL dump script contents from an HTML file using streaming.
|
|
48
|
+
* Each entry includes the full opening tag (for attribute extraction) and the content.
|
|
49
|
+
*
|
|
50
|
+
* @param filePath - Absolute path to the HTML file
|
|
51
|
+
* @returns Array of { openTag, content } for each dump script found
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractAllDumpScriptsSync(filePath: string): {
|
|
54
|
+
openTag: string;
|
|
55
|
+
content: string;
|
|
56
|
+
}[];
|
|
57
|
+
/**
|
|
58
|
+
* Stream ALL dump scripts from an HTML file.
|
|
59
|
+
* Calls onMatch for each dump script and keeps memory bounded to a single
|
|
60
|
+
* dump script payload instead of accumulating every dump in memory.
|
|
61
|
+
*
|
|
62
|
+
* @param filePath - Absolute path to the HTML file
|
|
63
|
+
* @param onMatch - Callback for each dump script; return true to stop early
|
|
64
|
+
*/
|
|
65
|
+
export declare function streamDumpScriptsSync(filePath: string, onMatch: (dumpScript: {
|
|
66
|
+
openTag: string;
|
|
67
|
+
content: string;
|
|
68
|
+
}) => boolean): void;
|
|
69
|
+
export declare function parseImageScripts(html: string): Record<string, string>;
|
|
70
|
+
export declare function parseDumpScript(html: string): string;
|
|
71
|
+
export declare function parseDumpScriptAttributes(html: string): Record<string, string>;
|
|
72
|
+
export declare function generateImageScriptTag(id: string, data: string): string;
|
|
73
|
+
export declare function getBaseUrlFixScript(): string;
|
|
74
|
+
export declare function generateDumpScriptTag(json: string, attributes?: Record<string, string | number | boolean>): string;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dump module - utilities for HTML parsing and image restoration.
|
|
3
|
+
*/
|
|
4
|
+
export { restoreImageReferences } from './screenshot-restoration';
|
|
5
|
+
export { escapeContent, unescapeContent, parseImageScripts, parseDumpScript, parseDumpScriptAttributes, generateImageScriptTag, generateDumpScriptTag, } from './html-utils';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ScreenshotRef } from './screenshot-store';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively restore image references in parsed data.
|
|
4
|
+
* Replaces ScreenshotRef with lazy
|
|
5
|
+
* { get base64() {...}, capturedAt } objects.
|
|
6
|
+
* The resolver is only called when .base64 is first accessed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function restoreImageReferences<T>(data: T, resolveImage: (ref: ScreenshotRef) => string): T;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ScreenshotItem } from '../screenshot-item';
|
|
2
|
+
export interface ScreenshotRef {
|
|
3
|
+
type: 'midscene_screenshot_ref';
|
|
4
|
+
id: string;
|
|
5
|
+
capturedAt: number;
|
|
6
|
+
mimeType: 'image/png' | 'image/jpeg';
|
|
7
|
+
storage: 'inline' | 'file';
|
|
8
|
+
path?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function normalizeScreenshotRef(value: unknown): ScreenshotRef | null;
|
|
11
|
+
type ResolvedScreenshotSource = {
|
|
12
|
+
type: 'data-uri';
|
|
13
|
+
id: string;
|
|
14
|
+
mimeType: ScreenshotRef['mimeType'];
|
|
15
|
+
dataUri: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'file';
|
|
18
|
+
id: string;
|
|
19
|
+
mimeType: ScreenshotRef['mimeType'];
|
|
20
|
+
filePath: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function resolveScreenshotSource(refInput: unknown, options: {
|
|
23
|
+
reportPath: string;
|
|
24
|
+
fallbackId?: string;
|
|
25
|
+
fallbackMimeType?: ScreenshotRef['mimeType'];
|
|
26
|
+
}): ResolvedScreenshotSource;
|
|
27
|
+
export declare class ScreenshotStore {
|
|
28
|
+
private readonly mode;
|
|
29
|
+
private readonly reportPath;
|
|
30
|
+
private readonly screenshotsDir?;
|
|
31
|
+
private readonly writeInlineImage?;
|
|
32
|
+
private readonly alsoWriteFileCopy;
|
|
33
|
+
private readonly writtenInlineIds;
|
|
34
|
+
private readonly writtenFileIds;
|
|
35
|
+
constructor(options: {
|
|
36
|
+
mode: 'inline' | 'directory';
|
|
37
|
+
reportPath: string;
|
|
38
|
+
screenshotsDir?: string;
|
|
39
|
+
writeInlineImage?: (id: string, base64: string) => void;
|
|
40
|
+
alsoWriteFileCopy?: boolean;
|
|
41
|
+
/** @deprecated Use alsoWriteFileCopy instead. */
|
|
42
|
+
ensureFileCopy?: boolean;
|
|
43
|
+
});
|
|
44
|
+
persist(screenshot: ScreenshotItem): ScreenshotRef;
|
|
45
|
+
private persistToSharedFileIfNeeded;
|
|
46
|
+
loadBase64(refInput: unknown): string;
|
|
47
|
+
cleanup(): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import Service from './service/index';
|
|
3
|
+
import { TaskRunner } from './task-runner';
|
|
4
|
+
import { getVersion } from './utils';
|
|
5
|
+
export { plan, AiLocateElement, runConnectivityTest, getMidsceneLocationSchema, PointSchema, SizeSchema, RectSchema, TMultimodalPromptSchema, TUserPromptSchema, type TMultimodalPrompt, type TUserPrompt, type ConnectivityCheckResultItem, type ConnectivityTestConfig, type ConnectivityTestResult, } from './ai-model/index';
|
|
6
|
+
export { MIDSCENE_MODEL_NAME, type CreateOpenAIClientFn, } from '@midscene/shared/env';
|
|
7
|
+
export type * from './types';
|
|
8
|
+
export { ServiceError, ExecutionDump, ReportActionDump, GroupedActionDump, type IExecutionDump, type IReportActionDump, type IGroupedActionDump, type ReportMeta, type GroupMeta, } from './types';
|
|
9
|
+
export { z };
|
|
10
|
+
export default Service;
|
|
11
|
+
export { TaskRunner, Service, getVersion };
|
|
12
|
+
export type { MidsceneYamlScript, MidsceneYamlTask, MidsceneYamlFlowItem, MidsceneYamlConfigResult, MidsceneYamlConfig, MidsceneYamlScriptWebEnv, MidsceneYamlScriptAndroidEnv, MidsceneYamlScriptIOSEnv, MidsceneYamlScriptEnv, LocateOption, DetailedLocateParam, } from './yaml';
|
|
13
|
+
export { Agent, type AgentOpt, type AiActOptions, createAgent } from './agent';
|
|
14
|
+
export { restoreImageReferences, escapeContent, unescapeContent, parseImageScripts, parseDumpScript, parseDumpScriptAttributes, generateImageScriptTag, generateDumpScriptTag, } from './dump';
|
|
15
|
+
export type { IReportGenerator } from './report-generator';
|
|
16
|
+
export { ReportGenerator, nullReportGenerator } from './report-generator';
|
|
17
|
+
export { collectDedupedExecutions, ReportMergingTool, dedupeExecutionsKeepLatest, splitReportHtmlByExecution, } from './report';
|
|
18
|
+
export { createReportCliCommands, reportFileToMarkdown, splitReportFile, type ConsumeReportFileAction, type ReportFileToMarkdownOptions, type ReportCliCommandDefinition, type ReportCliCommandEntry, type SplitReportFileOptions, } from './report-cli';
|
|
19
|
+
export { ScreenshotItem } from './screenshot-item';
|
|
20
|
+
export { ScreenshotStore, type ScreenshotRef } from './dump/screenshot-store';
|
|
21
|
+
export { executionToMarkdown, reportToMarkdown, type ExecutionMarkdownOptions, type ExecutionMarkdownResult, type ReportMarkdownResult, type MarkdownAttachment, } from './report-markdown';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
type ReportCliToolResult = {
|
|
3
|
+
isError: boolean;
|
|
4
|
+
content: Array<{
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
type ReportCliSchema = Record<string, z.ZodTypeAny>;
|
|
10
|
+
export interface ReportCliCommandDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
schema: ReportCliSchema;
|
|
14
|
+
handler: (args: Record<string, unknown>) => Promise<ReportCliToolResult>;
|
|
15
|
+
}
|
|
16
|
+
export interface ReportCliCommandEntry {
|
|
17
|
+
name: string;
|
|
18
|
+
def: ReportCliCommandDefinition;
|
|
19
|
+
}
|
|
20
|
+
export type ConsumeReportFileAction = 'split' | 'to-markdown';
|
|
21
|
+
export interface ConsumeReportFileOptions {
|
|
22
|
+
htmlPath: string;
|
|
23
|
+
outputDir: string;
|
|
24
|
+
}
|
|
25
|
+
export type SplitReportFileOptions = ConsumeReportFileOptions;
|
|
26
|
+
export type ReportFileToMarkdownOptions = ConsumeReportFileOptions;
|
|
27
|
+
export declare function splitReportFile(options: SplitReportFileOptions): {
|
|
28
|
+
executionJsonFiles: string[];
|
|
29
|
+
screenshotFiles: string[];
|
|
30
|
+
};
|
|
31
|
+
export declare function reportFileToMarkdown(options: ReportFileToMarkdownOptions): Promise<{
|
|
32
|
+
markdownFiles: string[];
|
|
33
|
+
screenshotFiles: string[];
|
|
34
|
+
}>;
|
|
35
|
+
export declare function createReportCliCommands(): ReportCliCommandEntry[];
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type ExecutionDump, ReportActionDump, type ReportAttributes, type ReportMeta } from './types';
|
|
2
|
+
export interface IReportGenerator {
|
|
3
|
+
/**
|
|
4
|
+
* Write or update a single execution.
|
|
5
|
+
* Each call appends a new dump script tag. The frontend deduplicates
|
|
6
|
+
* executions with the same id/name, keeping only the last one.
|
|
7
|
+
*
|
|
8
|
+
* @param execution Current execution's full data
|
|
9
|
+
* @param reportMeta Report-level metadata (groupName, sdkVersion, etc.)
|
|
10
|
+
*/
|
|
11
|
+
onExecutionUpdate(execution: ExecutionDump, reportMeta: ReportMeta, attributes?: ReportAttributes): void;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use onExecutionUpdate instead. Kept for backward compatibility.
|
|
14
|
+
*/
|
|
15
|
+
onDumpUpdate?(dump: ReportActionDump): void;
|
|
16
|
+
/**
|
|
17
|
+
* Wait for all queued write operations to complete.
|
|
18
|
+
*/
|
|
19
|
+
flush(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Finalize the report. Calls flush() internally.
|
|
22
|
+
*/
|
|
23
|
+
finalize(): Promise<string | undefined>;
|
|
24
|
+
getReportPath(): string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export declare const nullReportGenerator: IReportGenerator;
|
|
27
|
+
export declare function assertReportGenerationOptions(opts: {
|
|
28
|
+
generateReport?: boolean;
|
|
29
|
+
persistExecutionDump?: boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
export declare class ReportGenerator implements IReportGenerator {
|
|
32
|
+
private reportPath;
|
|
33
|
+
private screenshotMode;
|
|
34
|
+
private shouldPersistExecutionDump;
|
|
35
|
+
private autoPrint;
|
|
36
|
+
private firstWriteDone;
|
|
37
|
+
private executionLogIndex;
|
|
38
|
+
private executionLogFileIndexByExecutionKey;
|
|
39
|
+
private readonly reportStreamId;
|
|
40
|
+
private screenshotStore;
|
|
41
|
+
private initialized;
|
|
42
|
+
private lastExecution?;
|
|
43
|
+
private lastReportMeta?;
|
|
44
|
+
private reportAttributes;
|
|
45
|
+
private writeQueue;
|
|
46
|
+
private destroyed;
|
|
47
|
+
constructor(options: {
|
|
48
|
+
reportPath: string;
|
|
49
|
+
screenshotMode: 'inline' | 'directory';
|
|
50
|
+
persistExecutionDump?: boolean;
|
|
51
|
+
autoPrint?: boolean;
|
|
52
|
+
});
|
|
53
|
+
static create(reportFileName: string, opts: {
|
|
54
|
+
generateReport?: boolean;
|
|
55
|
+
persistExecutionDump?: boolean;
|
|
56
|
+
outputFormat?: 'single-html' | 'html-and-external-assets';
|
|
57
|
+
autoPrintReportMsg?: boolean;
|
|
58
|
+
}): IReportGenerator;
|
|
59
|
+
onExecutionUpdate(execution: ExecutionDump, reportMeta: ReportMeta, attributes?: ReportAttributes): void;
|
|
60
|
+
flush(): Promise<void>;
|
|
61
|
+
finalize(): Promise<string | undefined>;
|
|
62
|
+
getReportPath(): string | undefined;
|
|
63
|
+
private printReportPath;
|
|
64
|
+
private doWriteExecution;
|
|
65
|
+
private mergeReportAttributes;
|
|
66
|
+
private hydrateStateFromExistingReport;
|
|
67
|
+
private getDumpScriptAttributes;
|
|
68
|
+
/**
|
|
69
|
+
* Wrap an ExecutionDump + ReportMeta into a single-execution ReportActionDump.
|
|
70
|
+
*/
|
|
71
|
+
private wrapAsReportDump;
|
|
72
|
+
/**
|
|
73
|
+
* Append-only inline mode: write new screenshots and a dump tag on every call.
|
|
74
|
+
* The frontend deduplicates executions with the same id/name (keeps last).
|
|
75
|
+
* Duplicate dump JSON is acceptable; only screenshots are deduplicated.
|
|
76
|
+
*/
|
|
77
|
+
private writeInlineExecution;
|
|
78
|
+
private writeDirectoryExecution;
|
|
79
|
+
private getExecutionLogKey;
|
|
80
|
+
private persistExecutionDumpToFile;
|
|
81
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExecutionDump, IExecutionDump, IReportActionDump, ReportActionDump } from './types';
|
|
2
|
+
export interface MarkdownAttachment {
|
|
3
|
+
id: string;
|
|
4
|
+
suggestedFileName: string;
|
|
5
|
+
mimeType?: string;
|
|
6
|
+
filePath: string;
|
|
7
|
+
executionIndex: number;
|
|
8
|
+
taskIndex: number;
|
|
9
|
+
/** Populated when screenshot data is available in memory (e.g. browser context). */
|
|
10
|
+
base64Data?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ExecutionMarkdownOptions {
|
|
13
|
+
screenshotBaseDir?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ExecutionMarkdownResult {
|
|
16
|
+
markdown: string;
|
|
17
|
+
attachments: MarkdownAttachment[];
|
|
18
|
+
}
|
|
19
|
+
export interface ReportMarkdownResult {
|
|
20
|
+
markdown: string;
|
|
21
|
+
attachments: MarkdownAttachment[];
|
|
22
|
+
}
|
|
23
|
+
export declare function executionToMarkdown(execution: ExecutionDump | IExecutionDump, options?: ExecutionMarkdownOptions): ExecutionMarkdownResult;
|
|
24
|
+
export declare function reportToMarkdown(report: ReportActionDump | IReportActionDump): ReportMarkdownResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ExecutionDump, type IExecutionDump, ReportActionDump } from './types';
|
|
2
|
+
import type { ReportFileWithAttributes } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Check if a report is in directory mode (html-and-external-assets).
|
|
5
|
+
* Directory mode reports: {name}/index.html + {name}/screenshots/
|
|
6
|
+
*/
|
|
7
|
+
export declare function isDirectoryModeReport(reportFilePath: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Deduplicate executions by stable id, keeping only the last occurrence.
|
|
10
|
+
* Old-format executions without id are always preserved.
|
|
11
|
+
*/
|
|
12
|
+
export declare function dedupeExecutionsKeepLatest<T extends Pick<ExecutionDump, 'id'>>(executions: T[]): T[];
|
|
13
|
+
export declare class ReportMergingTool {
|
|
14
|
+
private reportInfos;
|
|
15
|
+
private createEmptyDumpString;
|
|
16
|
+
append(reportInfo: ReportFileWithAttributes): void;
|
|
17
|
+
clear(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Merge multiple dump script contents (from the same source report)
|
|
20
|
+
* into a single serialized ReportActionDump string.
|
|
21
|
+
* If there's only one dump, return it as-is. If multiple, merge
|
|
22
|
+
* all executions into the first dump's group structure.
|
|
23
|
+
*/
|
|
24
|
+
private mergeDumpScripts;
|
|
25
|
+
mergeReports(reportFileName?: 'AUTO' | string, opts?: {
|
|
26
|
+
rmOriginalReports?: boolean;
|
|
27
|
+
overwrite?: boolean;
|
|
28
|
+
}): string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface SplitReportHtmlOptions {
|
|
31
|
+
htmlPath: string;
|
|
32
|
+
outputDir: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SplitReportHtmlResult {
|
|
35
|
+
executionJsonFiles: string[];
|
|
36
|
+
screenshotFiles: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface CollectedReportExecutions {
|
|
39
|
+
baseDump: ReportActionDump;
|
|
40
|
+
executions: IExecutionDump[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Collect executions from a report HTML, deduplicating by stable id while
|
|
44
|
+
* keeping only the latest occurrence. Old-format executions without id are
|
|
45
|
+
* always preserved.
|
|
46
|
+
*/
|
|
47
|
+
export declare function collectDedupedExecutions(htmlPath: string): CollectedReportExecutions;
|
|
48
|
+
/**
|
|
49
|
+
* Reverse parse a Midscene report HTML into per-execution JSON files and
|
|
50
|
+
* externalized screenshots.
|
|
51
|
+
*/
|
|
52
|
+
export declare function splitReportHtmlByExecution(options: SplitReportHtmlOptions): SplitReportHtmlResult;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type ScreenshotRef } from './dump/screenshot-store';
|
|
2
|
+
/**
|
|
3
|
+
* Serialization format for ScreenshotItem
|
|
4
|
+
* - { $screenshot: "id" } - inline mode, references imageMap in HTML
|
|
5
|
+
* - { base64: "path" } - directory mode, references external file path
|
|
6
|
+
*/
|
|
7
|
+
export type ScreenshotSerializeFormat = ScreenshotRef;
|
|
8
|
+
/**
|
|
9
|
+
* ScreenshotItem encapsulates screenshot data.
|
|
10
|
+
*
|
|
11
|
+
* Supports lazy loading after memory release:
|
|
12
|
+
* - inline mode: reads from HTML file using streaming (extractImageByIdSync)
|
|
13
|
+
* - directory mode: reads from file on disk
|
|
14
|
+
*
|
|
15
|
+
* After persistence, memory is released but the screenshot can be recovered
|
|
16
|
+
* on-demand from disk, making it safe to release memory at any time.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ScreenshotItem {
|
|
19
|
+
private _id;
|
|
20
|
+
private _base64;
|
|
21
|
+
private _format;
|
|
22
|
+
private _capturedAt;
|
|
23
|
+
private _serializedRef;
|
|
24
|
+
private _persistedPath;
|
|
25
|
+
private _persistedHtmlPath;
|
|
26
|
+
private constructor();
|
|
27
|
+
/** Create a new ScreenshotItem from base64 data */
|
|
28
|
+
static create(base64: string, capturedAt: number): ScreenshotItem;
|
|
29
|
+
get id(): string;
|
|
30
|
+
/** Get the image format (png or jpeg) */
|
|
31
|
+
get format(): 'png' | 'jpeg';
|
|
32
|
+
/** Get the file extension for this screenshot */
|
|
33
|
+
get extension(): string;
|
|
34
|
+
/** Get screenshot capture timestamp in milliseconds */
|
|
35
|
+
get capturedAt(): number;
|
|
36
|
+
get base64(): string;
|
|
37
|
+
/** Check if base64 data is still available in memory (not yet released) */
|
|
38
|
+
hasBase64(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Mark as persisted to HTML (inline mode).
|
|
41
|
+
* Releases base64 memory, but keeps HTML path for lazy loading recovery.
|
|
42
|
+
* @param htmlPath - absolute path to the HTML file containing the image
|
|
43
|
+
*/
|
|
44
|
+
markPersistedInline(htmlPath: string): ScreenshotRef;
|
|
45
|
+
/**
|
|
46
|
+
* Register a file-backed recovery path without changing the serialized mode.
|
|
47
|
+
* Used when inline persistence also needs a shared file copy next to dumps.
|
|
48
|
+
*/
|
|
49
|
+
registerPersistedFileCopy(relativePath: string, absolutePath: string): ScreenshotRef;
|
|
50
|
+
/**
|
|
51
|
+
* Mark as persisted to file (directory mode).
|
|
52
|
+
* Releases base64 memory, but keeps file path for lazy loading recovery.
|
|
53
|
+
* @param relativePath - relative path for serialization (e.g., "./screenshots/id.jpeg")
|
|
54
|
+
* @param absolutePath - absolute path for lazy loading recovery
|
|
55
|
+
*/
|
|
56
|
+
markPersistedToPath(relativePath: string, absolutePath: string): ScreenshotRef;
|
|
57
|
+
/** Serialize for JSON - format depends on persistence state */
|
|
58
|
+
toSerializable(): ScreenshotSerializeFormat;
|
|
59
|
+
/** Check if a value is a serialized ScreenshotItem reference (inline or directory mode) */
|
|
60
|
+
static isSerialized(value: unknown): value is ScreenshotSerializeFormat;
|
|
61
|
+
private createRef;
|
|
62
|
+
/**
|
|
63
|
+
* Get base64 data without the data URI prefix.
|
|
64
|
+
* Useful for writing raw binary data to files.
|
|
65
|
+
*/
|
|
66
|
+
get rawBase64(): string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AIDescribeElementResponse, LocateResultElement, LocateResultWithDump, PlanningLocateParam, Rect, ServiceExtractOption, ServiceExtractParam, ServiceExtractResult, ServiceTaskInfo, UIContext } from '../types';
|
|
2
|
+
import type { IModelConfig } from '@midscene/shared/env';
|
|
3
|
+
import type { TMultimodalPrompt } from '../common';
|
|
4
|
+
export interface LocateOpts {
|
|
5
|
+
context?: UIContext;
|
|
6
|
+
planLocatedElement?: LocateResultElement;
|
|
7
|
+
}
|
|
8
|
+
export type AnyValue<T> = {
|
|
9
|
+
[K in keyof T]: unknown extends T[K] ? any : T[K];
|
|
10
|
+
};
|
|
11
|
+
interface ServiceOptions {
|
|
12
|
+
taskInfo?: Omit<ServiceTaskInfo, 'durationMs'>;
|
|
13
|
+
}
|
|
14
|
+
export default class Service {
|
|
15
|
+
contextRetrieverFn: () => Promise<UIContext> | UIContext;
|
|
16
|
+
taskInfo?: Omit<ServiceTaskInfo, 'durationMs'>;
|
|
17
|
+
constructor(context: UIContext | (() => Promise<UIContext> | UIContext), opt?: ServiceOptions);
|
|
18
|
+
locate(query: PlanningLocateParam, opt: LocateOpts, modelConfig: IModelConfig, abortSignal?: AbortSignal): Promise<LocateResultWithDump>;
|
|
19
|
+
extract<T>(dataDemand: ServiceExtractParam, modelConfig: IModelConfig, opt?: ServiceExtractOption, pageDescription?: string, multimodalPrompt?: TMultimodalPrompt, context?: UIContext): Promise<ServiceExtractResult<T>>;
|
|
20
|
+
describe(target: Rect | [number, number], modelConfig: IModelConfig, opt?: {
|
|
21
|
+
deepLocate?: boolean;
|
|
22
|
+
}): Promise<Pick<AIDescribeElementResponse, 'description'>>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AbstractInterface } from '../device';
|
|
2
|
+
type DeviceClass = new (...args: any[]) => AbstractInterface;
|
|
3
|
+
export interface SkillCLIOptions {
|
|
4
|
+
scriptName: string;
|
|
5
|
+
DeviceClass: DeviceClass;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Launch a Skill CLI for a custom interface Device class.
|
|
9
|
+
* This enables AI coding assistants (Claude Code, Cline, etc.) to control
|
|
10
|
+
* your custom interface through CLI commands.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* #!/usr/bin/env node
|
|
15
|
+
* import { runSkillCLI } from '@midscene/core/skill';
|
|
16
|
+
* import { SampleDevice } from './sample-device';
|
|
17
|
+
*
|
|
18
|
+
* runSkillCLI({
|
|
19
|
+
* DeviceClass: SampleDevice,
|
|
20
|
+
* scriptName: 'my-device',
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function runSkillCLI(options: SkillCLIOptions): Promise<void>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ExecutionDump, type ExecutionTask, type ExecutionTaskApply, type ExecutionTaskProgressOptions, type UIContext } from './types';
|
|
2
|
+
type TaskRunnerInitOptions = ExecutionTaskProgressOptions & {
|
|
3
|
+
tasks?: ExecutionTaskApply[];
|
|
4
|
+
onTaskUpdate?: (runner: TaskRunner, error?: TaskExecutionError) => Promise<void> | void;
|
|
5
|
+
};
|
|
6
|
+
type TaskRunnerOperationOptions = {
|
|
7
|
+
allowWhenError?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare class TaskRunner {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
tasks: ExecutionTask[];
|
|
13
|
+
status: 'init' | 'pending' | 'running' | 'completed' | 'error';
|
|
14
|
+
onTaskStart?: ExecutionTaskProgressOptions['onTaskStart'];
|
|
15
|
+
private readonly uiContextBuilder;
|
|
16
|
+
private readonly onTaskUpdate?;
|
|
17
|
+
private readonly executionLogTime;
|
|
18
|
+
constructor(name: string, uiContextBuilder: () => Promise<UIContext>, options?: TaskRunnerInitOptions);
|
|
19
|
+
private emitOnTaskUpdate;
|
|
20
|
+
private lastUiContext?;
|
|
21
|
+
private getUiContext;
|
|
22
|
+
private captureScreenshot;
|
|
23
|
+
private attachRecorderItem;
|
|
24
|
+
private markTaskAsPending;
|
|
25
|
+
private normalizeStatusFromError;
|
|
26
|
+
append(task: ExecutionTaskApply[] | ExecutionTaskApply, options?: TaskRunnerOperationOptions): Promise<void>;
|
|
27
|
+
appendAndFlush(task: ExecutionTaskApply[] | ExecutionTaskApply, options?: TaskRunnerOperationOptions): Promise<{
|
|
28
|
+
output: any;
|
|
29
|
+
thought?: string;
|
|
30
|
+
} | undefined>;
|
|
31
|
+
flush(options?: TaskRunnerOperationOptions): Promise<{
|
|
32
|
+
output: any;
|
|
33
|
+
thought?: string;
|
|
34
|
+
} | undefined>;
|
|
35
|
+
isInErrorState(): boolean;
|
|
36
|
+
latestErrorTask(): ExecutionTask | null;
|
|
37
|
+
dump(): ExecutionDump;
|
|
38
|
+
appendErrorPlan(errorMsg: string): Promise<{
|
|
39
|
+
output: undefined;
|
|
40
|
+
runner: TaskRunner;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
export declare class TaskExecutionError extends Error {
|
|
44
|
+
runner: TaskRunner;
|
|
45
|
+
errorTask: ExecutionTask | null;
|
|
46
|
+
constructor(message: string, runner: TaskRunner, errorTask: ExecutionTask | null, options?: {
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExecutionTask } from './types';
|
|
2
|
+
type ExecutionTaskTiming = NonNullable<ExecutionTask['timing']>;
|
|
3
|
+
type NumericTimingField = {
|
|
4
|
+
[K in keyof ExecutionTaskTiming]-?: ExecutionTaskTiming[K] extends number | undefined ? K : never;
|
|
5
|
+
}[keyof ExecutionTaskTiming];
|
|
6
|
+
export type TimingSettableField = Exclude<NumericTimingField, 'start' | 'end' | 'cost'>;
|
|
7
|
+
export declare function setTimingFieldOnce(timing: ExecutionTaskTiming | undefined, field: TimingSettableField): void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseElement, ElementTreeNode } from '@midscene/shared/types';
|
|
2
|
+
import { trimAttributes, truncateText } from '@midscene/shared/extractor';
|
|
3
|
+
export { trimAttributes, truncateText };
|
|
4
|
+
export declare function descriptionOfTree<ElementType extends BaseElement = BaseElement>(tree: ElementTreeNode<ElementType>, truncateTextLength?: number, filterNonTextContent?: boolean, visibleOnly?: boolean): string;
|