@godscene/core 1.7.11
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 +767 -0
- package/dist/es/agent/common.mjs +0 -0
- package/dist/es/agent/execution-session.mjs +39 -0
- package/dist/es/agent/index.mjs +6 -0
- package/dist/es/agent/task-builder.mjs +343 -0
- package/dist/es/agent/task-cache.mjs +212 -0
- package/dist/es/agent/tasks.mjs +428 -0
- package/dist/es/agent/ui-utils.mjs +101 -0
- package/dist/es/agent/utils.mjs +167 -0
- package/dist/es/ai-model/auto-glm/actions.mjs +237 -0
- package/dist/es/ai-model/auto-glm/index.mjs +6 -0
- package/dist/es/ai-model/auto-glm/parser.mjs +237 -0
- package/dist/es/ai-model/auto-glm/planning.mjs +69 -0
- package/dist/es/ai-model/auto-glm/prompt.mjs +220 -0
- package/dist/es/ai-model/auto-glm/util.mjs +7 -0
- package/dist/es/ai-model/connectivity.mjs +136 -0
- package/dist/es/ai-model/conversation-history.mjs +193 -0
- package/dist/es/ai-model/index.mjs +12 -0
- package/dist/es/ai-model/inspect.mjs +395 -0
- package/dist/es/ai-model/llm-planning.mjs +231 -0
- package/dist/es/ai-model/prompt/common.mjs +5 -0
- package/dist/es/ai-model/prompt/describe.mjs +64 -0
- package/dist/es/ai-model/prompt/extraction.mjs +129 -0
- package/dist/es/ai-model/prompt/llm-locator.mjs +49 -0
- package/dist/es/ai-model/prompt/llm-planning.mjs +584 -0
- package/dist/es/ai-model/prompt/llm-section-locator.mjs +42 -0
- package/dist/es/ai-model/prompt/order-sensitive-judge.mjs +33 -0
- package/dist/es/ai-model/prompt/playwright-generator.mjs +115 -0
- package/dist/es/ai-model/prompt/ui-tars-planning.mjs +34 -0
- package/dist/es/ai-model/prompt/util.mjs +57 -0
- package/dist/es/ai-model/prompt/yaml-generator.mjs +201 -0
- package/dist/es/ai-model/service-caller/codex-app-server.mjs +573 -0
- package/dist/es/ai-model/service-caller/image-detail.mjs +4 -0
- package/dist/es/ai-model/service-caller/index.mjs +648 -0
- package/dist/es/ai-model/service-caller/request-timeout.mjs +47 -0
- package/dist/es/ai-model/ui-tars-planning.mjs +247 -0
- package/dist/es/common.mjs +382 -0
- package/dist/es/device/device-options.mjs +0 -0
- package/dist/es/device/index.mjs +340 -0
- package/dist/es/dump/html-utils.mjs +290 -0
- package/dist/es/dump/index.mjs +3 -0
- package/dist/es/dump/screenshot-restoration.mjs +30 -0
- package/dist/es/dump/screenshot-store.mjs +125 -0
- package/dist/es/index.mjs +17 -0
- package/dist/es/report-cli.mjs +149 -0
- package/dist/es/report-generator.mjs +203 -0
- package/dist/es/report-markdown.mjs +216 -0
- package/dist/es/report.mjs +287 -0
- package/dist/es/screenshot-item.mjs +120 -0
- package/dist/es/service/index.mjs +272 -0
- package/dist/es/service/utils.mjs +13 -0
- package/dist/es/skill/index.mjs +35 -0
- package/dist/es/task-runner.mjs +261 -0
- package/dist/es/task-timing.mjs +10 -0
- package/dist/es/tree.mjs +11 -0
- package/dist/es/types.mjs +202 -0
- package/dist/es/utils.mjs +232 -0
- package/dist/es/yaml/builder.mjs +11 -0
- package/dist/es/yaml/index.mjs +4 -0
- package/dist/es/yaml/player.mjs +425 -0
- package/dist/es/yaml/utils.mjs +100 -0
- package/dist/es/yaml.mjs +0 -0
- package/dist/lib/agent/agent.js +815 -0
- package/dist/lib/agent/common.js +5 -0
- package/dist/lib/agent/execution-session.js +73 -0
- package/dist/lib/agent/index.js +76 -0
- package/dist/lib/agent/task-builder.js +380 -0
- package/dist/lib/agent/task-cache.js +264 -0
- package/dist/lib/agent/tasks.js +471 -0
- package/dist/lib/agent/ui-utils.js +153 -0
- package/dist/lib/agent/utils.js +238 -0
- package/dist/lib/ai-model/auto-glm/actions.js +271 -0
- package/dist/lib/ai-model/auto-glm/index.js +64 -0
- package/dist/lib/ai-model/auto-glm/parser.js +280 -0
- package/dist/lib/ai-model/auto-glm/planning.js +103 -0
- package/dist/lib/ai-model/auto-glm/prompt.js +257 -0
- package/dist/lib/ai-model/auto-glm/util.js +44 -0
- package/dist/lib/ai-model/connectivity.js +180 -0
- package/dist/lib/ai-model/conversation-history.js +227 -0
- package/dist/lib/ai-model/index.js +127 -0
- package/dist/lib/ai-model/inspect.js +441 -0
- package/dist/lib/ai-model/llm-planning.js +268 -0
- package/dist/lib/ai-model/prompt/common.js +39 -0
- package/dist/lib/ai-model/prompt/describe.js +98 -0
- package/dist/lib/ai-model/prompt/extraction.js +169 -0
- package/dist/lib/ai-model/prompt/llm-locator.js +86 -0
- package/dist/lib/ai-model/prompt/llm-planning.js +621 -0
- package/dist/lib/ai-model/prompt/llm-section-locator.js +79 -0
- package/dist/lib/ai-model/prompt/order-sensitive-judge.js +70 -0
- package/dist/lib/ai-model/prompt/playwright-generator.js +176 -0
- package/dist/lib/ai-model/prompt/ui-tars-planning.js +71 -0
- package/dist/lib/ai-model/prompt/util.js +103 -0
- package/dist/lib/ai-model/prompt/yaml-generator.js +262 -0
- package/dist/lib/ai-model/service-caller/codex-app-server.js +622 -0
- package/dist/lib/ai-model/service-caller/image-detail.js +38 -0
- package/dist/lib/ai-model/service-caller/index.js +716 -0
- package/dist/lib/ai-model/service-caller/request-timeout.js +93 -0
- package/dist/lib/ai-model/ui-tars-planning.js +281 -0
- package/dist/lib/common.js +491 -0
- package/dist/lib/device/device-options.js +18 -0
- package/dist/lib/device/index.js +467 -0
- package/dist/lib/dump/html-utils.js +366 -0
- package/dist/lib/dump/index.js +58 -0
- package/dist/lib/dump/screenshot-restoration.js +64 -0
- package/dist/lib/dump/screenshot-store.js +165 -0
- package/dist/lib/index.js +184 -0
- package/dist/lib/report-cli.js +189 -0
- package/dist/lib/report-generator.js +244 -0
- package/dist/lib/report-markdown.js +253 -0
- package/dist/lib/report.js +333 -0
- package/dist/lib/screenshot-item.js +154 -0
- package/dist/lib/service/index.js +306 -0
- package/dist/lib/service/utils.js +47 -0
- package/dist/lib/skill/index.js +69 -0
- package/dist/lib/task-runner.js +298 -0
- package/dist/lib/task-timing.js +44 -0
- package/dist/lib/tree.js +51 -0
- package/dist/lib/types.js +298 -0
- package/dist/lib/utils.js +314 -0
- package/dist/lib/yaml/builder.js +55 -0
- package/dist/lib/yaml/index.js +79 -0
- package/dist/lib/yaml/player.js +459 -0
- package/dist/lib/yaml/utils.js +153 -0
- package/dist/lib/yaml.js +18 -0
- package/dist/types/agent/agent.d.ts +220 -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 +70 -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 +60 -0
- package/dist/types/ai-model/service-caller/request-timeout.d.ts +32 -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 +155 -0
- package/dist/types/device/index.d.ts +2565 -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 +88 -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 +684 -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 +130 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
groupedActionDumpFileExt: ()=>groupedActionDumpFileExt,
|
|
28
|
+
sleep: ()=>sleep,
|
|
29
|
+
writeDumpReport: ()=>writeDumpReport,
|
|
30
|
+
writeLogFile: ()=>writeLogFile,
|
|
31
|
+
stringifyDumpData: ()=>stringifyDumpData,
|
|
32
|
+
getReportTpl: ()=>getReportTpl,
|
|
33
|
+
processCacheConfig: ()=>processCacheConfig,
|
|
34
|
+
appendFileSync: ()=>external_node_fs_namespaceObject.appendFileSync,
|
|
35
|
+
getTmpDir: ()=>getTmpDir,
|
|
36
|
+
replacerForPageObject: ()=>replacerForPageObject,
|
|
37
|
+
insertScriptBeforeClosingHtml: ()=>insertScriptBeforeClosingHtml,
|
|
38
|
+
uploadTestInfoToServer: ()=>uploadTestInfoToServer,
|
|
39
|
+
getVersion: ()=>getVersion,
|
|
40
|
+
overlapped: ()=>overlapped,
|
|
41
|
+
insertContentBeforeClosingHtml: ()=>insertContentBeforeClosingHtml,
|
|
42
|
+
reportHTMLContent: ()=>reportHTMLContent,
|
|
43
|
+
getTmpFile: ()=>getTmpFile
|
|
44
|
+
});
|
|
45
|
+
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
46
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
47
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
48
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
49
|
+
const external_node_util_namespaceObject = require("node:util");
|
|
50
|
+
const common_namespaceObject = require("@godscene/shared/common");
|
|
51
|
+
const env_namespaceObject = require("@godscene/shared/env");
|
|
52
|
+
const node_namespaceObject = require("@godscene/shared/node");
|
|
53
|
+
const utils_namespaceObject = require("@godscene/shared/utils");
|
|
54
|
+
let logEnvReady = false;
|
|
55
|
+
const groupedActionDumpFileExt = 'web-dump.json';
|
|
56
|
+
function processCacheConfig(cache, cacheId) {
|
|
57
|
+
if (void 0 !== cache) {
|
|
58
|
+
if (false === cache) return;
|
|
59
|
+
if (true === cache) return {
|
|
60
|
+
id: cacheId
|
|
61
|
+
};
|
|
62
|
+
if ('object' == typeof cache && null !== cache) {
|
|
63
|
+
if (!cache.id) return {
|
|
64
|
+
...cache,
|
|
65
|
+
id: cacheId
|
|
66
|
+
};
|
|
67
|
+
return cache;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const envEnabled = env_namespaceObject.globalConfigManager.getEnvConfigInBoolean(env_namespaceObject.MIDSCENE_CACHE);
|
|
71
|
+
if (envEnabled && cacheId) return {
|
|
72
|
+
id: cacheId
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const reportInitializedMap = new Map();
|
|
76
|
+
const reportGroupIdMap = new Map();
|
|
77
|
+
function getReportTpl() {
|
|
78
|
+
const reportTpl = /*REPORT_HTML_REPLACED*/"<!doctype html>\n<html>\n\n<head>\n <title>Report - RPA智能助手</title>\n <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"./favicon-32x32.png\" />\n</head>\n\n<body>\n <!-- it should be replaced by the actual content -->\n <div id=\"<%= mountId %>\" style=\"height: 100vh; width: 100vw\"></div>\n</body>\n\n</html>";
|
|
79
|
+
return reportTpl;
|
|
80
|
+
}
|
|
81
|
+
function insertContentBeforeClosingHtml(html, content) {
|
|
82
|
+
const htmlEndIdx = html.lastIndexOf('</html>');
|
|
83
|
+
if (-1 === htmlEndIdx) return html + content;
|
|
84
|
+
return `${html.slice(0, htmlEndIdx)}${content}\n${html.slice(htmlEndIdx)}`;
|
|
85
|
+
}
|
|
86
|
+
function insertScriptBeforeClosingHtml(filePath, scriptContent) {
|
|
87
|
+
const htmlEndTag = '</html>';
|
|
88
|
+
const stat = external_node_fs_namespaceObject.statSync(filePath);
|
|
89
|
+
const readSize = Math.min(stat.size, 4096);
|
|
90
|
+
const start = Math.max(0, stat.size - readSize);
|
|
91
|
+
const buffer = Buffer.alloc(stat.size - start);
|
|
92
|
+
const fd = external_node_fs_namespaceObject.openSync(filePath, 'r');
|
|
93
|
+
external_node_fs_namespaceObject.readSync(fd, buffer, 0, buffer.length, start);
|
|
94
|
+
external_node_fs_namespaceObject.closeSync(fd);
|
|
95
|
+
const tailStr = buffer.toString('utf8');
|
|
96
|
+
const htmlEndIdx = tailStr.lastIndexOf(htmlEndTag);
|
|
97
|
+
if (-1 === htmlEndIdx) throw new Error(`No </html> found in file:${filePath}`);
|
|
98
|
+
const beforeHtmlInTail = tailStr.slice(0, htmlEndIdx);
|
|
99
|
+
const htmlEndPos = start + Buffer.byteLength(beforeHtmlInTail, 'utf8');
|
|
100
|
+
external_node_fs_namespaceObject.truncateSync(filePath, htmlEndPos);
|
|
101
|
+
external_node_fs_namespaceObject.appendFileSync(filePath, `${scriptContent}\n${htmlEndTag}\n`);
|
|
102
|
+
}
|
|
103
|
+
function reportHTMLContent(dumpData, reportPath, appendReport, withTpl = true) {
|
|
104
|
+
let tpl = '';
|
|
105
|
+
if (withTpl) {
|
|
106
|
+
tpl = getReportTpl();
|
|
107
|
+
if (!tpl) {
|
|
108
|
+
console.warn('reportTpl is not set, will not write report');
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const writeToFile = reportPath && !utils_namespaceObject.ifInBrowser;
|
|
113
|
+
let dumpContent = '';
|
|
114
|
+
const resolveAutoGroupId = ()=>{
|
|
115
|
+
if (!reportPath || !appendReport) return (0, utils_namespaceObject.uuid)();
|
|
116
|
+
const existingGroupId = reportGroupIdMap.get(reportPath);
|
|
117
|
+
if (existingGroupId) return existingGroupId;
|
|
118
|
+
const newGroupId = (0, utils_namespaceObject.uuid)();
|
|
119
|
+
reportGroupIdMap.set(reportPath, newGroupId);
|
|
120
|
+
return newGroupId;
|
|
121
|
+
};
|
|
122
|
+
if ('string' == typeof dumpData) {
|
|
123
|
+
const groupId = resolveAutoGroupId();
|
|
124
|
+
dumpContent = '<script type="midscene_web_dump" type="application/json" data-group-id="' + encodeURIComponent(groupId) + '">\n' + (0, utils_namespaceObject.escapeScriptTag)(dumpData) + "\n<\/script>";
|
|
125
|
+
} else {
|
|
126
|
+
const { dumpString, attributes } = dumpData;
|
|
127
|
+
const attributesArr = Object.entries(attributes || {}).filter((entry)=>void 0 !== entry[1] && null !== entry[1]).map(([key, value])=>`${key}="${encodeURIComponent(value)}"`);
|
|
128
|
+
dumpContent = '<script type="midscene_web_dump" type="application/json" ' + attributesArr.join(' ') + '>\n' + (0, utils_namespaceObject.escapeScriptTag)(dumpString) + "\n<\/script>";
|
|
129
|
+
}
|
|
130
|
+
if (writeToFile) {
|
|
131
|
+
if (!appendReport) {
|
|
132
|
+
(0, external_node_fs_namespaceObject.writeFileSync)(reportPath, insertContentBeforeClosingHtml(tpl, dumpContent), {
|
|
133
|
+
flag: 'w'
|
|
134
|
+
});
|
|
135
|
+
return reportPath;
|
|
136
|
+
}
|
|
137
|
+
if (!reportInitializedMap.get(reportPath)) {
|
|
138
|
+
(0, external_node_fs_namespaceObject.writeFileSync)(reportPath, tpl, {
|
|
139
|
+
flag: 'w'
|
|
140
|
+
});
|
|
141
|
+
reportInitializedMap.set(reportPath, true);
|
|
142
|
+
}
|
|
143
|
+
insertScriptBeforeClosingHtml(reportPath, dumpContent);
|
|
144
|
+
return reportPath;
|
|
145
|
+
}
|
|
146
|
+
return insertContentBeforeClosingHtml(tpl, dumpContent);
|
|
147
|
+
}
|
|
148
|
+
function writeDumpReport(fileName, dumpData, appendReport) {
|
|
149
|
+
if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) {
|
|
150
|
+
console.log('will not write report in browser');
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const reportPath = external_node_path_namespaceObject.join((0, common_namespaceObject.getMidsceneRunSubDir)('report'), `${fileName}.html`);
|
|
154
|
+
reportHTMLContent(dumpData, reportPath, appendReport);
|
|
155
|
+
if (process.env.MIDSCENE_DEBUG_LOG_JSON) {
|
|
156
|
+
const jsonPath = `${reportPath}.json`;
|
|
157
|
+
let data;
|
|
158
|
+
data = 'string' == typeof dumpData ? JSON.parse(dumpData) : dumpData;
|
|
159
|
+
(0, external_node_fs_namespaceObject.writeFileSync)(jsonPath, JSON.stringify(data, null, 2), {
|
|
160
|
+
flag: appendReport ? 'a' : 'w'
|
|
161
|
+
});
|
|
162
|
+
(0, utils_namespaceObject.logMsg)(`Midscene - dump file written: ${jsonPath}`);
|
|
163
|
+
}
|
|
164
|
+
return reportPath;
|
|
165
|
+
}
|
|
166
|
+
function writeLogFile(opts) {
|
|
167
|
+
if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) return '/mock/report.html';
|
|
168
|
+
const { fileName, fileExt, fileContent, type = 'dump' } = opts;
|
|
169
|
+
const targetDir = (0, common_namespaceObject.getMidsceneRunSubDir)(type);
|
|
170
|
+
if (!logEnvReady) {
|
|
171
|
+
(0, utils_namespaceObject.assert)(targetDir, 'logDir should be set before writing dump file');
|
|
172
|
+
const gitIgnorePath = external_node_path_namespaceObject.join(targetDir, '../../.gitignore');
|
|
173
|
+
const gitPath = external_node_path_namespaceObject.join(targetDir, '../../.git');
|
|
174
|
+
let gitIgnoreContent = '';
|
|
175
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(gitPath)) {
|
|
176
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(gitIgnorePath)) gitIgnoreContent = (0, external_node_fs_namespaceObject.readFileSync)(gitIgnorePath, 'utf-8');
|
|
177
|
+
if (!gitIgnoreContent.includes(`${common_namespaceObject.defaultRunDirName}/`)) (0, external_node_fs_namespaceObject.writeFileSync)(gitIgnorePath, `${gitIgnoreContent}\n# RPA智能助手 dump files\n${common_namespaceObject.defaultRunDirName}/dump\n${common_namespaceObject.defaultRunDirName}/report\n${common_namespaceObject.defaultRunDirName}/tmp\n${common_namespaceObject.defaultRunDirName}/log\n`, 'utf-8');
|
|
178
|
+
}
|
|
179
|
+
logEnvReady = true;
|
|
180
|
+
}
|
|
181
|
+
const filePath = external_node_path_namespaceObject.join(targetDir, `${fileName}.${fileExt}`);
|
|
182
|
+
if ('dump' !== type) (0, external_node_fs_namespaceObject.writeFileSync)(filePath, JSON.stringify(fileContent));
|
|
183
|
+
if (opts?.generateReport) return writeDumpReport(fileName, fileContent, opts.appendReport);
|
|
184
|
+
return filePath;
|
|
185
|
+
}
|
|
186
|
+
function getTmpDir() {
|
|
187
|
+
try {
|
|
188
|
+
const runningPkgInfo = (0, node_namespaceObject.getRunningPkgInfo)();
|
|
189
|
+
if (!runningPkgInfo) return null;
|
|
190
|
+
const { name } = runningPkgInfo;
|
|
191
|
+
const tmpPath = external_node_path_namespaceObject.join((0, external_node_os_namespaceObject.tmpdir)(), name);
|
|
192
|
+
(0, external_node_fs_namespaceObject.mkdirSync)(tmpPath, {
|
|
193
|
+
recursive: true
|
|
194
|
+
});
|
|
195
|
+
return tmpPath;
|
|
196
|
+
} catch (e) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function getTmpFile(fileExtWithoutDot) {
|
|
201
|
+
if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) return null;
|
|
202
|
+
const tmpDir = getTmpDir();
|
|
203
|
+
const filename = `${(0, utils_namespaceObject.uuid)()}.${fileExtWithoutDot}`;
|
|
204
|
+
return external_node_path_namespaceObject.join(tmpDir, filename);
|
|
205
|
+
}
|
|
206
|
+
function overlapped(container, target) {
|
|
207
|
+
return container.left < target.left + target.width && container.left + container.width > target.left && container.top < target.top + target.height && container.top + container.height > target.top;
|
|
208
|
+
}
|
|
209
|
+
async function sleep(ms) {
|
|
210
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
211
|
+
}
|
|
212
|
+
function replacerForPageObject(_key, value) {
|
|
213
|
+
if (value && value.constructor?.name === 'Page') return '[Page object]';
|
|
214
|
+
if (value && value.constructor?.name === 'Browser') return '[Browser object]';
|
|
215
|
+
if (value && 'function' == typeof value.toSerializable) return value.toSerializable();
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
function stringifyDumpData(data, indents) {
|
|
219
|
+
return JSON.stringify(data, replacerForPageObject, indents);
|
|
220
|
+
}
|
|
221
|
+
function getVersion() {
|
|
222
|
+
return "1.7.10";
|
|
223
|
+
}
|
|
224
|
+
function debugLog(...message) {
|
|
225
|
+
const debugMode = process.env[env_namespaceObject.MIDSCENE_DEBUG_MODE];
|
|
226
|
+
if (debugMode) console.log('[Midscene]', ...message);
|
|
227
|
+
}
|
|
228
|
+
let gitInfoPromise = null;
|
|
229
|
+
function getGitInfoAsync() {
|
|
230
|
+
if (gitInfoPromise) return gitInfoPromise;
|
|
231
|
+
const execFileAsync = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile);
|
|
232
|
+
gitInfoPromise = Promise.all([
|
|
233
|
+
execFileAsync('git', [
|
|
234
|
+
'config',
|
|
235
|
+
'--get',
|
|
236
|
+
'remote.origin.url'
|
|
237
|
+
]).then(({ stdout })=>stdout.trim(), ()=>''),
|
|
238
|
+
execFileAsync('git', [
|
|
239
|
+
'config',
|
|
240
|
+
'--get',
|
|
241
|
+
'user.email'
|
|
242
|
+
]).then(({ stdout })=>stdout.trim(), ()=>'')
|
|
243
|
+
]).then(([repoUrl, userEmail])=>({
|
|
244
|
+
repoUrl,
|
|
245
|
+
userEmail
|
|
246
|
+
}));
|
|
247
|
+
return gitInfoPromise;
|
|
248
|
+
}
|
|
249
|
+
let lastReportedRepoUrl = '';
|
|
250
|
+
async function uploadTestInfoToServer({ testUrl, serverUrl }) {
|
|
251
|
+
if (!serverUrl) return;
|
|
252
|
+
const { repoUrl, userEmail } = await getGitInfoAsync();
|
|
253
|
+
if (repoUrl ? repoUrl !== lastReportedRepoUrl : !!testUrl) {
|
|
254
|
+
debugLog('Uploading test info to server', {
|
|
255
|
+
serverUrl,
|
|
256
|
+
repoUrl,
|
|
257
|
+
testUrl,
|
|
258
|
+
userEmail
|
|
259
|
+
});
|
|
260
|
+
fetch(serverUrl, {
|
|
261
|
+
method: 'POST',
|
|
262
|
+
headers: {
|
|
263
|
+
'Content-Type': 'application/json'
|
|
264
|
+
},
|
|
265
|
+
body: JSON.stringify({
|
|
266
|
+
repo_url: repoUrl,
|
|
267
|
+
test_url: testUrl,
|
|
268
|
+
user_email: userEmail
|
|
269
|
+
})
|
|
270
|
+
}).then((response)=>response.json()).then((data)=>{
|
|
271
|
+
debugLog('Successfully uploaded test info to server:', data);
|
|
272
|
+
}).catch((error)=>debugLog('Failed to upload test info to server:', error));
|
|
273
|
+
lastReportedRepoUrl = repoUrl;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.appendFileSync = __webpack_exports__.appendFileSync;
|
|
277
|
+
exports.getReportTpl = __webpack_exports__.getReportTpl;
|
|
278
|
+
exports.getTmpDir = __webpack_exports__.getTmpDir;
|
|
279
|
+
exports.getTmpFile = __webpack_exports__.getTmpFile;
|
|
280
|
+
exports.getVersion = __webpack_exports__.getVersion;
|
|
281
|
+
exports.groupedActionDumpFileExt = __webpack_exports__.groupedActionDumpFileExt;
|
|
282
|
+
exports.insertContentBeforeClosingHtml = __webpack_exports__.insertContentBeforeClosingHtml;
|
|
283
|
+
exports.insertScriptBeforeClosingHtml = __webpack_exports__.insertScriptBeforeClosingHtml;
|
|
284
|
+
exports.overlapped = __webpack_exports__.overlapped;
|
|
285
|
+
exports.processCacheConfig = __webpack_exports__.processCacheConfig;
|
|
286
|
+
exports.replacerForPageObject = __webpack_exports__.replacerForPageObject;
|
|
287
|
+
exports.reportHTMLContent = __webpack_exports__.reportHTMLContent;
|
|
288
|
+
exports.sleep = __webpack_exports__.sleep;
|
|
289
|
+
exports.stringifyDumpData = __webpack_exports__.stringifyDumpData;
|
|
290
|
+
exports.uploadTestInfoToServer = __webpack_exports__.uploadTestInfoToServer;
|
|
291
|
+
exports.writeDumpReport = __webpack_exports__.writeDumpReport;
|
|
292
|
+
exports.writeLogFile = __webpack_exports__.writeLogFile;
|
|
293
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
294
|
+
"appendFileSync",
|
|
295
|
+
"getReportTpl",
|
|
296
|
+
"getTmpDir",
|
|
297
|
+
"getTmpFile",
|
|
298
|
+
"getVersion",
|
|
299
|
+
"groupedActionDumpFileExt",
|
|
300
|
+
"insertContentBeforeClosingHtml",
|
|
301
|
+
"insertScriptBeforeClosingHtml",
|
|
302
|
+
"overlapped",
|
|
303
|
+
"processCacheConfig",
|
|
304
|
+
"replacerForPageObject",
|
|
305
|
+
"reportHTMLContent",
|
|
306
|
+
"sleep",
|
|
307
|
+
"stringifyDumpData",
|
|
308
|
+
"uploadTestInfoToServer",
|
|
309
|
+
"writeDumpReport",
|
|
310
|
+
"writeLogFile"
|
|
311
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
312
|
+
Object.defineProperty(exports, '__esModule', {
|
|
313
|
+
value: true
|
|
314
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
buildYaml: ()=>buildYaml
|
|
37
|
+
});
|
|
38
|
+
const external_js_yaml_namespaceObject = require("js-yaml");
|
|
39
|
+
var external_js_yaml_default = /*#__PURE__*/ __webpack_require__.n(external_js_yaml_namespaceObject);
|
|
40
|
+
function buildYaml(env, tasks) {
|
|
41
|
+
const result = {
|
|
42
|
+
target: env,
|
|
43
|
+
tasks
|
|
44
|
+
};
|
|
45
|
+
return external_js_yaml_default().dump(result, {
|
|
46
|
+
indent: 2
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.buildYaml = __webpack_exports__.buildYaml;
|
|
50
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
51
|
+
"buildYaml"
|
|
52
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
53
|
+
Object.defineProperty(exports, '__esModule', {
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"../yaml" (module) {
|
|
4
|
+
module.exports = require("../yaml.js");
|
|
5
|
+
},
|
|
6
|
+
"./builder" (module) {
|
|
7
|
+
module.exports = require("./builder.js");
|
|
8
|
+
},
|
|
9
|
+
"./player" (module) {
|
|
10
|
+
module.exports = require("./player.js");
|
|
11
|
+
},
|
|
12
|
+
"./utils" (module) {
|
|
13
|
+
module.exports = require("./utils.js");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
37
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: definition[key]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
45
|
+
})();
|
|
46
|
+
(()=>{
|
|
47
|
+
__webpack_require__.r = (exports1)=>{
|
|
48
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
+
value: 'Module'
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __webpack_exports__ = {};
|
|
57
|
+
(()=>{
|
|
58
|
+
__webpack_require__.r(__webpack_exports__);
|
|
59
|
+
var _yaml__rspack_import_0 = __webpack_require__("../yaml");
|
|
60
|
+
var __rspack_reexport = {};
|
|
61
|
+
for(const __rspack_import_key in _yaml__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_yaml__rspack_import_0[__rspack_import_key];
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
63
|
+
var _player__rspack_import_1 = __webpack_require__("./player");
|
|
64
|
+
var __rspack_reexport = {};
|
|
65
|
+
for(const __rspack_import_key in _player__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_player__rspack_import_1[__rspack_import_key];
|
|
66
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
67
|
+
var _builder__rspack_import_2 = __webpack_require__("./builder");
|
|
68
|
+
var __rspack_reexport = {};
|
|
69
|
+
for(const __rspack_import_key in _builder__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_builder__rspack_import_2[__rspack_import_key];
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
71
|
+
var _utils__rspack_import_3 = __webpack_require__("./utils");
|
|
72
|
+
var __rspack_reexport = {};
|
|
73
|
+
for(const __rspack_import_key in _utils__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_utils__rspack_import_3[__rspack_import_key];
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
75
|
+
})();
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|