@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,298 @@
|
|
|
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
|
+
TaskExecutionError: ()=>TaskExecutionError,
|
|
28
|
+
TaskRunner: ()=>TaskRunner
|
|
29
|
+
});
|
|
30
|
+
const external_task_timing_js_namespaceObject = require("./task-timing.js");
|
|
31
|
+
const external_types_js_namespaceObject = require("./types.js");
|
|
32
|
+
const logger_namespaceObject = require("@godscene/shared/logger");
|
|
33
|
+
const utils_namespaceObject = require("@godscene/shared/utils");
|
|
34
|
+
function _define_property(obj, key, value) {
|
|
35
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
36
|
+
value: value,
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true
|
|
40
|
+
});
|
|
41
|
+
else obj[key] = value;
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
const debug = (0, logger_namespaceObject.getDebug)('task-runner');
|
|
45
|
+
const UI_CONTEXT_CACHE_TTL_MS = 300;
|
|
46
|
+
class TaskRunner {
|
|
47
|
+
async emitOnTaskUpdate(error) {
|
|
48
|
+
if (!this.onTaskUpdate) return;
|
|
49
|
+
await this.onTaskUpdate(this, error);
|
|
50
|
+
}
|
|
51
|
+
async getUiContext(options) {
|
|
52
|
+
const now = Date.now();
|
|
53
|
+
const shouldReuse = !options?.forceRefresh && this.lastUiContext && now - this.lastUiContext.capturedAt <= UI_CONTEXT_CACHE_TTL_MS;
|
|
54
|
+
if (shouldReuse && this.lastUiContext?.context) {
|
|
55
|
+
debug(`reuse cached uiContext captured ${now - this.lastUiContext.capturedAt}ms ago`);
|
|
56
|
+
return this.lastUiContext?.context;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const uiContext = await this.uiContextBuilder();
|
|
60
|
+
if (uiContext) this.lastUiContext = {
|
|
61
|
+
context: uiContext,
|
|
62
|
+
capturedAt: Date.now()
|
|
63
|
+
};
|
|
64
|
+
else this.lastUiContext = void 0;
|
|
65
|
+
return uiContext;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
this.lastUiContext = void 0;
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async captureScreenshot() {
|
|
72
|
+
try {
|
|
73
|
+
const uiContext = await this.getUiContext({
|
|
74
|
+
forceRefresh: true
|
|
75
|
+
});
|
|
76
|
+
return uiContext?.screenshot;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('error while capturing screenshot', error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
attachRecorderItem(task, screenshot, phase) {
|
|
82
|
+
if (!phase || !screenshot) return;
|
|
83
|
+
const recorderItem = {
|
|
84
|
+
type: 'screenshot',
|
|
85
|
+
ts: Date.now(),
|
|
86
|
+
screenshot,
|
|
87
|
+
timing: phase
|
|
88
|
+
};
|
|
89
|
+
if (!task.recorder) {
|
|
90
|
+
task.recorder = [
|
|
91
|
+
recorderItem
|
|
92
|
+
];
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
task.recorder.push(recorderItem);
|
|
96
|
+
}
|
|
97
|
+
markTaskAsPending(task) {
|
|
98
|
+
return {
|
|
99
|
+
taskId: (0, utils_namespaceObject.uuid)(),
|
|
100
|
+
status: 'pending',
|
|
101
|
+
...task
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
normalizeStatusFromError(options, errorMessage) {
|
|
105
|
+
if ('error' !== this.status) return;
|
|
106
|
+
(0, utils_namespaceObject.assert)(options?.allowWhenError, errorMessage || `task runner is in error state, cannot proceed\nerror=${this.latestErrorTask()?.error}\n${this.latestErrorTask()?.errorStack}`);
|
|
107
|
+
this.status = this.tasks.length > 0 ? 'pending' : 'init';
|
|
108
|
+
}
|
|
109
|
+
async append(task, options) {
|
|
110
|
+
this.normalizeStatusFromError(options, `task runner is in error state, cannot append task\nerror=${this.latestErrorTask()?.error}\n${this.latestErrorTask()?.errorStack}`);
|
|
111
|
+
if (Array.isArray(task)) this.tasks.push(...task.map((item)=>this.markTaskAsPending(item)));
|
|
112
|
+
else this.tasks.push(this.markTaskAsPending(task));
|
|
113
|
+
if ('running' !== this.status) this.status = 'pending';
|
|
114
|
+
await this.emitOnTaskUpdate();
|
|
115
|
+
}
|
|
116
|
+
async appendAndFlush(task, options) {
|
|
117
|
+
await this.append(task, options);
|
|
118
|
+
return this.flush(options);
|
|
119
|
+
}
|
|
120
|
+
async flush(options) {
|
|
121
|
+
if ('init' === this.status && this.tasks.length > 0) console.warn('illegal state for task runner, status is init but tasks are not empty');
|
|
122
|
+
this.normalizeStatusFromError(options, 'task runner is in error state');
|
|
123
|
+
(0, utils_namespaceObject.assert)('running' !== this.status, 'task runner is already running');
|
|
124
|
+
(0, utils_namespaceObject.assert)('completed' !== this.status, 'task runner is already completed');
|
|
125
|
+
const nextPendingIndex = this.tasks.findIndex((task)=>'pending' === task.status);
|
|
126
|
+
if (nextPendingIndex < 0) return;
|
|
127
|
+
this.status = 'running';
|
|
128
|
+
await this.emitOnTaskUpdate();
|
|
129
|
+
let taskIndex = nextPendingIndex;
|
|
130
|
+
let successfullyCompleted = true;
|
|
131
|
+
let previousFindOutput;
|
|
132
|
+
while(taskIndex < this.tasks.length){
|
|
133
|
+
const task = this.tasks[taskIndex];
|
|
134
|
+
(0, utils_namespaceObject.assert)('pending' === task.status, `task status should be pending, but got: ${task.status}`);
|
|
135
|
+
task.timing = {
|
|
136
|
+
start: Date.now()
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
task.status = 'running';
|
|
140
|
+
await this.emitOnTaskUpdate();
|
|
141
|
+
try {
|
|
142
|
+
if (this.onTaskStart) await this.onTaskStart(task);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
console.error('error in onTaskStart', e);
|
|
145
|
+
}
|
|
146
|
+
(0, utils_namespaceObject.assert)([
|
|
147
|
+
'Insight',
|
|
148
|
+
'Action Space',
|
|
149
|
+
'Planning'
|
|
150
|
+
].indexOf(task.type) >= 0, `unsupported task type: ${task.type}`);
|
|
151
|
+
const { executor, param } = task;
|
|
152
|
+
(0, utils_namespaceObject.assert)(executor, `executor is required for task type: ${task.type}`);
|
|
153
|
+
let returnValue;
|
|
154
|
+
const forceRefresh = 'Insight' === task.type;
|
|
155
|
+
(0, external_task_timing_js_namespaceObject.setTimingFieldOnce)(task.timing, 'getUiContextStart');
|
|
156
|
+
const uiContext = await this.getUiContext({
|
|
157
|
+
forceRefresh
|
|
158
|
+
});
|
|
159
|
+
(0, external_task_timing_js_namespaceObject.setTimingFieldOnce)(task.timing, 'getUiContextEnd');
|
|
160
|
+
task.uiContext = uiContext;
|
|
161
|
+
const executorContext = {
|
|
162
|
+
task,
|
|
163
|
+
element: previousFindOutput?.element,
|
|
164
|
+
uiContext
|
|
165
|
+
};
|
|
166
|
+
if ('Insight' === task.type) {
|
|
167
|
+
(0, utils_namespaceObject.assert)('Query' === task.subType || 'Assert' === task.subType || 'WaitFor' === task.subType || 'Boolean' === task.subType || 'Number' === task.subType || 'String' === task.subType, `unsupported service subType: ${task.subType}`);
|
|
168
|
+
returnValue = await task.executor(param, executorContext);
|
|
169
|
+
} else if ('Planning' === task.type) {
|
|
170
|
+
returnValue = await task.executor(param, executorContext);
|
|
171
|
+
if ('Locate' === task.subType) previousFindOutput = returnValue?.output;
|
|
172
|
+
} else if ('Action Space' === task.type) returnValue = await task.executor(param, executorContext);
|
|
173
|
+
else {
|
|
174
|
+
console.warn(`unsupported task type: ${task.type}, will try to execute it directly`);
|
|
175
|
+
returnValue = await task.executor(param, executorContext);
|
|
176
|
+
}
|
|
177
|
+
const isLastTask = taskIndex === this.tasks.length - 1;
|
|
178
|
+
if (isLastTask) {
|
|
179
|
+
(0, external_task_timing_js_namespaceObject.setTimingFieldOnce)(task.timing, 'captureAfterCallingSnapshotStart');
|
|
180
|
+
const screenshot = await this.captureScreenshot();
|
|
181
|
+
this.attachRecorderItem(task, screenshot, 'after-calling');
|
|
182
|
+
(0, external_task_timing_js_namespaceObject.setTimingFieldOnce)(task.timing, 'captureAfterCallingSnapshotEnd');
|
|
183
|
+
}
|
|
184
|
+
Object.assign(task, returnValue);
|
|
185
|
+
task.status = 'finished';
|
|
186
|
+
task.timing.end = Date.now();
|
|
187
|
+
task.timing.cost = task.timing.end - task.timing.start;
|
|
188
|
+
await this.emitOnTaskUpdate();
|
|
189
|
+
taskIndex++;
|
|
190
|
+
} catch (e) {
|
|
191
|
+
successfullyCompleted = false;
|
|
192
|
+
task.error = e;
|
|
193
|
+
task.errorMessage = e?.message || ('string' == typeof e ? e : 'error-without-message');
|
|
194
|
+
task.errorStack = e.stack;
|
|
195
|
+
task.status = 'failed';
|
|
196
|
+
task.timing.end = Date.now();
|
|
197
|
+
task.timing.cost = task.timing.end - task.timing.start;
|
|
198
|
+
await this.emitOnTaskUpdate();
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
for(let i = taskIndex + 1; i < this.tasks.length; i++)this.tasks[i].status = 'cancelled';
|
|
203
|
+
if (taskIndex + 1 < this.tasks.length) await this.emitOnTaskUpdate();
|
|
204
|
+
let finalizeError;
|
|
205
|
+
if (successfullyCompleted) {
|
|
206
|
+
this.status = 'completed';
|
|
207
|
+
await this.emitOnTaskUpdate();
|
|
208
|
+
} else {
|
|
209
|
+
this.status = 'error';
|
|
210
|
+
const errorTask = this.latestErrorTask();
|
|
211
|
+
const messageBase = errorTask?.errorMessage || (errorTask?.error ? String(errorTask.error) : 'Task execution failed');
|
|
212
|
+
const stack = errorTask?.errorStack;
|
|
213
|
+
const message = stack ? `${messageBase}\n${stack}` : messageBase;
|
|
214
|
+
finalizeError = new TaskExecutionError(message, this, errorTask, {
|
|
215
|
+
cause: errorTask?.error
|
|
216
|
+
});
|
|
217
|
+
await this.emitOnTaskUpdate(finalizeError);
|
|
218
|
+
}
|
|
219
|
+
if (finalizeError) throw finalizeError;
|
|
220
|
+
if (this.tasks.length) {
|
|
221
|
+
const outputIndex = Math.min(taskIndex, this.tasks.length - 1);
|
|
222
|
+
const { thought, output } = this.tasks[outputIndex];
|
|
223
|
+
return {
|
|
224
|
+
thought,
|
|
225
|
+
output
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
isInErrorState() {
|
|
230
|
+
return 'error' === this.status;
|
|
231
|
+
}
|
|
232
|
+
latestErrorTask() {
|
|
233
|
+
if ('error' !== this.status) return null;
|
|
234
|
+
for(let i = this.tasks.length - 1; i >= 0; i--)if ('failed' === this.tasks[i].status) return this.tasks[i];
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
dump() {
|
|
238
|
+
return new external_types_js_namespaceObject.ExecutionDump({
|
|
239
|
+
id: this.id,
|
|
240
|
+
logTime: this.executionLogTime,
|
|
241
|
+
name: this.name,
|
|
242
|
+
tasks: this.tasks
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
async appendErrorPlan(errorMsg) {
|
|
246
|
+
const errorTask = {
|
|
247
|
+
type: 'Action Space',
|
|
248
|
+
subType: 'Error',
|
|
249
|
+
param: {
|
|
250
|
+
thought: errorMsg
|
|
251
|
+
},
|
|
252
|
+
thought: errorMsg,
|
|
253
|
+
executor: async ()=>{
|
|
254
|
+
throw new Error(errorMsg || 'error without thought');
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
await this.appendAndFlush(errorTask);
|
|
258
|
+
return {
|
|
259
|
+
output: void 0,
|
|
260
|
+
runner: this
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
constructor(name, uiContextBuilder, options){
|
|
264
|
+
_define_property(this, "id", void 0);
|
|
265
|
+
_define_property(this, "name", void 0);
|
|
266
|
+
_define_property(this, "tasks", void 0);
|
|
267
|
+
_define_property(this, "status", void 0);
|
|
268
|
+
_define_property(this, "onTaskStart", void 0);
|
|
269
|
+
_define_property(this, "uiContextBuilder", void 0);
|
|
270
|
+
_define_property(this, "onTaskUpdate", void 0);
|
|
271
|
+
_define_property(this, "executionLogTime", void 0);
|
|
272
|
+
_define_property(this, "lastUiContext", void 0);
|
|
273
|
+
this.id = (0, utils_namespaceObject.uuid)();
|
|
274
|
+
this.status = options?.tasks && options.tasks.length > 0 ? 'pending' : 'init';
|
|
275
|
+
this.name = name;
|
|
276
|
+
this.tasks = (options?.tasks || []).map((item)=>this.markTaskAsPending(item));
|
|
277
|
+
this.onTaskStart = options?.onTaskStart;
|
|
278
|
+
this.uiContextBuilder = uiContextBuilder;
|
|
279
|
+
this.onTaskUpdate = options?.onTaskUpdate;
|
|
280
|
+
this.executionLogTime = Date.now();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
class TaskExecutionError extends Error {
|
|
284
|
+
constructor(message, runner, errorTask, options){
|
|
285
|
+
super(message, options), _define_property(this, "runner", void 0), _define_property(this, "errorTask", void 0);
|
|
286
|
+
this.runner = runner;
|
|
287
|
+
this.errorTask = errorTask;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
exports.TaskExecutionError = __webpack_exports__.TaskExecutionError;
|
|
291
|
+
exports.TaskRunner = __webpack_exports__.TaskRunner;
|
|
292
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
293
|
+
"TaskExecutionError",
|
|
294
|
+
"TaskRunner"
|
|
295
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
296
|
+
Object.defineProperty(exports, '__esModule', {
|
|
297
|
+
value: true
|
|
298
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
setTimingFieldOnce: ()=>setTimingFieldOnce
|
|
28
|
+
});
|
|
29
|
+
const logger_namespaceObject = require("@godscene/shared/logger");
|
|
30
|
+
const debugTiming = (0, logger_namespaceObject.getDebug)('task-timing');
|
|
31
|
+
function setTimingFieldOnce(timing, field) {
|
|
32
|
+
if (!timing) return void debugTiming(`[warning] timing object missing, skip set. field=${field}`);
|
|
33
|
+
const value = Date.now();
|
|
34
|
+
const existingValue = timing[field];
|
|
35
|
+
if (void 0 !== existingValue) return void debugTiming(`[warning] duplicate timing field set ignored. field=${field}, existing=${existingValue}, incoming=${value}`);
|
|
36
|
+
timing[field] = value;
|
|
37
|
+
}
|
|
38
|
+
exports.setTimingFieldOnce = __webpack_exports__.setTimingFieldOnce;
|
|
39
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
+
"setTimingFieldOnce"
|
|
41
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
42
|
+
Object.defineProperty(exports, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
package/dist/lib/tree.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
descriptionOfTree: ()=>descriptionOfTree,
|
|
28
|
+
truncateText: ()=>extractor_namespaceObject.truncateText,
|
|
29
|
+
trimAttributes: ()=>extractor_namespaceObject.trimAttributes
|
|
30
|
+
});
|
|
31
|
+
const extractor_namespaceObject = require("@godscene/shared/extractor");
|
|
32
|
+
const ELEMENT_COUNT_WARNING_THRESHOLD = 5000;
|
|
33
|
+
const TREE_SIZE_WARNING_MESSAGE = 'The number of elements is too large, it may cause the prompt to be too long, please use domIncluded: "visible-only" to reduce the number of elements';
|
|
34
|
+
function descriptionOfTree(tree, truncateTextLength, filterNonTextContent = false, visibleOnly = true) {
|
|
35
|
+
if (!visibleOnly) {
|
|
36
|
+
const flatElements = (0, extractor_namespaceObject.treeToList)(tree);
|
|
37
|
+
if (flatElements.length >= ELEMENT_COUNT_WARNING_THRESHOLD) console.warn(TREE_SIZE_WARNING_MESSAGE);
|
|
38
|
+
}
|
|
39
|
+
return (0, extractor_namespaceObject.descriptionOfTree)(tree, truncateTextLength, filterNonTextContent, visibleOnly);
|
|
40
|
+
}
|
|
41
|
+
exports.descriptionOfTree = __webpack_exports__.descriptionOfTree;
|
|
42
|
+
exports.trimAttributes = __webpack_exports__.trimAttributes;
|
|
43
|
+
exports.truncateText = __webpack_exports__.truncateText;
|
|
44
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
45
|
+
"descriptionOfTree",
|
|
46
|
+
"trimAttributes",
|
|
47
|
+
"truncateText"
|
|
48
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
49
|
+
Object.defineProperty(exports, '__esModule', {
|
|
50
|
+
value: true
|
|
51
|
+
});
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./dump/screenshot-restoration" (module) {
|
|
4
|
+
module.exports = require("./dump/screenshot-restoration.js");
|
|
5
|
+
},
|
|
6
|
+
"./dump/screenshot-store" (module) {
|
|
7
|
+
module.exports = require("./dump/screenshot-store.js");
|
|
8
|
+
},
|
|
9
|
+
"./screenshot-item" (module) {
|
|
10
|
+
module.exports = require("./screenshot-item.js");
|
|
11
|
+
},
|
|
12
|
+
"./yaml" (module) {
|
|
13
|
+
module.exports = require("./yaml.js");
|
|
14
|
+
},
|
|
15
|
+
"node:fs" (module) {
|
|
16
|
+
module.exports = require("node:fs");
|
|
17
|
+
},
|
|
18
|
+
"node:path" (module) {
|
|
19
|
+
module.exports = require("node:path");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var __webpack_module_cache__ = {};
|
|
23
|
+
function __webpack_require__(moduleId) {
|
|
24
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
25
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
26
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
27
|
+
exports: {}
|
|
28
|
+
};
|
|
29
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
30
|
+
return module.exports;
|
|
31
|
+
}
|
|
32
|
+
(()=>{
|
|
33
|
+
__webpack_require__.n = (module)=>{
|
|
34
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
35
|
+
__webpack_require__.d(getter, {
|
|
36
|
+
a: getter
|
|
37
|
+
});
|
|
38
|
+
return getter;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
(()=>{
|
|
42
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
43
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: definition[key]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
(()=>{
|
|
50
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
51
|
+
})();
|
|
52
|
+
(()=>{
|
|
53
|
+
__webpack_require__.r = (exports1)=>{
|
|
54
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
55
|
+
value: 'Module'
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
var __webpack_exports__ = {};
|
|
63
|
+
(()=>{
|
|
64
|
+
__webpack_require__.r(__webpack_exports__);
|
|
65
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
66
|
+
ExecutionDump: ()=>ExecutionDump,
|
|
67
|
+
GroupedActionDump: ()=>GroupedActionDump,
|
|
68
|
+
ReportActionDump: ()=>ReportActionDump,
|
|
69
|
+
ServiceError: ()=>ServiceError,
|
|
70
|
+
UIContext: ()=>UIContext
|
|
71
|
+
});
|
|
72
|
+
var node_fs__rspack_import_0 = __webpack_require__("node:fs");
|
|
73
|
+
var node_path__rspack_import_1 = __webpack_require__("node:path");
|
|
74
|
+
var _dump_screenshot_restoration__rspack_import_2 = __webpack_require__("./dump/screenshot-restoration");
|
|
75
|
+
var _dump_screenshot_store__rspack_import_3 = __webpack_require__("./dump/screenshot-store");
|
|
76
|
+
var _screenshot_item__rspack_import_4 = __webpack_require__("./screenshot-item");
|
|
77
|
+
var _yaml__rspack_import_5 = __webpack_require__("./yaml");
|
|
78
|
+
var __rspack_reexport = {};
|
|
79
|
+
for(const __rspack_import_key in _yaml__rspack_import_5)if ([
|
|
80
|
+
"UIContext",
|
|
81
|
+
"ServiceError",
|
|
82
|
+
"default",
|
|
83
|
+
"ReportActionDump",
|
|
84
|
+
"GroupedActionDump",
|
|
85
|
+
"ExecutionDump"
|
|
86
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_yaml__rspack_import_5[__rspack_import_key];
|
|
87
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
88
|
+
function _define_property(obj, key, value) {
|
|
89
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
90
|
+
value: value,
|
|
91
|
+
enumerable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
writable: true
|
|
94
|
+
});
|
|
95
|
+
else obj[key] = value;
|
|
96
|
+
return obj;
|
|
97
|
+
}
|
|
98
|
+
class UIContext {
|
|
99
|
+
}
|
|
100
|
+
class ServiceError extends Error {
|
|
101
|
+
constructor(message, dump){
|
|
102
|
+
super(message), _define_property(this, "dump", void 0);
|
|
103
|
+
this.name = 'ServiceError';
|
|
104
|
+
this.dump = dump;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function replacerForDumpSerialization(_key, value) {
|
|
108
|
+
if (value && value.constructor?.name === 'Page') return '[Page object]';
|
|
109
|
+
if (value && value.constructor?.name === 'Browser') return '[Browser object]';
|
|
110
|
+
if (value && 'function' == typeof value.toSerializable) return value.toSerializable();
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function reviverForDumpDeserialization(key, value) {
|
|
114
|
+
if ('screenshot' !== key || 'object' != typeof value || null === value) return value;
|
|
115
|
+
_screenshot_item__rspack_import_4.ScreenshotItem.isSerialized(value);
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
class ExecutionDump {
|
|
119
|
+
serialize(indents) {
|
|
120
|
+
return JSON.stringify(this.toJSON(), replacerForDumpSerialization, indents);
|
|
121
|
+
}
|
|
122
|
+
toJSON() {
|
|
123
|
+
return {
|
|
124
|
+
id: this.id,
|
|
125
|
+
logTime: this.logTime,
|
|
126
|
+
name: this.name,
|
|
127
|
+
description: this.description,
|
|
128
|
+
tasks: this.tasks.map((task)=>({
|
|
129
|
+
...task,
|
|
130
|
+
recorder: task.recorder || []
|
|
131
|
+
})),
|
|
132
|
+
aiActContext: this.aiActContext
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
static fromSerializedString(serialized) {
|
|
136
|
+
const parsed = JSON.parse(serialized, reviverForDumpDeserialization);
|
|
137
|
+
return new ExecutionDump(parsed);
|
|
138
|
+
}
|
|
139
|
+
static fromJSON(data) {
|
|
140
|
+
return new ExecutionDump(data);
|
|
141
|
+
}
|
|
142
|
+
collectScreenshots() {
|
|
143
|
+
const screenshots = [];
|
|
144
|
+
for (const task of this.tasks){
|
|
145
|
+
if (task.uiContext?.screenshot instanceof _screenshot_item__rspack_import_4.ScreenshotItem) screenshots.push(task.uiContext.screenshot);
|
|
146
|
+
if (task.recorder) {
|
|
147
|
+
for (const record of task.recorder)if (record.screenshot instanceof _screenshot_item__rspack_import_4.ScreenshotItem) screenshots.push(record.screenshot);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return screenshots;
|
|
151
|
+
}
|
|
152
|
+
constructor(data){
|
|
153
|
+
_define_property(this, "id", void 0);
|
|
154
|
+
_define_property(this, "logTime", void 0);
|
|
155
|
+
_define_property(this, "name", void 0);
|
|
156
|
+
_define_property(this, "description", void 0);
|
|
157
|
+
_define_property(this, "tasks", void 0);
|
|
158
|
+
_define_property(this, "aiActContext", void 0);
|
|
159
|
+
this.id = data.id;
|
|
160
|
+
this.logTime = data.logTime;
|
|
161
|
+
this.name = data.name;
|
|
162
|
+
this.description = data.description;
|
|
163
|
+
this.tasks = data.tasks;
|
|
164
|
+
this.aiActContext = data.aiActContext;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
class ReportActionDump {
|
|
168
|
+
serialize(indents) {
|
|
169
|
+
return JSON.stringify(this.toJSON(), replacerForDumpSerialization, indents);
|
|
170
|
+
}
|
|
171
|
+
serializeWithInlineScreenshots(indents) {
|
|
172
|
+
const processValue = (obj)=>{
|
|
173
|
+
if (obj instanceof _screenshot_item__rspack_import_4.ScreenshotItem) return {
|
|
174
|
+
base64: obj.base64,
|
|
175
|
+
capturedAt: obj.capturedAt
|
|
176
|
+
};
|
|
177
|
+
if (Array.isArray(obj)) return obj.map(processValue);
|
|
178
|
+
if (obj && 'object' == typeof obj) {
|
|
179
|
+
const entries = Object.entries(obj).map(([key, value])=>[
|
|
180
|
+
key,
|
|
181
|
+
processValue(value)
|
|
182
|
+
]);
|
|
183
|
+
return Object.fromEntries(entries);
|
|
184
|
+
}
|
|
185
|
+
return obj;
|
|
186
|
+
};
|
|
187
|
+
const data = processValue(this.toJSON());
|
|
188
|
+
return JSON.stringify(data, null, indents);
|
|
189
|
+
}
|
|
190
|
+
toJSON() {
|
|
191
|
+
return {
|
|
192
|
+
sdkVersion: this.sdkVersion,
|
|
193
|
+
groupName: this.groupName,
|
|
194
|
+
groupDescription: this.groupDescription,
|
|
195
|
+
modelBriefs: this.modelBriefs,
|
|
196
|
+
executions: this.executions.map((exec)=>exec.toJSON()),
|
|
197
|
+
deviceType: this.deviceType
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
static fromSerializedString(serialized) {
|
|
201
|
+
const parsed = JSON.parse(serialized, reviverForDumpDeserialization);
|
|
202
|
+
return new ReportActionDump(parsed);
|
|
203
|
+
}
|
|
204
|
+
static fromJSON(data) {
|
|
205
|
+
return new ReportActionDump(data);
|
|
206
|
+
}
|
|
207
|
+
collectAllScreenshots() {
|
|
208
|
+
const screenshots = [];
|
|
209
|
+
for (const execution of this.executions)screenshots.push(...execution.collectScreenshots());
|
|
210
|
+
return screenshots;
|
|
211
|
+
}
|
|
212
|
+
serializeToFiles(basePath) {
|
|
213
|
+
const screenshotsDir = `${basePath}.screenshots`;
|
|
214
|
+
if (!(0, node_fs__rspack_import_0.existsSync)(screenshotsDir)) (0, node_fs__rspack_import_0.mkdirSync)(screenshotsDir, {
|
|
215
|
+
recursive: true
|
|
216
|
+
});
|
|
217
|
+
const screenshots = this.collectAllScreenshots();
|
|
218
|
+
for (const screenshot of screenshots){
|
|
219
|
+
const imagePath = (0, node_path__rspack_import_1.join)(screenshotsDir, `${screenshot.id}.${screenshot.extension}`);
|
|
220
|
+
if ((0, node_fs__rspack_import_0.existsSync)(imagePath)) continue;
|
|
221
|
+
const rawBase64 = screenshot.rawBase64;
|
|
222
|
+
(0, node_fs__rspack_import_0.writeFileSync)(imagePath, Buffer.from(rawBase64, 'base64'));
|
|
223
|
+
}
|
|
224
|
+
(0, node_fs__rspack_import_0.writeFileSync)(basePath, this.serialize(), 'utf-8');
|
|
225
|
+
}
|
|
226
|
+
static fromFilesAsInlineJson(basePath) {
|
|
227
|
+
const dumpString = (0, node_fs__rspack_import_0.readFileSync)(basePath, 'utf-8');
|
|
228
|
+
const screenshotsDir = `${basePath}.screenshots`;
|
|
229
|
+
const loadFromExecutionScreenshotDir = (id, mimeType)=>{
|
|
230
|
+
const ext = 'image/jpeg' === mimeType ? 'jpeg' : 'png';
|
|
231
|
+
const filePath = (0, node_path__rspack_import_1.join)(screenshotsDir, `${id}.${ext}`);
|
|
232
|
+
if (!(0, node_fs__rspack_import_0.existsSync)(filePath)) return '';
|
|
233
|
+
const data = (0, node_fs__rspack_import_0.readFileSync)(filePath);
|
|
234
|
+
return `data:image/${ext};base64,${data.toString('base64')}`;
|
|
235
|
+
};
|
|
236
|
+
const dumpData = JSON.parse(dumpString);
|
|
237
|
+
const store = new _dump_screenshot_store__rspack_import_3.ScreenshotStore({
|
|
238
|
+
mode: 'directory',
|
|
239
|
+
reportPath: basePath
|
|
240
|
+
});
|
|
241
|
+
const processedData = (0, _dump_screenshot_restoration__rspack_import_2.restoreImageReferences)(dumpData, (ref)=>{
|
|
242
|
+
const executionFileImage = loadFromExecutionScreenshotDir(ref.id, ref.mimeType);
|
|
243
|
+
if (executionFileImage) return executionFileImage;
|
|
244
|
+
if ('inline' === ref.storage) return '';
|
|
245
|
+
return store.loadBase64(ref);
|
|
246
|
+
});
|
|
247
|
+
return JSON.stringify(processedData);
|
|
248
|
+
}
|
|
249
|
+
static cleanupFiles(basePath) {
|
|
250
|
+
const filesToClean = [
|
|
251
|
+
basePath,
|
|
252
|
+
`${basePath}.screenshots`
|
|
253
|
+
];
|
|
254
|
+
for (const filePath of filesToClean)try {
|
|
255
|
+
(0, node_fs__rspack_import_0.rmSync)(filePath, {
|
|
256
|
+
force: true,
|
|
257
|
+
recursive: true
|
|
258
|
+
});
|
|
259
|
+
} catch {}
|
|
260
|
+
}
|
|
261
|
+
static getFilePaths(basePath) {
|
|
262
|
+
return [
|
|
263
|
+
basePath,
|
|
264
|
+
`${basePath}.screenshots`
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
constructor(data){
|
|
268
|
+
_define_property(this, "sdkVersion", void 0);
|
|
269
|
+
_define_property(this, "groupName", void 0);
|
|
270
|
+
_define_property(this, "groupDescription", void 0);
|
|
271
|
+
_define_property(this, "modelBriefs", void 0);
|
|
272
|
+
_define_property(this, "executions", void 0);
|
|
273
|
+
_define_property(this, "deviceType", void 0);
|
|
274
|
+
this.sdkVersion = data.sdkVersion;
|
|
275
|
+
this.groupName = data.groupName;
|
|
276
|
+
this.groupDescription = data.groupDescription;
|
|
277
|
+
this.modelBriefs = data.modelBriefs;
|
|
278
|
+
this.executions = data.executions.map((exec)=>exec instanceof ExecutionDump ? exec : ExecutionDump.fromJSON(exec));
|
|
279
|
+
this.deviceType = data.deviceType;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const GroupedActionDump = ReportActionDump;
|
|
283
|
+
})();
|
|
284
|
+
exports.ExecutionDump = __webpack_exports__.ExecutionDump;
|
|
285
|
+
exports.GroupedActionDump = __webpack_exports__.GroupedActionDump;
|
|
286
|
+
exports.ReportActionDump = __webpack_exports__.ReportActionDump;
|
|
287
|
+
exports.ServiceError = __webpack_exports__.ServiceError;
|
|
288
|
+
exports.UIContext = __webpack_exports__.UIContext;
|
|
289
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
290
|
+
"ExecutionDump",
|
|
291
|
+
"GroupedActionDump",
|
|
292
|
+
"ReportActionDump",
|
|
293
|
+
"ServiceError",
|
|
294
|
+
"UIContext"
|
|
295
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
296
|
+
Object.defineProperty(exports, '__esModule', {
|
|
297
|
+
value: true
|
|
298
|
+
});
|