@midscene/core 0.26.2 → 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.
Files changed (47) hide show
  1. package/dist/es/ai-model.mjs +2502 -0
  2. package/dist/es/ai-model.mjs.map +1 -0
  3. package/dist/es/index.mjs +2362 -0
  4. package/dist/es/index.mjs.map +1 -0
  5. package/dist/es/tree.mjs +2 -0
  6. package/dist/es/utils.mjs +188 -0
  7. package/dist/es/{chunk-O3KUKF2A.js.map → utils.mjs.map} +1 -1
  8. package/dist/lib/ai-model.js +2581 -3
  9. package/dist/lib/ai-model.js.map +1 -0
  10. package/dist/lib/index.js +2375 -493
  11. package/dist/lib/index.js.map +1 -1
  12. package/dist/lib/tree.js +42 -11
  13. package/dist/lib/tree.js.map +1 -1
  14. package/dist/lib/utils.js +257 -29
  15. package/dist/lib/utils.js.map +1 -0
  16. package/dist/types/ai-model.d.ts +505 -99
  17. package/dist/types/index.d.ts +1299 -53
  18. package/dist/types/tree.d.ts +11 -1
  19. package/dist/types/utils.d.ts +47 -33
  20. package/package.json +28 -12
  21. package/dist/es/ai-model.d.ts +0 -99
  22. package/dist/es/ai-model.js +0 -44
  23. package/dist/es/chunk-DDYIQHOA.js +0 -2883
  24. package/dist/es/chunk-DDYIQHOA.js.map +0 -1
  25. package/dist/es/chunk-O3KUKF2A.js +0 -265
  26. package/dist/es/index.d.ts +0 -53
  27. package/dist/es/index.js +0 -570
  28. package/dist/es/index.js.map +0 -1
  29. package/dist/es/llm-planning-4e0c16fe.d.ts +0 -106
  30. package/dist/es/tree.d.ts +0 -1
  31. package/dist/es/tree.js +0 -13
  32. package/dist/es/tree.js.map +0 -1
  33. package/dist/es/types-8a6be57c.d.ts +0 -577
  34. package/dist/es/utils.d.ts +0 -33
  35. package/dist/es/utils.js +0 -30
  36. package/dist/lib/ai-model.d.ts +0 -99
  37. package/dist/lib/chunk-DDYIQHOA.js +0 -2883
  38. package/dist/lib/chunk-DDYIQHOA.js.map +0 -1
  39. package/dist/lib/chunk-O3KUKF2A.js +0 -265
  40. package/dist/lib/chunk-O3KUKF2A.js.map +0 -1
  41. package/dist/lib/index.d.ts +0 -53
  42. package/dist/lib/llm-planning-4e0c16fe.d.ts +0 -106
  43. package/dist/lib/tree.d.ts +0 -1
  44. package/dist/lib/types-8a6be57c.d.ts +0 -577
  45. package/dist/lib/utils.d.ts +0 -33
  46. package/dist/types/llm-planning-4e0c16fe.d.ts +0 -106
  47. package/dist/types/types-8a6be57c.d.ts +0 -577
