@roll-agent/browser-use-agent 0.7.6 → 0.7.7

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.
@@ -0,0 +1,55 @@
1
+ import type { NativeCdpController, NativeCdpMouseEventInput } from "@roll-agent/browser";
2
+ export type NativeMousePoint = {
3
+ readonly x: number;
4
+ readonly y: number;
5
+ };
6
+ export type NativeMouseMotionPreview = {
7
+ readonly points: readonly NativeMousePoint[];
8
+ readonly durationMs: number;
9
+ };
10
+ export type NativeMouseClickPreview = {
11
+ readonly point: NativeMousePoint;
12
+ readonly durationMs: number;
13
+ };
14
+ export type NativeMouseMotionObserver = {
15
+ previewMouseMotion(preview: NativeMouseMotionPreview): Promise<void>;
16
+ previewMouseClick?(preview: NativeMouseClickPreview): Promise<void>;
17
+ };
18
+ export type NativeMouseMotionControllerOptions = {
19
+ readonly sleep?: (ms: number) => Promise<void>;
20
+ readonly stepDelayMs?: number;
21
+ };
22
+ export type NativeMouseMoveOptions = {
23
+ readonly button?: NativeCdpMouseEventInput["button"];
24
+ readonly buttons?: number;
25
+ readonly motionObserver?: NativeMouseMotionObserver;
26
+ readonly stepDelayMs?: number;
27
+ };
28
+ export type NativeMouseClickOptions = {
29
+ readonly button?: NativeCdpMouseEventInput["button"];
30
+ readonly clickCount?: number;
31
+ readonly motionObserver?: NativeMouseMotionObserver;
32
+ readonly preClickDelayMs?: number;
33
+ readonly pressDurationMs?: number;
34
+ readonly settleMs?: number;
35
+ };
36
+ export type NativeMouseDragOptions = {
37
+ readonly motionObserver?: NativeMouseMotionObserver;
38
+ readonly pressDurationMs?: number;
39
+ readonly stepDelayMs?: number;
40
+ };
41
+ type NativeMouseDispatcher = Pick<NativeCdpController, "dispatchMouseEvent">;
42
+ export declare function createNativeMousePath(currentPoint: NativeMousePoint | undefined, targetPoint: NativeMousePoint): readonly NativeMousePoint[];
43
+ export declare class NativeMouseMotionController {
44
+ private readonly dispatcher;
45
+ private readonly sleep;
46
+ private readonly defaultStepDelayMs;
47
+ private lastPoint;
48
+ constructor(dispatcher: NativeMouseDispatcher, options?: NativeMouseMotionControllerOptions);
49
+ reset(point?: NativeMousePoint): void;
50
+ moveTo(targetPoint: NativeMousePoint, options?: NativeMouseMoveOptions): Promise<NativeMouseMotionPreview>;
51
+ click(targetPoint: NativeMousePoint, options?: NativeMouseClickOptions): Promise<void>;
52
+ drag(fromPoint: NativeMousePoint, toPoint: NativeMousePoint, options?: NativeMouseDragOptions): Promise<void>;
53
+ private delayIfPositive;
54
+ }
55
+ export {};
@@ -1,4 +1,5 @@
1
1
  import type { VisualActivityTone } from "./visual-activity.ts";
2
+ import type { NativeMouseClickPreview, NativeMouseMotionObserver, NativeMouseMotionPreview } from "./native-mouse-motion.ts";
2
3
  type NativeVisualTarget = {
3
4
  evaluateJson<T = unknown>(expression: string): Promise<T>;
4
5
  };
@@ -7,15 +8,13 @@ type NativeVisualHighlightOptions = {
7
8
  readonly padding?: number;
8
9
  readonly tone?: VisualActivityTone;
9
10
  };
