@aiscene/shared 8.0.3 → 8.0.5

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.
Files changed (105) hide show
  1. package/dist/es/agent-tools/agent-behavior-init-args.mjs +44 -0
  2. package/dist/es/agent-tools/base-tools.mjs +163 -0
  3. package/dist/es/agent-tools/chrome-path.mjs +50 -0
  4. package/dist/es/agent-tools/cli-report-session.mjs +78 -0
  5. package/dist/es/agent-tools/error-formatter.mjs +106 -0
  6. package/dist/es/agent-tools/index.mjs +9 -0
  7. package/dist/es/agent-tools/init-arg-utils.mjs +38 -0
  8. package/dist/es/agent-tools/observation-artifact.mjs +5 -0
  9. package/dist/es/agent-tools/observation-record.mjs +248 -0
  10. package/dist/es/agent-tools/tool-defaults.mjs +54 -0
  11. package/dist/es/agent-tools/tool-generator.mjs +529 -0
  12. package/dist/es/agent-tools/types.mjs +3 -0
  13. package/dist/es/agent-tools/user-prompt.mjs +66 -0
  14. package/dist/es/cli/interrupt.mjs +116 -0
  15. package/dist/es/cli/record-command.mjs +130 -0
  16. package/dist/es/cli/screenshot-file.mjs +24 -0
  17. package/dist/es/cli/verbose-ai-act.mjs +230 -0
  18. package/dist/es/cli/verbose-screenshot.mjs +134 -0
  19. package/dist/es/cli/verbose.mjs +404 -0
  20. package/dist/es/env/parse-model-config.mjs +1 -1
  21. package/dist/es/env/types.mjs +18 -3
  22. package/dist/es/img/index.mjs +3 -3
  23. package/dist/es/img/info.mjs +45 -1
  24. package/dist/es/img/photon-loader.mjs +4 -0
  25. package/dist/es/img/transform.mjs +113 -3
  26. package/dist/es/recorder.mjs +249 -0
  27. package/dist/lib/agent-tools/agent-behavior-init-args.js +87 -0
  28. package/dist/lib/agent-tools/base-tools.js +197 -0
  29. package/dist/lib/agent-tools/chrome-path.js +87 -0
  30. package/dist/lib/agent-tools/cli-report-session.js +121 -0
  31. package/dist/lib/agent-tools/error-formatter.js +149 -0
  32. package/dist/lib/agent-tools/index.js +114 -0
  33. package/dist/lib/agent-tools/init-arg-utils.js +78 -0
  34. package/dist/lib/agent-tools/observation-artifact.js +42 -0
  35. package/dist/lib/agent-tools/observation-record.js +297 -0
  36. package/dist/lib/agent-tools/tool-defaults.js +97 -0
  37. package/dist/lib/agent-tools/tool-generator.js +569 -0
  38. package/dist/lib/agent-tools/types.js +40 -0
  39. package/dist/lib/agent-tools/user-prompt.js +103 -0
  40. package/dist/lib/cli/interrupt.js +156 -0
  41. package/dist/lib/cli/record-command.js +164 -0
  42. package/dist/lib/cli/screenshot-file.js +58 -0
  43. package/dist/lib/cli/verbose-ai-act.js +273 -0
  44. package/dist/lib/cli/verbose-screenshot.js +177 -0
  45. package/dist/lib/cli/verbose.js +465 -0
  46. package/dist/lib/env/parse-model-config.js +1 -1
  47. package/dist/lib/env/types.js +32 -2
  48. package/dist/lib/img/index.js +29 -5
  49. package/dist/lib/img/info.js +48 -1
  50. package/dist/lib/img/photon-loader.js +38 -0
  51. package/dist/lib/img/transform.js +135 -4
  52. package/dist/lib/recorder.js +307 -0
  53. package/dist/types/agent-tools/agent-behavior-init-args.d.ts +17 -0
  54. package/dist/types/agent-tools/base-tools.d.ts +158 -0
  55. package/dist/types/agent-tools/chrome-path.d.ts +2 -0
  56. package/dist/types/agent-tools/cli-report-session.d.ts +12 -0
  57. package/dist/types/agent-tools/error-formatter.d.ts +30 -0
  58. package/dist/types/agent-tools/index.d.ts +9 -0
  59. package/dist/types/agent-tools/init-arg-utils.d.ts +13 -0
  60. package/dist/types/agent-tools/observation-artifact.d.ts +10 -0
  61. package/dist/types/agent-tools/observation-record.d.ts +38 -0
  62. package/dist/types/agent-tools/tool-defaults.d.ts +63 -0
  63. package/dist/types/agent-tools/tool-generator.d.ts +13 -0
  64. package/dist/types/agent-tools/types.d.ts +213 -0
  65. package/dist/types/agent-tools/user-prompt.d.ts +13 -0
  66. package/dist/types/cli/interrupt.d.ts +49 -0
  67. package/dist/types/cli/record-command.d.ts +3 -0
  68. package/dist/types/cli/screenshot-file.d.ts +10 -0
  69. package/dist/types/cli/verbose-ai-act.d.ts +44 -0
  70. package/dist/types/cli/verbose-screenshot.d.ts +10 -0
  71. package/dist/types/cli/verbose.d.ts +40 -0
  72. package/dist/types/env/types.d.ts +16 -7
  73. package/dist/types/img/index.d.ts +2 -2
  74. package/dist/types/img/info.d.ts +2 -0
  75. package/dist/types/img/photon-loader.d.ts +2 -0
  76. package/dist/types/img/transform.d.ts +22 -2
  77. package/dist/types/mcp/types.d.ts +1 -0
  78. package/dist/types/recorder.d.ts +113 -0
  79. package/package.json +1 -1
  80. package/src/agent-tools/agent-behavior-init-args.ts +109 -0
  81. package/src/agent-tools/base-tools.ts +399 -0
  82. package/src/agent-tools/chrome-path.ts +74 -0
  83. package/src/agent-tools/cli-report-session.ts +130 -0
  84. package/src/agent-tools/error-formatter.ts +177 -0
  85. package/src/agent-tools/index.ts +9 -0
  86. package/src/agent-tools/init-arg-utils.ts +105 -0
  87. package/src/agent-tools/observation-artifact.ts +29 -0
  88. package/src/agent-tools/observation-record.ts +331 -0
  89. package/src/agent-tools/tool-defaults.ts +119 -0
  90. package/src/agent-tools/tool-generator.ts +866 -0
  91. package/src/agent-tools/types.ts +250 -0
  92. package/src/agent-tools/user-prompt.ts +102 -0
  93. package/src/cli/interrupt.ts +207 -0
  94. package/src/cli/record-command.ts +177 -0
  95. package/src/cli/screenshot-file.ts +61 -0
  96. package/src/cli/verbose-ai-act.ts +387 -0
  97. package/src/cli/verbose-screenshot.ts +269 -0
  98. package/src/cli/verbose.ts +753 -0
  99. package/src/env/types.ts +30 -2
  100. package/src/img/index.ts +12 -0
  101. package/src/img/info.ts +61 -0
  102. package/src/img/photon-loader.ts +5 -0
  103. package/src/img/transform.ts +262 -3
  104. package/src/mcp/types.ts +2 -0
  105. package/src/recorder.ts +625 -0
