@aiscene/core 8.1.2 → 9.0.1

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 (112) hide show
  1. package/dist/es/agent/agent.mjs +26 -11
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/task-builder.mjs +4 -2
  4. package/dist/es/agent/task-builder.mjs.map +1 -1
  5. package/dist/es/agent/tasks.mjs +26 -14
  6. package/dist/es/agent/tasks.mjs.map +1 -1
  7. package/dist/es/agent/ui-utils.mjs +13 -1
  8. package/dist/es/agent/ui-utils.mjs.map +1 -1
  9. package/dist/es/agent/usage-intent.mjs +18 -0
  10. package/dist/es/agent/usage-intent.mjs.map +1 -0
  11. package/dist/es/agent/utils.mjs +9 -26
  12. package/dist/es/agent/utils.mjs.map +1 -1
  13. package/dist/es/ai-model/auto-glm/planning.mjs.map +1 -1
  14. package/dist/es/ai-model/inspect.mjs +2 -4
  15. package/dist/es/ai-model/inspect.mjs.map +1 -1
  16. package/dist/es/ai-model/llm-planning.mjs +1 -3
  17. package/dist/es/ai-model/llm-planning.mjs.map +1 -1
  18. package/dist/es/ai-model/prompt/extraction.mjs +0 -2
  19. package/dist/es/ai-model/prompt/extraction.mjs.map +1 -1
  20. package/dist/es/ai-model/prompt/llm-planning.mjs +18 -0
  21. package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -1
  22. package/dist/es/ai-model/prompt/playwright-generator.mjs +4 -4
  23. package/dist/es/ai-model/prompt/playwright-generator.mjs.map +1 -1
  24. package/dist/es/ai-model/service-caller/codex-app-server.mjs +12 -12
  25. package/dist/es/ai-model/service-caller/codex-app-server.mjs.map +1 -1
  26. package/dist/es/ai-model/service-caller/index.mjs +148 -118
  27. package/dist/es/ai-model/service-caller/index.mjs.map +1 -1
  28. package/dist/es/ai-model/service-caller/request-timeout.mjs +49 -0
  29. package/dist/es/ai-model/service-caller/request-timeout.mjs.map +1 -0
  30. package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -1
  31. package/dist/es/common.mjs +16 -3
  32. package/dist/es/common.mjs.map +1 -1
  33. package/dist/es/device/index.mjs +171 -30
  34. package/dist/es/device/index.mjs.map +1 -1
  35. package/dist/es/dump/screenshot-store.mjs +7 -6
  36. package/dist/es/dump/screenshot-store.mjs.map +1 -1
  37. package/dist/es/index.mjs +2 -2
  38. package/dist/es/index.mjs.map +1 -1
  39. package/dist/es/report-generator.mjs +25 -25
  40. package/dist/es/report-generator.mjs.map +1 -1
  41. package/dist/es/report.mjs +20 -1
  42. package/dist/es/report.mjs.map +1 -1
  43. package/dist/es/skill/index.mjs +3 -4
  44. package/dist/es/skill/index.mjs.map +1 -1
  45. package/dist/es/types.mjs +20 -1
  46. package/dist/es/types.mjs.map +1 -1
  47. package/dist/es/utils.mjs +2 -2
  48. package/dist/es/yaml/player.mjs +2 -17
  49. package/dist/es/yaml/player.mjs.map +1 -1
  50. package/dist/lib/agent/agent.js +26 -11
  51. package/dist/lib/agent/agent.js.map +1 -1
  52. package/dist/lib/agent/task-builder.js +4 -2
  53. package/dist/lib/agent/task-builder.js.map +1 -1
  54. package/dist/lib/agent/tasks.js +25 -13
  55. package/dist/lib/agent/tasks.js.map +1 -1
  56. package/dist/lib/agent/ui-utils.js +13 -1
  57. package/dist/lib/agent/ui-utils.js.map +1 -1
  58. package/dist/lib/agent/usage-intent.js +52 -0
  59. package/dist/lib/agent/usage-intent.js.map +1 -0
  60. package/dist/lib/agent/utils.js +9 -26
  61. package/dist/lib/agent/utils.js.map +1 -1
  62. package/dist/lib/ai-model/auto-glm/planning.js.map +1 -1
  63. package/dist/lib/ai-model/inspect.js +2 -4
  64. package/dist/lib/ai-model/inspect.js.map +1 -1
  65. package/dist/lib/ai-model/llm-planning.js +1 -3
  66. package/dist/lib/ai-model/llm-planning.js.map +1 -1
  67. package/dist/lib/ai-model/prompt/extraction.js +0 -2
  68. package/dist/lib/ai-model/prompt/extraction.js.map +1 -1
  69. package/dist/lib/ai-model/prompt/llm-planning.js +18 -0
  70. package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -1
  71. package/dist/lib/ai-model/prompt/playwright-generator.js +4 -4
  72. package/dist/lib/ai-model/prompt/playwright-generator.js.map +1 -1
  73. package/dist/lib/ai-model/service-caller/codex-app-server.js +12 -12
  74. package/dist/lib/ai-model/service-caller/codex-app-server.js.map +1 -1
  75. package/dist/lib/ai-model/service-caller/index.js +148 -118
  76. package/dist/lib/ai-model/service-caller/index.js.map +1 -1
  77. package/dist/lib/ai-model/service-caller/request-timeout.js +95 -0
  78. package/dist/lib/ai-model/service-caller/request-timeout.js.map +1 -0
  79. package/dist/lib/ai-model/ui-tars-planning.js.map +1 -1
  80. package/dist/lib/common.js +16 -3
  81. package/dist/lib/common.js.map +1 -1
  82. package/dist/lib/device/index.js +176 -29
  83. package/dist/lib/device/index.js.map +1 -1
  84. package/dist/lib/dump/screenshot-store.js +6 -5
  85. package/dist/lib/dump/screenshot-store.js.map +1 -1
  86. package/dist/lib/index.js +7 -1
  87. package/dist/lib/index.js.map +1 -1
  88. package/dist/lib/report-generator.js +23 -23
  89. package/dist/lib/report-generator.js.map +1 -1
  90. package/dist/lib/report.js +19 -0
  91. package/dist/lib/report.js.map +1 -1
  92. package/dist/lib/skill/index.js +3 -4
  93. package/dist/lib/skill/index.js.map +1 -1
  94. package/dist/lib/types.js +33 -6
  95. package/dist/lib/types.js.map +1 -1
  96. package/dist/lib/utils.js +2 -2
  97. package/dist/lib/yaml/player.js +2 -17
  98. package/dist/lib/yaml/player.js.map +1 -1
  99. package/dist/types/agent/agent.d.ts +4 -0
  100. package/dist/types/agent/tasks.d.ts +8 -7
  101. package/dist/types/agent/usage-intent.d.ts +3 -0
  102. package/dist/types/ai-model/llm-planning.d.ts +2 -2
  103. package/dist/types/ai-model/service-caller/codex-app-server.d.ts +5 -5
  104. package/dist/types/ai-model/service-caller/index.d.ts +1 -4
  105. package/dist/types/ai-model/service-caller/request-timeout.d.ts +32 -0
  106. package/dist/types/device/device-options.d.ts +11 -1
  107. package/dist/types/device/index.d.ts +195 -24
  108. package/dist/types/dump/screenshot-store.d.ts +2 -2
  109. package/dist/types/index.d.ts +1 -2
  110. package/dist/types/report-generator.d.ts +7 -0
  111. package/dist/types/types.d.ts +50 -4
  112. package/package.json +2 -2
