@midscene/core 0.26.2-beta-20250812091127.0 → 0.26.3-beta-20250813021342.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/ai-model.mjs +2502 -0
- package/dist/es/ai-model.mjs.map +1 -0
- package/dist/es/index.mjs +2362 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/tree.mjs +2 -0
- package/dist/es/utils.mjs +188 -0
- package/dist/es/{chunk-WXNDYUNG.js.map → utils.mjs.map} +1 -1
- package/dist/lib/ai-model.js +2581 -3
- package/dist/lib/ai-model.js.map +1 -0
- package/dist/lib/index.js +2375 -493
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/tree.js +42 -11
- package/dist/lib/tree.js.map +1 -1
- package/dist/lib/utils.js +257 -29
- package/dist/lib/utils.js.map +1 -0
- package/dist/types/ai-model.d.ts +505 -99
- package/dist/types/index.d.ts +1299 -53
- package/dist/types/tree.d.ts +11 -1
- package/dist/types/utils.d.ts +47 -33
- package/package.json +28 -12
- package/dist/es/ai-model.d.ts +0 -99
- package/dist/es/ai-model.js +0 -44
- package/dist/es/chunk-DDYIQHOA.js +0 -2883
- package/dist/es/chunk-DDYIQHOA.js.map +0 -1
- package/dist/es/chunk-WXNDYUNG.js +0 -265
- package/dist/es/index.d.ts +0 -53
- package/dist/es/index.js +0 -570
- package/dist/es/index.js.map +0 -1
- package/dist/es/llm-planning-4e0c16fe.d.ts +0 -106
- package/dist/es/tree.d.ts +0 -1
- package/dist/es/tree.js +0 -13
- package/dist/es/tree.js.map +0 -1
- package/dist/es/types-8a6be57c.d.ts +0 -577
- package/dist/es/utils.d.ts +0 -33
- package/dist/es/utils.js +0 -30
- package/dist/lib/ai-model.d.ts +0 -99
- package/dist/lib/chunk-DDYIQHOA.js +0 -2883
- package/dist/lib/chunk-DDYIQHOA.js.map +0 -1
- package/dist/lib/chunk-WXNDYUNG.js +0 -265
- package/dist/lib/chunk-WXNDYUNG.js.map +0 -1
- package/dist/lib/index.d.ts +0 -53
- package/dist/lib/llm-planning-4e0c16fe.d.ts +0 -106
- package/dist/lib/tree.d.ts +0 -1
- package/dist/lib/types-8a6be57c.d.ts +0 -577
- package/dist/lib/utils.d.ts +0 -33
- package/dist/types/llm-planning-4e0c16fe.d.ts +0 -106
- package/dist/types/types-8a6be57c.d.ts +0 -577
|
@@ -1,577 +0,0 @@
|
|
|
1
|
-
import { NodeType } from '@midscene/shared/constants';
|
|
2
|
-
import { BaseElement, Rect, ElementTreeNode, Size } from '@midscene/shared/types';
|
|
3
|
-
import { ChatCompletionMessageParam } from 'openai/resources';
|
|
4
|
-
|
|
5
|
-
interface LocateOption {
|
|
6
|
-
deepThink?: boolean;
|
|
7
|
-
cacheable?: boolean;
|
|
8
|
-
xpath?: string;
|
|
9
|
-
pageContext?: UIContext<BaseElement>;
|
|
10
|
-
}
|
|
11
|
-
interface InsightExtractOption {
|
|
12
|
-
domIncluded?: boolean | 'visible-only';
|
|
13
|
-
screenshotIncluded?: boolean;
|
|
14
|
-
returnThought?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface ReferenceImage {
|
|
17
|
-
base64: string;
|
|
18
|
-
rect?: Rect;
|
|
19
|
-
}
|
|
20
|
-
interface DetailedLocateParam extends LocateOption {
|
|
21
|
-
prompt: TUserPrompt;
|
|
22
|
-
referenceImage?: ReferenceImage;
|
|
23
|
-
}
|
|
24
|
-
interface scrollParam {
|
|
25
|
-
direction: 'down' | 'up' | 'right' | 'left';
|
|
26
|
-
scrollType: 'once' | 'untilBottom' | 'untilTop' | 'untilRight' | 'untilLeft';
|
|
27
|
-
distance?: null | number;
|
|
28
|
-
}
|
|
29
|
-
interface MidsceneYamlScript {
|
|
30
|
-
target?: MidsceneYamlScriptWebEnv;
|
|
31
|
-
web?: MidsceneYamlScriptWebEnv;
|
|
32
|
-
android?: MidsceneYamlScriptAndroidEnv;
|
|
33
|
-
tasks: MidsceneYamlTask[];
|
|
34
|
-
}
|
|
35
|
-
interface MidsceneYamlTask {
|
|
36
|
-
name: string;
|
|
37
|
-
flow: MidsceneYamlFlowItem[];
|
|
38
|
-
continueOnError?: boolean;
|
|
39
|
-
}
|
|
40
|
-
interface MidsceneYamlScriptEnvBase {
|
|
41
|
-
output?: string;
|
|
42
|
-
unstableLogContent?: boolean | string;
|
|
43
|
-
aiActionContext?: string;
|
|
44
|
-
}
|
|
45
|
-
interface MidsceneYamlScriptWebEnv extends MidsceneYamlScriptEnvBase {
|
|
46
|
-
serve?: string;
|
|
47
|
-
url: string;
|
|
48
|
-
userAgent?: string;
|
|
49
|
-
acceptInsecureCerts?: boolean;
|
|
50
|
-
viewportWidth?: number;
|
|
51
|
-
viewportHeight?: number;
|
|
52
|
-
viewportScale?: number;
|
|
53
|
-
waitForNetworkIdle?: {
|
|
54
|
-
timeout?: number;
|
|
55
|
-
continueOnNetworkIdleError?: boolean;
|
|
56
|
-
};
|
|
57
|
-
cookie?: string;
|
|
58
|
-
forceSameTabNavigation?: boolean;
|
|
59
|
-
bridgeMode?: false | 'newTabWithUrl' | 'currentTab';
|
|
60
|
-
closeNewTabsAfterDisconnect?: boolean;
|
|
61
|
-
}
|
|
62
|
-
interface MidsceneYamlScriptAndroidEnv extends MidsceneYamlScriptEnvBase {
|
|
63
|
-
deviceId?: string;
|
|
64
|
-
launch?: string;
|
|
65
|
-
}
|
|
66
|
-
type MidsceneYamlScriptEnv = MidsceneYamlScriptWebEnv | MidsceneYamlScriptAndroidEnv;
|
|
67
|
-
interface MidsceneYamlFlowItemAIAction {
|
|
68
|
-
ai?: string;
|
|
69
|
-
aiAction?: string;
|
|
70
|
-
aiActionProgressTips?: string[];
|
|
71
|
-
cacheable?: boolean;
|
|
72
|
-
}
|
|
73
|
-
interface MidsceneYamlFlowItemAIAssert {
|
|
74
|
-
aiAssert: string;
|
|
75
|
-
errorMessage?: string;
|
|
76
|
-
}
|
|
77
|
-
interface MidsceneYamlFlowItemAIQuery extends InsightExtractOption {
|
|
78
|
-
aiQuery: string;
|
|
79
|
-
name?: string;
|
|
80
|
-
}
|
|
81
|
-
interface MidsceneYamlFlowItemAINumber extends InsightExtractOption {
|
|
82
|
-
aiNumber: string;
|
|
83
|
-
name?: string;
|
|
84
|
-
}
|
|
85
|
-
interface MidsceneYamlFlowItemAIString extends InsightExtractOption {
|
|
86
|
-
aiString: string;
|
|
87
|
-
name?: string;
|
|
88
|
-
}
|
|
89
|
-
interface MidsceneYamlFlowItemAIAsk extends InsightExtractOption {
|
|
90
|
-
aiAsk: string;
|
|
91
|
-
name?: string;
|
|
92
|
-
}
|
|
93
|
-
interface MidsceneYamlFlowItemAIBoolean extends InsightExtractOption {
|
|
94
|
-
aiBoolean: string;
|
|
95
|
-
name?: string;
|
|
96
|
-
}
|
|
97
|
-
interface MidsceneYamlFlowItemAILocate extends LocateOption {
|
|
98
|
-
aiLocate: string;
|
|
99
|
-
name?: string;
|
|
100
|
-
}
|
|
101
|
-
interface MidsceneYamlFlowItemAIWaitFor {
|
|
102
|
-
aiWaitFor: string;
|
|
103
|
-
timeout?: number;
|
|
104
|
-
}
|
|
105
|
-
interface MidsceneYamlFlowItemAITap extends LocateOption {
|
|
106
|
-
aiTap: TUserPrompt;
|
|
107
|
-
}
|
|
108
|
-
interface MidsceneYamlFlowItemAIRightClick extends LocateOption {
|
|
109
|
-
aiRightClick: TUserPrompt;
|
|
110
|
-
}
|
|
111
|
-
interface MidsceneYamlFlowItemAIHover extends LocateOption {
|
|
112
|
-
aiHover: TUserPrompt;
|
|
113
|
-
}
|
|
114
|
-
interface MidsceneYamlFlowItemAIInput extends LocateOption {
|
|
115
|
-
aiInput: string;
|
|
116
|
-
locate: TUserPrompt;
|
|
117
|
-
}
|
|
118
|
-
interface MidsceneYamlFlowItemAIKeyboardPress extends LocateOption {
|
|
119
|
-
aiKeyboardPress: string;
|
|
120
|
-
locate?: TUserPrompt;
|
|
121
|
-
}
|
|
122
|
-
interface MidsceneYamlFlowItemAIScroll extends LocateOption, PlanningActionParamScroll {
|
|
123
|
-
aiScroll: null;
|
|
124
|
-
locate?: TUserPrompt;
|
|
125
|
-
}
|
|
126
|
-
interface MidsceneYamlFlowItemEvaluateJavaScript {
|
|
127
|
-
javascript: string;
|
|
128
|
-
name?: string;
|
|
129
|
-
}
|
|
130
|
-
interface MidsceneYamlFlowItemSleep {
|
|
131
|
-
sleep: number;
|
|
132
|
-
}
|
|
133
|
-
interface MidsceneYamlFlowItemLogScreenshot {
|
|
134
|
-
logScreenshot?: string;
|
|
135
|
-
content?: string;
|
|
136
|
-
}
|
|
137
|
-
type MidsceneYamlFlowItem = MidsceneYamlFlowItemAIAction | MidsceneYamlFlowItemAIAssert | MidsceneYamlFlowItemAIQuery | MidsceneYamlFlowItemAIWaitFor | MidsceneYamlFlowItemAITap | MidsceneYamlFlowItemAIRightClick | MidsceneYamlFlowItemAIHover | MidsceneYamlFlowItemAIInput | MidsceneYamlFlowItemAIKeyboardPress | MidsceneYamlFlowItemAIScroll | MidsceneYamlFlowItemSleep | MidsceneYamlFlowItemLogScreenshot;
|
|
138
|
-
interface FreeFn {
|
|
139
|
-
name: string;
|
|
140
|
-
fn: () => void;
|
|
141
|
-
}
|
|
142
|
-
interface ScriptPlayerTaskStatus extends MidsceneYamlTask {
|
|
143
|
-
status: ScriptPlayerStatusValue;
|
|
144
|
-
currentStep?: number;
|
|
145
|
-
totalSteps: number;
|
|
146
|
-
error?: Error;
|
|
147
|
-
}
|
|
148
|
-
type ScriptPlayerStatusValue = 'init' | 'running' | 'done' | 'error';
|
|
149
|
-
interface MidsceneYamlConfig {
|
|
150
|
-
concurrent?: number;
|
|
151
|
-
continueOnError?: boolean;
|
|
152
|
-
summary?: string;
|
|
153
|
-
shareBrowserContext?: boolean;
|
|
154
|
-
web?: MidsceneYamlScriptWebEnv;
|
|
155
|
-
android?: MidsceneYamlScriptAndroidEnv;
|
|
156
|
-
files: string[];
|
|
157
|
-
headed?: boolean;
|
|
158
|
-
keepWindow?: boolean;
|
|
159
|
-
dotenvOverride?: boolean;
|
|
160
|
-
dotenvDebug?: boolean;
|
|
161
|
-
}
|
|
162
|
-
interface MidsceneYamlConfigOutput {
|
|
163
|
-
format?: 'json';
|
|
164
|
-
path?: string;
|
|
165
|
-
}
|
|
166
|
-
interface MidsceneYamlConfigResult {
|
|
167
|
-
file: string;
|
|
168
|
-
success: boolean;
|
|
169
|
-
executed: boolean;
|
|
170
|
-
output?: string | null;
|
|
171
|
-
report?: string | null;
|
|
172
|
-
error?: string;
|
|
173
|
-
duration?: number;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
type AIUsageInfo = Record<string, any> & {
|
|
177
|
-
prompt_tokens: number | undefined;
|
|
178
|
-
completion_tokens: number | undefined;
|
|
179
|
-
total_tokens: number | undefined;
|
|
180
|
-
time_cost: number | undefined;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* openai
|
|
184
|
-
*
|
|
185
|
-
*/
|
|
186
|
-
declare enum AIResponseFormat {
|
|
187
|
-
JSON = "json_object",
|
|
188
|
-
TEXT = "text"
|
|
189
|
-
}
|
|
190
|
-
type AISingleElementResponseById = {
|
|
191
|
-
id: string;
|
|
192
|
-
reason?: string;
|
|
193
|
-
text?: string;
|
|
194
|
-
xpaths?: string[];
|
|
195
|
-
};
|
|
196
|
-
type AISingleElementResponseByPosition = {
|
|
197
|
-
position?: {
|
|
198
|
-
x: number;
|
|
199
|
-
y: number;
|
|
200
|
-
};
|
|
201
|
-
bbox?: [number, number, number, number];
|
|
202
|
-
reason: string;
|
|
203
|
-
text: string;
|
|
204
|
-
};
|
|
205
|
-
type AISingleElementResponse = AISingleElementResponseById;
|
|
206
|
-
interface AIElementLocatorResponse {
|
|
207
|
-
elements: {
|
|
208
|
-
id: string;
|
|
209
|
-
reason?: string;
|
|
210
|
-
text?: string;
|
|
211
|
-
xpaths?: string[];
|
|
212
|
-
}[];
|
|
213
|
-
bbox?: [number, number, number, number];
|
|
214
|
-
isOrderSensitive?: boolean;
|
|
215
|
-
errors?: string[];
|
|
216
|
-
}
|
|
217
|
-
interface AIElementCoordinatesResponse {
|
|
218
|
-
bbox: [number, number, number, number];
|
|
219
|
-
isOrderSensitive?: boolean;
|
|
220
|
-
errors?: string[];
|
|
221
|
-
}
|
|
222
|
-
type AIElementResponse = AIElementLocatorResponse | AIElementCoordinatesResponse;
|
|
223
|
-
interface AIDataExtractionResponse<DataDemand> {
|
|
224
|
-
data: DataDemand;
|
|
225
|
-
errors?: string[];
|
|
226
|
-
thought?: string;
|
|
227
|
-
}
|
|
228
|
-
interface AISectionLocatorResponse {
|
|
229
|
-
bbox: [number, number, number, number];
|
|
230
|
-
references_bbox?: [number, number, number, number][];
|
|
231
|
-
error?: string;
|
|
232
|
-
}
|
|
233
|
-
interface AIAssertionResponse {
|
|
234
|
-
pass: boolean;
|
|
235
|
-
thought: string;
|
|
236
|
-
}
|
|
237
|
-
interface AIDescribeElementResponse {
|
|
238
|
-
description: string;
|
|
239
|
-
error?: string;
|
|
240
|
-
}
|
|
241
|
-
interface LocatorValidatorOption {
|
|
242
|
-
centerDistanceThreshold?: number;
|
|
243
|
-
}
|
|
244
|
-
interface LocateValidatorResult {
|
|
245
|
-
pass: boolean;
|
|
246
|
-
rect: Rect;
|
|
247
|
-
center: [number, number];
|
|
248
|
-
centerDistance?: number;
|
|
249
|
-
}
|
|
250
|
-
interface AgentDescribeElementAtPointResult {
|
|
251
|
-
prompt: string;
|
|
252
|
-
deepThink: boolean;
|
|
253
|
-
verifyResult?: LocateValidatorResult;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* context
|
|
257
|
-
*/
|
|
258
|
-
declare abstract class UIContext<ElementType extends BaseElement = BaseElement> {
|
|
259
|
-
abstract screenshotBase64: string;
|
|
260
|
-
abstract tree: ElementTreeNode<ElementType>;
|
|
261
|
-
abstract size: Size;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* insight
|
|
265
|
-
*/
|
|
266
|
-
type CallAIFn = <T>(messages: ChatCompletionMessageParam[]) => Promise<T>;
|
|
267
|
-
interface InsightOptions {
|
|
268
|
-
taskInfo?: Omit<InsightTaskInfo, 'durationMs'>;
|
|
269
|
-
aiVendorFn?: CallAIFn;
|
|
270
|
-
}
|
|
271
|
-
type EnsureObject<T> = {
|
|
272
|
-
[K in keyof T]: any;
|
|
273
|
-
};
|
|
274
|
-
type InsightAction = 'locate' | 'extract' | 'assert' | 'describe';
|
|
275
|
-
type InsightExtractParam = string | Record<string, string>;
|
|
276
|
-
type LocateResultElement = {
|
|
277
|
-
id: string;
|
|
278
|
-
indexId?: number;
|
|
279
|
-
center: [number, number];
|
|
280
|
-
rect: Rect;
|
|
281
|
-
xpaths: string[];
|
|
282
|
-
attributes: {
|
|
283
|
-
nodeType: NodeType;
|
|
284
|
-
[key: string]: string;
|
|
285
|
-
};
|
|
286
|
-
isOrderSensitive?: boolean;
|
|
287
|
-
};
|
|
288
|
-
interface LocateResult {
|
|
289
|
-
element: LocateResultElement | null;
|
|
290
|
-
rect?: Rect;
|
|
291
|
-
}
|
|
292
|
-
interface InsightTaskInfo {
|
|
293
|
-
durationMs: number;
|
|
294
|
-
formatResponse?: string;
|
|
295
|
-
rawResponse?: string;
|
|
296
|
-
usage?: AIUsageInfo;
|
|
297
|
-
searchArea?: Rect;
|
|
298
|
-
searchAreaRawResponse?: string;
|
|
299
|
-
searchAreaUsage?: AIUsageInfo;
|
|
300
|
-
}
|
|
301
|
-
interface DumpMeta {
|
|
302
|
-
sdkVersion: string;
|
|
303
|
-
logTime: number;
|
|
304
|
-
model_name: string;
|
|
305
|
-
model_description?: string;
|
|
306
|
-
}
|
|
307
|
-
interface ReportDumpWithAttributes {
|
|
308
|
-
dumpString: string;
|
|
309
|
-
attributes?: Record<string, any>;
|
|
310
|
-
}
|
|
311
|
-
interface InsightDump extends DumpMeta {
|
|
312
|
-
type: 'locate' | 'extract' | 'assert';
|
|
313
|
-
logId: string;
|
|
314
|
-
userQuery: {
|
|
315
|
-
element?: TUserPrompt;
|
|
316
|
-
dataDemand?: InsightExtractParam;
|
|
317
|
-
assertion?: TUserPrompt;
|
|
318
|
-
};
|
|
319
|
-
matchedElement: BaseElement[];
|
|
320
|
-
matchedRect?: Rect;
|
|
321
|
-
deepThink?: boolean;
|
|
322
|
-
data: any;
|
|
323
|
-
assertionPass?: boolean;
|
|
324
|
-
assertionThought?: string;
|
|
325
|
-
taskInfo: InsightTaskInfo;
|
|
326
|
-
error?: string;
|
|
327
|
-
output?: any;
|
|
328
|
-
}
|
|
329
|
-
type PartialInsightDumpFromSDK = Omit<InsightDump, 'sdkVersion' | 'logTime' | 'logId' | 'model_name'>;
|
|
330
|
-
type DumpSubscriber = (dump: InsightDump) => Promise<void> | void;
|
|
331
|
-
interface LiteUISection {
|
|
332
|
-
name: string;
|
|
333
|
-
description: string;
|
|
334
|
-
sectionCharacteristics: string;
|
|
335
|
-
textIds: string[];
|
|
336
|
-
}
|
|
337
|
-
type ElementById = (id: string) => BaseElement | null;
|
|
338
|
-
type InsightAssertionResponse = AIAssertionResponse & {
|
|
339
|
-
usage?: AIUsageInfo;
|
|
340
|
-
};
|
|
341
|
-
/**
|
|
342
|
-
* agent
|
|
343
|
-
*/
|
|
344
|
-
type OnTaskStartTip = (tip: string) => Promise<void> | void;
|
|
345
|
-
interface AgentWaitForOpt {
|
|
346
|
-
checkIntervalMs?: number;
|
|
347
|
-
timeoutMs?: number;
|
|
348
|
-
}
|
|
349
|
-
interface AgentAssertOpt {
|
|
350
|
-
keepRawResponse?: boolean;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* planning
|
|
354
|
-
*
|
|
355
|
-
*/
|
|
356
|
-
interface PlanningLocateParam extends DetailedLocateParam {
|
|
357
|
-
id?: string;
|
|
358
|
-
bbox?: [number, number, number, number];
|
|
359
|
-
}
|
|
360
|
-
interface PlanningAction<ParamType = any> {
|
|
361
|
-
thought?: string;
|
|
362
|
-
type: 'Locate' | 'Tap' | 'RightClick' | 'Hover' | 'Drag' | 'Input' | 'KeyboardPress' | 'Scroll' | 'Error' | 'Assert' | 'AssertWithoutThrow' | 'Sleep' | 'Finished' | 'AndroidBackButton' | 'AndroidHomeButton' | 'AndroidRecentAppsButton' | 'AndroidLongPress' | 'AndroidPull';
|
|
363
|
-
param: ParamType;
|
|
364
|
-
locate?: PlanningLocateParam | null;
|
|
365
|
-
}
|
|
366
|
-
interface PlanningAIResponse {
|
|
367
|
-
action?: PlanningAction;
|
|
368
|
-
actions?: PlanningAction[];
|
|
369
|
-
more_actions_needed_by_instruction: boolean;
|
|
370
|
-
log: string;
|
|
371
|
-
sleep?: number;
|
|
372
|
-
error?: string;
|
|
373
|
-
usage?: AIUsageInfo;
|
|
374
|
-
rawResponse?: string;
|
|
375
|
-
yamlFlow?: MidsceneYamlFlowItem[];
|
|
376
|
-
yamlString?: string;
|
|
377
|
-
}
|
|
378
|
-
type PlanningActionParamTap = null;
|
|
379
|
-
type PlanningActionParamHover = null;
|
|
380
|
-
type PlanningActionParamRightClick = null;
|
|
381
|
-
interface PlanningActionParamInputOrKeyPress {
|
|
382
|
-
value: string;
|
|
383
|
-
autoDismissKeyboard?: boolean;
|
|
384
|
-
}
|
|
385
|
-
type PlanningActionParamScroll = scrollParam;
|
|
386
|
-
interface PlanningActionParamAssert {
|
|
387
|
-
assertion: TUserPrompt;
|
|
388
|
-
}
|
|
389
|
-
interface PlanningActionParamSleep {
|
|
390
|
-
timeMs: number;
|
|
391
|
-
}
|
|
392
|
-
interface PlanningActionParamError {
|
|
393
|
-
thought: string;
|
|
394
|
-
}
|
|
395
|
-
type PlanningActionParamWaitFor = AgentWaitForOpt & {
|
|
396
|
-
assertion: string;
|
|
397
|
-
};
|
|
398
|
-
interface PlanningActionParamAndroidLongPress {
|
|
399
|
-
x: number;
|
|
400
|
-
y: number;
|
|
401
|
-
duration?: number;
|
|
402
|
-
}
|
|
403
|
-
interface PlanningActionParamAndroidPull {
|
|
404
|
-
direction: 'up' | 'down';
|
|
405
|
-
startPoint?: {
|
|
406
|
-
x: number;
|
|
407
|
-
y: number;
|
|
408
|
-
};
|
|
409
|
-
distance?: number;
|
|
410
|
-
duration?: number;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* misc
|
|
414
|
-
*/
|
|
415
|
-
interface Color {
|
|
416
|
-
name: string;
|
|
417
|
-
hex: string;
|
|
418
|
-
}
|
|
419
|
-
interface BaseAgentParserOpt {
|
|
420
|
-
selector?: string;
|
|
421
|
-
ignoreMarker?: boolean;
|
|
422
|
-
}
|
|
423
|
-
interface PuppeteerParserOpt extends BaseAgentParserOpt {
|
|
424
|
-
}
|
|
425
|
-
interface PlaywrightParserOpt extends BaseAgentParserOpt {
|
|
426
|
-
}
|
|
427
|
-
interface ExecutionTaskProgressOptions {
|
|
428
|
-
onTaskStart?: (task: ExecutionTask) => Promise<void> | void;
|
|
429
|
-
}
|
|
430
|
-
interface ExecutionRecorderItem {
|
|
431
|
-
type: 'screenshot';
|
|
432
|
-
ts: number;
|
|
433
|
-
screenshot?: string;
|
|
434
|
-
timing?: string;
|
|
435
|
-
}
|
|
436
|
-
type ExecutionTaskType = 'Planning' | 'Insight' | 'Action' | 'Assertion' | 'Log';
|
|
437
|
-
interface ExecutorContext {
|
|
438
|
-
task: ExecutionTask;
|
|
439
|
-
element?: LocateResultElement | null;
|
|
440
|
-
}
|
|
441
|
-
interface ExecutionTaskApply<Type extends ExecutionTaskType = any, TaskParam = any, TaskOutput = any, TaskLog = any> {
|
|
442
|
-
type: Type;
|
|
443
|
-
subType?: string;
|
|
444
|
-
param?: TaskParam;
|
|
445
|
-
thought?: string;
|
|
446
|
-
locate?: PlanningLocateParam | null;
|
|
447
|
-
pageContext?: UIContext;
|
|
448
|
-
executor: (param: TaskParam, context: ExecutorContext) => Promise<ExecutionTaskReturn<TaskOutput, TaskLog> | undefined | void> | undefined | void;
|
|
449
|
-
}
|
|
450
|
-
interface ExecutionTaskHitBy {
|
|
451
|
-
from: string;
|
|
452
|
-
context: Record<string, any>;
|
|
453
|
-
}
|
|
454
|
-
interface ExecutionTaskReturn<TaskOutput = unknown, TaskLog = unknown> {
|
|
455
|
-
output?: TaskOutput;
|
|
456
|
-
log?: TaskLog;
|
|
457
|
-
recorder?: ExecutionRecorderItem[];
|
|
458
|
-
hitBy?: ExecutionTaskHitBy;
|
|
459
|
-
}
|
|
460
|
-
type ExecutionTask<E extends ExecutionTaskApply<any, any, any> = ExecutionTaskApply<any, any, any>> = E & ExecutionTaskReturn<E extends ExecutionTaskApply<any, any, infer TaskOutput, any> ? TaskOutput : unknown, E extends ExecutionTaskApply<any, any, any, infer TaskLog> ? TaskLog : unknown> & {
|
|
461
|
-
status: 'pending' | 'running' | 'finished' | 'failed' | 'cancelled';
|
|
462
|
-
error?: Error;
|
|
463
|
-
errorMessage?: string;
|
|
464
|
-
errorStack?: string;
|
|
465
|
-
timing?: {
|
|
466
|
-
start: number;
|
|
467
|
-
end?: number;
|
|
468
|
-
cost?: number;
|
|
469
|
-
};
|
|
470
|
-
usage?: AIUsageInfo;
|
|
471
|
-
};
|
|
472
|
-
interface ExecutionDump extends DumpMeta {
|
|
473
|
-
name: string;
|
|
474
|
-
description?: string;
|
|
475
|
-
tasks: ExecutionTask[];
|
|
476
|
-
}
|
|
477
|
-
type ExecutionTaskInsightLocateParam = PlanningLocateParam;
|
|
478
|
-
interface ExecutionTaskInsightLocateOutput {
|
|
479
|
-
element: LocateResultElement | null;
|
|
480
|
-
}
|
|
481
|
-
interface ExecutionTaskInsightDumpLog {
|
|
482
|
-
dump?: InsightDump;
|
|
483
|
-
}
|
|
484
|
-
type ExecutionTaskInsightLocateApply = ExecutionTaskApply<'Insight', ExecutionTaskInsightLocateParam, ExecutionTaskInsightLocateOutput, ExecutionTaskInsightDumpLog>;
|
|
485
|
-
type ExecutionTaskInsightLocate = ExecutionTask<ExecutionTaskInsightLocateApply>;
|
|
486
|
-
interface ExecutionTaskInsightQueryParam {
|
|
487
|
-
dataDemand: InsightExtractParam;
|
|
488
|
-
}
|
|
489
|
-
interface ExecutionTaskInsightQueryOutput {
|
|
490
|
-
data: any;
|
|
491
|
-
}
|
|
492
|
-
type ExecutionTaskInsightQueryApply = ExecutionTaskApply<'Insight', ExecutionTaskInsightQueryParam, any, ExecutionTaskInsightDumpLog>;
|
|
493
|
-
type ExecutionTaskInsightQuery = ExecutionTask<ExecutionTaskInsightQueryApply>;
|
|
494
|
-
interface ExecutionTaskInsightAssertionParam {
|
|
495
|
-
assertion: string;
|
|
496
|
-
}
|
|
497
|
-
type ExecutionTaskInsightAssertionApply = ExecutionTaskApply<'Insight', ExecutionTaskInsightAssertionParam, InsightAssertionResponse, ExecutionTaskInsightDumpLog>;
|
|
498
|
-
type ExecutionTaskInsightAssertion = ExecutionTask<ExecutionTaskInsightAssertionApply>;
|
|
499
|
-
type ExecutionTaskActionApply<ActionParam = any> = ExecutionTaskApply<'Action', ActionParam, void, void>;
|
|
500
|
-
type ExecutionTaskAction = ExecutionTask<ExecutionTaskActionApply>;
|
|
501
|
-
type ExecutionTaskLogApply<LogParam = {
|
|
502
|
-
content: string;
|
|
503
|
-
}> = ExecutionTaskApply<'Log', LogParam, void, void>;
|
|
504
|
-
type ExecutionTaskLog = ExecutionTask<ExecutionTaskLogApply>;
|
|
505
|
-
type ExecutionTaskPlanningApply = ExecutionTaskApply<'Planning', {
|
|
506
|
-
userInstruction: string;
|
|
507
|
-
log?: string;
|
|
508
|
-
}, PlanningAIResponse>;
|
|
509
|
-
type ExecutionTaskPlanning = ExecutionTask<ExecutionTaskPlanningApply>;
|
|
510
|
-
interface GroupedActionDump {
|
|
511
|
-
groupName: string;
|
|
512
|
-
groupDescription?: string;
|
|
513
|
-
executions: ExecutionDump[];
|
|
514
|
-
}
|
|
515
|
-
type PageType = 'puppeteer' | 'playwright' | 'static' | 'chrome-extension-proxy' | 'android';
|
|
516
|
-
interface StreamingCodeGenerationOptions {
|
|
517
|
-
/** Whether to enable streaming output */
|
|
518
|
-
stream?: boolean;
|
|
519
|
-
/** Callback function to handle streaming chunks */
|
|
520
|
-
onChunk?: StreamingCallback;
|
|
521
|
-
/** Callback function to handle streaming completion */
|
|
522
|
-
onComplete?: (finalCode: string) => void;
|
|
523
|
-
/** Callback function to handle streaming errors */
|
|
524
|
-
onError?: (error: Error) => void;
|
|
525
|
-
}
|
|
526
|
-
type StreamingCallback = (chunk: CodeGenerationChunk) => void;
|
|
527
|
-
interface CodeGenerationChunk {
|
|
528
|
-
/** The incremental content chunk */
|
|
529
|
-
content: string;
|
|
530
|
-
/** The reasoning content */
|
|
531
|
-
reasoning_content: string;
|
|
532
|
-
/** The accumulated content so far */
|
|
533
|
-
accumulated: string;
|
|
534
|
-
/** Whether this is the final chunk */
|
|
535
|
-
isComplete: boolean;
|
|
536
|
-
/** Token usage information if available */
|
|
537
|
-
usage?: AIUsageInfo;
|
|
538
|
-
}
|
|
539
|
-
interface StreamingAIResponse {
|
|
540
|
-
/** The final accumulated content */
|
|
541
|
-
content: string;
|
|
542
|
-
/** Token usage information */
|
|
543
|
-
usage?: AIUsageInfo;
|
|
544
|
-
/** Whether the response was streamed */
|
|
545
|
-
isStreamed: boolean;
|
|
546
|
-
}
|
|
547
|
-
type TMultimodalPrompt = {
|
|
548
|
-
/**
|
|
549
|
-
* Support use image to inspect elements.
|
|
550
|
-
* The "images" field is an object that uses image name as key and image url as value.
|
|
551
|
-
* The image url can be a local path, a http link , or a base64 string.
|
|
552
|
-
*/
|
|
553
|
-
images?: {
|
|
554
|
-
name: string;
|
|
555
|
-
url: string;
|
|
556
|
-
}[];
|
|
557
|
-
/**
|
|
558
|
-
* By default, the image url in the "images" filed starts with `https://` or `http://` will be directly sent to the LLM.
|
|
559
|
-
* In case the images are not accessible to the LLM (One common case is that image url is internal network only.), you can enable this option.
|
|
560
|
-
* Then image will be download and convert to base64 format.
|
|
561
|
-
*/
|
|
562
|
-
convertHttpImage2Base64?: boolean;
|
|
563
|
-
};
|
|
564
|
-
type TUserPrompt = string | ({
|
|
565
|
-
prompt: string;
|
|
566
|
-
} & Partial<TMultimodalPrompt>);
|
|
567
|
-
interface DeviceAction<ParamType = any> {
|
|
568
|
-
name: string;
|
|
569
|
-
description?: string;
|
|
570
|
-
paramSchema?: string;
|
|
571
|
-
paramDescription?: string;
|
|
572
|
-
location?: 'required' | 'optional' | false;
|
|
573
|
-
whatToLocate?: string;
|
|
574
|
-
call: (param: ParamType) => Promise<void> | void;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
export { type PlanningActionParamHover as $, type AIUsageInfo as A, type LocatorValidatorOption as B, type LocateValidatorResult as C, type DumpSubscriber as D, type ExecutionTask as E, type AgentDescribeElementAtPointResult as F, type CallAIFn as G, type EnsureObject as H, type InsightAction as I, type LocateResultElement as J, type DumpMeta as K, type LocateResult as L, type MidsceneYamlScript as M, type InsightDump as N, type LiteUISection as O, type PartialInsightDumpFromSDK as P, type ElementById as Q, type ReportDumpWithAttributes as R, type OnTaskStartTip as S, type TMultimodalPrompt as T, UIContext as U, type AgentWaitForOpt as V, type AgentAssertOpt as W, type PlanningLocateParam as X, type PlanningAction as Y, type PlanningAIResponse as Z, type PlanningActionParamTap as _, type ExecutionTaskProgressOptions as a, type MidsceneYamlFlowItemEvaluateJavaScript as a$, type PlanningActionParamRightClick as a0, type PlanningActionParamInputOrKeyPress as a1, type PlanningActionParamScroll as a2, type PlanningActionParamAssert as a3, type PlanningActionParamSleep as a4, type PlanningActionParamError as a5, type PlanningActionParamWaitFor as a6, type PlanningActionParamAndroidLongPress as a7, type PlanningActionParamAndroidPull as a8, type Color as a9, type GroupedActionDump as aA, type PageType as aB, type StreamingCodeGenerationOptions as aC, type StreamingCallback as aD, type CodeGenerationChunk as aE, type StreamingAIResponse as aF, type DeviceAction as aG, type ReferenceImage as aH, type scrollParam as aI, type MidsceneYamlScriptEnvBase as aJ, type MidsceneYamlScriptWebEnv as aK, type MidsceneYamlScriptAndroidEnv as aL, type MidsceneYamlScriptEnv as aM, type MidsceneYamlFlowItemAIAction as aN, type MidsceneYamlFlowItemAIAssert as aO, type MidsceneYamlFlowItemAIQuery as aP, type MidsceneYamlFlowItemAINumber as aQ, type MidsceneYamlFlowItemAIString as aR, type MidsceneYamlFlowItemAIAsk as aS, type MidsceneYamlFlowItemAIBoolean as aT, type MidsceneYamlFlowItemAILocate as aU, type MidsceneYamlFlowItemAIWaitFor as aV, type MidsceneYamlFlowItemAITap as aW, type MidsceneYamlFlowItemAIHover as aX, type MidsceneYamlFlowItemAIInput as aY, type MidsceneYamlFlowItemAIKeyboardPress as aZ, type MidsceneYamlFlowItemAIScroll as a_, type BaseAgentParserOpt as aa, type PuppeteerParserOpt as ab, type PlaywrightParserOpt as ac, type ExecutionRecorderItem as ad, type ExecutionTaskType as ae, type ExecutorContext as af, type ExecutionTaskHitBy as ag, type ExecutionTaskReturn as ah, type ExecutionTaskInsightLocateParam as ai, type ExecutionTaskInsightLocateOutput as aj, type ExecutionTaskInsightDumpLog as ak, type ExecutionTaskInsightLocateApply as al, type ExecutionTaskInsightLocate as am, type ExecutionTaskInsightQueryParam as an, type ExecutionTaskInsightQueryOutput as ao, type ExecutionTaskInsightQueryApply as ap, type ExecutionTaskInsightQuery as aq, type ExecutionTaskInsightAssertionParam as ar, type ExecutionTaskInsightAssertionApply as as, type ExecutionTaskInsightAssertion as at, type ExecutionTaskActionApply as au, type ExecutionTaskAction as av, type ExecutionTaskLogApply as aw, type ExecutionTaskLog as ax, type ExecutionTaskPlanningApply as ay, type ExecutionTaskPlanning as az, type ExecutionTaskApply as b, type MidsceneYamlFlowItemSleep as b0, type MidsceneYamlFlowItemLogScreenshot as b1, type FreeFn as b2, type ScriptPlayerTaskStatus as b3, type ScriptPlayerStatusValue as b4, type MidsceneYamlConfig as b5, type MidsceneYamlConfigOutput as b6, type ExecutionDump as c, type InsightTaskInfo as d, type InsightOptions as e, type DetailedLocateParam as f, type InsightExtractParam as g, type InsightExtractOption as h, type TUserPrompt as i, type InsightAssertionResponse as j, type AIDescribeElementResponse as k, type MidsceneYamlTask as l, type MidsceneYamlFlowItem as m, type MidsceneYamlFlowItemAIRightClick as n, type MidsceneYamlConfigResult as o, type LocateOption as p, AIResponseFormat as q, type AISingleElementResponseById as r, type AISingleElementResponseByPosition as s, type AISingleElementResponse as t, type AIElementLocatorResponse as u, type AIElementCoordinatesResponse as v, type AIElementResponse as w, type AIDataExtractionResponse as x, type AISectionLocatorResponse as y, type AIAssertionResponse as z };
|
package/dist/es/utils.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { R as ReportDumpWithAttributes } from './types-8a6be57c.js';
|
|
2
|
-
import { Rect } from '@midscene/shared/types';
|
|
3
|
-
import '@midscene/shared/constants';
|
|
4
|
-
import 'openai/resources';
|
|
5
|
-
|
|
6
|
-
declare const groupedActionDumpFileExt = "web-dump.json";
|
|
7
|
-
/**
|
|
8
|
-
* high performance, insert script before </html> in HTML file
|
|
9
|
-
* only truncate and append, no temporary file
|
|
10
|
-
*/
|
|
11
|
-
declare function insertScriptBeforeClosingHtml(filePath: string, scriptContent: string): void;
|
|
12
|
-
declare function reportHTMLContent(dumpData: string | ReportDumpWithAttributes, reportPath?: string, appendReport?: boolean): string;
|
|
13
|
-
declare function writeDumpReport(fileName: string, dumpData: string | ReportDumpWithAttributes, appendReport?: boolean): string | null;
|
|
14
|
-
declare function writeLogFile(opts: {
|
|
15
|
-
fileName: string;
|
|
16
|
-
fileExt: string;
|
|
17
|
-
fileContent: string;
|
|
18
|
-
type: 'dump' | 'cache' | 'report' | 'tmp';
|
|
19
|
-
generateReport?: boolean;
|
|
20
|
-
appendReport?: boolean;
|
|
21
|
-
}): string | null;
|
|
22
|
-
declare function getTmpDir(): string | null;
|
|
23
|
-
declare function getTmpFile(fileExtWithoutDot: string): string | null;
|
|
24
|
-
declare function overlapped(container: Rect, target: Rect): boolean;
|
|
25
|
-
declare function sleep(ms: number): Promise<unknown>;
|
|
26
|
-
declare function replacerForPageObject(key: string, value: any): any;
|
|
27
|
-
declare function stringifyDumpData(data: any, indents?: number): string;
|
|
28
|
-
declare function getVersion(): string;
|
|
29
|
-
declare function uploadTestInfoToServer({ testUrl }: {
|
|
30
|
-
testUrl: string;
|
|
31
|
-
}): void;
|
|
32
|
-
|
|
33
|
-
export { getTmpDir, getTmpFile, getVersion, groupedActionDumpFileExt, insertScriptBeforeClosingHtml, overlapped, replacerForPageObject, reportHTMLContent, sleep, stringifyDumpData, uploadTestInfoToServer, writeDumpReport, writeLogFile };
|
package/dist/es/utils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTmpDir,
|
|
3
|
-
getTmpFile,
|
|
4
|
-
getVersion,
|
|
5
|
-
groupedActionDumpFileExt,
|
|
6
|
-
insertScriptBeforeClosingHtml,
|
|
7
|
-
overlapped,
|
|
8
|
-
replacerForPageObject,
|
|
9
|
-
reportHTMLContent,
|
|
10
|
-
sleep,
|
|
11
|
-
stringifyDumpData,
|
|
12
|
-
uploadTestInfoToServer,
|
|
13
|
-
writeDumpReport,
|
|
14
|
-
writeLogFile
|
|
15
|
-
} from "./chunk-WXNDYUNG.js";
|
|
16
|
-
export {
|
|
17
|
-
getTmpDir,
|
|
18
|
-
getTmpFile,
|
|
19
|
-
getVersion,
|
|
20
|
-
groupedActionDumpFileExt,
|
|
21
|
-
insertScriptBeforeClosingHtml,
|
|
22
|
-
overlapped,
|
|
23
|
-
replacerForPageObject,
|
|
24
|
-
reportHTMLContent,
|
|
25
|
-
sleep,
|
|
26
|
-
stringifyDumpData,
|
|
27
|
-
uploadTestInfoToServer,
|
|
28
|
-
writeDumpReport,
|
|
29
|
-
writeLogFile
|
|
30
|
-
};
|