@@ -0,0 +1,273 @@
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 ('undefined' != 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
+ buildAiActProgressEventLines: ()=>buildAiActProgressEventLines,
28
+ aiActCliProgressRenderer: ()=>aiActCliProgressRenderer,
29
+ cliAiActProgressScope: ()=>cliAiActProgressScope,
30
+ normalizeAiActProgressEventForCli: ()=>normalizeAiActProgressEventForCli
31
+ });
32
+ const external_verbose_screenshot_js_namespaceObject = require("./verbose-screenshot.js");
33
+ const cliAiActProgressScope = 'aiAct';
34
+ function isRecord(value) {
35
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
36
+ }
37
+ function compactText(value) {
38
+ if (null == value || '' === value) return '';
39
+ if ('string' == typeof value) return value.length > 180 ? `${value.slice(0, 177)}...` : value;
40
+ if ('number' == typeof value || 'boolean' == typeof value) return String(value);
41
+ try {
42
+ const json = JSON.stringify(value);
43
+ return json.length > 180 ? `${json.slice(0, 177)}...` : json;
44
+ } catch {
45
+ return String(value);
46
+ }
47
+ }
48
+ function numericValue(value) {
49
+ return 'number' == typeof value && Number.isFinite(value) ? value : void 0;
50
+ }
51
+ function firstText(values) {
52
+ for (const value of values){
53
+ const text = compactText(value);
54
+ if (text) return text;
55
+ }
56
+ return '';
57
+ }
58
+ function planPrefix(event) {
59
+ const planIndex = numericValue(event.planIndex);
60
+ if (!planIndex) return '[Midscene][aiAct]';
61
+ const planLimit = numericValue(event.planLimit);
62
+ return `[Midscene][aiAct][Plan ${Math.round(planIndex)}${planLimit ? `/${Math.round(planLimit)}` : ''}]`;
63
+ }
64
+ function eventKey(event, suffix) {
65
+ const sequence = numericValue(event.sequence);
66
+ if (sequence) return `aiAct:${sequence}:${suffix}`;
67
+ return [
68
+ 'aiAct',
69
+ compactText(event.phase),
70
+ compactText(event.planIndex),
71
+ suffix
72
+ ].filter(Boolean).join(':');
73
+ }
74
+ function integerText(value) {
75
+ return String(Math.round(value));
76
+ }
77
+ function numberTuple2(value) {
78
+ if (Array.isArray(value) && value.length >= 2 && 'number' == typeof value[0] && 'number' == typeof value[1]) return [
79
+ value[0],
80
+ value[1]
81
+ ];
82
+ }
83
+ function numberTuple4(value) {
84
+ if (Array.isArray(value) && value.length >= 4 && value.slice(0, 4).every((item)=>'number' == typeof item)) return [
85
+ value[0],
86
+ value[1],
87
+ value[2],
88
+ value[3]
89
+ ];
90
+ }
91
+ function parseAction(value) {
92
+ if (!isRecord(value) || 'string' != typeof value.name) return;
93
+ return {
94
+ name: value.name,
95
+ target: 'string' == typeof value.target ? value.target : void 0,
96
+ point: numberTuple2(value.point),
97
+ bbox: numberTuple4(value.bbox),
98
+ param: value.param
99
+ };
100
+ }
101
+ function formatPoint(point) {
102
+ return `(${integerText(point[0])}, ${integerText(point[1])})`;
103
+ }
104
+ function formatBbox(bbox) {
105
+ return `(${bbox.map(integerText).join(',')})`;
106
+ }
107
+ function sleepActionText(action) {
108
+ if ('Sleep' !== action.name || !isRecord(action.param)) return;
109
+ const timeMs = numericValue(action.param.timeMs) ?? numericValue(action.param.duration) ?? numericValue(action.param.timeoutMs);
110
+ return void 0 !== timeMs ? `Sleep ${integerText(timeMs)}ms` : void 0;
111
+ }
112
+ function plannedActionText(action) {
113
+ if (action.point) {
114
+ const targetSegment = action.target ? ` "${action.target}"` : '';
115
+ const bboxSegment = action.bbox ? `, bbox=${formatBbox(action.bbox)}` : '';
116
+ return `${action.name}${targetSegment} at ${formatPoint(action.point)}${bboxSegment}`;
117
+ }
118
+ const sleep = sleepActionText(action);
119
+ if (sleep) return sleep;
120
+ const paramText = compactText(action.param);
121
+ return paramText ? `${action.name}: ${paramText}` : action.name;
122
+ }
123
+ function runningActionText(action) {
124
+ if (action.point) return `${action.name} at ${formatPoint(action.point)}`;
125
+ return plannedActionText(action);
126
+ }
127
+ function normalizeAiActProgressEventForCli(event, screenshotOptions = {}) {
128
+ if (!isRecord(event) || event.scope !== cliAiActProgressScope) return;
129
+ const data = isRecord(event.data) ? event.data : {};
130
+ const screenshots = (0, external_verbose_screenshot_js_namespaceObject.collectScreenshotRefs)(data.screenshot, screenshotOptions);
131
+ const latestPath = screenshots.slice().reverse().find((item)=>'string' == typeof item.path && item.path.length > 0)?.path;
132
+ const screenshotPath = 'string' == typeof latestPath ? (0, external_verbose_screenshot_js_namespaceObject.pathForReportScreenshot)(latestPath, screenshotOptions.reportFile) : void 0;
133
+ const { prompt, planIndex, planLimit, action, thought, log, output, durationMs, error } = data;
134
+ return {
135
+ phase: event.phase,
136
+ sequence: event.sequence,
137
+ prompt,
138
+ planIndex,
139
+ planLimit,
140
+ action,
141
+ thought,
142
+ log,
143
+ output,
144
+ durationMs,
145
+ error,
146
+ ...screenshots.length > 0 ? {
147
+ screenshots
148
+ } : {},
149
+ ...screenshotPath ? {
150
+ screenshotPath
151
+ } : {}
152
+ };
153
+ }
154
+ function buildAiActProgressEventLines(event) {
155
+ const phase = 'string' == typeof event.phase ? event.phase : '';
156
+ const prefix = planPrefix(event);
157
+ const error = compactText(event.error);
158
+ const duration = 'number' == typeof event.durationMs ? ` cost=${Math.round(event.durationMs)}ms` : '';
159
+ const action = parseAction(event.action);
160
+ switch(phase){
161
+ case 'start':
162
+ {
163
+ const prompt = compactText(event.prompt);
164
+ return [
165
+ {
166
+ key: `aiAct:start:${prompt}`,
167
+ text: prompt ? `[Midscene][aiAct] Start: ${prompt}` : '[Midscene][aiAct] Start'
168
+ }
169
+ ];
170
+ }
171
+ case 'plan_thinking':
172
+ return event.screenshotPath ? [
173
+ {
174
+ key: eventKey(event, 'thinking'),
175
+ text: `${prefix} Thinking with the latest screenshot: ${event.screenshotPath}`
176
+ }
177
+ ] : [
178
+ {
179
+ key: eventKey(event, 'thinking'),
180
+ text: `${prefix} Thinking with the latest screenshot`
181
+ }
182
+ ];
183
+ case 'plan_planned':
184
+ {
185
+ const text = firstText([
186
+ event.log,
187
+ event.thought,
188
+ event.output
189
+ ]);
190
+ return text ? [
191
+ {
192
+ key: eventKey(event, 'planned'),
193
+ text: `${prefix} Planned: ${text}`
194
+ }
195
+ ] : [];
196
+ }
197
+ case 'plan_action':
198
+ return action ? [
199
+ {
200
+ key: eventKey(event, 'action'),
201
+ text: `${prefix} Action: ${plannedActionText(action)}`
202
+ }
203
+ ] : [];
204
+ case 'plan_failed':
205
+ return [
206
+ {
207
+ key: eventKey(event, 'plan_failed'),
208
+ text: `${prefix} Failed${error ? `: ${error}` : ''}`
209
+ }
210
+ ];
211
+ case 'action_running':
212
+ return action ? [
213
+ {
214
+ key: eventKey(event, 'action_running'),
215
+ text: `[Midscene][aiAct][Action] Running: ${runningActionText(action)}`
216
+ }
217
+ ] : [];
218
+ case 'action_done':
219
+ return action ? [
220
+ {
221
+ key: eventKey(event, 'action_done'),
222
+ text: `[Midscene][aiAct][Action] Done: ${action.name}${duration}`
223
+ }
224
+ ] : [];
225
+ case 'action_failed':
226
+ return [
227
+ {
228
+ key: eventKey(event, 'action_failed'),
229
+ text: `[Midscene][aiAct][Action] Failed${action ? `: ${action.name}` : ''}${duration}${error ? ` error=${error}` : ''}`
230
+ }
231
+ ];
232
+ case 'complete':
233
+ {
234
+ const text = firstText([
235
+ event.output,
236
+ event.log,
237
+ event.thought
238
+ ]);
239
+ return [
240
+ {
241
+ key: eventKey(event, 'complete'),
242
+ text: `[Midscene][aiAct] Complete${text ? `: ${text}` : ''}`
243
+ }
244
+ ];
245
+ }
246
+ case 'failed':
247
+ return [
248
+ {
249
+ key: eventKey(event, 'failed'),
250
+ text: `[Midscene][aiAct] Failed${error ? `: ${error}` : ''}`
251
+ }
252
+ ];
253
+ default:
254
+ return [];
255
+ }
256
+ }
257
+ const aiActCliProgressRenderer = {
258
+ normalize: normalizeAiActProgressEventForCli,
259
+ buildLines: buildAiActProgressEventLines
260
+ };
261
+ exports.aiActCliProgressRenderer = __webpack_exports__.aiActCliProgressRenderer;
262
+ exports.buildAiActProgressEventLines = __webpack_exports__.buildAiActProgressEventLines;
263
+ exports.cliAiActProgressScope = __webpack_exports__.cliAiActProgressScope;
264
+ exports.normalizeAiActProgressEventForCli = __webpack_exports__.normalizeAiActProgressEventForCli;
265
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
266
+ "aiActCliProgressRenderer",
267
+ "buildAiActProgressEventLines",
268
+ "cliAiActProgressScope",
269
+ "normalizeAiActProgressEventForCli"
270
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
271
+ Object.defineProperty(exports, '__esModule', {
272
+ value: true
273
+ });
@@ -0,0 +1,177 @@
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 ('undefined' != 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
+ collectScreenshotRefs: ()=>collectScreenshotRefs,
28
+ pathForReportScreenshot: ()=>pathForReportScreenshot,
29
+ latestScreenshotPathForAiAct: ()=>latestScreenshotPathForAiAct,
30
+ renderScreenshotList: ()=>renderScreenshotList
31
+ });
32
+ const external_node_path_namespaceObject = require("node:path");
33
+ const external_screenshot_file_js_namespaceObject = require("./screenshot-file.js");
34
+ function isRecord(value) {
35
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
36
+ }
37
+ function isCliVerboseScreenshotRefLike(value) {
38
+ return isRecord(value) && 'midscene_screenshot_ref' === value.type;
39
+ }
40
+ function toSerializableScreenshot(value) {
41
+ if (!value || 'object' != typeof value) return null;
42
+ const maybeSerializable = value;
43
+ if ('function' == typeof maybeSerializable.toSerializable) try {
44
+ const serialized = maybeSerializable.toSerializable();
45
+ return isCliVerboseScreenshotRefLike(serialized) ? serialized : null;
46
+ } catch {
47
+ return null;
48
+ }
49
+ return isCliVerboseScreenshotRefLike(value) ? value : null;
50
+ }
51
+ function getStringProperty(value, key) {
52
+ if (!isRecord(value)) return;
53
+ try {
54
+ const property = value[key];
55
+ return 'string' == typeof property && property.length > 0 ? property : void 0;
56
+ } catch {
57
+ return;
58
+ }
59
+ }
60
+ function screenshotRawBase64(value) {
61
+ const rawBase64 = getStringProperty(value, 'rawBase64');
62
+ if (rawBase64) return rawBase64;
63
+ const base64 = getStringProperty(value, 'base64');
64
+ const match = base64?.match(/^data:image\/(?:png|jpeg|jpg);base64,(.+)$/);
65
+ return match?.[1];
66
+ }
67
+ function inlineScreenshotCacheKey(rawBase64, serialized, directoryPath, directoryName, extension) {
68
+ return JSON.stringify([
69
+ serialized.id,
70
+ serialized.mimeType,
71
+ directoryPath,
72
+ directoryName,
73
+ extension,
74
+ rawBase64
75
+ ]);
76
+ }
77
+ function exportInlineScreenshotForVerbose(value, serialized, options) {
78
+ if ('string' == typeof serialized.path) return serialized.path;
79
+ const exportMode = options.exportMode ?? 'tmp';
80
+ if ('none' === exportMode) return;
81
+ const rawBase64 = screenshotRawBase64(value);
82
+ if (!rawBase64) return;
83
+ const directoryPath = 'report' === exportMode && 'string' == typeof options.reportFile && options.reportFile.length > 0 ? (0, external_node_path_namespaceObject.join)((0, external_node_path_namespaceObject.dirname)(options.reportFile), 'screenshots') : void 0;
84
+ const directoryName = directoryPath ? void 0 : 'midscene-cli-screenshots';
85
+ const extension = getStringProperty(value, 'extension');
86
+ const cacheKey = inlineScreenshotCacheKey(rawBase64, serialized, directoryPath, directoryName, extension);
87
+ const cachedPath = options.cache?.get(cacheKey);
88
+ if (cachedPath) return cachedPath;
89
+ try {
90
+ const path = (0, external_screenshot_file_js_namespaceObject.writeCliScreenshotFile)(rawBase64, {
91
+ id: serialized.id,
92
+ mimeType: serialized.mimeType,
93
+ extension,
94
+ ...directoryPath ? {
95
+ directoryPath
96
+ } : {
97
+ directoryName
98
+ },
99
+ overwrite: false
100
+ });
101
+ options.cache?.set(cacheKey, path);
102
+ return path;
103
+ } catch {
104
+ return;
105
+ }
106
+ }
107
+ function collectScreenshotRefs(value, options = {}) {
108
+ const screenshots = [];
109
+ const visit = (candidate, timing)=>{
110
+ if (Array.isArray(candidate)) {
111
+ for (const item of candidate)visit(item, timing);
112
+ return;
113
+ }
114
+ const serialized = toSerializableScreenshot(candidate);
115
+ if (serialized?.type === 'midscene_screenshot_ref') {
116
+ const screenshot = {
117
+ id: serialized.id,
118
+ storage: serialized.storage
119
+ };
120
+ const exportedPath = exportInlineScreenshotForVerbose(candidate, serialized, options);
121
+ if (exportedPath) {
122
+ screenshot.path = exportedPath;
123
+ screenshot.file = (0, external_node_path_namespaceObject.basename)(exportedPath);
124
+ }
125
+ if ('string' == typeof timing) screenshot.timing = timing;
126
+ screenshots.push(screenshot);
127
+ return;
128
+ }
129
+ if (!isRecord(candidate)) return;
130
+ const screenshotRecord = candidate.screenshot;
131
+ if (screenshotRecord) visit(screenshotRecord, candidate.timing);
132
+ if (candidate.recorder) visit(candidate.recorder);
133
+ if (isRecord(candidate.uiContext)) visit(candidate.uiContext.screenshot);
134
+ };
135
+ visit(value);
136
+ return screenshots;
137
+ }
138
+ function pathForReportScreenshot(path, reportFile) {
139
+ const resolvedPath = 'string' == typeof reportFile && reportFile.length > 0 && (path.startsWith('./') || path.startsWith('../')) ? (0, external_node_path_namespaceObject.join)((0, external_node_path_namespaceObject.dirname)(reportFile), path) : path;
140
+ if (!(0, external_node_path_namespaceObject.isAbsolute)(resolvedPath)) return resolvedPath;
141
+ const relativePath = (0, external_node_path_namespaceObject.relative)(process.cwd(), resolvedPath);
142
+ if (relativePath && !relativePath.startsWith('..') && !(0, external_node_path_namespaceObject.isAbsolute)(relativePath)) return relativePath;
143
+ return resolvedPath;
144
+ }
145
+ function latestScreenshotPathForAiAct(value, options = {}) {
146
+ const screenshot = collectScreenshotRefs(value, {
147
+ ...options,
148
+ exportMode: options.exportMode ?? 'report'
149
+ }).slice().reverse().find((item)=>'string' == typeof item.path && item.path.length > 0);
150
+ const path = 'string' == typeof screenshot?.path ? screenshot.path : '';
151
+ return path ? pathForReportScreenshot(path, options.reportFile) : '';
152
+ }
153
+ function renderScreenshotList(screenshots) {
154
+ if (!Array.isArray(screenshots) || 0 === screenshots.length) return '';
155
+ return screenshots.map((item)=>{
156
+ if (!isRecord(item)) return '';
157
+ const path = 'string' == typeof item.path ? item.path : 'string' == typeof item.file ? item.file : 'string' == typeof item.id ? item.id : '';
158
+ const timing = 'string' == typeof item.timing ? item.timing : '';
159
+ return [
160
+ timing,
161
+ path
162
+ ].filter(Boolean).join(' ');
163
+ }).filter(Boolean).join(', ');
164
+ }
165
+ exports.collectScreenshotRefs = __webpack_exports__.collectScreenshotRefs;
166
+ exports.latestScreenshotPathForAiAct = __webpack_exports__.latestScreenshotPathForAiAct;
167
+ exports.pathForReportScreenshot = __webpack_exports__.pathForReportScreenshot;
168
+ exports.renderScreenshotList = __webpack_exports__.renderScreenshotList;
169
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
170
+ "collectScreenshotRefs",
171
+ "latestScreenshotPathForAiAct",
172
+ "pathForReportScreenshot",
173
+ "renderScreenshotList"
174
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
175
+ Object.defineProperty(exports, '__esModule', {
176
+ value: true
177
+ });