@@ -6,6 +6,110 @@ import type { ElementCacheFeature, Rect, Size } from '../types';
6
6
  export interface FileChooserHandler {
7
7
  accept(files: string[]): Promise<void>;
8
8
  }
9
+ export interface MjpegStreamFrame {
10
+ /** Raw base64-encoded image bytes WITHOUT a `data:image/...;base64,` prefix. */
11
+ data: string;
12
+ contentType?: string;
13
+ }
14
+ export interface MjpegStreamHandle {
15
+ stop(): void | Promise<void>;
16
+ }
17
+ export interface MjpegStreamOptions {
18
+ signal?: AbortSignal;
19
+ onFrame(frame: MjpegStreamFrame): void;
20
+ onError?(error: unknown): void;
21
+ }
22
+ /** A point in device-pixel coordinates on the screen. */
23
+ export interface PointerPoint {
24
+ x: number;
25
+ y: number;
26
+ }
27
+ export interface PointerInputPrimitives {
28
+ tap(p: PointerPoint, opts?: {
29
+ duration?: number;
30
+ }): Promise<void>;
31
+ doubleClick?(p: PointerPoint): Promise<void>;
32
+ rightClick?(p: PointerPoint): Promise<void>;
33
+ hover?(p: PointerPoint): Promise<void>;
34
+ longPress?(p: PointerPoint, opts?: {
35
+ duration?: number;
36
+ }): Promise<void>;
37
+ dragAndDrop?(from: PointerPoint, to: PointerPoint): Promise<void>;
38
+ }
39
+ export interface TouchInputPrimitives {
40
+ swipe(start: PointerPoint, end: PointerPoint, opts?: {
41
+ duration?: number;
42
+ repeat?: number;
43
+ }): Promise<void>;
44
+ pinch?(center: PointerPoint, opts: {
45
+ startDistance: number;
46
+ endDistance: number;
47
+ duration: number;
48
+ }): Promise<void>;
49
+ }
50
+ export interface KeyboardInputPrimitives {
51
+ keyboardPress(keyName: string, opts?: {
52
+ target?: unknown;
53
+ }): Promise<void>;
54
+ cursorMove?(direction: 'left' | 'right', times?: number): Promise<void>;
55
+ typeText(value: string, opts?: {
56
+ autoDismissKeyboard?: boolean;
57
+ target?: unknown;
58
+ replace?: boolean;
59
+ focusOnly?: boolean;
60
+ }): Promise<void>;
61
+ clearInput(target?: unknown): Promise<void>;
62
+ }
63
+ export interface ScrollInputPrimitives {
64
+ scroll(param: ActionScrollParam): Promise<void>;
65
+ }
66
+ export interface SystemInputPrimitives {
67
+ backButton?(): Promise<void>;
68
+ homeButton?(): Promise<void>;
69
+ recentAppsButton?(): Promise<void>;
70
+ }
71
+ export interface InputPrimitives {
72
+ pointer?: PointerInputPrimitives;
73
+ keyboard?: KeyboardInputPrimitives;
74
+ touch?: TouchInputPrimitives;
75
+ scroll?: ScrollInputPrimitives;
76
+ system?: SystemInputPrimitives;
77
+ }
78
+ export interface MobileInputPrimitives extends InputPrimitives {
79
+ pointer: PointerInputPrimitives & {
80
+ doubleClick(p: PointerPoint): Promise<void>;
81
+ longPress(p: PointerPoint, opts?: {
82
+ duration?: number;
83
+ }): Promise<void>;
84
+ dragAndDrop(from: PointerPoint, to: PointerPoint): Promise<void>;
85
+ };
86
+ keyboard: KeyboardInputPrimitives;
87
+ touch: TouchInputPrimitives;
88
+ }
89
+ export interface BrowserInputPrimitives extends InputPrimitives {
90
+ pointer: PointerInputPrimitives & {
91
+ doubleClick(p: PointerPoint): Promise<void>;
92
+ rightClick(p: PointerPoint): Promise<void>;
93
+ hover(p: PointerPoint): Promise<void>;
94
+ dragAndDrop(from: PointerPoint, to: PointerPoint): Promise<void>;
95
+ longPress(p: PointerPoint, opts?: {
96
+ duration?: number;
97
+ }): Promise<void>;
98
+ };
99
+ keyboard: KeyboardInputPrimitives;
100
+ scroll: ScrollInputPrimitives;
101
+ touch: TouchInputPrimitives;
102
+ }
103
+ export interface ComputerInputPrimitives extends InputPrimitives {
104
+ pointer: PointerInputPrimitives & {
105
+ doubleClick(p: PointerPoint): Promise<void>;
106
+ rightClick(p: PointerPoint): Promise<void>;
107
+ hover(p: PointerPoint): Promise<void>;
108
+ dragAndDrop(from: PointerPoint, to: PointerPoint): Promise<void>;
109
+ };
110
+ keyboard: KeyboardInputPrimitives;
111
+ scroll: ScrollInputPrimitives;
112
+ }
9
113
  export declare abstract class AbstractInterface {
10
114
  abstract interfaceType: string;
11
115
  abstract screenshotBase64(): Promise<string>;
@@ -28,13 +132,39 @@ export declare abstract class AbstractInterface {
28
132
  abstract url?: () => string | Promise<string>;
29
133
  abstract evaluateJavaScript?<T = any>(script: string): Promise<T>;
30
134
  /**
31
- * Get the current time from the device.
32
- * Returns the device's current timestamp in milliseconds.
33
- * This is useful when the system time and device time are not synchronized.
135
+ * Get the current device-local time as a formatted string.
136
+ * Prefer this for user-visible time because timestamps alone do not preserve
137
+ * the target device's timezone when formatted on the host machine.
34
138
  */
35
- getTimestamp?(): Promise<number>;
139
+ getDeviceLocalTimeString?(format?: string): Promise<string>;
36
140
  /** URL of native MJPEG stream for real-time screen preview (e.g. WDA MJPEG server) */
37
141
  mjpegStreamUrl?: string;
142
+ /**
143
+ * Optional in-process MJPEG frame producer. Implementations can push raw
144
+ * base64 frames here when there is no standalone native MJPEG URL, e.g.
145
+ * Chromium CDP Page.startScreencast for web previews.
146
+ */
147
+ startMjpegStream?(options: MjpegStreamOptions): MjpegStreamHandle | undefined | Promise<MjpegStreamHandle | undefined>;
148
+ /**
149
+ * Optional hook used after keyboard-only actions to force a fresh frame on
150
+ * the active MJPEG stream. Implementations should be a no-op when no stream
151
+ * is active.
152
+ */
153
+ flushPendingVisualUpdate?(): Promise<void>;
154
+ /**
155
+ * Optional navigation state probe for browser-like interfaces, used to drive
156
+ * loading indicators in playground UIs. Returning `undefined` means the
157
+ * interface does not expose this concept.
158
+ */
159
+ navigationState?(): Promise<{
160
+ isLoading: boolean;
161
+ }>;
162
+ /**
163
+ * Low-level device input surface. Platform implementations expose transport
164
+ * primitives here; higher-level AI actions and manual pointer dispatch should
165
+ * adapt to this instead of duplicating platform gesture logic.
166
+ */
167
+ inputPrimitives?: InputPrimitives;
38
168
  }
39
169
  export declare const defineAction: <TSchema extends z.ZodType | undefined = undefined, TRuntime = TSchema extends z.ZodType ? z.infer<TSchema> : undefined, TReturn = any>(config: {
40
170
  name: string;
@@ -193,7 +323,7 @@ export declare const actionTapParamSchema: z.ZodObject<{
193
323
  export type ActionTapParam = {
194
324
  locate: LocateResultElement;
195
325
  };
196
- export declare const defineActionTap: (call: (param: ActionTapParam) => Promise<void>) => DeviceAction<ActionTapParam>;
326
+ export declare const defineActionTap: (tap: PointerInputPrimitives["tap"]) => DeviceAction<ActionTapParam>;
197
327
  export declare const actionRightClickParamSchema: z.ZodObject<{
198
328
  locate: z.ZodObject<{
199
329
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -344,7 +474,7 @@ export declare const actionRightClickParamSchema: z.ZodObject<{
344
474
  export type ActionRightClickParam = {
345
475
  locate: LocateResultElement;
346
476
  };
347
- export declare const defineActionRightClick: (call: (param: ActionRightClickParam) => Promise<void>) => DeviceAction<ActionRightClickParam>;
477
+ export declare const defineActionRightClick: (rightClick: NonNullable<PointerInputPrimitives["rightClick"]>) => DeviceAction<ActionRightClickParam>;
348
478
  export declare const actionDoubleClickParamSchema: z.ZodObject<{
349
479
  locate: z.ZodObject<{
350
480
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -495,7 +625,7 @@ export declare const actionDoubleClickParamSchema: z.ZodObject<{
495
625
  export type ActionDoubleClickParam = {
496
626
  locate: LocateResultElement;
497
627
  };
498
- export declare const defineActionDoubleClick: (call: (param: ActionDoubleClickParam) => Promise<void>) => DeviceAction<ActionDoubleClickParam>;
628
+ export declare const defineActionDoubleClick: (doubleClick: NonNullable<PointerInputPrimitives["doubleClick"]>) => DeviceAction<ActionDoubleClickParam>;
499
629
  export declare const actionHoverParamSchema: z.ZodObject<{
500
630
  locate: z.ZodObject<{
501
631
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -646,7 +776,7 @@ export declare const actionHoverParamSchema: z.ZodObject<{
646
776
  export type ActionHoverParam = {
647
777
  locate: LocateResultElement;
648
778
  };
649
- export declare const defineActionHover: (call: (param: ActionHoverParam) => Promise<void>) => DeviceAction<ActionHoverParam>;
779
+ export declare const defineActionHover: (hover: NonNullable<PointerInputPrimitives["hover"]>) => DeviceAction<ActionHoverParam>;
650
780
  export declare const actionInputParamSchema: z.ZodObject<{
651
781
  value: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>;
652
782
  locate: z.ZodOptional<z.ZodObject<{
@@ -759,6 +889,7 @@ export declare const actionInputParamSchema: z.ZodObject<{
759
889
  xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
760
890
  }, z.ZodTypeAny, "passthrough">>>;
761
891
  mode: z.ZodDefault<z.ZodEnum<["replace", "clear", "typeOnly"]>>;
892
+ autoDismissKeyboard: z.ZodOptional<z.ZodBoolean>;
762
893
  }, "strip", z.ZodTypeAny, {
763
894
  value: string;
764
895
  mode: "replace" | "clear" | "typeOnly";
@@ -799,6 +930,7 @@ export declare const actionInputParamSchema: z.ZodObject<{
799
930
  cacheable: z.ZodOptional<z.ZodBoolean>;
800
931
  xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
801
932
  }, z.ZodTypeAny, "passthrough"> | undefined;
933
+ autoDismissKeyboard?: boolean | undefined;
802
934
  }, {
803
935
  value: string | number;
804
936
  locate?: z.objectInputType<{
@@ -839,13 +971,15 @@ export declare const actionInputParamSchema: z.ZodObject<{
839
971
  xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
840
972
  }, z.ZodTypeAny, "passthrough"> | undefined;
841
973
  mode?: "replace" | "clear" | "typeOnly" | undefined;
974
+ autoDismissKeyboard?: boolean | undefined;
842
975
  }>;
843
976
  export type ActionInputParam = {
844
977
  value: string;
845
978
  locate?: LocateResultElement;
846
979
  mode?: 'replace' | 'clear' | 'typeOnly' | 'append';
980
+ autoDismissKeyboard?: boolean;
847
981
  };
848
- export declare const defineActionInput: (call: (param: ActionInputParam) => Promise<void>) => DeviceAction<ActionInputParam>;
982
+ export declare const defineActionInput: (keyboard: KeyboardInputPrimitives) => DeviceAction<ActionInputParam>;
849
983
  export declare const actionKeyboardPressParamSchema: z.ZodObject<{
850
984
  locate: z.ZodOptional<z.ZodObject<{
851
985
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -1040,7 +1174,7 @@ export type ActionKeyboardPressParam = {
1040
1174
  locate?: LocateResultElement;
1041
1175
  keyName: string;
1042
1176
  };
1043
- export declare const defineActionKeyboardPress: (call: (param: ActionKeyboardPressParam) => Promise<void>) => DeviceAction<ActionKeyboardPressParam>;
1177
+ export declare const defineActionKeyboardPress: (keyboardPress: KeyboardInputPrimitives["keyboardPress"]) => DeviceAction<ActionKeyboardPressParam>;
1044
1178
  export declare const actionScrollParamSchema: z.ZodObject<{
1045
1179
  scrollType: z.ZodDefault<z.ZodEnum<["singleAction", "scrollToBottom", "scrollToTop", "scrollToRight", "scrollToLeft"]>>;
1046
1180
  direction: z.ZodDefault<z.ZodEnum<["down", "up", "right", "left"]>>;
@@ -1156,7 +1290,7 @@ export declare const actionScrollParamSchema: z.ZodObject<{
1156
1290
  }, z.ZodTypeAny, "passthrough">>>;
1157
1291
  }, "strip", z.ZodTypeAny, {
1158
1292
  scrollType: "singleAction" | "scrollToBottom" | "scrollToTop" | "scrollToRight" | "scrollToLeft";
1159
- direction: "down" | "up" | "right" | "left";
1293
+ direction: "left" | "right" | "down" | "up";
1160
1294
  locate?: z.objectOutputType<{
1161
1295
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
1162
1296
  prompt: z.ZodString;
@@ -1234,10 +1368,10 @@ export declare const actionScrollParamSchema: z.ZodObject<{
1234
1368
  xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
1235
1369
  }, z.ZodTypeAny, "passthrough"> | undefined;
1236
1370
  scrollType?: "singleAction" | "scrollToBottom" | "scrollToTop" | "scrollToRight" | "scrollToLeft" | undefined;
1237
- direction?: "down" | "up" | "right" | "left" | undefined;
1371
+ direction?: "left" | "right" | "down" | "up" | undefined;
1238
1372
  distance?: number | null | undefined;
1239
1373
  }>;
1240
- export declare const defineActionScroll: (call: (param: ActionScrollParam) => Promise<void>) => DeviceAction<ActionScrollParam>;
1374
+ export declare const defineActionScroll: (scroll: ScrollInputPrimitives["scroll"]) => DeviceAction<ActionScrollParam>;
1241
1375
  export declare const actionDragAndDropParamSchema: z.ZodObject<{
1242
1376
  from: z.ZodObject<{
1243
1377
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -1532,7 +1666,7 @@ export type ActionDragAndDropParam = {
1532
1666
  from: LocateResultElement;
1533
1667
  to: LocateResultElement;
1534
1668
  };
1535
- export declare const defineActionDragAndDrop: (call: (param: ActionDragAndDropParam) => Promise<void>) => DeviceAction<ActionDragAndDropParam>;
1669
+ export declare const defineActionDragAndDrop: (dragAndDrop: NonNullable<PointerInputPrimitives["dragAndDrop"]>) => DeviceAction<ActionDragAndDropParam>;
1536
1670
  export declare const ActionLongPressParamSchema: z.ZodObject<{
1537
1671
  locate: z.ZodObject<{
1538
1672
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -1643,7 +1777,7 @@ export declare const ActionLongPressParamSchema: z.ZodObject<{
1643
1777
  cacheable: z.ZodOptional<z.ZodBoolean>;
1644
1778
  xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
1645
1779
  }, z.ZodTypeAny, "passthrough">>;
1646
- duration: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1780
+ duration: z.ZodOptional<z.ZodNumber>;
1647
1781
  }, "strip", z.ZodTypeAny, {
1648
1782
  locate: {
1649
1783
  prompt: string | ({
@@ -1687,7 +1821,7 @@ export type ActionLongPressParam = {
1687
1821
  locate: LocateResultElement;
1688
1822
  duration?: number;
1689
1823
  };
1690
- export declare const defineActionLongPress: (call: (param: ActionLongPressParam) => Promise<void>) => DeviceAction<ActionLongPressParam>;
1824
+ export declare const defineActionLongPress: (longPress: NonNullable<PointerInputPrimitives["longPress"]>) => DeviceAction<ActionLongPressParam>;
1691
1825
  export declare const ActionSwipeParamSchema: z.ZodObject<{
1692
1826
  start: z.ZodOptional<z.ZodObject<{
1693
1827
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -1913,7 +2047,7 @@ export declare const ActionSwipeParamSchema: z.ZodObject<{
1913
2047
  repeat: z.ZodOptional<z.ZodNumber>;
1914
2048
  }, "strip", z.ZodTypeAny, {
1915
2049
  duration: number;
1916
- direction?: "down" | "up" | "right" | "left" | undefined;
2050
+ direction?: "left" | "right" | "down" | "up" | undefined;
1917
2051
  distance?: number | undefined;
1918
2052
  start?: z.objectOutputType<{
1919
2053
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -1991,7 +2125,7 @@ export declare const ActionSwipeParamSchema: z.ZodObject<{
1991
2125
  }, z.ZodTypeAny, "passthrough"> | undefined;
1992
2126
  repeat?: number | undefined;
1993
2127
  }, {
1994
- direction?: "down" | "up" | "right" | "left" | undefined;
2128
+ direction?: "left" | "right" | "down" | "up" | undefined;
1995
2129
  distance?: number | undefined;
1996
2130
  duration?: number | undefined;
1997
2131
  start?: z.objectInputType<{
@@ -2093,7 +2227,10 @@ export declare function normalizeMobileSwipeParam(param: ActionSwipeParam, scree
2093
2227
  duration: number;
2094
2228
  repeatCount: number;
2095
2229
  };
2096
- export declare const defineActionSwipe: (call: (param: ActionSwipeParam) => Promise<void>) => DeviceAction<ActionSwipeParam>;
2230
+ export declare const defineActionSwipe: (config: {
2231
+ swipe: TouchInputPrimitives["swipe"];
2232
+ size(): Promise<Size>;
2233
+ }) => DeviceAction<ActionSwipeParam>;
2097
2234
  export declare const actionClearInputParamSchema: z.ZodObject<{
2098
2235
  locate: z.ZodOptional<z.ZodObject<{
2099
2236
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -2284,22 +2421,25 @@ export declare const actionClearInputParamSchema: z.ZodObject<{
2284
2421
  export type ActionClearInputParam = {
2285
2422
  locate?: LocateResultElement;
2286
2423
  };
2287
- export declare const defineActionClearInput: (call: (param: ActionClearInputParam) => Promise<void>) => DeviceAction<ActionClearInputParam>;
2424
+ export declare const defineActionClearInput: (clearInput: KeyboardInputPrimitives["clearInput"]) => DeviceAction<ActionClearInputParam>;
2288
2425
  export declare const actionCursorMoveParamSchema: z.ZodObject<{
2289
2426
  direction: z.ZodEnum<["left", "right"]>;
2290
2427
  times: z.ZodDefault<z.ZodNumber>;
2291
2428
  }, "strip", z.ZodTypeAny, {
2292
- direction: "right" | "left";
2429
+ direction: "left" | "right";
2293
2430
  times: number;
2294
2431
  }, {
2295
- direction: "right" | "left";
2432
+ direction: "left" | "right";
2296
2433
  times?: number | undefined;
2297
2434
  }>;
2298
2435
  export type ActionCursorMoveParam = {
2299
2436
  direction: 'left' | 'right';
2300
2437
  times?: number;
2301
2438
  };
2302
- export declare const defineActionCursorMove: (call: (param: ActionCursorMoveParam) => Promise<void>) => DeviceAction<ActionCursorMoveParam>;
2439
+ export declare const defineActionCursorMove: (config: {
2440
+ keyboard: Pick<KeyboardInputPrimitives, "keyboardPress" | "cursorMove">;
2441
+ sleep?(timeMs: number): Promise<void>;
2442
+ }) => DeviceAction<ActionCursorMoveParam>;
2303
2443
  export declare const ActionPinchParamSchema: z.ZodObject<{
2304
2444
  locate: z.ZodOptional<z.ZodObject<{
2305
2445
  prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
@@ -2502,7 +2642,10 @@ export type ActionPinchParam = {
2502
2642
  distance?: number;
2503
2643
  duration?: number;
2504
2644
  };
2505
- export declare const defineActionPinch: (call: (param: ActionPinchParam) => Promise<void>) => DeviceAction<ActionPinchParam>;
2645
+ export declare const defineActionPinch: (config: {
2646
+ pinch: TouchInputPrimitives["pinch"];
2647
+ size(): Promise<Size>;
2648
+ }) => DeviceAction<ActionPinchParam> | undefined;
2506
2649
  export declare function normalizePinchParam(param: ActionPinchParam, screenSize: {
2507
2650
  width: number;
2508
2651
  height: number;
@@ -2513,6 +2656,34 @@ export declare function normalizePinchParam(param: ActionPinchParam, screenSize:
2513
2656
  endDistance: number;
2514
2657
  duration: number;
2515
2658
  };
2659
+ export interface MobileInputActionContext {
2660
+ input: MobileInputPrimitives;
2661
+ size(): Promise<Size>;
2662
+ sleep?(timeMs: number): Promise<void>;
2663
+ getDefaultAutoDismissKeyboard?(): boolean | undefined;
2664
+ systemActions?: SystemInputActionOptions;
2665
+ }
2666
+ export interface SystemInputActionConfig {
2667
+ name: string;
2668
+ description: string;
2669
+ interfaceAlias?: string;
2670
+ delayBeforeRunner?: number;
2671
+ delayAfterRunner?: number;
2672
+ }
2673
+ export interface SystemInputActionOptions {
2674
+ backButton?: SystemInputActionConfig;
2675
+ homeButton?: SystemInputActionConfig;
2676
+ recentAppsButton?: SystemInputActionConfig;
2677
+ }
2678
+ export interface InputPrimitiveActionOptions {
2679
+ size?: () => Promise<Size>;
2680
+ sleep?: (timeMs: number) => Promise<void>;
2681
+ includeSwipe?: boolean;
2682
+ includePinch?: boolean;
2683
+ systemActions?: SystemInputActionOptions;
2684
+ }
2685
+ export declare function defineActionsFromInputPrimitives(input: InputPrimitives, options?: InputPrimitiveActionOptions): DeviceAction<any>[];
2686
+ export declare function createDefaultMobileActions(context: MobileInputActionContext): DeviceAction<any>[];
2516
2687
  export declare const ActionSleepParamSchema: z.ZodObject<{
2517
2688
  timeMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
2518
2689
  }, "strip", z.ZodTypeAny, {
@@ -36,12 +36,12 @@ export declare class ScreenshotStore {
36
36
  mode: 'inline' | 'directory';
37
37
  reportPath: string;
38
38
  screenshotsDir?: string;
39
- writeInlineImage?: (id: string, base64: string) => void;
39
+ writeInlineImage?: (id: string, base64: string) => void | Promise<void>;
40
40
  alsoWriteFileCopy?: boolean;
41
41
  /** @deprecated Use alsoWriteFileCopy instead. */
42
42
  ensureFileCopy?: boolean;
43
43
  });
44
- persist(screenshot: ScreenshotItem): ScreenshotRef;
44
+ persist(screenshot: ScreenshotItem): Promise<ScreenshotRef>;
45
45
  private persistToSharedFileIfNeeded;
46
46
  loadBase64(refInput: unknown): string;
47
47
  cleanup(): void;
@@ -5,8 +5,7 @@ import { getVersion } from './utils';
5
5
  export { plan, AiLocateElement, runConnectivityTest, getMidsceneLocationSchema, PointSchema, SizeSchema, RectSchema, TMultimodalPromptSchema, TUserPromptSchema, type TMultimodalPrompt, type TUserPrompt, type ConnectivityCheckResultItem, type ConnectivityTestConfig, type ConnectivityTestResult, } from './ai-model/index';
6
6
  export { MIDSCENE_MODEL_NAME, type CreateOpenAIClientFn, } from '@aiscene/shared/env';
7
7
  export type * from './types';
8
- export type { DeviceAction, } from './types';
9
- export { ServiceError, ExecutionDump, ReportActionDump, GroupedActionDump, type IExecutionDump, type IReportActionDump, type IGroupedActionDump, type ReportMeta, type GroupMeta, } from './types';
8
+ export { ServiceError, ActionAssertionError, isActionAssertionError, ExecutionDump, ReportActionDump, GroupedActionDump, type IExecutionDump, type IReportActionDump, type IGroupedActionDump, type ReportMeta, type GroupMeta, } from './types';
10
9
  export { z };
11
10
  export default Service;
12
11
  export { TaskRunner, Service, getVersion };
@@ -49,12 +49,14 @@ export declare class ReportGenerator implements IReportGenerator {
49
49
  screenshotMode: 'inline' | 'directory';
50
50
  persistExecutionDump?: boolean;
51
51
  autoPrint?: boolean;
52
+ reuseExistingReport?: boolean;
52
53
  });
53
54
  static create(reportFileName: string, opts: {
54
55
  generateReport?: boolean;
55
56
  persistExecutionDump?: boolean;
56
57
  outputFormat?: 'single-html' | 'html-and-external-assets';
57
58
  autoPrintReportMsg?: boolean;
59
+ reuseExistingReport?: boolean;
58
60
  }): IReportGenerator;
59
61
  onExecutionUpdate(execution: ExecutionDump, reportMeta: ReportMeta, attributes?: ReportAttributes): void;
60
62
  flush(): Promise<void>;
@@ -73,6 +75,11 @@ export declare class ReportGenerator implements IReportGenerator {
73
75
  * Append-only inline mode: write new screenshots and a dump tag on every call.
74
76
  * The frontend deduplicates executions with the same id/name (keeps last).
75
77
  * Duplicate dump JSON is acceptable; only screenshots are deduplicated.
78
+ *
79
+ * All writes go through `fs/promises` so they run on libuv's thread pool
80
+ * rather than blocking the Node event loop. A long agent run previously
81
+ * appended multi-MB dumps (screenshots + serialized tasks) per progress
82
+ * tick on the main thread, starving IPC and UI for >10s per stall.
76
83
  */
77
84
  private writeInlineExecution;
78
85
  private writeDirectoryExecution;
@@ -15,7 +15,15 @@ export type AIUsageInfo = Record<string, any> & {
15
15
  time_cost: number | undefined;
16
16
  model_name: string | undefined;
17
17
  model_description: string | undefined;
18
+ /**
19
+ * Semantic intent of the model call, such as default, planning, or insight.
20
+ */
18
21
  intent: string | undefined;
22
+ /**
23
+ * Config slot where the model config was resolved from. For example, a
24
+ * planning call may use the default slot when no planning model is configured.
25
+ */
26
+ slot: string | undefined;
19
27
  request_id: string | undefined;
20
28
  };
21
29
  export type { LocateResultElement };
@@ -155,6 +163,41 @@ export declare class ServiceError extends Error {
155
163
  dump: ServiceDump;
156
164
  constructor(message: string, dump: ServiceDump);
157
165
  }
166
+ /**
167
+ * Thrown by a DeviceAction whose semantics are "assert / verify".
168
+ *
169
+ * The task executor in [`tasks.ts`](packages/core/src/agent/tasks.ts) treats
170
+ * regular action errors as soft failures and asks the planner to retry — that
171
+ * is the right behavior for transient issues like a missed tap, but it is the
172
+ * wrong behavior for actions like `ExpectToast` whose entire purpose is to
173
+ * guarantee a postcondition. When an `ActionAssertionError` bubbles out of
174
+ * `action.call()`, the executor MUST stop the current `aiAct` run and surface
175
+ * the error to the caller without re-planning.
176
+ *
177
+ * Use this class (or a subclass) instead of a plain `Error` from any action
178
+ * whose contract is verification rather than mutation.
179
+ */
180
+ export declare class ActionAssertionError extends Error {
181
+ /** Name of the action that raised the assertion (e.g. "ExpectToast"). */
182
+ readonly actionName?: string;
183
+ /**
184
+ * Optional structured detail — surfaced to the test report so users can see
185
+ * what was expected vs. observed without parsing the message string.
186
+ */
187
+ readonly detail?: Record<string, unknown>;
188
+ constructor(message: string, options?: {
189
+ actionName?: string;
190
+ detail?: Record<string, unknown>;
191
+ });
192
+ }
193
+ /**
194
+ * Type guard usable across packages without instanceof issues.
195
+ *
196
+ * Walks the `.cause` chain (depth-limited) so that wrappers like
197
+ * `TaskExecutionError` — which the task runner uses to re-throw the failure of
198
+ * an individual action — still report as assertion errors.
199
+ */
200
+ export declare function isActionAssertionError(err: unknown): err is ActionAssertionError;
158
201
  export interface LiteUISection {
159
202
  name: string;
160
203
  description: string;
@@ -530,6 +573,7 @@ export interface DeviceAction<TParam = any, TReturn = any> {
530
573
  interfaceAlias?: string;
531
574
  paramSchema?: z.ZodType<TParam>;
532
575
  call: (param: TParam, context: ExecutorContext) => Promise<TReturn> | TReturn;
576
+ delayBeforeRunner?: number;
533
577
  delayAfterRunner?: number;
534
578
  /**
535
579
  * An example param object for this action.
@@ -595,6 +639,7 @@ export interface AgentOpt {
595
639
  aiActContext?: string;
596
640
  aiActionContext?: string;
597
641
  reportFileName?: string;
642
+ reportAttributes?: ReportAttributes;
598
643
  modelConfig?: TModelConfig;
599
644
  cache?: Cache;
600
645
  /**
@@ -610,11 +655,12 @@ export interface AgentOpt {
610
655
  */
611
656
  waitAfterAction?: number;
612
657
  /**
613
- * When set to true, Midscene will use the target device's time (Android/iOS)
614
- * instead of the system time. Useful when the device time differs from the
615
- * host machine. Default: false
658
+ * When set to true, Midscene will use the target device's formatted local
659
+ * time instead of the runtime system time. The target interface must implement
660
+ * getDeviceLocalTimeString to provide device-local wall-clock time.
661
+ * Default: false
616
662
  */
617
- useDeviceTimestamp?: boolean;
663
+ useDeviceTime?: boolean;
618
664
  /**
619
665
  * Custom screenshot shrink factor to reduce AI token usage.
620
666
  * When set, the screenshot will be scaled down by this factor from the physical resolution.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aiscene/core",
3
3
  "description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
4
- "version": "8.1.2",
4
+ "version": "9.0.1",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "main": "./dist/lib/index.js",
@@ -78,7 +78,7 @@
78
78
  "test:parse-action": "npm run test:ai -- tests/ai/parse-action.test.ts"
79
79
  },
80
80
  "dependencies": {
81
- "@aiscene/shared": "^8.0.2",
81
+ "@aiscene/shared": "workspace:*",
82
82
  "@ui-tars/action-parser": "1.2.3",
83
83
  "dayjs": "^1.11.11",
84
84
  "dotenv": "^16.4.5",