@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,465 @@
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
+ getCliVerboseContext: ()=>getCliVerboseContext,
28
+ attachCliVerboseDumpListener: ()=>attachCliVerboseDumpListener,
29
+ compactCliVerboseValue: ()=>compactCliVerboseValue,
30
+ cliVerboseFlag: ()=>cliVerboseFlag,
31
+ emitCliVerboseEvent: ()=>emitCliVerboseEvent,
32
+ cliVerboseErrorMessage: ()=>errorMessageOf,
33
+ compactCliVerboseArgs: ()=>compactCliVerboseArgs,
34
+ stripVerboseFlag: ()=>stripVerboseFlag,
35
+ isCliVerboseEnabled: ()=>isCliVerboseEnabled,
36
+ withCliVerboseContext: ()=>withCliVerboseContext
37
+ });
38
+ const external_verbose_ai_act_js_namespaceObject = require("./verbose-ai-act.js");
39
+ const external_verbose_screenshot_js_namespaceObject = require("./verbose-screenshot.js");
40
+ const cliVerboseFlag = 'verbose';
41
+ const progressRenderers = {
42
+ [external_verbose_ai_act_js_namespaceObject.cliAiActProgressScope]: external_verbose_ai_act_js_namespaceObject.aiActCliProgressRenderer
43
+ };
44
+ function progressRendererForEvent(event) {
45
+ if ('object' != typeof event || null === event) return;
46
+ const scope = event.scope;
47
+ if ('string' != typeof scope) return;
48
+ const renderer = progressRenderers[scope];
49
+ return renderer ? {
50
+ scope,
51
+ renderer
52
+ } : void 0;
53
+ }
54
+ const progressEventName = 'midscene_progress';
55
+ const cliVerboseContextKey = '__midscene_cli_verbose_context__';
56
+ const getGlobalContext = ()=>{
57
+ const globalWithContext = globalThis;
58
+ if (!globalWithContext[cliVerboseContextKey]) globalWithContext[cliVerboseContextKey] = {
59
+ current: {
60
+ enabled: false
61
+ }
62
+ };
63
+ return globalWithContext[cliVerboseContextKey];
64
+ };
65
+ function parseVerboseFormat(rawFormat) {
66
+ if ('text' === rawFormat || 'jsonl' === rawFormat) return rawFormat;
67
+ throw new Error(`Unsupported --${cliVerboseFlag} format "${rawFormat}". Use "--${cliVerboseFlag}" or "--${cliVerboseFlag}=jsonl".`);
68
+ }
69
+ function stripVerboseFlag(argv) {
70
+ const rawArgs = [];
71
+ let verbose = false;
72
+ let format = 'text';
73
+ for (const arg of argv){
74
+ if (arg === `--${cliVerboseFlag}`) {
75
+ verbose = true;
76
+ continue;
77
+ }
78
+ if (arg.startsWith(`--${cliVerboseFlag}=`)) {
79
+ verbose = true;
80
+ format = parseVerboseFormat(arg.slice(`--${cliVerboseFlag}=`.length));
81
+ continue;
82
+ }
83
+ rawArgs.push(arg);
84
+ }
85
+ return {
86
+ rawArgs,
87
+ verbose,
88
+ format
89
+ };
90
+ }
91
+ async function withCliVerboseContext(context, fn) {
92
+ const globalContext = getGlobalContext();
93
+ const previous = globalContext.current;
94
+ globalContext.current = {
95
+ ...context,
96
+ renderedLineKeys: context.renderedLineKeys ?? new Set()
97
+ };
98
+ try {
99
+ return await fn();
100
+ } finally{
101
+ globalContext.current = previous;
102
+ }
103
+ }
104
+ function getCliVerboseContext() {
105
+ return getGlobalContext().current;
106
+ }
107
+ function isCliVerboseEnabled() {
108
+ return getCliVerboseContext().enabled;
109
+ }
110
+ function emitCliVerboseEvent(event) {
111
+ const context = getCliVerboseContext();
112
+ if (!context.enabled) return;
113
+ const payload = {
114
+ type: progressEventName,
115
+ timestamp: new Date().toISOString(),
116
+ scriptName: context.scriptName,
117
+ command: context.commandName,
118
+ ...event
119
+ };
120
+ if ('jsonl' === context.format) return void console.log(JSON.stringify(payload));
121
+ const text = renderCliVerboseEventText(payload, context);
122
+ if (text) console.log(text);
123
+ }
124
+ function errorMessageOf(error) {
125
+ return error instanceof Error ? error.message : String(error);
126
+ }
127
+ function isRecord(value) {
128
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
129
+ }
130
+ function compactText(value) {
131
+ if (null == value || '' === value) return '';
132
+ if ('string' == typeof value) return value.length > 180 ? `${value.slice(0, 177)}...` : value;
133
+ if ('number' == typeof value || 'boolean' == typeof value) return String(value);
134
+ try {
135
+ const json = JSON.stringify(value);
136
+ return json.length > 180 ? `${json.slice(0, 177)}...` : json;
137
+ } catch {
138
+ return String(value);
139
+ }
140
+ }
141
+ function compactPrimitiveCliVerboseValue(value) {
142
+ if (null == value) return {
143
+ handled: true,
144
+ value
145
+ };
146
+ if ('string' == typeof value) return {
147
+ handled: true,
148
+ value: value.length > 180 ? `${value.slice(0, 177)}...` : value
149
+ };
150
+ if ('number' == typeof value || 'boolean' == typeof value) return {
151
+ handled: true,
152
+ value
153
+ };
154
+ if ('object' != typeof value) return {
155
+ handled: true,
156
+ value: String(value)
157
+ };
158
+ return {
159
+ handled: false
160
+ };
161
+ }
162
+ function compactStructuredCliVerboseValue(value) {
163
+ const primitive = compactPrimitiveCliVerboseValue(value);
164
+ if (primitive.handled) return primitive.value;
165
+ if (Array.isArray(value)) return value.slice(0, 5).map(compactStructuredCliVerboseValue);
166
+ if (!isRecord(value)) return String(value);
167
+ const entries = Object.entries(value).slice(0, 6);
168
+ return Object.fromEntries(entries.map(([key, entryValue])=>[
169
+ key,
170
+ compactStructuredCliVerboseValue(entryValue)
171
+ ]));
172
+ }
173
+ function compactCliVerboseValue(value) {
174
+ const primitive = compactPrimitiveCliVerboseValue(value);
175
+ if (primitive.handled) return primitive.value;
176
+ if (Array.isArray(value)) return value.slice(0, 5).map(compactCliVerboseValue);
177
+ if (isRecord(value) && 'string' == typeof value.prompt) return compactCliVerboseValue(value.prompt);
178
+ if (!isRecord(value)) return String(value);
179
+ const entries = Object.entries(value).slice(0, 6);
180
+ return Object.fromEntries(entries.map(([key, entryValue])=>[
181
+ key,
182
+ compactCliVerboseValue(entryValue)
183
+ ]));
184
+ }
185
+ function compactCliVerboseArgs(args) {
186
+ return Object.fromEntries(Object.entries(args).slice(0, 8).map(([key, value])=>[
187
+ key,
188
+ compactStructuredCliVerboseValue(value)
189
+ ]));
190
+ }
191
+ function summarizeParam(param) {
192
+ if (!param || 'object' != typeof param) return compactCliVerboseValue(param);
193
+ const record = param;
194
+ if ('string' == typeof record.prompt) return compactCliVerboseValue(record.prompt);
195
+ if (record.locate && 'object' == typeof record.locate && null !== record.locate) {
196
+ const locate = record.locate;
197
+ return {
198
+ locate: compactCliVerboseValue(locate.prompt),
199
+ ...Object.fromEntries(Object.entries(record).filter(([key])=>'locate' !== key).slice(0, 4).map(([key, value])=>[
200
+ key,
201
+ compactCliVerboseValue(value)
202
+ ]))
203
+ };
204
+ }
205
+ return compactCliVerboseValue(record);
206
+ }
207
+ function summarizeUserInstruction(value) {
208
+ if ('string' == typeof value) return compactText(value);
209
+ if (isRecord(value) && 'string' == typeof value.prompt) return compactText(value.prompt);
210
+ return compactText(value);
211
+ }
212
+ function summarizeTaskParamText(task) {
213
+ if (!isRecord(task.param)) return compactText(summarizeParam(task.param));
214
+ if ('Planning' === task.type && 'Locate' !== task.subType) {
215
+ if (task.param.userInstructionDisplay) return summarizeUserInstruction(task.param.userInstructionDisplay);
216
+ if (task.param.userInstruction) return summarizeUserInstruction(task.param.userInstruction);
217
+ }
218
+ if (task.param.dataDemand) return compactText(summarizeParam(task.param.dataDemand));
219
+ if (task.param.assertion) return compactText(summarizeParam(task.param.assertion));
220
+ return compactText(summarizeParam(task.param));
221
+ }
222
+ function summarizeSubGoals(value) {
223
+ if (!Array.isArray(value) || 0 === value.length) return '';
224
+ const goals = value.slice(0, 6).map((goal)=>{
225
+ if (!isRecord(goal)) return '';
226
+ const index = 'number' == typeof goal.index ? `${goal.index}. ` : '';
227
+ const status = 'string' == typeof goal.status ? `[${goal.status}] ` : '';
228
+ const description = 'string' == typeof goal.description ? goal.description : '';
229
+ return `${index}${status}${description}`.trim();
230
+ }).filter(Boolean);
231
+ return goals.length > 0 ? `sub-goals: ${goals.join('; ')}` : '';
232
+ }
233
+ function summarizeActions(value) {
234
+ if (!Array.isArray(value) || 0 === value.length) return '';
235
+ const actions = value.slice(0, 5).map((action)=>{
236
+ if (!isRecord(action)) return '';
237
+ const type = 'string' == typeof action.type ? action.type : 'Action';
238
+ const param = compactText(summarizeParam(action.param));
239
+ return param ? `${type}: ${param}` : type;
240
+ }).filter(Boolean);
241
+ return actions.length > 0 ? `actions: ${actions.join('; ')}` : '';
242
+ }
243
+ function summarizeTaskOutputText(task) {
244
+ if (!isRecord(task.output)) return compactText(task.output);
245
+ return summarizeSubGoals(task.output.updateSubGoals) || compactText(task.output.log) || compactText(task.output.output) || summarizeActions(task.output.actions);
246
+ }
247
+ function summarizeTaskText(task) {
248
+ const parts = [
249
+ task.type,
250
+ task.subType
251
+ ].filter((part)=>'string' == typeof part && part.length > 0);
252
+ const label = parts.length > 0 ? parts.join('/') : 'Task';
253
+ const status = 'string' == typeof task.status && task.status.length > 0 ? task.status : 'unknown';
254
+ const param = summarizeTaskParamText(task);
255
+ const output = summarizeTaskOutputText(task);
256
+ const thought = compactText(task.thought);
257
+ const detail = output || thought || param;
258
+ return detail ? `${label} ${status}: ${detail}` : `${label} ${status}`;
259
+ }
260
+ function isCliVerboseExecutionDumpLike(value) {
261
+ return isRecord(value) && Array.isArray(value.tasks);
262
+ }
263
+ function summarizeDumpUpdate(executionDump, screenshotOptions = {}) {
264
+ if (!isCliVerboseExecutionDumpLike(executionDump)) return;
265
+ const tasks = executionDump.tasks;
266
+ const latestTask = tasks[tasks.length - 1];
267
+ const steps = tasks.map((task, index)=>({
268
+ id: task.taskId,
269
+ index: index + 1,
270
+ total: tasks.length,
271
+ type: task.type,
272
+ subType: task.subType,
273
+ status: task.status,
274
+ param: summarizeParam(task.param),
275
+ message: summarizeTaskText(task),
276
+ error: task.errorMessage,
277
+ durationMs: task.timing?.cost,
278
+ screenshots: (0, external_verbose_screenshot_js_namespaceObject.collectScreenshotRefs)(task, screenshotOptions).slice(-3)
279
+ }));
280
+ return {
281
+ execution: {
282
+ id: executionDump.id,
283
+ name: executionDump.name,
284
+ description: compactCliVerboseValue(executionDump.description),
285
+ taskCount: tasks.length
286
+ },
287
+ steps,
288
+ task: latestTask ? {
289
+ id: latestTask.taskId,
290
+ index: tasks.length,
291
+ total: tasks.length,
292
+ type: latestTask.type,
293
+ subType: latestTask.subType,
294
+ status: latestTask.status,
295
+ param: summarizeParam(latestTask.param),
296
+ message: summarizeTaskText(latestTask),
297
+ error: latestTask.errorMessage,
298
+ durationMs: latestTask.timing?.cost
299
+ } : void 0,
300
+ screenshots: (0, external_verbose_screenshot_js_namespaceObject.collectScreenshotRefs)(tasks, screenshotOptions).slice(-5)
301
+ };
302
+ }
303
+ function stringifyArgs(args) {
304
+ if (!isRecord(args) || 0 === Object.keys(args).length) return '';
305
+ return Object.entries(args).map(([key, value])=>`${key}=${compactText(value)}`).join(', ');
306
+ }
307
+ function isActVerboseEvent(command, tool) {
308
+ return 'act' === command || 'act' === tool;
309
+ }
310
+ function renderLinesOnce(context, lines) {
311
+ if (0 === lines.length) return;
312
+ if (!context.renderedLineKeys) context.renderedLineKeys = new Set();
313
+ const renderedLineKeys = context.renderedLineKeys;
314
+ const pendingLines = lines.filter((line)=>{
315
+ if (renderedLineKeys.has(line.key)) return false;
316
+ renderedLineKeys.add(line.key);
317
+ return true;
318
+ });
319
+ return pendingLines.length > 0 ? pendingLines.map((line)=>line.text).join('\n') : void 0;
320
+ }
321
+ function renderCliVerboseEventText(event, context) {
322
+ const command = 'string' == typeof event.command ? event.command : 'command';
323
+ const tool = 'string' == typeof event.tool ? event.tool : void 0;
324
+ switch(event.event){
325
+ case 'agent_progress':
326
+ {
327
+ const scope = 'string' == typeof event.scope ? event.scope : void 0;
328
+ const renderer = scope ? progressRenderers[scope] : void 0;
329
+ const progressEvent = isRecord(event.progress) ? event.progress : void 0;
330
+ if (!renderer || !progressEvent) return;
331
+ return renderLinesOnce(context, renderer.buildLines(progressEvent));
332
+ }
333
+ case 'command_start':
334
+ {
335
+ if (isActVerboseEvent(command, tool)) return;
336
+ const args = stringifyArgs(event.args);
337
+ return args ? `[Midscene] ${command} started (${args})` : `[Midscene] ${command} started`;
338
+ }
339
+ case 'agent_ready':
340
+ if (isActVerboseEvent(command, tool)) return;
341
+ return `[Midscene] ${tool ?? command} ready`;
342
+ case 'recording_ready':
343
+ return '[Midscene] Recording. Press Ctrl+C to stop and save.';
344
+ case 'recording_stopping':
345
+ if ('watchdog' === event.reason) return '[Midscene] Recording watchdog reached; finalizing and saving.';
346
+ if ('sigterm' === event.reason) return '[Midscene] SIGTERM received; finalizing and saving.';
347
+ return 'sighup' === event.reason ? '[Midscene] SIGHUP received; finalizing and saving.' : '[Midscene] Ctrl+C received; finalizing and saving. Press Ctrl+C again to force exit.';
348
+ case 'dump_update':
349
+ {
350
+ if (isActVerboseEvent(command, tool)) return;
351
+ const task = isRecord(event.task) ? event.task : void 0;
352
+ const steps = Array.isArray(event.steps) ? event.steps.filter(isRecord) : [];
353
+ const execution = isRecord(event.execution) ? event.execution : void 0;
354
+ const executionName = 'string' == typeof execution?.name ? execution.name : 'execution';
355
+ const lines = steps.length > 0 ? [
356
+ `[Midscene] Progress: ${executionName} (${steps.length} steps)`,
357
+ ...steps.map((step)=>{
358
+ const index = 'number' == typeof step.index && 'number' == typeof step.total ? `Step ${step.index}/${step.total}` : 'Step';
359
+ const message = 'string' == typeof step.message ? step.message : 'string' == typeof step.status ? step.status : 'updated';
360
+ return `[Midscene] ${index}: ${message}`;
361
+ })
362
+ ] : [
363
+ `[Midscene] Step: ${'string' == typeof task?.message ? task.message : 'string' == typeof task?.status ? task.status : 'updated'}`
364
+ ];
365
+ const screenshots = (0, external_verbose_screenshot_js_namespaceObject.renderScreenshotList)(event.screenshots);
366
+ if (screenshots) lines.push(`[Midscene] Screenshot: ${screenshots}`);
367
+ if ('string' == typeof event.report && event.report.length > 0) lines.push(`[Midscene] Report: ${event.report}`);
368
+ return lines.join('\n');
369
+ }
370
+ case 'artifact':
371
+ {
372
+ if (isActVerboseEvent(command, tool)) return;
373
+ const kind = 'string' == typeof event.kind ? event.kind : 'artifact';
374
+ const path = 'string' == typeof event.path ? event.path : void 0;
375
+ return path ? `[Midscene] ${kind} saved: ${path}` : `[Midscene] ${kind} ready`;
376
+ }
377
+ case 'command_done':
378
+ {
379
+ if (isActVerboseEvent(command, tool)) {
380
+ if ('error' === event.status) {
381
+ const error = 'string' == typeof event.error && event.error.length > 0 ? `: ${event.error}` : '';
382
+ return renderLinesOnce(context, [
383
+ {
384
+ key: `aiAct:command_failed:${event.error ?? 'unknown'}`,
385
+ text: `[Midscene][aiAct] Failed${error}`
386
+ }
387
+ ]);
388
+ }
389
+ return;
390
+ }
391
+ const status = 'error' === event.status ? 'failed' : 'finished';
392
+ const duration = 'number' == typeof event.durationMs ? ` in ${event.durationMs}ms` : '';
393
+ const error = 'error' === event.status && 'string' == typeof event.error ? `: ${event.error}` : '';
394
+ return `[Midscene] ${command} ${status}${duration}${error}`;
395
+ }
396
+ default:
397
+ return;
398
+ }
399
+ }
400
+ function attachCliVerboseDumpListener(agent, options) {
401
+ if (!isCliVerboseEnabled()) return ()=>{};
402
+ const isActTool = options?.toolName === 'act';
403
+ const screenshotExportCache = new Map();
404
+ if (isActTool && 'function' == typeof agent.addProgressListener) return agent.addProgressListener((event)=>{
405
+ const match = progressRendererForEvent(event);
406
+ if (!match) return;
407
+ const context = getCliVerboseContext();
408
+ const isTextMode = 'jsonl' !== context.format;
409
+ const progress = match.renderer.normalize(event, {
410
+ reportFile: agent.reportFile,
411
+ exportMode: isTextMode ? 'report' : 'none',
412
+ cache: screenshotExportCache
413
+ });
414
+ if (!progress) return;
415
+ emitCliVerboseEvent({
416
+ event: 'agent_progress',
417
+ tool: options?.toolName,
418
+ scope: match.scope,
419
+ progress
420
+ });
421
+ });
422
+ if (isActTool) return ()=>{};
423
+ if ('function' != typeof agent.addDumpUpdateListener) return ()=>{};
424
+ return agent.addDumpUpdateListener((_dump, executionDump)=>{
425
+ const context = getCliVerboseContext();
426
+ const isTextMode = 'jsonl' !== context.format;
427
+ const summaryExportMode = isTextMode && !isActTool ? 'tmp' : 'none';
428
+ const summary = summarizeDumpUpdate(executionDump, {
429
+ exportMode: summaryExportMode,
430
+ cache: screenshotExportCache
431
+ });
432
+ if (!summary) return;
433
+ emitCliVerboseEvent({
434
+ event: 'dump_update',
435
+ tool: options?.toolName,
436
+ report: agent.reportFile || void 0,
437
+ ...summary
438
+ });
439
+ });
440
+ }
441
+ exports.attachCliVerboseDumpListener = __webpack_exports__.attachCliVerboseDumpListener;
442
+ exports.cliVerboseErrorMessage = __webpack_exports__.cliVerboseErrorMessage;
443
+ exports.cliVerboseFlag = __webpack_exports__.cliVerboseFlag;
444
+ exports.compactCliVerboseArgs = __webpack_exports__.compactCliVerboseArgs;
445
+ exports.compactCliVerboseValue = __webpack_exports__.compactCliVerboseValue;
446
+ exports.emitCliVerboseEvent = __webpack_exports__.emitCliVerboseEvent;
447
+ exports.getCliVerboseContext = __webpack_exports__.getCliVerboseContext;
448
+ exports.isCliVerboseEnabled = __webpack_exports__.isCliVerboseEnabled;
449
+ exports.stripVerboseFlag = __webpack_exports__.stripVerboseFlag;
450
+ exports.withCliVerboseContext = __webpack_exports__.withCliVerboseContext;
451
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
452
+ "attachCliVerboseDumpListener",
453
+ "cliVerboseErrorMessage",
454
+ "cliVerboseFlag",
455
+ "compactCliVerboseArgs",
456
+ "compactCliVerboseValue",
457
+ "emitCliVerboseEvent",
458
+ "getCliVerboseContext",
459
+ "isCliVerboseEnabled",
460
+ "stripVerboseFlag",
461
+ "withCliVerboseContext"
462
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
463
+ Object.defineProperty(exports, '__esModule', {
464
+ value: true
465
+ });
@@ -37,7 +37,7 @@ const external_utils_js_namespaceObject = require("../utils.js");
37
37
  const external_helper_js_namespaceObject = require("./helper.js");
38
38
  const external_init_debug_js_namespaceObject = require("./init-debug.js");
39
39
  const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
40
- const getCurrentVersion = ()=>"8.0.3";
40
+ const getCurrentVersion = ()=>"8.0.5";
41
41
  const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
42
42
  const KEYS_MAP = {
43
43
  insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,