@@ -1,106 +0,0 @@
1
- import { A as AIUsageInfo, U as UIContext, i as TUserPrompt, aH as ReferenceImage, u as AIElementLocatorResponse, Q as ElementById, T as TMultimodalPrompt, h as InsightExtractOption, x as AIDataExtractionResponse, z as AIAssertionResponse, aB as PageType, aG as DeviceAction, Z as PlanningAIResponse } from './types-8a6be57c.js';
2
- import { Rect, ElementTreeNode, BaseElement } from '@midscene/shared/types';
3
- import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources';
4
-
5
- type AIArgs = [
6
- ChatCompletionSystemMessageParam,
7
- ...ChatCompletionUserMessageParam[]
8
- ];
9
- declare enum AIActionType {
10
- ASSERT = 0,
11
- INSPECT_ELEMENT = 1,
12
- EXTRACT_DATA = 2,
13
- PLAN = 3,
14
- DESCRIBE_ELEMENT = 4
15
- }
16
- declare function callAiFn<T>(msgs: AIArgs, AIActionTypeValue: AIActionType): Promise<{
17
- content: T;
18
- usage?: AIUsageInfo;
19
- }>;
20
- declare function adaptBboxToRect(bbox: number[], width: number, height: number, offsetX?: number, offsetY?: number): Rect;
21
-
22
- declare function elementByPositionWithElementInfo(treeRoot: ElementTreeNode<BaseElement>, position: {
23
- x: number;
24
- y: number;
25
- }, options?: {
26
- requireStrictDistance?: boolean;
27
- filterPositionElements?: boolean;
28
- }): BaseElement | undefined;
29
- declare function describeUserPage<ElementType extends BaseElement = BaseElement>(context: Omit<UIContext<ElementType>, 'describer'>, opt?: {
30
- truncateTextLength?: number;
31
- filterNonTextContent?: boolean;
32
- domIncluded?: boolean | 'visible-only';
33
- visibleOnly?: boolean;
34
- }): Promise<{
35
- description: string;
36
- elementById(idOrIndexId: string): ElementType;
37
- elementByPosition(position: {
38
- x: number;
39
- y: number;
40
- }, size: {
41
- width: number;
42
- height: number;
43
- }): BaseElement | undefined;
44
- insertElementByPosition(position: {
45
- x: number;
46
- y: number;
47
- }): ElementType;
48
- size: {
49
- width: number;
50
- height: number;
51
- };
52
- }>;
53
-
54
- declare function AiLocateElement<ElementType extends BaseElement = BaseElement>(options: {
55
- context: UIContext<ElementType>;
56
- targetElementDescription: TUserPrompt;
57
- referenceImage?: ReferenceImage;
58
- callAI?: typeof callAiFn<AIElementResponse | [number, number]>;
59
- searchConfig?: Awaited<ReturnType<typeof AiLocateSection>>;
60
- }): Promise<{
61
- parseResult: AIElementLocatorResponse;
62
- rect?: Rect;
63
- rawResponse: string;
64
- elementById: ElementById;
65
- usage?: AIUsageInfo;
66
- isOrderSensitive?: boolean;
67
- }>;
68
- declare function AiLocateSection(options: {
69
- context: UIContext<BaseElement>;
70
- sectionDescription: TUserPrompt;
71
- callAI?: typeof callAiFn<AISectionLocatorResponse>;
72
- }): Promise<{
73
- rect?: Rect;
74
- imageBase64?: string;
75
- error?: string;
76
- rawResponse: string;
77
- usage?: AIUsageInfo;
78
- }>;
79
- declare function AiExtractElementInfo<T, ElementType extends BaseElement = BaseElement>(options: {
80
- dataQuery: string | Record<string, string>;
81
- multimodalPrompt?: TMultimodalPrompt;
82
- context: UIContext<ElementType>;
83
- extractOption?: InsightExtractOption;
84
- }): Promise<{
85
- parseResult: AIDataExtractionResponse<T>;
86
- elementById: (idOrIndexId: string) => ElementType;
87
- usage: AIUsageInfo | undefined;
88
- }>;
89
- declare function AiAssert<ElementType extends BaseElement = BaseElement>(options: {
90
- assertion: TUserPrompt;
91
- context: UIContext<ElementType>;
92
- }): Promise<{
93
- content: AIAssertionResponse;
94
- usage: AIUsageInfo | undefined;
95
- }>;
96
-
97
- declare function plan(userInstruction: string, opts: {
98
- context: UIContext;
99
- pageType: PageType;
100
- actionSpace: DeviceAction[];
101
- callAI?: typeof callAiFn<PlanningAIResponse>;
102
- log?: string;
103
- actionContext?: string;
104
- }): Promise<PlanningAIResponse>;
105
-
106
- export { AiLocateElement as A, AiAssert as a, AIActionType as b, callAiFn as c, describeUserPage as d, type AIArgs as e, elementByPositionWithElementInfo as f, AiExtractElementInfo as g, AiLocateSection as h, adaptBboxToRect as i, plan as p };
@@ -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 };