@midscene/core 0.30.5 → 1.0.1-beta-20251021060907.0
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/dist/es/agent/agent.mjs +41 -33
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/execution-session.mjs +41 -0
- package/dist/es/agent/execution-session.mjs.map +1 -0
- package/dist/es/agent/task-builder.mjs +303 -0
- package/dist/es/agent/task-builder.mjs.map +1 -0
- package/dist/es/agent/tasks.mjs +68 -391
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/ui-utils.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +6 -6
- package/dist/es/agent/utils.mjs.map +1 -1
- package/dist/es/ai-model/common.mjs +1 -15
- package/dist/es/ai-model/common.mjs.map +1 -1
- package/dist/es/ai-model/inspect.mjs +2 -3
- package/dist/es/ai-model/inspect.mjs.map +1 -1
- package/dist/es/ai-model/llm-planning.mjs +6 -24
- package/dist/es/ai-model/llm-planning.mjs.map +1 -1
- package/dist/es/ai-model/prompt/llm-locator.mjs +3 -204
- package/dist/es/ai-model/prompt/llm-locator.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/index.mjs +101 -231
- package/dist/es/ai-model/service-caller/index.mjs.map +1 -1
- package/dist/es/index.mjs +3 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/insight/index.mjs +18 -19
- package/dist/es/insight/index.mjs.map +1 -1
- package/dist/es/insight/utils.mjs +3 -3
- package/dist/es/insight/utils.mjs.map +1 -1
- package/dist/es/report.mjs.map +1 -1
- package/dist/es/{ai-model/action-executor.mjs → task-runner.mjs} +69 -10
- package/dist/es/task-runner.mjs.map +1 -0
- package/dist/es/types.mjs +18 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +2 -2
- package/dist/es/yaml/player.mjs +18 -14
- package/dist/es/yaml/player.mjs.map +1 -1
- package/dist/lib/agent/agent.js +41 -33
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/execution-session.js +75 -0
- package/dist/lib/agent/execution-session.js.map +1 -0
- package/dist/lib/agent/task-builder.js +340 -0
- package/dist/lib/agent/task-builder.js.map +1 -0
- package/dist/lib/agent/tasks.js +68 -391
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/ui-utils.js.map +1 -1
- package/dist/lib/agent/utils.js +6 -6
- package/dist/lib/agent/utils.js.map +1 -1
- package/dist/lib/ai-model/common.js +2 -19
- package/dist/lib/ai-model/common.js.map +1 -1
- package/dist/lib/ai-model/inspect.js +1 -2
- package/dist/lib/ai-model/inspect.js.map +1 -1
- package/dist/lib/ai-model/llm-planning.js +5 -23
- package/dist/lib/ai-model/llm-planning.js.map +1 -1
- package/dist/lib/ai-model/prompt/llm-locator.js +2 -206
- package/dist/lib/ai-model/prompt/llm-locator.js.map +1 -1
- package/dist/lib/ai-model/service-caller/index.js +236 -384
- package/dist/lib/ai-model/service-caller/index.js.map +1 -1
- package/dist/lib/index.js +9 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/insight/index.js +17 -18
- package/dist/lib/insight/index.js.map +1 -1
- package/dist/lib/insight/utils.js +5 -5
- package/dist/lib/insight/utils.js.map +1 -1
- package/dist/lib/report.js.map +1 -1
- package/dist/lib/{ai-model/action-executor.js → task-runner.js} +71 -12
- package/dist/lib/task-runner.js.map +1 -0
- package/dist/lib/types.js +22 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/lib/yaml/player.js +18 -14
- package/dist/lib/yaml/player.js.map +1 -1
- package/dist/types/agent/agent.d.ts +16 -0
- package/dist/types/agent/execution-session.d.ts +27 -0
- package/dist/types/agent/task-builder.d.ts +24 -0
- package/dist/types/agent/tasks.d.ts +8 -11
- package/dist/types/agent/ui-utils.d.ts +2 -2
- package/dist/types/agent/utils.d.ts +5 -2
- package/dist/types/ai-model/common.d.ts +0 -1
- package/dist/types/ai-model/prompt/llm-locator.d.ts +0 -2
- package/dist/types/index.d.ts +4 -3
- package/dist/types/insight/index.d.ts +5 -10
- package/dist/types/insight/utils.d.ts +2 -2
- package/dist/types/{ai-model/action-executor.d.ts → task-runner.d.ts} +14 -3
- package/dist/types/types.d.ts +47 -4
- package/dist/types/yaml.d.ts +3 -1
- package/package.json +4 -7
- package/dist/es/ai-model/action-executor.mjs.map +0 -1
- package/dist/lib/ai-model/action-executor.js.map +0 -1
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { InsightError } from "../types.mjs";
|
|
2
|
+
import { sleep } from "../utils.mjs";
|
|
3
|
+
import { getDebug } from "@midscene/shared/logger";
|
|
4
|
+
import { assert } from "@midscene/shared/utils";
|
|
5
|
+
import { findAllMidsceneLocatorField, parseActionParam } from "../ai-model/index.mjs";
|
|
6
|
+
import { matchElementFromCache, matchElementFromPlan } from "./utils.mjs";
|
|
7
|
+
function _define_property(obj, key, value) {
|
|
8
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
9
|
+
value: value,
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true
|
|
13
|
+
});
|
|
14
|
+
else obj[key] = value;
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
const debug = getDebug('agent:task-builder');
|
|
18
|
+
function locatePlanForLocate(param) {
|
|
19
|
+
const locate = 'string' == typeof param ? {
|
|
20
|
+
prompt: param
|
|
21
|
+
} : param;
|
|
22
|
+
const locatePlan = {
|
|
23
|
+
type: 'Locate',
|
|
24
|
+
locate,
|
|
25
|
+
param: locate,
|
|
26
|
+
thought: ''
|
|
27
|
+
};
|
|
28
|
+
return locatePlan;
|
|
29
|
+
}
|
|
30
|
+
class TaskBuilder {
|
|
31
|
+
async build(plans, modelConfig, options) {
|
|
32
|
+
const tasks = [];
|
|
33
|
+
const cacheable = null == options ? void 0 : options.cacheable;
|
|
34
|
+
const taskForLocatePlan = (plan, detailedLocateParam, onResult)=>{
|
|
35
|
+
if ('string' == typeof detailedLocateParam) detailedLocateParam = {
|
|
36
|
+
prompt: detailedLocateParam
|
|
37
|
+
};
|
|
38
|
+
if (void 0 !== cacheable) detailedLocateParam = {
|
|
39
|
+
...detailedLocateParam,
|
|
40
|
+
cacheable
|
|
41
|
+
};
|
|
42
|
+
const taskFind = {
|
|
43
|
+
type: 'Insight',
|
|
44
|
+
subType: 'Locate',
|
|
45
|
+
param: detailedLocateParam,
|
|
46
|
+
thought: plan.thought,
|
|
47
|
+
executor: async (param, taskContext)=>{
|
|
48
|
+
var _this_taskCache, _locateCacheRecord_cacheContent;
|
|
49
|
+
const { task } = taskContext;
|
|
50
|
+
let { uiContext } = taskContext;
|
|
51
|
+
assert((null == param ? void 0 : param.prompt) || (null == param ? void 0 : param.id) || (null == param ? void 0 : param.bbox), `No prompt or id or position or bbox to locate, param=${JSON.stringify(param)}`);
|
|
52
|
+
if (!uiContext) uiContext = await this.insight.contextRetrieverFn();
|
|
53
|
+
assert(uiContext, 'uiContext is required for Insight task');
|
|
54
|
+
let locateDump;
|
|
55
|
+
let locateResult;
|
|
56
|
+
const applyDump = (dump)=>{
|
|
57
|
+
var _dump_taskInfo, _dump_taskInfo1;
|
|
58
|
+
if (!dump) return;
|
|
59
|
+
locateDump = dump;
|
|
60
|
+
task.log = {
|
|
61
|
+
dump
|
|
62
|
+
};
|
|
63
|
+
task.usage = null == (_dump_taskInfo = dump.taskInfo) ? void 0 : _dump_taskInfo.usage;
|
|
64
|
+
if (null == (_dump_taskInfo1 = dump.taskInfo) ? void 0 : _dump_taskInfo1.searchAreaUsage) task.searchAreaUsage = dump.taskInfo.searchAreaUsage;
|
|
65
|
+
};
|
|
66
|
+
const elementFromXpath = param.xpath && this.interface.getElementInfoByXpath ? await this.interface.getElementInfoByXpath(param.xpath) : void 0;
|
|
67
|
+
const userExpectedPathHitFlag = !!elementFromXpath;
|
|
68
|
+
const cachePrompt = param.prompt;
|
|
69
|
+
const locateCacheRecord = null == (_this_taskCache = this.taskCache) ? void 0 : _this_taskCache.matchLocateCache(cachePrompt);
|
|
70
|
+
const cacheEntry = null == locateCacheRecord ? void 0 : null == (_locateCacheRecord_cacheContent = locateCacheRecord.cacheContent) ? void 0 : _locateCacheRecord_cacheContent.cache;
|
|
71
|
+
const elementFromCache = userExpectedPathHitFlag ? null : await matchElementFromCache({
|
|
72
|
+
taskCache: this.taskCache,
|
|
73
|
+
interfaceInstance: this.interface
|
|
74
|
+
}, cacheEntry, cachePrompt, param.cacheable);
|
|
75
|
+
const cacheHitFlag = !!elementFromCache;
|
|
76
|
+
const elementFromPlan = userExpectedPathHitFlag || cacheHitFlag ? void 0 : matchElementFromPlan(param, uiContext.tree);
|
|
77
|
+
const planHitFlag = !!elementFromPlan;
|
|
78
|
+
let elementFromAiLocate;
|
|
79
|
+
if (!userExpectedPathHitFlag && !cacheHitFlag && !planHitFlag) try {
|
|
80
|
+
locateResult = await this.insight.locate(param, {
|
|
81
|
+
context: uiContext
|
|
82
|
+
}, modelConfig);
|
|
83
|
+
applyDump(locateResult.dump);
|
|
84
|
+
elementFromAiLocate = locateResult.element;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (error instanceof InsightError) applyDump(error.dump);
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
const aiLocateHitFlag = !!elementFromAiLocate;
|
|
90
|
+
const element = elementFromXpath || elementFromCache || elementFromPlan || elementFromAiLocate;
|
|
91
|
+
let currentCacheEntry;
|
|
92
|
+
if (element && this.taskCache && !cacheHitFlag && (null == param ? void 0 : param.cacheable) !== false) if (this.interface.cacheFeatureForRect) try {
|
|
93
|
+
const feature = await this.interface.cacheFeatureForRect(element.rect, void 0 !== element.isOrderSensitive ? {
|
|
94
|
+
_orderSensitive: element.isOrderSensitive
|
|
95
|
+
} : void 0);
|
|
96
|
+
if (feature && Object.keys(feature).length > 0) {
|
|
97
|
+
debug('update cache, prompt: %s, cache: %o', cachePrompt, feature);
|
|
98
|
+
currentCacheEntry = feature;
|
|
99
|
+
this.taskCache.updateOrAppendCacheRecord({
|
|
100
|
+
type: 'locate',
|
|
101
|
+
prompt: cachePrompt,
|
|
102
|
+
cache: feature
|
|
103
|
+
}, locateCacheRecord);
|
|
104
|
+
} else debug('no cache data returned, skip cache update, prompt: %s', cachePrompt);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
debug('cacheFeatureForRect failed: %s', error);
|
|
107
|
+
}
|
|
108
|
+
else debug('cacheFeatureForRect is not supported, skip cache update');
|
|
109
|
+
if (!element) {
|
|
110
|
+
if (locateDump) throw new InsightError(`Element not found: ${param.prompt}`, locateDump);
|
|
111
|
+
throw new Error(`Element not found: ${param.prompt}`);
|
|
112
|
+
}
|
|
113
|
+
let hitBy;
|
|
114
|
+
if (userExpectedPathHitFlag) hitBy = {
|
|
115
|
+
from: 'User expected path',
|
|
116
|
+
context: {
|
|
117
|
+
xpath: param.xpath
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
else if (cacheHitFlag) hitBy = {
|
|
121
|
+
from: 'Cache',
|
|
122
|
+
context: {
|
|
123
|
+
cacheEntry,
|
|
124
|
+
cacheToSave: currentCacheEntry
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
else if (planHitFlag) hitBy = {
|
|
128
|
+
from: 'Planning',
|
|
129
|
+
context: {
|
|
130
|
+
id: null == elementFromPlan ? void 0 : elementFromPlan.id,
|
|
131
|
+
bbox: null == elementFromPlan ? void 0 : elementFromPlan.bbox
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
else if (aiLocateHitFlag) hitBy = {
|
|
135
|
+
from: 'AI model',
|
|
136
|
+
context: {
|
|
137
|
+
prompt: param.prompt
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
null == onResult || onResult(element);
|
|
141
|
+
return {
|
|
142
|
+
output: {
|
|
143
|
+
element
|
|
144
|
+
},
|
|
145
|
+
uiContext,
|
|
146
|
+
hitBy
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
return taskFind;
|
|
151
|
+
};
|
|
152
|
+
for (const plan of plans){
|
|
153
|
+
if ('Locate' === plan.type) {
|
|
154
|
+
if (!plan.locate || null === plan.locate) {
|
|
155
|
+
debug('Locate action with id is null, will be ignored', plan);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const taskLocate = taskForLocatePlan(plan, plan.locate);
|
|
159
|
+
tasks.push(taskLocate);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if ('Error' === plan.type) {
|
|
163
|
+
var _plan_param;
|
|
164
|
+
const taskActionError = {
|
|
165
|
+
type: 'Action',
|
|
166
|
+
subType: 'Error',
|
|
167
|
+
param: plan.param,
|
|
168
|
+
thought: plan.thought || (null == (_plan_param = plan.param) ? void 0 : _plan_param.thought),
|
|
169
|
+
locate: plan.locate,
|
|
170
|
+
executor: async ()=>{
|
|
171
|
+
var _plan_param;
|
|
172
|
+
throw new Error((null == plan ? void 0 : plan.thought) || (null == (_plan_param = plan.param) ? void 0 : _plan_param.thought) || 'error without thought');
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
tasks.push(taskActionError);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if ('Finished' === plan.type) {
|
|
179
|
+
const taskActionFinished = {
|
|
180
|
+
type: 'Action',
|
|
181
|
+
subType: 'Finished',
|
|
182
|
+
param: null,
|
|
183
|
+
thought: plan.thought,
|
|
184
|
+
locate: plan.locate,
|
|
185
|
+
executor: async ()=>{}
|
|
186
|
+
};
|
|
187
|
+
tasks.push(taskActionFinished);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if ('Sleep' === plan.type) {
|
|
191
|
+
const taskActionSleep = {
|
|
192
|
+
type: 'Action',
|
|
193
|
+
subType: 'Sleep',
|
|
194
|
+
param: plan.param,
|
|
195
|
+
thought: plan.thought,
|
|
196
|
+
locate: plan.locate,
|
|
197
|
+
executor: async (taskParam)=>{
|
|
198
|
+
await sleep((null == taskParam ? void 0 : taskParam.timeMs) || 3000);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
tasks.push(taskActionSleep);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const planType = plan.type;
|
|
205
|
+
const actionSpace = await this.interface.actionSpace();
|
|
206
|
+
const action = actionSpace.find((item)=>item.name === planType);
|
|
207
|
+
const param = plan.param;
|
|
208
|
+
if (!action) throw new Error(`Action type '${planType}' not found`);
|
|
209
|
+
const locateFields = action ? findAllMidsceneLocatorField(action.paramSchema) : [];
|
|
210
|
+
const requiredLocateFields = action ? findAllMidsceneLocatorField(action.paramSchema, true) : [];
|
|
211
|
+
locateFields.forEach((field)=>{
|
|
212
|
+
if (param[field]) {
|
|
213
|
+
const locatePlan = locatePlanForLocate(param[field]);
|
|
214
|
+
debug('will prepend locate param for field', `action.type=${planType}`, `param=${JSON.stringify(param[field])}`, `locatePlan=${JSON.stringify(locatePlan)}`);
|
|
215
|
+
const locateTask = taskForLocatePlan(locatePlan, param[field], (result)=>{
|
|
216
|
+
param[field] = result;
|
|
217
|
+
});
|
|
218
|
+
tasks.push(locateTask);
|
|
219
|
+
} else {
|
|
220
|
+
assert(!requiredLocateFields.includes(field), `Required locate field '${field}' is not provided for action ${planType}`);
|
|
221
|
+
debug(`field '${field}' is not provided for action ${planType}`);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
const task = {
|
|
225
|
+
type: 'Action',
|
|
226
|
+
subType: planType,
|
|
227
|
+
thought: plan.thought,
|
|
228
|
+
param: plan.param,
|
|
229
|
+
executor: async (param, taskContext)=>{
|
|
230
|
+
var _taskContext_element;
|
|
231
|
+
debug('executing action', planType, param, `taskContext.element.center: ${null == (_taskContext_element = taskContext.element) ? void 0 : _taskContext_element.center}`);
|
|
232
|
+
const uiContext = taskContext.uiContext;
|
|
233
|
+
assert(uiContext, 'uiContext is required for Action task');
|
|
234
|
+
requiredLocateFields.forEach((field)=>{
|
|
235
|
+
assert(param[field], `field '${field}' is required for action ${planType} but not provided. Cannot execute action ${planType}.`);
|
|
236
|
+
});
|
|
237
|
+
try {
|
|
238
|
+
await Promise.all([
|
|
239
|
+
(async ()=>{
|
|
240
|
+
if (this.interface.beforeInvokeAction) {
|
|
241
|
+
debug('will call "beforeInvokeAction" for interface');
|
|
242
|
+
await this.interface.beforeInvokeAction(action.name, param);
|
|
243
|
+
debug('called "beforeInvokeAction" for interface');
|
|
244
|
+
}
|
|
245
|
+
})(),
|
|
246
|
+
sleep(200)
|
|
247
|
+
]);
|
|
248
|
+
} catch (originalError) {
|
|
249
|
+
const originalMessage = (null == originalError ? void 0 : originalError.message) || String(originalError);
|
|
250
|
+
throw new Error(`error in running beforeInvokeAction for ${action.name}: ${originalMessage}`, {
|
|
251
|
+
cause: originalError
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (action.paramSchema) try {
|
|
255
|
+
param = parseActionParam(param, action.paramSchema);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
throw new Error(`Invalid parameters for action ${action.name}: ${error.message}\nParameters: ${JSON.stringify(param)}`, {
|
|
258
|
+
cause: error
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
debug('calling action', action.name);
|
|
262
|
+
const actionFn = action.call.bind(this.interface);
|
|
263
|
+
await actionFn(param, taskContext);
|
|
264
|
+
debug('called action', action.name);
|
|
265
|
+
try {
|
|
266
|
+
if (this.interface.afterInvokeAction) {
|
|
267
|
+
debug('will call "afterInvokeAction" for interface');
|
|
268
|
+
await this.interface.afterInvokeAction(action.name, param);
|
|
269
|
+
debug('called "afterInvokeAction" for interface');
|
|
270
|
+
}
|
|
271
|
+
} catch (originalError) {
|
|
272
|
+
const originalMessage = (null == originalError ? void 0 : originalError.message) || String(originalError);
|
|
273
|
+
throw new Error(`error in running afterInvokeAction for ${action.name}: ${originalMessage}`, {
|
|
274
|
+
cause: originalError
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
output: {
|
|
279
|
+
success: true,
|
|
280
|
+
action: planType,
|
|
281
|
+
param: param
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
tasks.push(task);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
tasks
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
constructor({ interfaceInstance, insight, taskCache }){
|
|
293
|
+
_define_property(this, "interface", void 0);
|
|
294
|
+
_define_property(this, "insight", void 0);
|
|
295
|
+
_define_property(this, "taskCache", void 0);
|
|
296
|
+
this.interface = interfaceInstance;
|
|
297
|
+
this.insight = insight;
|
|
298
|
+
this.taskCache = taskCache;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
export { TaskBuilder, locatePlanForLocate };
|
|
302
|
+
|
|
303
|
+
//# sourceMappingURL=task-builder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent/task-builder.mjs","sources":["webpack://@midscene/core/./src/agent/task-builder.ts"],"sourcesContent":["import type { AbstractInterface } from '@/device';\nimport type Insight from '@/insight';\nimport type {\n DetailedLocateParam,\n ElementCacheFeature,\n ExecutionTaskActionApply,\n ExecutionTaskApply,\n ExecutionTaskHitBy,\n ExecutionTaskInsightLocateApply,\n InsightDump,\n LocateResultElement,\n LocateResultWithDump,\n PlanningAction,\n PlanningActionParamError,\n PlanningActionParamSleep,\n PlanningLocateParam,\n} from '@/types';\nimport { InsightError } from '@/types';\nimport { sleep } from '@/utils';\nimport type { IModelConfig } from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { TaskCache } from './task-cache';\nimport {\n findAllMidsceneLocatorField,\n parseActionParam,\n} from '@/ai-model';\nimport {\n matchElementFromCache,\n matchElementFromPlan,\n} from './utils';\n\nconst debug = getDebug('agent:task-builder');\n\nexport function locatePlanForLocate(param: string | DetailedLocateParam) {\n const locate = typeof param === 'string' ? { prompt: param } : param;\n const locatePlan: PlanningAction<PlanningLocateParam> = {\n type: 'Locate',\n locate,\n param: locate,\n thought: '',\n };\n return locatePlan;\n}\n\ninterface TaskBuilderDeps {\n interfaceInstance: AbstractInterface;\n insight: Insight;\n taskCache?: TaskCache;\n}\n\ninterface BuildOptions {\n cacheable?: boolean;\n}\n\nexport class TaskBuilder {\n private readonly interface: AbstractInterface;\n\n private readonly insight: Insight;\n\n private readonly taskCache?: TaskCache;\n\n constructor({ interfaceInstance, insight, taskCache }: TaskBuilderDeps) {\n this.interface = interfaceInstance;\n this.insight = insight;\n this.taskCache = taskCache;\n }\n\n public async build(\n plans: PlanningAction[],\n modelConfig: IModelConfig,\n options?: BuildOptions,\n ): Promise<{ tasks: ExecutionTaskApply[] }> {\n const tasks: ExecutionTaskApply[] = [];\n const cacheable = options?.cacheable;\n\n const taskForLocatePlan = (\n plan: PlanningAction<PlanningLocateParam>,\n detailedLocateParam: DetailedLocateParam | string,\n onResult?: (result: LocateResultElement) => void,\n ): ExecutionTaskInsightLocateApply => {\n if (typeof detailedLocateParam === 'string') {\n detailedLocateParam = {\n prompt: detailedLocateParam,\n };\n }\n\n if (cacheable !== undefined) {\n detailedLocateParam = {\n ...detailedLocateParam,\n cacheable,\n };\n }\n\n const taskFind: ExecutionTaskInsightLocateApply = {\n type: 'Insight',\n subType: 'Locate',\n param: detailedLocateParam,\n thought: plan.thought,\n executor: async (param, taskContext) => {\n const { task } = taskContext;\n let { uiContext } = taskContext;\n\n assert(\n param?.prompt || param?.id || param?.bbox,\n `No prompt or id or position or bbox to locate, param=${JSON.stringify(\n param,\n )}`,\n );\n\n if (!uiContext) {\n uiContext = await this.insight.contextRetrieverFn();\n }\n\n assert(uiContext, 'uiContext is required for Insight task');\n\n let locateDump: InsightDump | undefined;\n let locateResult: LocateResultWithDump | undefined;\n\n const applyDump = (dump?: InsightDump) => {\n if (!dump) {\n return;\n }\n locateDump = dump;\n task.log = {\n dump,\n };\n task.usage = dump.taskInfo?.usage;\n if (dump.taskInfo?.searchAreaUsage) {\n task.searchAreaUsage = dump.taskInfo.searchAreaUsage;\n }\n };\n\n const elementFromXpath =\n param.xpath && (this.interface as any).getElementInfoByXpath\n ? await (this.interface as any).getElementInfoByXpath(param.xpath)\n : undefined;\n const userExpectedPathHitFlag = !!elementFromXpath;\n\n const cachePrompt = param.prompt;\n const locateCacheRecord = this.taskCache?.matchLocateCache(\n cachePrompt,\n );\n const cacheEntry = locateCacheRecord?.cacheContent?.cache;\n\n const elementFromCache = userExpectedPathHitFlag\n ? null\n : await matchElementFromCache(\n {\n taskCache: this.taskCache,\n interfaceInstance: this.interface,\n },\n cacheEntry,\n cachePrompt,\n param.cacheable,\n );\n const cacheHitFlag = !!elementFromCache;\n\n const elementFromPlan =\n !userExpectedPathHitFlag && !cacheHitFlag\n ? matchElementFromPlan(param, uiContext.tree)\n : undefined;\n const planHitFlag = !!elementFromPlan;\n\n let elementFromAiLocate: LocateResultElement | null | undefined;\n if (!userExpectedPathHitFlag && !cacheHitFlag && !planHitFlag) {\n try {\n locateResult = await this.insight.locate(\n param,\n {\n context: uiContext,\n },\n modelConfig,\n );\n applyDump(locateResult.dump);\n elementFromAiLocate = locateResult.element;\n } catch (error) {\n if (error instanceof InsightError) {\n applyDump(error.dump);\n }\n throw error;\n }\n }\n const aiLocateHitFlag = !!elementFromAiLocate;\n\n const element =\n elementFromXpath ||\n elementFromCache ||\n elementFromPlan ||\n elementFromAiLocate;\n\n let currentCacheEntry: ElementCacheFeature | undefined;\n if (\n element &&\n this.taskCache &&\n !cacheHitFlag &&\n param?.cacheable !== false\n ) {\n if (this.interface.cacheFeatureForRect) {\n try {\n const feature = await this.interface.cacheFeatureForRect(\n element.rect,\n element.isOrderSensitive !== undefined\n ? { _orderSensitive: element.isOrderSensitive }\n : undefined,\n );\n if (feature && Object.keys(feature).length > 0) {\n debug(\n 'update cache, prompt: %s, cache: %o',\n cachePrompt,\n feature,\n );\n currentCacheEntry = feature;\n this.taskCache.updateOrAppendCacheRecord(\n {\n type: 'locate',\n prompt: cachePrompt,\n cache: feature,\n },\n locateCacheRecord,\n );\n } else {\n debug(\n 'no cache data returned, skip cache update, prompt: %s',\n cachePrompt,\n );\n }\n } catch (error) {\n debug('cacheFeatureForRect failed: %s', error);\n }\n } else {\n debug('cacheFeatureForRect is not supported, skip cache update');\n }\n }\n\n if (!element) {\n if (locateDump) {\n throw new InsightError(\n `Element not found: ${param.prompt}`,\n locateDump,\n );\n }\n throw new Error(`Element not found: ${param.prompt}`);\n }\n\n let hitBy: ExecutionTaskHitBy | undefined;\n\n if (userExpectedPathHitFlag) {\n hitBy = {\n from: 'User expected path',\n context: {\n xpath: param.xpath,\n },\n };\n } else if (cacheHitFlag) {\n hitBy = {\n from: 'Cache',\n context: {\n cacheEntry,\n cacheToSave: currentCacheEntry,\n },\n };\n } else if (planHitFlag) {\n hitBy = {\n from: 'Planning',\n context: {\n id: elementFromPlan?.id,\n bbox: elementFromPlan?.bbox,\n },\n };\n } else if (aiLocateHitFlag) {\n hitBy = {\n from: 'AI model',\n context: {\n prompt: param.prompt,\n },\n };\n }\n\n onResult?.(element);\n\n return {\n output: {\n element,\n },\n uiContext,\n hitBy,\n };\n },\n };\n\n return taskFind;\n };\n\n for (const plan of plans) {\n if (plan.type === 'Locate') {\n if (!plan.locate || plan.locate === null) {\n debug('Locate action with id is null, will be ignored', plan);\n continue;\n }\n const taskLocate = taskForLocatePlan(plan, plan.locate);\n tasks.push(taskLocate);\n continue;\n }\n\n if (plan.type === 'Error') {\n const taskActionError: ExecutionTaskActionApply<PlanningActionParamError> =\n {\n type: 'Action',\n subType: 'Error',\n param: plan.param,\n thought: plan.thought || plan.param?.thought,\n locate: plan.locate,\n executor: async () => {\n throw new Error(\n plan?.thought || plan.param?.thought || 'error without thought',\n );\n },\n };\n tasks.push(taskActionError);\n continue;\n }\n\n if (plan.type === 'Finished') {\n const taskActionFinished: ExecutionTaskActionApply<null> = {\n type: 'Action',\n subType: 'Finished',\n param: null,\n thought: plan.thought,\n locate: plan.locate,\n executor: async () => {},\n };\n tasks.push(taskActionFinished);\n continue;\n }\n\n if (plan.type === 'Sleep') {\n const taskActionSleep: ExecutionTaskActionApply<PlanningActionParamSleep> =\n {\n type: 'Action',\n subType: 'Sleep',\n param: plan.param,\n thought: plan.thought,\n locate: plan.locate,\n executor: async (taskParam) => {\n await sleep(taskParam?.timeMs || 3000);\n },\n };\n tasks.push(taskActionSleep);\n continue;\n }\n\n const planType = plan.type;\n const actionSpace = await this.interface.actionSpace();\n const action = actionSpace.find((item) => item.name === planType);\n const param = plan.param;\n\n if (!action) {\n throw new Error(`Action type '${planType}' not found`);\n }\n\n const locateFields = action\n ? findAllMidsceneLocatorField(action.paramSchema)\n : [];\n\n const requiredLocateFields = action\n ? findAllMidsceneLocatorField(action.paramSchema, true)\n : [];\n\n locateFields.forEach((field) => {\n if (param[field]) {\n const locatePlan = locatePlanForLocate(param[field]);\n debug(\n 'will prepend locate param for field',\n `action.type=${planType}`,\n `param=${JSON.stringify(param[field])}`,\n `locatePlan=${JSON.stringify(locatePlan)}`,\n );\n const locateTask = taskForLocatePlan(\n locatePlan,\n param[field],\n (result) => {\n param[field] = result;\n },\n );\n tasks.push(locateTask);\n } else {\n assert(\n !requiredLocateFields.includes(field),\n `Required locate field '${field}' is not provided for action ${planType}`,\n );\n debug(`field '${field}' is not provided for action ${planType}`);\n }\n });\n\n const task: ExecutionTaskApply<\n 'Action',\n any,\n { success: boolean; action: string; param: any },\n void\n > = {\n type: 'Action',\n subType: planType,\n thought: plan.thought,\n param: plan.param,\n executor: async (param, taskContext) => {\n debug(\n 'executing action',\n planType,\n param,\n `taskContext.element.center: ${taskContext.element?.center}`,\n );\n\n const uiContext = taskContext.uiContext;\n assert(uiContext, 'uiContext is required for Action task');\n\n requiredLocateFields.forEach((field) => {\n assert(\n param[field],\n `field '${field}' is required for action ${planType} but not provided. Cannot execute action ${planType}.`,\n );\n });\n\n try {\n await Promise.all([\n (async () => {\n if (this.interface.beforeInvokeAction) {\n debug('will call \"beforeInvokeAction\" for interface');\n await this.interface.beforeInvokeAction(action.name, param);\n debug('called \"beforeInvokeAction\" for interface');\n }\n })(),\n sleep(200),\n ]);\n } catch (originalError: any) {\n const originalMessage =\n originalError?.message || String(originalError);\n throw new Error(\n `error in running beforeInvokeAction for ${action.name}: ${originalMessage}`,\n { cause: originalError },\n );\n }\n\n if (action.paramSchema) {\n try {\n param = parseActionParam(param, action.paramSchema);\n } catch (error: any) {\n throw new Error(\n `Invalid parameters for action ${action.name}: ${error.message}\\nParameters: ${JSON.stringify(param)}`,\n { cause: error },\n );\n }\n }\n\n debug('calling action', action.name);\n const actionFn = action.call.bind(this.interface);\n await actionFn(param, taskContext);\n debug('called action', action.name);\n\n try {\n if (this.interface.afterInvokeAction) {\n debug('will call \"afterInvokeAction\" for interface');\n await this.interface.afterInvokeAction(action.name, param);\n debug('called \"afterInvokeAction\" for interface');\n }\n } catch (originalError: any) {\n const originalMessage =\n originalError?.message || String(originalError);\n throw new Error(\n `error in running afterInvokeAction for ${action.name}: ${originalMessage}`,\n { cause: originalError },\n );\n }\n\n return {\n output: {\n success: true,\n action: planType,\n param: param,\n },\n };\n },\n };\n\n tasks.push(task);\n }\n\n return {\n tasks,\n };\n }\n}\n"],"names":["debug","getDebug","locatePlanForLocate","param","locate","locatePlan","TaskBuilder","plans","modelConfig","options","tasks","cacheable","taskForLocatePlan","plan","detailedLocateParam","onResult","undefined","taskFind","taskContext","_this_taskCache","_locateCacheRecord_cacheContent","task","uiContext","assert","JSON","locateDump","locateResult","applyDump","dump","_dump_taskInfo","_dump_taskInfo1","elementFromXpath","userExpectedPathHitFlag","cachePrompt","locateCacheRecord","cacheEntry","elementFromCache","matchElementFromCache","cacheHitFlag","elementFromPlan","matchElementFromPlan","planHitFlag","elementFromAiLocate","error","InsightError","aiLocateHitFlag","element","currentCacheEntry","feature","Object","Error","hitBy","taskLocate","_plan_param","taskActionError","taskActionFinished","taskActionSleep","taskParam","sleep","planType","actionSpace","action","item","locateFields","findAllMidsceneLocatorField","requiredLocateFields","field","locateTask","result","_taskContext_element","Promise","originalError","originalMessage","String","parseActionParam","actionFn","interfaceInstance","insight","taskCache"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAMA,QAAQC,SAAS;AAEhB,SAASC,oBAAoBC,KAAmC;IACrE,MAAMC,SAAS,AAAiB,YAAjB,OAAOD,QAAqB;QAAE,QAAQA;IAAM,IAAIA;IAC/D,MAAME,aAAkD;QACtD,MAAM;QACND;QACA,OAAOA;QACP,SAAS;IACX;IACA,OAAOC;AACT;AAYO,MAAMC;IAaX,MAAa,MACXC,KAAuB,EACvBC,WAAyB,EACzBC,OAAsB,EACoB;QAC1C,MAAMC,QAA8B,EAAE;QACtC,MAAMC,YAAYF,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,SAAS;QAEpC,MAAMG,oBAAoB,CACxBC,MACAC,qBACAC;YAEA,IAAI,AAA+B,YAA/B,OAAOD,qBACTA,sBAAsB;gBACpB,QAAQA;YACV;YAGF,IAAIH,AAAcK,WAAdL,WACFG,sBAAsB;gBACpB,GAAGA,mBAAmB;gBACtBH;YACF;YAGF,MAAMM,WAA4C;gBAChD,MAAM;gBACN,SAAS;gBACT,OAAOH;gBACP,SAASD,KAAK,OAAO;gBACrB,UAAU,OAAOV,OAAOe;wBAyCIC,iBAGPC;oBA3CnB,MAAM,EAAEC,IAAI,EAAE,GAAGH;oBACjB,IAAI,EAAEI,SAAS,EAAE,GAAGJ;oBAEpBK,OACEpB,AAAAA,CAAAA,QAAAA,QAAAA,KAAAA,IAAAA,MAAO,MAAM,AAAD,KAAKA,CAAAA,QAAAA,QAAAA,KAAAA,IAAAA,MAAO,EAAE,AAAD,KAAKA,CAAAA,QAAAA,QAAAA,KAAAA,IAAAA,MAAO,IAAI,AAAD,GACxC,CAAC,qDAAqD,EAAEqB,KAAK,SAAS,CACpErB,QACC;oBAGL,IAAI,CAACmB,WACHA,YAAY,MAAM,IAAI,CAAC,OAAO,CAAC,kB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