@midscene/core 1.12.4-beta-20260904065253.0 → 1.12.4
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 +72 -25
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/index.mjs +2 -1
- package/dist/es/agent/insight.mjs +26 -10
- package/dist/es/agent/insight.mjs.map +1 -1
- package/dist/es/agent/prompt-context.mjs +12 -7
- package/dist/es/agent/prompt-context.mjs.map +1 -1
- package/dist/es/agent/run-gherkin-scenario.mjs +1 -1
- package/dist/es/agent/run-gherkin-scenario.mjs.map +1 -1
- package/dist/es/agent/tasks.mjs +2 -1
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/test-runner-nodes.mjs +274 -0
- package/dist/es/agent/test-runner-nodes.mjs.map +1 -0
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/ai-model/prompt/insight/user-prompt.mjs +1 -1
- package/dist/es/ai-model/prompt/insight/user-prompt.mjs.map +1 -1
- package/dist/es/ai-model/workflows/insight/extraction.mjs +3 -1
- package/dist/es/ai-model/workflows/insight/extraction.mjs.map +1 -1
- package/dist/es/ai-model/workflows/planning/custom-planning.mjs +3 -3
- package/dist/es/ai-model/workflows/planning/custom-planning.mjs.map +1 -1
- package/dist/es/ai-model/workflows/planning/standard-planning.mjs +1 -1
- package/dist/es/ai-model/workflows/planning/standard-planning.mjs.map +1 -1
- package/dist/es/report-html-template.mjs +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +1 -1
- package/dist/es/yaml/player.mjs +0 -5
- package/dist/es/yaml/player.mjs.map +1 -1
- package/dist/es/yaml.mjs.map +1 -1
- package/dist/lib/agent/agent.js +72 -25
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/index.js +57 -8
- package/dist/lib/agent/insight.js +26 -10
- package/dist/lib/agent/insight.js.map +1 -1
- package/dist/lib/agent/prompt-context.js +16 -8
- package/dist/lib/agent/prompt-context.js.map +1 -1
- package/dist/lib/agent/run-gherkin-scenario.js +1 -1
- package/dist/lib/agent/run-gherkin-scenario.js.map +1 -1
- package/dist/lib/agent/tasks.js +2 -1
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/test-runner-nodes.js +353 -0
- package/dist/lib/agent/test-runner-nodes.js.map +1 -0
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/ai-model/prompt/insight/user-prompt.js +1 -1
- package/dist/lib/ai-model/prompt/insight/user-prompt.js.map +1 -1
- package/dist/lib/ai-model/workflows/insight/extraction.js +3 -1
- package/dist/lib/ai-model/workflows/insight/extraction.js.map +1 -1
- package/dist/lib/ai-model/workflows/planning/custom-planning.js +3 -3
- package/dist/lib/ai-model/workflows/planning/custom-planning.js.map +1 -1
- package/dist/lib/ai-model/workflows/planning/standard-planning.js +1 -1
- package/dist/lib/ai-model/workflows/planning/standard-planning.js.map +1 -1
- package/dist/lib/report-html-template.js +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/yaml/player.js +0 -5
- package/dist/lib/yaml/player.js.map +1 -1
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent/agent.d.ts +26 -3
- package/dist/types/agent/index.d.ts +3 -1
- package/dist/types/agent/insight.d.ts +5 -1
- package/dist/types/agent/prompt-context.d.ts +2 -0
- package/dist/types/agent/run-gherkin-scenario.d.ts +1 -0
- package/dist/types/agent/test-runner-nodes.d.ts +192 -0
- package/dist/types/types.d.ts +28 -0
- package/dist/types/yaml.d.ts +12 -4
- package/package.json +10 -2
|
@@ -0,0 +1,353 @@
|
|
|
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
|
+
aiActOptionsInputSchema: ()=>aiActOptionsInputSchema,
|
|
28
|
+
aiTapInputSchema: ()=>aiTapInputSchema,
|
|
29
|
+
reportScreenshotInputSchema: ()=>reportScreenshotInputSchema,
|
|
30
|
+
createAgentTestRunnerNodeDefinition: ()=>createAgentTestRunnerNodeDefinition,
|
|
31
|
+
insightInputSchema: ()=>insightInputSchema,
|
|
32
|
+
locateOptionsInputSchema: ()=>locateOptionsInputSchema,
|
|
33
|
+
structuredUserPromptInputSchema: ()=>structuredUserPromptInputSchema,
|
|
34
|
+
promptImageInputSchema: ()=>promptImageInputSchema,
|
|
35
|
+
aiAssertInputSchema: ()=>aiAssertInputSchema,
|
|
36
|
+
commonAgentTestRunnerNodeDefinitions: ()=>commonAgentTestRunnerNodeDefinitions,
|
|
37
|
+
recordToReportInputSchema: ()=>recordToReportInputSchema,
|
|
38
|
+
recordToReportOptionsInputSchema: ()=>recordToReportOptionsInputSchema,
|
|
39
|
+
userPromptInputSchema: ()=>userPromptInputSchema,
|
|
40
|
+
aiAssertOptionsInputSchema: ()=>aiAssertOptionsInputSchema,
|
|
41
|
+
aiActInputSchema: ()=>aiActInputSchema,
|
|
42
|
+
insightOptionsInputSchema: ()=>insightOptionsInputSchema
|
|
43
|
+
});
|
|
44
|
+
const v4_namespaceObject = require("zod/v4");
|
|
45
|
+
const createAgentTestRunnerNodeDefinition = (agentLabel = 'an Agent')=>(definition)=>({
|
|
46
|
+
name: definition.name ?? definition.method,
|
|
47
|
+
...void 0 === definition.title ? {} : {
|
|
48
|
+
title: definition.title
|
|
49
|
+
},
|
|
50
|
+
...void 0 === definition.description ? {} : {
|
|
51
|
+
description: definition.description
|
|
52
|
+
},
|
|
53
|
+
...void 0 === definition.stringInputKey ? {} : {
|
|
54
|
+
stringInputKey: definition.stringInputKey
|
|
55
|
+
},
|
|
56
|
+
inputSchema: definition.inputSchema,
|
|
57
|
+
async execute (agent, input, context) {
|
|
58
|
+
if ('object' != typeof agent || null === agent || 'function' != typeof agent[definition.method]) throw new TypeError(`getAgent() must return ${agentLabel} with ${definition.method}().`);
|
|
59
|
+
const typedAgent = agent;
|
|
60
|
+
const method = typedAgent[definition.method];
|
|
61
|
+
const typedInput = input;
|
|
62
|
+
const result = await method.apply(typedAgent, definition.toArgs(typedInput, context));
|
|
63
|
+
return definition.toResult?.(result, typedInput);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const nonBlankText = (description)=>v4_namespaceObject.z.string().regex(/\S/, 'value must contain a non-whitespace character').describe(description);
|
|
67
|
+
const promptImageInputSchema = v4_namespaceObject.z.strictObject({
|
|
68
|
+
name: nonBlankText('The name used to identify this reference image.'),
|
|
69
|
+
url: nonBlankText('The URL, data URL, or file path of this reference image.')
|
|
70
|
+
});
|
|
71
|
+
const structuredUserPromptInputSchema = v4_namespaceObject.z.strictObject({
|
|
72
|
+
prompt: nonBlankText('The natural-language prompt.'),
|
|
73
|
+
images: v4_namespaceObject.z.array(promptImageInputSchema).min(1).optional(),
|
|
74
|
+
convertHttpImage2Base64: v4_namespaceObject.z.boolean().optional().describe('Whether HTTP reference images are converted to base64 first.')
|
|
75
|
+
});
|
|
76
|
+
const userPromptInputSchema = v4_namespaceObject.z.union([
|
|
77
|
+
nonBlankText('The natural-language prompt.'),
|
|
78
|
+
structuredUserPromptInputSchema
|
|
79
|
+
]);
|
|
80
|
+
const aiActOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
81
|
+
cacheable: v4_namespaceObject.z.boolean().optional().describe('Whether this action may use the Midscene cache.'),
|
|
82
|
+
fileChooserAccept: v4_namespaceObject.z.union([
|
|
83
|
+
v4_namespaceObject.z.string(),
|
|
84
|
+
v4_namespaceObject.z.array(v4_namespaceObject.z.string())
|
|
85
|
+
]).optional().describe('Accepted file types for a file chooser.'),
|
|
86
|
+
fileChooserAllowedDir: v4_namespaceObject.z.string().optional().describe('Directory allowed for prompt-driven file uploads.'),
|
|
87
|
+
deepThink: v4_namespaceObject.z.union([
|
|
88
|
+
v4_namespaceObject.z.literal('unset'),
|
|
89
|
+
v4_namespaceObject.z.boolean()
|
|
90
|
+
]).optional().describe('Whether to enable deep thinking for this action.'),
|
|
91
|
+
deepLocate: v4_namespaceObject.z.boolean().optional().describe('Whether to use deep element location.'),
|
|
92
|
+
context: v4_namespaceObject.z.string().optional().describe('Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.')
|
|
93
|
+
});
|
|
94
|
+
const aiActInputSchema = v4_namespaceObject.z.strictObject({
|
|
95
|
+
prompt: userPromptInputSchema,
|
|
96
|
+
options: aiActOptionsInputSchema.optional()
|
|
97
|
+
});
|
|
98
|
+
const insightOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
99
|
+
domIncluded: v4_namespaceObject.z.union([
|
|
100
|
+
v4_namespaceObject.z.boolean(),
|
|
101
|
+
v4_namespaceObject.z.literal('visible-only')
|
|
102
|
+
]).optional().describe('How DOM information is included.'),
|
|
103
|
+
screenshotIncluded: v4_namespaceObject.z.boolean().optional().describe('Whether the request includes a screenshot.'),
|
|
104
|
+
context: v4_namespaceObject.z.string().optional().describe('Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.')
|
|
105
|
+
});
|
|
106
|
+
const aiAssertOptionsInputSchema = insightOptionsInputSchema.extend({
|
|
107
|
+
keepRawResponse: v4_namespaceObject.z.boolean().optional().describe('Whether the Agent returns the structured assertion result.')
|
|
108
|
+
});
|
|
109
|
+
const aiAssertInputSchema = v4_namespaceObject.z.strictObject({
|
|
110
|
+
prompt: userPromptInputSchema,
|
|
111
|
+
message: v4_namespaceObject.z.string().optional().describe('The assertion failure message.'),
|
|
112
|
+
options: aiAssertOptionsInputSchema.optional()
|
|
113
|
+
});
|
|
114
|
+
const locateOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
115
|
+
context: v4_namespaceObject.z.string().optional().describe('Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.'),
|
|
116
|
+
deepLocate: v4_namespaceObject.z.boolean().optional().describe('Whether to use deep element location.'),
|
|
117
|
+
deepThink: v4_namespaceObject.z.boolean().optional().describe('Deprecated alias for deepLocate.'),
|
|
118
|
+
cacheable: v4_namespaceObject.z.boolean().optional().describe('Whether this location may use the Midscene cache.'),
|
|
119
|
+
xpath: v4_namespaceObject.z.string().optional().describe('A web XPath location hint.'),
|
|
120
|
+
fileChooserAccept: v4_namespaceObject.z.union([
|
|
121
|
+
v4_namespaceObject.z.string(),
|
|
122
|
+
v4_namespaceObject.z.array(v4_namespaceObject.z.string())
|
|
123
|
+
]).optional().describe('Files accepted when tapping opens a file chooser.')
|
|
124
|
+
});
|
|
125
|
+
const aiTapInputSchema = v4_namespaceObject.z.strictObject({
|
|
126
|
+
prompt: userPromptInputSchema,
|
|
127
|
+
options: locateOptionsInputSchema.optional()
|
|
128
|
+
});
|
|
129
|
+
const insightInputSchema = v4_namespaceObject.z.strictObject({
|
|
130
|
+
prompt: userPromptInputSchema,
|
|
131
|
+
options: insightOptionsInputSchema.optional()
|
|
132
|
+
});
|
|
133
|
+
const reportScreenshotInputSchema = v4_namespaceObject.z.strictObject({
|
|
134
|
+
base64: v4_namespaceObject.z.string().min(1).describe('A base64-encoded screenshot.'),
|
|
135
|
+
description: v4_namespaceObject.z.string().optional().describe('What the screenshot shows.')
|
|
136
|
+
});
|
|
137
|
+
const recordToReportOptionsInputSchema = v4_namespaceObject.z.strictObject({
|
|
138
|
+
content: v4_namespaceObject.z.string().optional().describe('The report text content.'),
|
|
139
|
+
screenshotBase64: v4_namespaceObject.z.string().optional().describe('One base64-encoded screenshot.'),
|
|
140
|
+
screenshots: v4_namespaceObject.z.array(reportScreenshotInputSchema).min(1).optional().describe('Screenshots attached to the report section.')
|
|
141
|
+
}).superRefine((input, context)=>{
|
|
142
|
+
if (void 0 !== input.screenshotBase64 && void 0 !== input.screenshots) context.addIssue({
|
|
143
|
+
code: 'custom',
|
|
144
|
+
message: 'screenshotBase64 and screenshots are mutually exclusive'
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
const recordToReportInputSchema = v4_namespaceObject.z.strictObject({
|
|
148
|
+
title: v4_namespaceObject.z.string().optional().describe('The report section title.'),
|
|
149
|
+
options: recordToReportOptionsInputSchema.optional()
|
|
150
|
+
});
|
|
151
|
+
const defineCommonAgentNode = createAgentTestRunnerNodeDefinition('an Agent');
|
|
152
|
+
const promptText = (prompt)=>'string' == typeof prompt ? prompt : prompt.prompt;
|
|
153
|
+
const aiActNode = defineCommonAgentNode({
|
|
154
|
+
method: 'aiAct',
|
|
155
|
+
description: 'Perform a natural-language task with a Midscene UI Agent.',
|
|
156
|
+
stringInputKey: 'prompt',
|
|
157
|
+
inputSchema: aiActInputSchema,
|
|
158
|
+
toArgs (input, context) {
|
|
159
|
+
return [
|
|
160
|
+
input.prompt,
|
|
161
|
+
{
|
|
162
|
+
...input.options,
|
|
163
|
+
abortSignal: context.signal
|
|
164
|
+
}
|
|
165
|
+
];
|
|
166
|
+
},
|
|
167
|
+
toResult (output) {
|
|
168
|
+
return void 0 === output ? void 0 : {
|
|
169
|
+
summary: output
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const aiTapNode = defineCommonAgentNode({
|
|
174
|
+
method: 'aiTap',
|
|
175
|
+
description: 'Locate and tap an element with a Midscene UI Agent.',
|
|
176
|
+
stringInputKey: 'prompt',
|
|
177
|
+
inputSchema: aiTapInputSchema,
|
|
178
|
+
toArgs (input) {
|
|
179
|
+
return [
|
|
180
|
+
input.prompt,
|
|
181
|
+
input.options
|
|
182
|
+
];
|
|
183
|
+
},
|
|
184
|
+
toResult (_output, input) {
|
|
185
|
+
return {
|
|
186
|
+
summary: `Tapped: ${promptText(input.prompt)}`
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const aiAssertNode = defineCommonAgentNode({
|
|
191
|
+
method: 'aiAssert',
|
|
192
|
+
description: 'Assert a natural-language condition with a Midscene UI Agent.',
|
|
193
|
+
stringInputKey: 'prompt',
|
|
194
|
+
inputSchema: aiAssertInputSchema,
|
|
195
|
+
toArgs (input, context) {
|
|
196
|
+
return [
|
|
197
|
+
input.prompt,
|
|
198
|
+
input.message,
|
|
199
|
+
{
|
|
200
|
+
...input.options,
|
|
201
|
+
abortSignal: context.signal
|
|
202
|
+
}
|
|
203
|
+
];
|
|
204
|
+
},
|
|
205
|
+
toResult (output, input) {
|
|
206
|
+
return {
|
|
207
|
+
summary: `Assertion passed: ${promptText(input.prompt)}`,
|
|
208
|
+
...void 0 === output ? {} : {
|
|
209
|
+
data: {
|
|
210
|
+
pass: output.pass,
|
|
211
|
+
...void 0 === output.thought ? {} : {
|
|
212
|
+
thought: output.thought
|
|
213
|
+
},
|
|
214
|
+
...void 0 === output.message ? {} : {
|
|
215
|
+
message: output.message
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
const insightNode = (method)=>{
|
|
223
|
+
if ('aiBoolean' === method) return defineCommonAgentNode({
|
|
224
|
+
method,
|
|
225
|
+
description: `Run ${method} with a Midscene UI Agent and store its value.`,
|
|
226
|
+
stringInputKey: 'prompt',
|
|
227
|
+
inputSchema: insightInputSchema,
|
|
228
|
+
toArgs: (input)=>[
|
|
229
|
+
input.prompt,
|
|
230
|
+
input.options
|
|
231
|
+
],
|
|
232
|
+
toResult: (value)=>({
|
|
233
|
+
summary: `${method} returned ${value}`,
|
|
234
|
+
data: {
|
|
235
|
+
value
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
if ('aiNumber' === method) return defineCommonAgentNode({
|
|
240
|
+
method,
|
|
241
|
+
description: `Run ${method} with a Midscene UI Agent and store its value.`,
|
|
242
|
+
stringInputKey: 'prompt',
|
|
243
|
+
inputSchema: insightInputSchema,
|
|
244
|
+
toArgs: (input)=>[
|
|
245
|
+
input.prompt,
|
|
246
|
+
input.options
|
|
247
|
+
],
|
|
248
|
+
toResult: (value)=>({
|
|
249
|
+
summary: `${method} returned ${value}`,
|
|
250
|
+
data: {
|
|
251
|
+
value
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
if ('aiString' === method) return defineCommonAgentNode({
|
|
256
|
+
method,
|
|
257
|
+
description: `Run ${method} with a Midscene UI Agent and store its value.`,
|
|
258
|
+
stringInputKey: 'prompt',
|
|
259
|
+
inputSchema: insightInputSchema,
|
|
260
|
+
toArgs: (input)=>[
|
|
261
|
+
input.prompt,
|
|
262
|
+
input.options
|
|
263
|
+
],
|
|
264
|
+
toResult: (value)=>({
|
|
265
|
+
summary: `${method} returned ${JSON.stringify(value)}`,
|
|
266
|
+
data: {
|
|
267
|
+
value
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
return defineCommonAgentNode({
|
|
272
|
+
method,
|
|
273
|
+
description: `Run ${method} with a Midscene UI Agent and store its value.`,
|
|
274
|
+
stringInputKey: 'prompt',
|
|
275
|
+
inputSchema: insightInputSchema,
|
|
276
|
+
toArgs: (input)=>[
|
|
277
|
+
input.prompt,
|
|
278
|
+
input.options
|
|
279
|
+
],
|
|
280
|
+
toResult: (value)=>({
|
|
281
|
+
summary: `${method} returned ${JSON.stringify(value)}`,
|
|
282
|
+
data: {
|
|
283
|
+
value
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
const recordToReportNode = defineCommonAgentNode({
|
|
289
|
+
method: 'recordToReport',
|
|
290
|
+
description: 'Add text or screenshots to the current Midscene report.',
|
|
291
|
+
stringInputKey: 'title',
|
|
292
|
+
inputSchema: recordToReportInputSchema,
|
|
293
|
+
toArgs (input) {
|
|
294
|
+
return [
|
|
295
|
+
input.title,
|
|
296
|
+
input.options
|
|
297
|
+
];
|
|
298
|
+
},
|
|
299
|
+
toResult (_output, input) {
|
|
300
|
+
return {
|
|
301
|
+
summary: `Recorded to report: ${input.title ?? 'untitled'}`
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
const commonAgentTestRunnerNodeDefinitions = [
|
|
306
|
+
aiActNode,
|
|
307
|
+
aiTapNode,
|
|
308
|
+
aiAssertNode,
|
|
309
|
+
insightNode('aiBoolean'),
|
|
310
|
+
insightNode('aiNumber'),
|
|
311
|
+
insightNode('aiString'),
|
|
312
|
+
insightNode('aiAsk'),
|
|
313
|
+
recordToReportNode
|
|
314
|
+
];
|
|
315
|
+
exports.aiActInputSchema = __webpack_exports__.aiActInputSchema;
|
|
316
|
+
exports.aiActOptionsInputSchema = __webpack_exports__.aiActOptionsInputSchema;
|
|
317
|
+
exports.aiAssertInputSchema = __webpack_exports__.aiAssertInputSchema;
|
|
318
|
+
exports.aiAssertOptionsInputSchema = __webpack_exports__.aiAssertOptionsInputSchema;
|
|
319
|
+
exports.aiTapInputSchema = __webpack_exports__.aiTapInputSchema;
|
|
320
|
+
exports.commonAgentTestRunnerNodeDefinitions = __webpack_exports__.commonAgentTestRunnerNodeDefinitions;
|
|
321
|
+
exports.createAgentTestRunnerNodeDefinition = __webpack_exports__.createAgentTestRunnerNodeDefinition;
|
|
322
|
+
exports.insightInputSchema = __webpack_exports__.insightInputSchema;
|
|
323
|
+
exports.insightOptionsInputSchema = __webpack_exports__.insightOptionsInputSchema;
|
|
324
|
+
exports.locateOptionsInputSchema = __webpack_exports__.locateOptionsInputSchema;
|
|
325
|
+
exports.promptImageInputSchema = __webpack_exports__.promptImageInputSchema;
|
|
326
|
+
exports.recordToReportInputSchema = __webpack_exports__.recordToReportInputSchema;
|
|
327
|
+
exports.recordToReportOptionsInputSchema = __webpack_exports__.recordToReportOptionsInputSchema;
|
|
328
|
+
exports.reportScreenshotInputSchema = __webpack_exports__.reportScreenshotInputSchema;
|
|
329
|
+
exports.structuredUserPromptInputSchema = __webpack_exports__.structuredUserPromptInputSchema;
|
|
330
|
+
exports.userPromptInputSchema = __webpack_exports__.userPromptInputSchema;
|
|
331
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
332
|
+
"aiActInputSchema",
|
|
333
|
+
"aiActOptionsInputSchema",
|
|
334
|
+
"aiAssertInputSchema",
|
|
335
|
+
"aiAssertOptionsInputSchema",
|
|
336
|
+
"aiTapInputSchema",
|
|
337
|
+
"commonAgentTestRunnerNodeDefinitions",
|
|
338
|
+
"createAgentTestRunnerNodeDefinition",
|
|
339
|
+
"insightInputSchema",
|
|
340
|
+
"insightOptionsInputSchema",
|
|
341
|
+
"locateOptionsInputSchema",
|
|
342
|
+
"promptImageInputSchema",
|
|
343
|
+
"recordToReportInputSchema",
|
|
344
|
+
"recordToReportOptionsInputSchema",
|
|
345
|
+
"reportScreenshotInputSchema",
|
|
346
|
+
"structuredUserPromptInputSchema",
|
|
347
|
+
"userPromptInputSchema"
|
|
348
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
349
|
+
Object.defineProperty(exports, '__esModule', {
|
|
350
|
+
value: true
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
//# sourceMappingURL=test-runner-nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent/test-runner-nodes.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/test-runner-nodes.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { z } from 'zod/v4';\nimport type { Agent } from './agent';\n\nexport interface AgentTestRunnerNodeResult<TData = unknown> {\n summary?: string;\n data?: TData;\n}\n\nexport interface AgentTestRunnerNodeExecutionContext {\n signal: AbortSignal;\n}\n\n/** Agent-owned Node description consumed by Test Runner adapters. */\nexport interface AgentTestRunnerNodeDefinition<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TData = unknown,\n> {\n name: string;\n title?: string;\n description?: string;\n /** Node input field populated by YAML string shorthand; omit to disable. */\n stringInputKey?: string | false;\n inputSchema: z.ZodObject;\n execute(\n agent: unknown,\n input: TInput,\n context: AgentTestRunnerNodeExecutionContext,\n ):\n | Promise<AgentTestRunnerNodeResult<TData> | undefined>\n | AgentTestRunnerNodeResult<TData>\n | undefined;\n}\n\n/** Static capability implemented by Agent classes that expose Runner Nodes. */\nexport interface AgentTestRunnerNodeProvider {\n getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];\n}\n\ntype AnyAgentMethod = (...args: any[]) => unknown;\ntype AgentMethodName<TAgent extends object> = {\n [TKey in keyof TAgent]-?: TAgent[TKey] extends AnyAgentMethod ? TKey : never;\n}[keyof TAgent] &\n string;\ntype AgentMethod<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n> = Extract<TAgent[TMethod], AnyAgentMethod>;\n\nexport interface DefineAgentTestRunnerNodeOptions<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n> {\n method: TMethod;\n name?: string;\n title?: string;\n description?: string;\n stringInputKey?: (keyof z.output<TSchema> & string) | false;\n inputSchema: TSchema;\n toArgs(\n input: z.output<TSchema>,\n context: AgentTestRunnerNodeExecutionContext,\n ): Parameters<AgentMethod<TAgent, TMethod>>;\n toResult?(\n result: Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>,\n input: z.output<TSchema>,\n ): AgentTestRunnerNodeResult<TData> | undefined;\n}\n\n/** Create a Node factory whose adapters are checked against an Agent API. */\nexport const createAgentTestRunnerNodeDefinition =\n <TAgent extends object>(agentLabel = 'an Agent') =>\n <\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n >(\n definition: DefineAgentTestRunnerNodeOptions<\n TAgent,\n TMethod,\n TSchema,\n TData\n >,\n ): AgentTestRunnerNodeDefinition => ({\n name: definition.name ?? definition.method,\n ...(definition.title === undefined ? {} : { title: definition.title }),\n ...(definition.description === undefined\n ? {}\n : { description: definition.description }),\n ...(definition.stringInputKey === undefined\n ? {}\n : { stringInputKey: definition.stringInputKey }),\n inputSchema: definition.inputSchema,\n async execute(agent, input, context) {\n if (\n typeof agent !== 'object' ||\n agent === null ||\n typeof (agent as Record<string, unknown>)[definition.method] !==\n 'function'\n ) {\n throw new TypeError(\n `getAgent() must return ${agentLabel} with ${definition.method}().`,\n );\n }\n\n const typedAgent = agent as TAgent;\n const method = typedAgent[definition.method] as AgentMethod<\n TAgent,\n TMethod\n >;\n const typedInput = input as z.output<TSchema>;\n const result = (await method.apply(\n typedAgent,\n definition.toArgs(typedInput, context),\n )) as Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>;\n return definition.toResult?.(result, typedInput);\n },\n });\n\nconst nonBlankText = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'value must contain a non-whitespace character')\n .describe(description);\n\nexport const promptImageInputSchema = z.strictObject({\n name: nonBlankText('The name used to identify this reference image.'),\n url: nonBlankText('The URL, data URL, or file path of this reference image.'),\n});\n\nexport const structuredUserPromptInputSchema = z.strictObject({\n prompt: nonBlankText('The natural-language prompt.'),\n images: z.array(promptImageInputSchema).min(1).optional(),\n convertHttpImage2Base64: z\n .boolean()\n .optional()\n .describe('Whether HTTP reference images are converted to base64 first.'),\n});\n\nexport const userPromptInputSchema = z.union([\n nonBlankText('The natural-language prompt.'),\n structuredUserPromptInputSchema,\n]);\n\nexport const aiActOptionsInputSchema = z.strictObject({\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this action may use the Midscene cache.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Accepted file types for a file chooser.'),\n fileChooserAllowedDir: z\n .string()\n .optional()\n .describe('Directory allowed for prompt-driven file uploads.'),\n deepThink: z\n .union([z.literal('unset'), z.boolean()])\n .optional()\n .describe('Whether to enable deep thinking for this action.'),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiActInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const insightOptionsInputSchema = z.strictObject({\n domIncluded: z\n .union([z.boolean(), z.literal('visible-only')])\n .optional()\n .describe('How DOM information is included.'),\n screenshotIncluded: z\n .boolean()\n .optional()\n .describe('Whether the request includes a screenshot.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiAssertOptionsInputSchema = insightOptionsInputSchema.extend({\n keepRawResponse: z\n .boolean()\n .optional()\n .describe('Whether the Agent returns the structured assertion result.'),\n});\n\nexport const aiAssertInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n message: z.string().optional().describe('The assertion failure message.'),\n options: aiAssertOptionsInputSchema.optional(),\n});\n\nexport const locateOptionsInputSchema = z.strictObject({\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n deepThink: z\n .boolean()\n .optional()\n .describe('Deprecated alias for deepLocate.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this location may use the Midscene cache.'),\n xpath: z.string().optional().describe('A web XPath location hint.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Files accepted when tapping opens a file chooser.'),\n});\n\nexport const aiTapInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const insightInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const reportScreenshotInputSchema = z.strictObject({\n base64: z.string().min(1).describe('A base64-encoded screenshot.'),\n description: z.string().optional().describe('What the screenshot shows.'),\n});\n\nexport const recordToReportOptionsInputSchema = z\n .strictObject({\n content: z.string().optional().describe('The report text content.'),\n screenshotBase64: z\n .string()\n .optional()\n .describe('One base64-encoded screenshot.'),\n screenshots: z\n .array(reportScreenshotInputSchema)\n .min(1)\n .optional()\n .describe('Screenshots attached to the report section.'),\n })\n .superRefine((input, context) => {\n if (\n input.screenshotBase64 !== undefined &&\n input.screenshots !== undefined\n ) {\n context.addIssue({\n code: 'custom',\n message: 'screenshotBase64 and screenshots are mutually exclusive',\n });\n }\n });\n\nexport const recordToReportInputSchema = z.strictObject({\n title: z.string().optional().describe('The report section title.'),\n options: recordToReportOptionsInputSchema.optional(),\n});\n\nexport type UserPromptNodeInput = z.infer<typeof userPromptInputSchema>;\nexport type AiActNodeOptions = z.infer<typeof aiActOptionsInputSchema>;\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeOptions = z.infer<typeof aiAssertOptionsInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type AiTapNodeOptions = z.infer<typeof locateOptionsInputSchema>;\nexport type AiTapNodeInput = z.infer<typeof aiTapInputSchema>;\nexport type InsightNodeOptions = z.infer<typeof insightOptionsInputSchema>;\nexport type InsightNodeInput = z.infer<typeof insightInputSchema>;\nexport type RecordToReportNodeOptions = z.infer<\n typeof recordToReportOptionsInputSchema\n>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\n\nexport type CommonAgentTestRunnerApi = Pick<\n Agent,\n | 'aiAct'\n | 'aiTap'\n | 'aiAssert'\n | 'aiBoolean'\n | 'aiNumber'\n | 'aiString'\n | 'aiAsk'\n | 'recordToReport'\n>;\n\nconst defineCommonAgentNode =\n createAgentTestRunnerNodeDefinition<CommonAgentTestRunnerApi>('an Agent');\n\nconst promptText = (prompt: UserPromptNodeInput): string =>\n typeof prompt === 'string' ? prompt : prompt.prompt;\n\nconst aiActNode = defineCommonAgentNode({\n method: 'aiAct',\n description: 'Perform a natural-language task with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiActInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output) {\n return output === undefined ? undefined : { summary: output };\n },\n});\n\nconst aiTapNode = defineCommonAgentNode({\n method: 'aiTap',\n description: 'Locate and tap an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs(input) {\n return [input.prompt, input.options];\n },\n toResult(_output, input) {\n return { summary: `Tapped: ${promptText(input.prompt)}` };\n },\n});\n\nconst aiAssertNode = defineCommonAgentNode({\n method: 'aiAssert',\n description: 'Assert a natural-language condition with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiAssertInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n input.message,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output, input) {\n return {\n summary: `Assertion passed: ${promptText(input.prompt)}`,\n ...(output === undefined\n ? {}\n : {\n data: {\n pass: output.pass,\n ...(output.thought === undefined\n ? {}\n : { thought: output.thought }),\n ...(output.message === undefined\n ? {}\n : { message: output.message }),\n },\n }),\n };\n },\n});\n\nconst insightNode = (\n method: 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk',\n) => {\n if (method === 'aiBoolean') {\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${value}`,\n data: { value },\n }),\n });\n }\n if (method === 'aiNumber') {\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${value}`,\n data: { value },\n }),\n });\n }\n if (method === 'aiString') {\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${JSON.stringify(value)}`,\n data: { value },\n }),\n });\n }\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${JSON.stringify(value)}`,\n data: { value },\n }),\n });\n};\n\nconst recordToReportNode = defineCommonAgentNode({\n method: 'recordToReport',\n description: 'Add text or screenshots to the current Midscene report.',\n stringInputKey: 'title',\n inputSchema: recordToReportInputSchema,\n toArgs(input) {\n return [input.title, input.options];\n },\n toResult(_output, input) {\n return { summary: `Recorded to report: ${input.title ?? 'untitled'}` };\n },\n});\n\nexport const commonAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition[] =\n [\n aiActNode,\n aiTapNode,\n aiAssertNode,\n insightNode('aiBoolean'),\n insightNode('aiNumber'),\n insightNode('aiString'),\n insightNode('aiAsk'),\n recordToReportNode,\n ];\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","createAgentTestRunnerNodeDefinition","agentLabel","undefined","agent","input","context","TypeError","typedAgent","method","typedInput","result","nonBlankText","description","z","promptImageInputSchema","structuredUserPromptInputSchema","userPromptInputSchema","aiActOptionsInputSchema","aiActInputSchema","insightOptionsInputSchema","aiAssertOptionsInputSchema","aiAssertInputSchema","locateOptionsInputSchema","aiTapInputSchema","insightInputSchema","reportScreenshotInputSchema","recordToReportOptionsInputSchema","recordToReportInputSchema","defineCommonAgentNode","promptText","prompt","aiActNode","output","aiTapNode","_output","aiAssertNode","insightNode","value","JSON","recordToReportNode","commonAgentTestRunnerNodeDefinitions"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,e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ACiC,QAAW;gBACpB,SAAS,GAAG7B,OAAO,UAAU,EAAE8B,KAAK,SAAS,CAACD,QAAQ;gBACtD,MAAM;oBAAEA;gBAAM;YAChB;IACF;AACF;AAEA,MAAME,qBAAqBX,sBAAsB;IAC/C,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,aAAaD;IACb,QAAOvB,KAAK;QACV,OAAO;YAACA,MAAM,KAAK;YAAEA,MAAM,OAAO;SAAC;IACrC;IACA,UAAS8B,OAAO,EAAE9B,KAAK;QACrB,OAAO;YAAE,SAAS,CAAC,oBAAoB,EAAEA,MAAM,KAAK,IAAI,YAAY;QAAC;IACvE;AACF;AAEO,MAAMoC,uCACX;IACET;IACAE;IACAE;IACAC,YAAY;IACZA,YAAY;IACZA,YAAY;IACZA,YAAY;IACZG;CACD"}
|
package/dist/lib/agent/utils.js
CHANGED
|
@@ -205,7 +205,7 @@ async function matchElementFromCache(context, cacheEntry, cachePrompt, cacheable
|
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
const getMidsceneVersion = ()=>"1.12.4
|
|
208
|
+
const getMidsceneVersion = ()=>"1.12.4";
|
|
209
209
|
const parsePrompt = (prompt)=>{
|
|
210
210
|
if ('string' == typeof prompt) return {
|
|
211
211
|
textPrompt: prompt,
|
|
@@ -36,7 +36,7 @@ function buildTypeQueryDemandValue(type, demand) {
|
|
|
36
36
|
const extractDataQueryPrompt = (pageDescription, dataQuery, context)=>{
|
|
37
37
|
const dataQueryText = 'string' == typeof dataQuery ? dataQuery : JSON.stringify(dataQuery, null, 2);
|
|
38
38
|
const trimmedContext = context?.trim();
|
|
39
|
-
const contextSection = trimmedContext ? `\n
|
|
39
|
+
const contextSection = trimmedContext ? `\n${trimmedContext}\n` : '';
|
|
40
40
|
return `
|
|
41
41
|
<PageDescription>
|
|
42
42
|
${pageDescription}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/prompt/insight/user-prompt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/prompt/insight/user-prompt.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { ServiceExtractParam } from '@/types';\n\nexport function buildTypeQueryDemandValue(\n type: 'Boolean' | 'Number' | 'String' | 'Assert' | 'WaitFor',\n demand: ServiceExtractParam,\n) {\n const currentScreenshotConstraint =\n 'based on the current screenshot and its contents if provided, unless the user explicitly asks to compare with reference images';\n\n if (type === 'Assert') {\n return `Boolean, ${currentScreenshotConstraint}, whether the following statement is true: ${demand}`;\n }\n\n if (type === 'WaitFor') {\n return `Boolean, the user wants to do some 'wait for' operation. ${currentScreenshotConstraint}, please check whether the following statement is true: ${demand}`;\n }\n\n return `${type}, ${currentScreenshotConstraint}, ${demand}`;\n}\n\nexport const extractDataQueryPrompt = (\n pageDescription: string,\n dataQuery: string | Record<string, string>,\n context?: string,\n) => {\n const dataQueryText =\n typeof dataQuery === 'string'\n ? dataQuery\n : JSON.stringify(dataQuery, null, 2);\n\n const trimmedContext = context?.trim();\n const contextSection = trimmedContext
|
|
1
|
+
{"version":3,"file":"ai-model/prompt/insight/user-prompt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/prompt/insight/user-prompt.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { ServiceExtractParam } from '@/types';\n\nexport function buildTypeQueryDemandValue(\n type: 'Boolean' | 'Number' | 'String' | 'Assert' | 'WaitFor',\n demand: ServiceExtractParam,\n) {\n const currentScreenshotConstraint =\n 'based on the current screenshot and its contents if provided, unless the user explicitly asks to compare with reference images';\n\n if (type === 'Assert') {\n return `Boolean, ${currentScreenshotConstraint}, whether the following statement is true: ${demand}`;\n }\n\n if (type === 'WaitFor') {\n return `Boolean, the user wants to do some 'wait for' operation. ${currentScreenshotConstraint}, please check whether the following statement is true: ${demand}`;\n }\n\n return `${type}, ${currentScreenshotConstraint}, ${demand}`;\n}\n\nexport const extractDataQueryPrompt = (\n pageDescription: string,\n dataQuery: string | Record<string, string>,\n context?: string,\n) => {\n const dataQueryText =\n typeof dataQuery === 'string'\n ? dataQuery\n : JSON.stringify(dataQuery, null, 2);\n\n const trimmedContext = context?.trim();\n const contextSection = trimmedContext ? `\\n${trimmedContext}\\n` : '';\n\n return `\n<PageDescription>\n${pageDescription}\n</PageDescription>\n${contextSection}\n<DATA_DEMAND>\n${dataQueryText}\n</DATA_DEMAND>\n `;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildTypeQueryDemandValue","type","demand","currentScreenshotConstraint","extractDataQueryPrompt","pageDescription","dataQuery","context","dataQueryText","JSON","trimmedContext","contextSection"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,Q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namespaceObject = require("@midscene/shared/logger");
|
|
30
|
+
const prompt_context_js_namespaceObject = require("../../../agent/prompt-context.js");
|
|
30
31
|
const index_js_namespaceObject = require("../../prompt/insight/index.js");
|
|
31
32
|
const external_service_caller_index_js_namespaceObject = require("../../service-caller/index.js");
|
|
32
33
|
const semantic_retry_js_namespaceObject = require("../../service-caller/semantic-retry.js");
|
|
@@ -42,7 +43,8 @@ async function AiExtractElementInfo(options) {
|
|
|
42
43
|
insightProtocol
|
|
43
44
|
});
|
|
44
45
|
const screenshotBase64 = context.screenshot.base64;
|
|
45
|
-
const
|
|
46
|
+
const renderedContext = (0, prompt_context_js_namespaceObject.renderAIContext)(extractOption?.context);
|
|
47
|
+
const extractDataPromptText = (0, index_js_namespaceObject.extractDataQueryPrompt)(options.pageDescription || '', dataQuery, renderedContext);
|
|
46
48
|
const userContent = [];
|
|
47
49
|
if (extractOption?.screenshotIncluded !== false) {
|
|
48
50
|
const screenshotSequence = context.screenshotSequence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/workflows/insight/extraction.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/insight/extraction.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { ServiceExtractOption, UIContext } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport type {\n ChatCompletionSystemMessageParam,\n ChatCompletionUserMessageParam,\n} from 'openai/resources/index';\nimport type { TMultimodalPrompt } from '../../../common';\nimport type { ModelRuntime } from '../../models';\nimport {\n buildInsightSystemPrompt,\n extractDataQueryPrompt,\n} from '../../prompt/insight';\nimport { AIResponseParseError, callAI } from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport { multimodalPromptToChatMessages } from '../../shared/multimodal-prompt';\nimport { parseInsightResponse } from './insight-response-parser';\n\ntype InsightAIArgs = [\n ChatCompletionSystemMessageParam,\n ...ChatCompletionUserMessageParam[],\n];\n\nconst debugInsight = getDebug('ai:insight');\n\nexport async function AiExtractElementInfo<T>(options: {\n dataQuery: string | Record<string, string>;\n multimodalPrompt?: TMultimodalPrompt;\n context: UIContext;\n pageDescription?: string;\n extractOption?: ServiceExtractOption;\n modelRuntime: ModelRuntime;\n abortSignal?: AbortSignal;\n}) {\n const { dataQuery, context, extractOption, multimodalPrompt, modelRuntime } =\n options;\n const insightProtocol = modelRuntime.adapter.insight.protocol;\n const systemPrompt = buildInsightSystemPrompt({\n screenshotIncluded: extractOption?.screenshotIncluded !== false,\n referenceImagesIncluded: !!multimodalPrompt?.images?.length,\n insightProtocol,\n });\n const screenshotBase64 = context.screenshot.base64;\n const extractDataPromptText = extractDataQueryPrompt(\n options.pageDescription || '',\n dataQuery,\n extractOption?.context,\n );\n\n const userContent: ChatCompletionUserMessageParam['content'] = [];\n\n if (extractOption?.screenshotIncluded !== false) {\n const screenshotSequence = context.screenshotSequence;\n if (screenshotSequence && screenshotSequence.length > 1) {\n userContent.push({\n type: 'text',\n text: `The following ${screenshotSequence.length} images are consecutive screenshots captured over a time window, ordered from earliest to latest (Frame 1 is first, Frame ${screenshotSequence.length} is last). They record what appeared on screen during that window. Some UI elements such as toasts, banners, or transitions may appear only in certain frames and be gone by later ones. Interpret the temporal scope from the statement or question itself: if it asks whether something appeared at any point, inspect the whole sequence; if it asks about the final or current state, use the relevant later frame; if it asks about a change or sequence, compare frames in order. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on these screenshots and their contents.`,\n });\n\n screenshotSequence.forEach((frame, index) => {\n userContent.push({\n type: 'text',\n text: `Frame ${index + 1}/${screenshotSequence.length}`,\n });\n userContent.push({\n type: 'image_url',\n image_url: {\n url: frame.base64,\n detail: 'high',\n },\n });\n });\n } else {\n userContent.push({\n type: 'text',\n text: 'This is the current screenshot to evaluate. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on this screenshot and its contents when provided.',\n });\n\n userContent.push({\n type: 'image_url',\n image_url: {\n url: screenshotBase64,\n detail: 'high',\n },\n });\n }\n }\n\n userContent.push({\n type: 'text',\n text: extractDataPromptText,\n });\n\n const msgs: InsightAIArgs = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: userContent,\n },\n ];\n\n if (multimodalPrompt) {\n const addOns = await multimodalPromptToChatMessages(multimodalPrompt);\n msgs.push(...addOns);\n }\n\n return callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callAI(\n withSemanticRetryFeedback(msgs, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const {\n content: rawResponse,\n usage,\n reasoning_content,\n rawChoiceMessage,\n } = response;\n const parseResult = parseInsightResponse<T>(\n rawResponse,\n insightProtocol.dataOutput,\n modelRuntime.adapter.jsonParser,\n );\n return {\n parseResult,\n rawResponse,\n rawChoiceMessage,\n usage,\n reasoning_content,\n };\n },\n toParseError: (parseError, response) => {\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n return new AIResponseParseError(\n `XML parse error: ${errorMessage}`,\n response.content,\n response.usage,\n response.rawChoiceMessage,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugInsight(\n 'retrying insight after XML parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugInsight","getDebug","AiExtractElementInfo","options","dataQuery","context","extractOption","multimodalPrompt","modelRuntime","insightProtocol","systemPrompt","buildInsightSystemPrompt","screenshotBase64","extractDataPromptText","extractDataQueryPrompt","userContent","screenshotSequence","frame","index","msgs","addOns","multimodalPromptToChatMessages","callAiAndParseWithRetry","retryAttempt","previousParseError","callAI","withSemanticRetryFeedback","response","rawResponse","usage","reasoning_content","rawChoiceMessage","parseResult","parseInsightResponse","parseError","errorMessage","Error","String","AIResponseParseError","error"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;ACmBA,MAAMI,eAAeC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AAEvB,eAAeC,qBAAwBC,OAQ7C;IACC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAEC,aAAa,EAAEC,gBAAgB,EAAEC,YAAY,EAAE,GACzEL;IACF,MAAMM,kBAAkBD,aAAa,OAAO,CAAC,OAAO,CAAC,QAAQ;IA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C,AAAAA,IAAAA,qCAAAA,8BAAAA,AAAAA,EAA+Bd;QACpDY,KAAK,IAAI,IAAIC;IACf;IAEA,OAAOE,AAAAA,IAAAA,kCAAAA,uBAAAA,AAAAA,EAAwB;QAC7B,QAAQ,CAACC,cAAcC,qBACrBC,AAAAA,IAAAA,iDAAAA,MAAAA,AAAAA,EACEC,AAAAA,IAAAA,kCAAAA,yBAAAA,AAAAA,EAA0BP,MAAMK,qBAChChB,cACA;gBACE,aAAaL,QAAQ,WAAW;gBAChC,sBAAsBoB;YACxB;QAEJ,eAAe,CAACI;YACd,MAAM,EACJ,SAASC,WAAW,EACpBC,KAAK,EACLC,iBAAiB,EACjBC,gBAAgB,EACjB,GAAGJ;YACJ,MAAMK,cAAcC,AAAAA,IAAAA,oDAAAA,oBAAAA,AAAAA,EAClBL,aACAnB,gBAAgB,UAAU,EAC1BD,aAAa,OAAO,CAAC,UAAU;YAEjC,OAAO;gBACLwB;gBACAJ;gBACAG;gBACAF;gBACAC;YACF;QACF;QACA,cAAc,CAACI,YAAYP;YACzB,MAAMQ,eACJD,sBAAsBE,QAAQF,WAAW,OAAO,GAAGG,OAAOH;YAC5D,OAAO,IAAII,iDAAAA,oBAAoBA,CAC7B,CAAC,iBAAiB,EAAEH,cAAc,EAClCR,SAAS,OAAO,EAChBA,SAAS,KAAK,EACdA,SAAS,gBAAgB;QAE7B;QACA,iBAAiBnB,aAAa,MAAM,CAAC,UAAU;QAC/C,oBAAoBA,aAAa,MAAM,CAAC,aAAa;QACrD,aAAaL,QAAQ,WAAW;QAChC,cAAc,CAACoC;YACbvC,aACE,iDACAuC,iBAAiBH,QAAQG,MAAM,OAAO,GAAGF,OAAOE;QAEpD;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"ai-model/workflows/insight/extraction.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/insight/extraction.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { ServiceExtractOption, UIContext } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport type {\n ChatCompletionSystemMessageParam,\n ChatCompletionUserMessageParam,\n} from 'openai/resources/index';\nimport { renderAIContext } from '../../../agent/prompt-context';\nimport type { TMultimodalPrompt } from '../../../common';\nimport type { ModelRuntime } from '../../models';\nimport {\n buildInsightSystemPrompt,\n extractDataQueryPrompt,\n} from '../../prompt/insight';\nimport { AIResponseParseError, callAI } from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport { multimodalPromptToChatMessages } from '../../shared/multimodal-prompt';\nimport { parseInsightResponse } from './insight-response-parser';\n\ntype InsightAIArgs = [\n ChatCompletionSystemMessageParam,\n ...ChatCompletionUserMessageParam[],\n];\n\nconst debugInsight = getDebug('ai:insight');\n\nexport async function AiExtractElementInfo<T>(options: {\n dataQuery: string | Record<string, string>;\n multimodalPrompt?: TMultimodalPrompt;\n context: UIContext;\n pageDescription?: string;\n extractOption?: ServiceExtractOption;\n modelRuntime: ModelRuntime;\n abortSignal?: AbortSignal;\n}) {\n const { dataQuery, context, extractOption, multimodalPrompt, modelRuntime } =\n options;\n const insightProtocol = modelRuntime.adapter.insight.protocol;\n const systemPrompt = buildInsightSystemPrompt({\n screenshotIncluded: extractOption?.screenshotIncluded !== false,\n referenceImagesIncluded: !!multimodalPrompt?.images?.length,\n insightProtocol,\n });\n const screenshotBase64 = context.screenshot.base64;\n\n const renderedContext = renderAIContext(extractOption?.context);\n const extractDataPromptText = extractDataQueryPrompt(\n options.pageDescription || '',\n dataQuery,\n renderedContext,\n );\n\n const userContent: ChatCompletionUserMessageParam['content'] = [];\n\n if (extractOption?.screenshotIncluded !== false) {\n const screenshotSequence = context.screenshotSequence;\n if (screenshotSequence && screenshotSequence.length > 1) {\n userContent.push({\n type: 'text',\n text: `The following ${screenshotSequence.length} images are consecutive screenshots captured over a time window, ordered from earliest to latest (Frame 1 is first, Frame ${screenshotSequence.length} is last). They record what appeared on screen during that window. Some UI elements such as toasts, banners, or transitions may appear only in certain frames and be gone by later ones. Interpret the temporal scope from the statement or question itself: if it asks whether something appeared at any point, inspect the whole sequence; if it asks about the final or current state, use the relevant later frame; if it asks about a change or sequence, compare frames in order. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on these screenshots and their contents.`,\n });\n\n screenshotSequence.forEach((frame, index) => {\n userContent.push({\n type: 'text',\n text: `Frame ${index + 1}/${screenshotSequence.length}`,\n });\n userContent.push({\n type: 'image_url',\n image_url: {\n url: frame.base64,\n detail: 'high',\n },\n });\n });\n } else {\n userContent.push({\n type: 'text',\n text: 'This is the current screenshot to evaluate. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on this screenshot and its contents when provided.',\n });\n\n userContent.push({\n type: 'image_url',\n image_url: {\n url: screenshotBase64,\n detail: 'high',\n },\n });\n }\n }\n\n userContent.push({\n type: 'text',\n text: extractDataPromptText,\n });\n\n const msgs: InsightAIArgs = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: userContent,\n },\n ];\n\n if (multimodalPrompt) {\n const addOns = await multimodalPromptToChatMessages(multimodalPrompt);\n msgs.push(...addOns);\n }\n\n return callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callAI(\n withSemanticRetryFeedback(msgs, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const {\n content: rawResponse,\n usage,\n reasoning_content,\n rawChoiceMessage,\n } = response;\n const parseResult = parseInsightResponse<T>(\n rawResponse,\n insightProtocol.dataOutput,\n modelRuntime.adapter.jsonParser,\n );\n return {\n parseResult,\n rawResponse,\n rawChoiceMessage,\n usage,\n reasoning_content,\n };\n },\n toParseError: (parseError, response) => {\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n return new AIResponseParseError(\n `XML parse error: ${errorMessage}`,\n response.content,\n response.usage,\n response.rawChoiceMessage,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugInsight(\n 'retrying insight after XML parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugInsight","getDebug","AiExtractElementInfo","options","dataQuery","context","extractOption","multimodalPrompt","modelRuntime","insightProtocol","systemPrompt","buildInsightSystemPrompt","screenshotBase64","renderedContext","renderAIContext","extractDataPromptText","extractDataQueryPrompt","userContent","screenshotSequence","frame","index","msgs","addOns","multimodalPromptToChatMessages","callAiAndParseWithRetry","retryAttempt","previousParseError","callAI","withSemanticRetryFeedback","response","rawResponse","usage","reasoning_content","rawChoiceMessage","parseResult","parseInsightResponse","parseError","errorMessage","Error","String","AIResponseParseError","error"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAA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,MAAMQ,eACJD,sBAAsBE,QAAQF,WAAW,OAAO,GAAGG,OAAOH;YAC5D,OAAO,IAAII,iDAAAA,oBAAoBA,CAC7B,CAAC,iBAAiB,EAAEH,cAAc,EAClCR,SAAS,OAAO,EAChBA,SAAS,KAAK,EACdA,SAAS,gBAAgB;QAE7B;QACA,iBAAiBrB,aAAa,MAAM,CAAC,UAAU;QAC/C,oBAAoBA,aAAa,MAAM,CAAC,aAAa;QACrD,aAAaL,QAAQ,WAAW;QAChC,cAAc,CAACsC;YACbzC,aACE,iDACAyC,iBAAiBH,QAAQG,MAAM,OAAO,GAAGF,OAAOE;QAEpD;IACF;AACF"}
|
|
@@ -32,13 +32,13 @@ const image_preprocess_js_namespaceObject = require("../../model-adapter/image-p
|
|
|
32
32
|
const index_js_namespaceObject = require("../../service-caller/index.js");
|
|
33
33
|
const multimodal_prompt_js_namespaceObject = require("../../shared/multimodal-prompt.js");
|
|
34
34
|
const external_locate_normalization_js_namespaceObject = require("./locate-normalization.js");
|
|
35
|
-
function
|
|
36
|
-
return systemPrompt + (actionContext ?
|
|
35
|
+
function appendActionContext(systemPrompt, actionContext) {
|
|
36
|
+
return systemPrompt + (actionContext ? `${actionContext}\n` : '');
|
|
37
37
|
}
|
|
38
38
|
function buildCustomPlanningMessages(input, config) {
|
|
39
39
|
const { options } = input;
|
|
40
40
|
const { conversationHistory, context, actionContext } = options;
|
|
41
|
-
const systemPrompt =
|
|
41
|
+
const systemPrompt = appendActionContext(config.buildSystemPrompt(), actionContext);
|
|
42
42
|
const userInstructionText = input.userInstruction.text;
|
|
43
43
|
const userInstruction = config.buildUserInstruction ? config.buildUserInstruction(userInstructionText) : userInstructionText;
|
|
44
44
|
const referenceImageMessages = (0, multimodal_prompt_js_namespaceObject.preparedReferenceImagesToChatMessages)(input.userInstruction.referenceImages);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/workflows/planning/custom-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/planning/custom-planning.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { PlanningAIResponse, PlanningAction } from '@/types';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport { ScreenshotItem } from '../../../screenshot-item';\nimport type {\n CustomPlanningInput,\n CustomPlanningMessageConfig,\n ResolvedCustomPlanningDefinition,\n} from '../../model-adapter/custom-planning-types';\nimport { prepareModelImage } from '../../model-adapter/image-preprocess';\nimport type { ParsedPlanningLocateParameter } from '../../model-adapter/planning-protocol';\nimport {\n AIResponseParseError,\n callAIWithStringResponse,\n} from '../../service-caller/index';\nimport {\n type PreparedUserPrompt,\n preparedReferenceImagesToChatMessages,\n} from '../../shared/multimodal-prompt';\nimport { normalizePlanningActionLocateFields } from './locate-normalization';\nimport type { PlanOptions } from './types';\n\nfunction appendHighPriorityKnowledge(\n systemPrompt: string,\n actionContext?: string,\n): string {\n return (\n systemPrompt +\n (actionContext\n ? `<high_priority_knowledge>${actionContext}</high_priority_knowledge>\\n`\n : '')\n );\n}\n\nexport function buildCustomPlanningMessages<TParsed>(\n input: CustomPlanningInput,\n config: CustomPlanningMessageConfig<TParsed>,\n): ChatCompletionMessageParam[] {\n const { options } = input;\n const { conversationHistory, context, actionContext } = options;\n const systemPrompt = appendHighPriorityKnowledge(\n config.buildSystemPrompt(),\n actionContext,\n );\n const userInstructionText = input.userInstruction.text;\n const userInstruction = config.buildUserInstruction\n ? config.buildUserInstruction(userInstructionText)\n : userInstructionText;\n const referenceImageMessages = preparedReferenceImagesToChatMessages(\n input.userInstruction.referenceImages,\n );\n\n if (conversationHistory.pendingFeedbackMessage) {\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.`,\n },\n ],\n });\n conversationHistory.resetPendingFeedbackMessageIfExists();\n }\n\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'image_url',\n image_url: { url: context.screenshot.base64 },\n },\n ],\n });\n\n if (config.systemPromptPlacement === 'system-message') {\n return [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [{ type: 'text', text: userInstruction }],\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n }\n\n return [\n {\n role: 'user',\n content: `${systemPrompt}${userInstruction}`,\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n}\n\nexport async function runCustomPlanning<TParsed>(\n userInstruction: PreparedUserPrompt,\n options: PlanOptions,\n config: ResolvedCustomPlanningDefinition<TParsed>,\n): Promise<PlanningAIResponse> {\n const { context } = options;\n const preparedImage = await prepareModelImage({\n imageBase64: context.screenshot.base64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n policy: options.modelRuntime.adapter.imagePreprocess,\n });\n const preparedOptions: PlanOptions = {\n ...options,\n context: {\n ...context,\n screenshot: ScreenshotItem.create(\n preparedImage.imageBase64,\n context.screenshot.capturedAt,\n ),\n shotSize: preparedImage.preparedSize,\n },\n };\n const input: CustomPlanningInput = {\n userInstruction,\n options: preparedOptions,\n coordinateSystem: config.coordinateSystem,\n };\n\n const messages = buildCustomPlanningMessages(input, config.messages);\n const { content, usage, rawChoiceMessage } = await callAIWithStringResponse(\n messages,\n preparedOptions.modelRuntime,\n {\n abortSignal: preparedOptions.abortSignal,\n requiresOriginalImageDetail: preparedOptions.includeLocateInPlanning,\n },\n );\n\n let parsed: TParsed;\n let actions: PlanningAction[];\n let shouldContinuePlanning: boolean;\n\n try {\n parsed = config.parseResponse(content, input);\n actions = config.transformActions(parsed, input);\n normalizePlanningActionLocateFields(actions, {\n actionSpace: preparedOptions.actionSpace,\n includeLocateInPlanning: preparedOptions.includeLocateInPlanning,\n locateResultCodec: config.coordinateNormalizer,\n locateResultContext: {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n },\n acceptBbox2dAlias: preparedOptions.modelRuntime.adapter.acceptBbox2dAlias,\n parseRawLocateParameter: (value) =>\n value as ParsedPlanningLocateParameter,\n });\n shouldContinuePlanning = config.shouldContinuePlanning(parsed, actions);\n } catch (parseError) {\n const errorMessage = `Parse error: ${\n parseError instanceof Error ? parseError.message : String(parseError)\n }`;\n throw new AIResponseParseError(\n errorMessage,\n JSON.stringify(content, undefined, 2),\n usage,\n rawChoiceMessage,\n );\n }\n\n const assistantContent = config.messages.buildAssistantContent?.(\n parsed,\n content,\n input,\n );\n // UI-TARS and Auto-GLM define their own assistant history format.\n if (assistantContent) {\n options.conversationHistory.append({\n role: 'assistant',\n content: assistantContent,\n });\n }\n\n return {\n actions,\n log: config.buildResponseLog(parsed, content),\n usage,\n shouldContinuePlanning,\n rawResponse: JSON.stringify(content, undefined, 2),\n rawChoiceMessage,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","appendHighPriorityKnowledge","systemPrompt","actionContext","buildCustomPlanningMessages","input","config","options","conversationHistory","context","userInstructionText","userInstruction","referenceImageMessages","preparedReferenceImagesToChatMessages","runCustomPlanning","preparedImage","prepareModelImage","preparedOptions","ScreenshotItem","messages","content","usage","rawChoiceMessage","callAIWithStringResponse","parsed","actions","shouldContinuePlanning","normalizePlanningActionLocateFields","value","parseError","errorMessage","Error","String","AIResponseParseError","JSON","undefined","assistantContent"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC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
|
+
{"version":3,"file":"ai-model/workflows/planning/custom-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/planning/custom-planning.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { PlanningAIResponse, PlanningAction } from '@/types';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport { ScreenshotItem } from '../../../screenshot-item';\nimport type {\n CustomPlanningInput,\n CustomPlanningMessageConfig,\n ResolvedCustomPlanningDefinition,\n} from '../../model-adapter/custom-planning-types';\nimport { prepareModelImage } from '../../model-adapter/image-preprocess';\nimport type { ParsedPlanningLocateParameter } from '../../model-adapter/planning-protocol';\nimport {\n AIResponseParseError,\n callAIWithStringResponse,\n} from '../../service-caller/index';\nimport {\n type PreparedUserPrompt,\n preparedReferenceImagesToChatMessages,\n} from '../../shared/multimodal-prompt';\nimport { normalizePlanningActionLocateFields } from './locate-normalization';\nimport type { PlanOptions } from './types';\n\nfunction appendActionContext(\n systemPrompt: string,\n actionContext?: string,\n): string {\n return systemPrompt + (actionContext ? `${actionContext}\\n` : '');\n}\n\nexport function buildCustomPlanningMessages<TParsed>(\n input: CustomPlanningInput,\n config: CustomPlanningMessageConfig<TParsed>,\n): ChatCompletionMessageParam[] {\n const { options } = input;\n const { conversationHistory, context, actionContext } = options;\n const systemPrompt = appendActionContext(\n config.buildSystemPrompt(),\n actionContext,\n );\n const userInstructionText = input.userInstruction.text;\n const userInstruction = config.buildUserInstruction\n ? config.buildUserInstruction(userInstructionText)\n : userInstructionText;\n const referenceImageMessages = preparedReferenceImagesToChatMessages(\n input.userInstruction.referenceImages,\n );\n\n if (conversationHistory.pendingFeedbackMessage) {\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.`,\n },\n ],\n });\n conversationHistory.resetPendingFeedbackMessageIfExists();\n }\n\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'image_url',\n image_url: { url: context.screenshot.base64 },\n },\n ],\n });\n\n if (config.systemPromptPlacement === 'system-message') {\n return [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [{ type: 'text', text: userInstruction }],\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n }\n\n return [\n {\n role: 'user',\n content: `${systemPrompt}${userInstruction}`,\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n}\n\nexport async function runCustomPlanning<TParsed>(\n userInstruction: PreparedUserPrompt,\n options: PlanOptions,\n config: ResolvedCustomPlanningDefinition<TParsed>,\n): Promise<PlanningAIResponse> {\n const { context } = options;\n const preparedImage = await prepareModelImage({\n imageBase64: context.screenshot.base64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n policy: options.modelRuntime.adapter.imagePreprocess,\n });\n const preparedOptions: PlanOptions = {\n ...options,\n context: {\n ...context,\n screenshot: ScreenshotItem.create(\n preparedImage.imageBase64,\n context.screenshot.capturedAt,\n ),\n shotSize: preparedImage.preparedSize,\n },\n };\n const input: CustomPlanningInput = {\n userInstruction,\n options: preparedOptions,\n coordinateSystem: config.coordinateSystem,\n };\n\n const messages = buildCustomPlanningMessages(input, config.messages);\n const { content, usage, rawChoiceMessage } = await callAIWithStringResponse(\n messages,\n preparedOptions.modelRuntime,\n {\n abortSignal: preparedOptions.abortSignal,\n requiresOriginalImageDetail: preparedOptions.includeLocateInPlanning,\n },\n );\n\n let parsed: TParsed;\n let actions: PlanningAction[];\n let shouldContinuePlanning: boolean;\n\n try {\n parsed = config.parseResponse(content, input);\n actions = config.transformActions(parsed, input);\n normalizePlanningActionLocateFields(actions, {\n actionSpace: preparedOptions.actionSpace,\n includeLocateInPlanning: preparedOptions.includeLocateInPlanning,\n locateResultCodec: config.coordinateNormalizer,\n locateResultContext: {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n },\n acceptBbox2dAlias: preparedOptions.modelRuntime.adapter.acceptBbox2dAlias,\n parseRawLocateParameter: (value) =>\n value as ParsedPlanningLocateParameter,\n });\n shouldContinuePlanning = config.shouldContinuePlanning(parsed, actions);\n } catch (parseError) {\n const errorMessage = `Parse error: ${\n parseError instanceof Error ? parseError.message : String(parseError)\n }`;\n throw new AIResponseParseError(\n errorMessage,\n JSON.stringify(content, undefined, 2),\n usage,\n rawChoiceMessage,\n );\n }\n\n const assistantContent = config.messages.buildAssistantContent?.(\n parsed,\n content,\n input,\n );\n // UI-TARS and Auto-GLM define their own assistant history format.\n if (assistantContent) {\n options.conversationHistory.append({\n role: 'assistant',\n content: assistantContent,\n });\n }\n\n return {\n actions,\n log: config.buildResponseLog(parsed, content),\n usage,\n shouldContinuePlanning,\n rawResponse: JSON.stringify(content, undefined, 2),\n rawChoiceMessage,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","appendActionContext","systemPrompt","actionContext","buildCustomPlanningMessages","input","config","options","conversationHistory","context","userInstructionText","userInstruction","referenceImageMessages","preparedReferenceImagesToChatMessages","runCustomPlanning","preparedImage","prepareModelImage","preparedOptions","ScreenshotItem","messages","content","usage","rawChoiceMessage","callAIWithStringResponse","parsed","actions","shouldContinuePlanning","normalizePlanningActionLocateFields","value","parseError","errorMessage","Error","String","AIResponseParseError","JSON","undefined","assistantContent"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,U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@@ -129,7 +129,7 @@ async function standardPlan(userInstruction, opts) {
|
|
|
129
129
|
policy: adapter.imagePreprocess
|
|
130
130
|
});
|
|
131
131
|
const imagePayload = preparedImage.imageBase64;
|
|
132
|
-
const actionContext = opts.actionContext ?
|
|
132
|
+
const actionContext = opts.actionContext ? `${opts.actionContext}\n` : '';
|
|
133
133
|
const referenceImageMessages = (0, multimodal_prompt_js_namespaceObject.preparedReferenceImagesToChatMessages)(userInstruction.referenceImages);
|
|
134
134
|
const instruction = [
|
|
135
135
|
{
|