10
- type NativeVisualPointOptions = {
11
- readonly durationMs?: number;
12
- };
13
- export declare class NativeVisualActivitySession {
11
+ export declare class NativeVisualActivitySession implements NativeMouseMotionObserver {
14
12
  private readonly target;
15
13
  constructor(target: NativeVisualTarget);
16
14
  begin(label: string, tone?: VisualActivityTone): Promise<boolean>;
17
15
  highlightSelector(selector: string, options?: NativeVisualHighlightOptions): Promise<boolean>;
18
- highlightPoint(x: number, y: number, options?: NativeVisualPointOptions): Promise<boolean>;
16
+ previewMouseMotion(preview: NativeMouseMotionPreview): Promise<void>;
17
+ previewMouseClick(preview: NativeMouseClickPreview): Promise<void>;
19
18
  succeed(label: string, lingerMs?: number): Promise<boolean>;
20
19
  fail(label: string, lingerMs?: number): Promise<boolean>;
21
20
  clear(): Promise<boolean>;
@@ -1,4 +1,5 @@
1
1
  import type { BrowserContextManager, BrowserInspectablePage, BrowserRuntime, NativeCdpController } from "@roll-agent/browser";
2
+ import { type NativeMouseMotionObserver } from "../../native-mouse-motion.ts";
2
3
  import type { DynamicListCollectionStopReason, DynamicListScrollResult, ScrollDirection } from "../shared/dynamic-list-scroller.ts";
3
4
  import { type ChatListItem, type ChatTarget, type OpenChatResult } from "./chat-navigation.ts";
4
5
  import { type ZhipinListSurface } from "./list-surfaces.ts";
@@ -37,6 +38,7 @@ export type ReadNativeRecommendCandidatesOptions = {
37
38
  export type OpenNativeChatOptions = ChatTarget & {
38
39
  readonly preferUnread?: boolean;
39
40
  readonly maxScrolls?: number;
41
+ readonly motionObserver?: NativeMouseMotionObserver;
40
42
  };
41
43
  export type NativeChatMessage = {
42
44
  readonly index: number;
@@ -97,13 +99,8 @@ export type NativeDynamicListCollectionResult<TItem> = DynamicListScrollResult &
97
99
  readonly noNewRounds: number;
98
100
  readonly stopReason: DynamicListCollectionStopReason;
99
101
  };
100
- type NativeClickTarget = {
101
- readonly found: boolean;
102
- readonly x: number;
103
- readonly y: number;
104
- };
105
102
  type NativeClickOptions = {
106
- readonly onTargetResolved?: (target: NativeClickTarget) => Promise<void>;
103
+ readonly motionObserver?: NativeMouseMotionObserver;
107
104
  readonly preClickDelayMs?: number;
108
105
  readonly pressDurationMs?: number;
109
106
  readonly settleMs?: number;
@@ -118,6 +115,7 @@ export declare function openZhipinNativePagePort(options?: NativePageResolutionO
118
115
  export declare class ZhipinNativePagePort {
119
116
  private readonly target;
120
117
  private readonly controller;
118
+ private readonly mouse;
121
119
  private recommendFrameContextId;
122
120
  private recommendFrameContextFrameId;
123
121
  constructor(options: ZhipinNativePagePortOptions);
@@ -1,7 +1,7 @@
1
1
  import { NativeVisualActivitySession } from "../native-visual-activity-session.ts";
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightPoint" | "succeed" | "fail">;
4
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "previewMouseMotion" | "succeed" | "fail">;
5
5
  type ZhipinExchangeWechatDeps = {
6
6
  readonly openNativePagePort: typeof openZhipinNativePagePort;
7
7
  readonly createNativeVisualActivitySession: (page: ZhipinNativePagePort) => NativeVisualActivitySessionLike;
@@ -1,7 +1,7 @@
1
1
  import { NativeVisualActivitySession } from "../native-visual-activity-session.ts";
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "highlightPoint" | "succeed" | "fail">;
4
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "previewMouseMotion" | "succeed" | "fail">;
5
5
  type ZhipinFilterRecommendCandidatesDeps = {
6
6
  readonly openNativePagePort: typeof openZhipinNativePagePort;
7
7
  readonly createNativeVisualActivitySession: (page: ZhipinNativePagePort) => NativeVisualActivitySessionLike;
@@ -2,9 +2,7 @@ import { NativeVisualActivitySession } from "../native-visual-activity-session.t
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
4
  import { getContextManager } from "../runtime-holder.ts";
5
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "succeed" | "fail"> & {
6
- readonly highlightPoint?: NativeVisualActivitySession["highlightPoint"];
7
- };
5
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "previewMouseMotion" | "succeed" | "fail">;
8
6
  type ZhipinOpenChatPageDeps = {
9
7
  readonly getContextManager: typeof getContextManager;
10
8
  readonly openNativePagePort: typeof openZhipinNativePagePort;
@@ -1,7 +1,7 @@
1
1
  import { NativeVisualActivitySession } from "../native-visual-activity-session.ts";
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "succeed" | "fail">;
4
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "previewMouseMotion" | "succeed" | "fail">;
5
5
  type ZhipinOpenChatDeps = {
6
6
  readonly openNativePagePort: typeof openZhipinNativePagePort;
7
7
  readonly createNativeVisualActivitySession: (page: ZhipinNativePagePort) => NativeVisualActivitySessionLike;
@@ -2,9 +2,7 @@ import { NativeVisualActivitySession } from "../native-visual-activity-session.t
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
4
  import { getContextManager } from "../runtime-holder.ts";
5
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "succeed" | "fail"> & {
6
- readonly highlightPoint?: NativeVisualActivitySession["highlightPoint"];
7
- };
5
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "previewMouseMotion" | "succeed" | "fail">;
8
6
  type ZhipinOpenRecommendPageDeps = {
9
7
  readonly getContextManager: typeof getContextManager;
10
8
  readonly openNativePagePort: typeof openZhipinNativePagePort;
@@ -1,7 +1,7 @@
1
1
  import { NativeVisualActivitySession } from "../native-visual-activity-session.ts";
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "highlightPoint" | "succeed" | "fail">;
4
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "previewMouseMotion" | "succeed" | "fail">;
5
5
  type ZhipinSayHelloDeps = {
6
6
  readonly openNativePagePort: typeof openZhipinNativePagePort;
7
7
  readonly createNativeVisualActivitySession: (page: ZhipinNativePagePort) => NativeVisualActivitySessionLike;
@@ -2,7 +2,7 @@ import { NativeVisualActivitySession } from "../native-visual-activity-session.t
2
2
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
3
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
4
4
  import { getReplyAuthorityKeysLoaded } from "../runtime-holder.ts";
5
- type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightPoint" | "succeed" | "fail">;
5
+ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "previewMouseMotion" | "succeed" | "fail">;
6
6
  type ZhipinSendReplyDeps = {
7
7
  readonly getReplyAuthorityKeysLoaded: typeof getReplyAuthorityKeysLoaded;
8
8
  readonly openNativePagePort: typeof openZhipinNativePagePort;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roll-agent/browser-use-agent",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",