@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,297 @@
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
+ cloneUIObservationRecord: ()=>cloneUIObservationRecord,
28
+ writeUIObservationRecord: ()=>writeUIObservationRecord,
29
+ UIObservationRecordWriter: ()=>UIObservationRecordWriter,
30
+ readUIObservationRecord: ()=>readUIObservationRecord,
31
+ parseUIObservationRecord: ()=>parseUIObservationRecord,
32
+ defaultObservationRecordPath: ()=>defaultObservationRecordPath
33
+ });
34
+ const external_node_crypto_namespaceObject = require("node:crypto");
35
+ const external_node_fs_namespaceObject = require("node:fs");
36
+ const external_node_path_namespaceObject = require("node:path");
37
+ const external_zod_namespaceObject = require("zod");
38
+ const external_common_js_namespaceObject = require("../common.js");
39
+ function _define_property(obj, key, value) {
40
+ if (key in obj) Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ else obj[key] = value;
47
+ return obj;
48
+ }
49
+ const observationRecordSchema = external_zod_namespaceObject.z.object({
50
+ type: external_zod_namespaceObject.z.literal('midscene_ui_observation'),
51
+ version: external_zod_namespaceObject.z.literal(1),
52
+ startedAt: external_zod_namespaceObject.z.number().finite().nonnegative(),
53
+ endedAt: external_zod_namespaceObject.z.number().finite().nonnegative(),
54
+ frames: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.object({
55
+ path: external_zod_namespaceObject.z.string().min(1),
56
+ mimeType: external_zod_namespaceObject.z["enum"]([
57
+ 'image/png',
58
+ 'image/jpeg'
59
+ ]),
60
+ capturedAt: external_zod_namespaceObject.z.number().finite().nonnegative()
61
+ }).strict()).min(1),
62
+ shotSize: external_zod_namespaceObject.z.object({
63
+ width: external_zod_namespaceObject.z.number().finite().positive(),
64
+ height: external_zod_namespaceObject.z.number().finite().positive()
65
+ }).strict(),
66
+ shrunkShotToLogicalRatio: external_zod_namespaceObject.z.number().finite().positive()
67
+ }).strict().refine((record)=>record.endedAt >= record.startedAt, {
68
+ path: [
69
+ 'endedAt'
70
+ ],
71
+ message: 'must be greater than or equal to startedAt'
72
+ });
73
+ function defaultObservationRecordPath() {
74
+ const suffix = Math.random().toString(36).slice(2, 10);
75
+ return (0, external_node_path_namespaceObject.resolve)((0, external_common_js_namespaceObject.getMidsceneRunSubDir)('output'), `observation-${Date.now()}-${suffix}.json`);
76
+ }
77
+ function parseUIObservationRecord(input) {
78
+ const result = observationRecordSchema.safeParse(input);
79
+ if (!result.success) {
80
+ const issue = result.error.issues[0];
81
+ const location = issue.path.length > 0 ? issue.path.join('.') : 'record';
82
+ throw new Error(`Invalid UI observation record at ${location}: ${issue.message}`);
83
+ }
84
+ return result.data;
85
+ }
86
+ function cloneUIObservationRecord(record) {
87
+ return {
88
+ ...record,
89
+ frames: record.frames.map((frame)=>({
90
+ ...frame
91
+ })),
92
+ shotSize: {
93
+ ...record.shotSize
94
+ }
95
+ };
96
+ }
97
+ function readUIObservationRecord(filePath) {
98
+ const resolvedPath = (0, external_node_path_namespaceObject.resolve)(filePath);
99
+ let parsed;
100
+ try {
101
+ parsed = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(resolvedPath, 'utf8'));
102
+ } catch (error) {
103
+ const message = error instanceof Error ? error.message : String(error);
104
+ throw new Error(`Failed to read UI observation record ${resolvedPath}: ${message}`);
105
+ }
106
+ const record = parseUIObservationRecord(parsed);
107
+ const manifestDirectory = (0, external_node_path_namespaceObject.dirname)(resolvedPath);
108
+ return {
109
+ ...record,
110
+ frames: record.frames.map((frame, index)=>{
111
+ if ((0, external_node_path_namespaceObject.isAbsolute)(frame.path)) throw new Error(`Invalid UI observation record at frames.${index}.path: expected a relative image path`);
112
+ const imagePath = (0, external_node_path_namespaceObject.resolve)(manifestDirectory, frame.path);
113
+ const relativeToManifest = (0, external_node_path_namespaceObject.relative)(manifestDirectory, imagePath);
114
+ if ('..' === relativeToManifest || relativeToManifest.startsWith(`..${'win32' === process.platform ? '\\' : '/'}`) || (0, external_node_path_namespaceObject.isAbsolute)(relativeToManifest)) throw new Error(`Invalid UI observation record at frames.${index}.path: image path escapes the manifest directory`);
115
+ try {
116
+ if (!(0, external_node_fs_namespaceObject.statSync)(imagePath).isFile()) throw new Error('path is not a file');
117
+ } catch (error) {
118
+ const message = error instanceof Error ? error.message : String(error);
119
+ throw new Error(`Invalid UI observation record at frames.${index}.path: cannot read image ${imagePath}: ${message}`);
120
+ }
121
+ return {
122
+ ...frame,
123
+ path: imagePath
124
+ };
125
+ })
126
+ };
127
+ }
128
+ class UIObservationRecordWriter {
129
+ persistFrame(dataUrl, capturedAt) {
130
+ if (this.disposed) throw new Error('UI observation record writer has been disposed');
131
+ if (this.finalized) throw new Error('UI observation record has already been finalized');
132
+ const match = /^data:image\/(png|jpe?g);base64,([\s\S]+)$/i.exec(dataUrl);
133
+ if (!match) throw new Error('UI observation frame must be a PNG or JPEG data URL');
134
+ const format = 'png' === match[1].toLowerCase() ? 'png' : 'jpeg';
135
+ const mimeType = 'png' === format ? 'image/png' : 'image/jpeg';
136
+ const bytes = Buffer.from(match[2], 'base64');
137
+ if (0 === bytes.length) throw new Error('UI observation frame contains no image data');
138
+ const digest = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(bytes).digest('hex');
139
+ const fileName = `${digest}.${format}`;
140
+ (0, external_node_fs_namespaceObject.mkdirSync)(this.temporaryFramesDirectory, {
141
+ recursive: true
142
+ });
143
+ const temporaryPath = (0, external_node_path_namespaceObject.join)(this.temporaryFramesDirectory, fileName);
144
+ if (!(0, external_node_fs_namespaceObject.existsSync)(temporaryPath)) (0, external_node_fs_namespaceObject.writeFileSync)(temporaryPath, bytes);
145
+ return {
146
+ path: `${(0, external_node_path_namespaceObject.basename)(this.framesDirectory)}/${fileName}`,
147
+ mimeType,
148
+ capturedAt
149
+ };
150
+ }
151
+ resolveFramePath(frame) {
152
+ if (this.disposed) throw new Error('UI observation record writer has been disposed');
153
+ const directory = this.finalized ? this.framesDirectory : this.temporaryFramesDirectory;
154
+ return (0, external_node_path_namespaceObject.join)(directory, (0, external_node_path_namespaceObject.basename)(frame.path));
155
+ }
156
+ pruneFrames(frames) {
157
+ if (this.disposed) throw new Error('UI observation record writer has been disposed');
158
+ if (this.finalized || !(0, external_node_fs_namespaceObject.existsSync)(this.temporaryFramesDirectory)) return;
159
+ const retainedFiles = new Set(frames.map((frame)=>(0, external_node_path_namespaceObject.basename)(frame.path)));
160
+ for (const fileName of (0, external_node_fs_namespaceObject.readdirSync)(this.temporaryFramesDirectory))if (!retainedFiles.has(fileName)) (0, external_node_fs_namespaceObject.rmSync)((0, external_node_path_namespaceObject.join)(this.temporaryFramesDirectory, fileName), {
161
+ force: true
162
+ });
163
+ }
164
+ finalize(frames, metadata) {
165
+ if (this.disposed) throw new Error('UI observation record writer has been disposed');
166
+ if (this.finalizedRecord) return this.finalizedRecord;
167
+ const record = parseUIObservationRecord({
168
+ type: 'midscene_ui_observation',
169
+ version: 1,
170
+ frames,
171
+ ...metadata
172
+ });
173
+ this.pruneFrames(record.frames);
174
+ (0, external_node_fs_namespaceObject.mkdirSync)((0, external_node_path_namespaceObject.dirname)(this.outputPath), {
175
+ recursive: true
176
+ });
177
+ (0, external_node_fs_namespaceObject.mkdirSync)(this.temporaryFramesDirectory, {
178
+ recursive: true
179
+ });
180
+ (0, external_node_fs_namespaceObject.rmSync)(this.framesDirectory, {
181
+ recursive: true,
182
+ force: true
183
+ });
184
+ (0, external_node_fs_namespaceObject.renameSync)(this.temporaryFramesDirectory, this.framesDirectory);
185
+ this.finalized = true;
186
+ this.finalizedRecord = {
187
+ ...record,
188
+ frames: record.frames.map((frame)=>({
189
+ ...frame,
190
+ path: (0, external_node_path_namespaceObject.resolve)((0, external_node_path_namespaceObject.dirname)(this.outputPath), frame.path)
191
+ }))
192
+ };
193
+ return this.finalizedRecord;
194
+ }
195
+ dispose() {
196
+ if (this.disposed) return;
197
+ (0, external_node_fs_namespaceObject.rmSync)(this.temporaryFramesDirectory, {
198
+ recursive: true,
199
+ force: true
200
+ });
201
+ (0, external_node_fs_namespaceObject.rmSync)(this.framesDirectory, {
202
+ recursive: true,
203
+ force: true
204
+ });
205
+ this.disposed = true;
206
+ this.finalizedRecord = null;
207
+ }
208
+ constructor(filePath){
209
+ _define_property(this, "outputPath", void 0);
210
+ _define_property(this, "framesDirectory", void 0);
211
+ _define_property(this, "temporaryFramesDirectory", void 0);
212
+ _define_property(this, "finalized", false);
213
+ _define_property(this, "disposed", false);
214
+ _define_property(this, "finalizedRecord", null);
215
+ this.outputPath = filePath ? (0, external_node_path_namespaceObject.resolve)(filePath) : defaultObservationRecordPath();
216
+ const extension = (0, external_node_path_namespaceObject.extname)(this.outputPath);
217
+ const stem = (0, external_node_path_namespaceObject.basename)(this.outputPath, extension);
218
+ this.framesDirectory = (0, external_node_path_namespaceObject.join)((0, external_node_path_namespaceObject.dirname)(this.outputPath), `${stem}.frames`);
219
+ this.temporaryFramesDirectory = `${this.framesDirectory}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
220
+ }
221
+ }
222
+ function writeUIObservationRecord(record, filePath) {
223
+ const validated = parseUIObservationRecord(record);
224
+ const outputPath = filePath ? (0, external_node_path_namespaceObject.resolve)(filePath) : defaultObservationRecordPath();
225
+ const extension = (0, external_node_path_namespaceObject.extname)(outputPath);
226
+ const stem = (0, external_node_path_namespaceObject.basename)(outputPath, extension);
227
+ const framesDirectory = (0, external_node_path_namespaceObject.join)((0, external_node_path_namespaceObject.dirname)(outputPath), `${stem}.frames`);
228
+ const temporaryFramesDirectory = `${framesDirectory}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
229
+ const temporaryManifest = `${outputPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
230
+ const copiedPaths = new Map();
231
+ try {
232
+ (0, external_node_fs_namespaceObject.mkdirSync)(temporaryFramesDirectory, {
233
+ recursive: true
234
+ });
235
+ const frames = validated.frames.map((frame, index)=>{
236
+ const sourcePath = (0, external_node_path_namespaceObject.resolve)(frame.path);
237
+ try {
238
+ if (!(0, external_node_fs_namespaceObject.statSync)(sourcePath).isFile()) throw new Error('path is not a file');
239
+ } catch (error) {
240
+ const message = error instanceof Error ? error.message : String(error);
241
+ throw new Error(`Invalid UI observation record at frames.${index}.path: cannot read image ${sourcePath}: ${message}`);
242
+ }
243
+ let relativePath = copiedPaths.get(sourcePath);
244
+ if (!relativePath) {
245
+ const imageExtension = 'image/png' === frame.mimeType ? 'png' : 'jpeg';
246
+ const fileName = `${String(copiedPaths.size).padStart(4, '0')}.${imageExtension}`;
247
+ relativePath = `${(0, external_node_path_namespaceObject.basename)(framesDirectory)}/${fileName}`;
248
+ (0, external_node_fs_namespaceObject.copyFileSync)(sourcePath, (0, external_node_path_namespaceObject.join)(temporaryFramesDirectory, fileName));
249
+ copiedPaths.set(sourcePath, relativePath);
250
+ }
251
+ return {
252
+ ...frame,
253
+ path: relativePath
254
+ };
255
+ });
256
+ const serializedRecord = parseUIObservationRecord({
257
+ ...validated,
258
+ frames
259
+ });
260
+ (0, external_node_fs_namespaceObject.mkdirSync)((0, external_node_path_namespaceObject.dirname)(outputPath), {
261
+ recursive: true
262
+ });
263
+ (0, external_node_fs_namespaceObject.writeFileSync)(temporaryManifest, JSON.stringify(serializedRecord, null, 2), 'utf8');
264
+ (0, external_node_fs_namespaceObject.rmSync)(framesDirectory, {
265
+ recursive: true,
266
+ force: true
267
+ });
268
+ (0, external_node_fs_namespaceObject.renameSync)(temporaryFramesDirectory, framesDirectory);
269
+ (0, external_node_fs_namespaceObject.renameSync)(temporaryManifest, outputPath);
270
+ return outputPath;
271
+ } finally{
272
+ (0, external_node_fs_namespaceObject.rmSync)(temporaryFramesDirectory, {
273
+ recursive: true,
274
+ force: true
275
+ });
276
+ (0, external_node_fs_namespaceObject.rmSync)(temporaryManifest, {
277
+ force: true
278
+ });
279
+ }
280
+ }
281
+ exports.UIObservationRecordWriter = __webpack_exports__.UIObservationRecordWriter;
282
+ exports.cloneUIObservationRecord = __webpack_exports__.cloneUIObservationRecord;
283
+ exports.defaultObservationRecordPath = __webpack_exports__.defaultObservationRecordPath;
284
+ exports.parseUIObservationRecord = __webpack_exports__.parseUIObservationRecord;
285
+ exports.readUIObservationRecord = __webpack_exports__.readUIObservationRecord;
286
+ exports.writeUIObservationRecord = __webpack_exports__.writeUIObservationRecord;
287
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
288
+ "UIObservationRecordWriter",
289
+ "cloneUIObservationRecord",
290
+ "defaultObservationRecordPath",
291
+ "parseUIObservationRecord",
292
+ "readUIObservationRecord",
293
+ "writeUIObservationRecord"
294
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
295
+ Object.defineProperty(exports, '__esModule', {
296
+ value: true
297
+ });
@@ -0,0 +1,97 @@
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
+ TOOL_BEHAVIOR_FLAGS: ()=>TOOL_BEHAVIOR_FLAGS,
28
+ mergeToolDefaults: ()=>mergeToolDefaults,
29
+ resolveToolDefaults: ()=>resolveToolDefaults,
30
+ stripBehaviorFlags: ()=>stripBehaviorFlags
31
+ });
32
+ const TOOL_BEHAVIOR_FLAGS = [
33
+ {
34
+ cli: 'deep-locate',
35
+ description: 'Force deep locate for every locating operation (better precision for small/ambiguous targets, a bit slower).',
36
+ defaults: {
37
+ locate: {
38
+ deepLocate: true
39
+ },
40
+ act: {
41
+ deepLocate: true
42
+ }
43
+ }
44
+ },
45
+ {
46
+ cli: 'deep-think',
47
+ description: 'Plan the act tool with deep thinking (richer context and sub-goal decomposition, a bit slower).',
48
+ defaults: {
49
+ act: {
50
+ deepThink: true
51
+ }
52
+ }
53
+ }
54
+ ];
55
+ function mergeToolDefaults(a, b) {
56
+ const locate = {
57
+ ...a.locate,
58
+ ...b.locate
59
+ };
60
+ const act = {
61
+ ...a.act,
62
+ ...b.act
63
+ };
64
+ const result = {};
65
+ if (Object.keys(locate).length > 0) result.locate = locate;
66
+ if (Object.keys(act).length > 0) result.act = act;
67
+ return result;
68
+ }
69
+ function resolveToolDefaults(isEnabled) {
70
+ return TOOL_BEHAVIOR_FLAGS.reduce((acc, flag)=>isEnabled(flag.cli) ? mergeToolDefaults(acc, flag.defaults) : acc, {});
71
+ }
72
+ function stripBehaviorFlags(argv) {
73
+ const enabled = new Set();
74
+ const rawArgs = [];
75
+ for (const arg of argv){
76
+ const flag = TOOL_BEHAVIOR_FLAGS.find((f)=>arg === `--${f.cli}`);
77
+ if (flag) enabled.add(flag.cli);
78
+ else rawArgs.push(arg);
79
+ }
80
+ return {
81
+ rawArgs,
82
+ toolDefaults: resolveToolDefaults((cli)=>enabled.has(cli))
83
+ };
84
+ }
85
+ exports.TOOL_BEHAVIOR_FLAGS = __webpack_exports__.TOOL_BEHAVIOR_FLAGS;
86
+ exports.mergeToolDefaults = __webpack_exports__.mergeToolDefaults;
87
+ exports.resolveToolDefaults = __webpack_exports__.resolveToolDefaults;
88
+ exports.stripBehaviorFlags = __webpack_exports__.stripBehaviorFlags;
89
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
90
+ "TOOL_BEHAVIOR_FLAGS",
91
+ "mergeToolDefaults",
92
+ "resolveToolDefaults",
93
+ "stripBehaviorFlags"
94
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
95
+ Object.defineProperty(exports, '__esModule', {
96
+ value: true
97
+ });