@roll-agent/browser-use-agent 0.15.0 → 0.16.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.
- package/SKILL.md +6 -1
- package/dist/index.js +1 -1
- package/dist/native-reload.d.ts +30 -0
- package/dist/pages/zhipin/native-page.d.ts +18 -0
- package/dist/reply-authority/prepared-reply-store.d.ts +1 -0
- package/dist/tools/browser-reload-active-tab.d.ts +28 -0
- package/dist/tools/zhipin-open-chat-page.d.ts +11 -3
- package/dist/tools/zhipin-send-reply.d.ts +1 -0
- package/package.json +2 -2
- package/references/zhipin-workflows.md +15 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type NativeReloadController = {
|
|
2
|
+
evaluateJson<T = unknown>(expression: string): Promise<T>;
|
|
3
|
+
reload(options?: {
|
|
4
|
+
readonly url?: string;
|
|
5
|
+
readonly ignoreCache?: boolean;
|
|
6
|
+
readonly timeoutMs?: number;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export type ReloadNativePageOptions = {
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly ignoreCache?: boolean;
|
|
12
|
+
readonly timeoutMs?: number;
|
|
13
|
+
readonly pollMs?: number;
|
|
14
|
+
readonly now?: () => number;
|
|
15
|
+
readonly delay?: (ms: number) => Promise<void>;
|
|
16
|
+
readonly createToken?: () => string;
|
|
17
|
+
readonly onReloadSent?: () => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reloads the current native page via CDP `Page.reload` and waits until the
|
|
21
|
+
* document has actually been swapped.
|
|
22
|
+
*
|
|
23
|
+
* A reload keeps the same URL, so the navigate ready-poll (which anchors on a
|
|
24
|
+
* URL change) would falsely report readiness while the stale document is still
|
|
25
|
+
* `readyState === "complete"`. Instead we tag the live document with a window
|
|
26
|
+
* sentinel, trigger the reload, and only return once that sentinel is gone
|
|
27
|
+
* (window globals are wiped when the document is replaced) and the fresh
|
|
28
|
+
* document has reached an interactive/complete ready state.
|
|
29
|
+
*/
|
|
30
|
+
export declare function reloadNativePageAndWaitForSwap(controller: NativeReloadController, options: ReloadNativePageOptions): Promise<void>;
|
|
@@ -9,6 +9,22 @@ export type ZhipinNativePagePortOptions = {
|
|
|
9
9
|
readonly target: BrowserInspectablePage;
|
|
10
10
|
readonly controller: NativeCdpController;
|
|
11
11
|
};
|
|
12
|
+
export type ZhipinNativeReloadOptions = {
|
|
13
|
+
readonly url: string;
|
|
14
|
+
readonly ignoreCache?: boolean;
|
|
15
|
+
readonly onReloadSent?: () => void;
|
|
16
|
+
};
|
|
17
|
+
export declare const ZHIPIN_CHAT_RELOAD_SKIPPED_REASONS: readonly ["not_chat_page"];
|
|
18
|
+
export type ZhipinChatReloadSkippedReason = (typeof ZHIPIN_CHAT_RELOAD_SKIPPED_REASONS)[number];
|
|
19
|
+
export type ZhipinChatReloadTarget = {
|
|
20
|
+
readonly ok: true;
|
|
21
|
+
readonly url: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly ok: false;
|
|
24
|
+
readonly url: string;
|
|
25
|
+
readonly skippedReason: ZhipinChatReloadSkippedReason;
|
|
26
|
+
readonly error: string;
|
|
27
|
+
};
|
|
12
28
|
export type ReadNativeChatCandidatesOptions = {
|
|
13
29
|
readonly targetCount?: number;
|
|
14
30
|
readonly autoScroll?: boolean;
|
|
@@ -176,6 +192,8 @@ export declare class ZhipinNativePagePort {
|
|
|
176
192
|
waitForSelector(selector: string, timeoutMs?: number): Promise<boolean>;
|
|
177
193
|
evaluateJson<T = unknown>(expression: string): Promise<T>;
|
|
178
194
|
bringToFront(): Promise<void>;
|
|
195
|
+
inspectChatReloadTarget(): Promise<ZhipinChatReloadTarget>;
|
|
196
|
+
reload(options: ZhipinNativeReloadOptions): Promise<void>;
|
|
179
197
|
isChatSurfaceOpen(): Promise<boolean>;
|
|
180
198
|
waitForChatSurface(timeoutMs?: number): Promise<boolean>;
|
|
181
199
|
isRecommendSurfaceOpen(): Promise<boolean>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getContextManager, getRuntime } from "../runtime-holder.ts";
|
|
2
|
+
import { toNativePageInfo } from "../page-info.ts";
|
|
3
|
+
import { reloadNativePageAndWaitForSwap } from "../native-reload.ts";
|
|
4
|
+
type ReloadActiveTabDeps = {
|
|
5
|
+
readonly getContextManager: typeof getContextManager;
|
|
6
|
+
readonly getRuntime: typeof getRuntime;
|
|
7
|
+
readonly toNativePageInfo: typeof toNativePageInfo;
|
|
8
|
+
readonly reloadNativePageAndWaitForSwap: typeof reloadNativePageAndWaitForSwap;
|
|
9
|
+
};
|
|
10
|
+
export declare function setReloadActiveTabDepsForTests(override: Partial<ReloadActiveTabDeps> | undefined): void;
|
|
11
|
+
export declare const browserReloadActiveTab: import("@roll-agent/sdk").ToolDefinition<{
|
|
12
|
+
ignoreCache?: boolean | undefined;
|
|
13
|
+
browserActionApproval?: {
|
|
14
|
+
id: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
success: boolean;
|
|
18
|
+
reloaded: boolean;
|
|
19
|
+
page: {
|
|
20
|
+
pageId: string;
|
|
21
|
+
url: string;
|
|
22
|
+
title: string;
|
|
23
|
+
boundPlatform: "zhipin" | "yupao" | null;
|
|
24
|
+
detectedPlatform: "zhipin" | "yupao" | null;
|
|
25
|
+
isSelectedForPlatform: boolean;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { NativeVisualActivitySession } from "../native-visual-activity-session.ts";
|
|
2
2
|
import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
|
|
3
|
-
import type
|
|
4
|
-
import { getContextManager } from "../runtime-holder.ts";
|
|
3
|
+
import { type ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
|
|
4
|
+
import { getContextManager, getRuntime } from "../runtime-holder.ts";
|
|
5
5
|
type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin" | "highlightSelector" | "previewMouseMotion" | "succeed" | "fail">;
|
|
6
6
|
type ZhipinOpenChatPageDeps = {
|
|
7
7
|
readonly getContextManager: typeof getContextManager;
|
|
8
|
+
readonly getRuntime: typeof getRuntime;
|
|
8
9
|
readonly openNativePagePort: typeof openZhipinNativePagePort;
|
|
9
10
|
readonly createNativeVisualActivitySession: (page: ZhipinNativePagePort) => NativeVisualActivitySessionLike;
|
|
10
11
|
};
|
|
11
12
|
export declare function setZhipinOpenChatPageDepsForTests(override: Partial<ZhipinOpenChatPageDeps> | undefined): void;
|
|
12
|
-
export declare const zhipinOpenChatPage: import("@roll-agent/sdk").ToolDefinition<{
|
|
13
|
+
export declare const zhipinOpenChatPage: import("@roll-agent/sdk").ToolDefinition<{
|
|
14
|
+
browserActionApproval?: {
|
|
15
|
+
id: string;
|
|
16
|
+
} | undefined;
|
|
17
|
+
forceReload?: boolean | undefined;
|
|
18
|
+
}, {
|
|
13
19
|
success: boolean;
|
|
14
20
|
alreadyOnChat: boolean;
|
|
15
21
|
usedSidebarClick: boolean;
|
|
22
|
+
usedReload: boolean;
|
|
16
23
|
chatReady: boolean;
|
|
17
24
|
error?: string | undefined;
|
|
18
25
|
page?: {
|
|
@@ -23,5 +30,6 @@ export declare const zhipinOpenChatPage: import("@roll-agent/sdk").ToolDefinitio
|
|
|
23
30
|
detectedPlatform: "zhipin" | "yupao" | null;
|
|
24
31
|
isSelectedForPlatform: boolean;
|
|
25
32
|
} | undefined;
|
|
33
|
+
reloadSkippedReason?: "not_chat_page" | undefined;
|
|
26
34
|
}>;
|
|
27
35
|
export {};
|
|
@@ -29,6 +29,7 @@ export declare function sendSignedZhipinReply(input: {
|
|
|
29
29
|
readonly signedEnvelope: string;
|
|
30
30
|
readonly candidateName?: string | undefined;
|
|
31
31
|
readonly index?: number | undefined;
|
|
32
|
+
readonly unreadCountBeforeReply?: number | undefined;
|
|
32
33
|
}, ctx: AgentContext): Promise<ZhipinSendReplyResult>;
|
|
33
34
|
export declare const zhipinSendReply: import("@roll-agent/sdk").ToolDefinition<{
|
|
34
35
|
signedEnvelope: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roll-agent/browser-use-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"zod": "^3.25.76",
|
|
48
48
|
"@roll-agent/reply-authority-client": "0.1.2",
|
|
49
49
|
"@roll-agent/sdk": "0.2.0",
|
|
50
|
-
"@roll-agent/browser": "0.
|
|
50
|
+
"@roll-agent/browser": "0.9.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^22.0.0"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
`jobRef` 规则:
|
|
69
69
|
|
|
70
70
|
- `jobRef` 格式如 `@j1`,只来自 `zhipin_list_recommend_jobs()` 输出。
|
|
71
|
-
- `jobRef`
|
|
71
|
+
- `jobRef` 只对最近一次岗位下拉快照有效;筛选、搜索、刷新、页面 reload 或页面重开后必须重新读取。
|
|
72
72
|
- orchestrator 不要自行构造 `jobRef`。
|
|
73
73
|
- `jobRef` 不是安全边界,只是降低编排认知负担;真实 DOM 点击仍由工具解析到 `value` / `index` 后执行。
|
|
74
74
|
- 默认不要传 `forceClick:true`;只有需要重新点击已选中的岗位项时才使用。
|
|
@@ -191,7 +191,7 @@ recommend-list -> 推荐牛人列表,默认向下滚动,去重主键 candid
|
|
|
191
191
|
|
|
192
192
|
1. 上层 orchestrator 优先把 `candidateRef` 传给 `zhipin_say_hello({ candidateRefs })` 或 `zhipin_open_resume({ candidateRef })`。
|
|
193
193
|
2. `indices` / `index` 只作为当前 DOM 快照兜底。
|
|
194
|
-
3.
|
|
194
|
+
3. 筛选、滚动加载、搜索、刷新、页面 reload 或页面重开后必须重新调用 `zhipin_get_candidate_list`,不要复用旧 `candidateRef`。
|
|
195
195
|
4. 不要由 orchestrator 自己构造 `@c1`;只使用 tool 输出中的 `candidateRef`。
|
|
196
196
|
5. 聊天消息列表没有 `candidateRef`;聊天回复链路继续使用 `conversationId` / `candidateId`。
|
|
197
197
|
6. 调 `zhipin_say_hello` 前先过滤 `buttonText:"打招呼"`;`buttonText` 为空通常表示已打过招呼,不应重复点击。
|
|
@@ -202,3 +202,16 @@ recommend-list -> 推荐牛人列表,默认向下滚动,去重主键 candid
|
|
|
202
202
|
- 如果 `candidateRef` 对应的 `candidateId` / `name` 与当前 DOM 不一致,工具会返回 `success:false` 并提示“候选人引用已过期”。
|
|
203
203
|
- 收到过期提示后,重新执行推荐候选人链路的第 3 步,再提交新的 `candidateRefs`。
|
|
204
204
|
- 同一快照内可以一次提交多个 `candidateRefs` 连续打招呼;如果 BOSS 在点击后重排列表,工具会拒绝过期 ref,orchestrator 应刷新列表后只重试剩余目标。
|
|
205
|
+
|
|
206
|
+
## 长跑 tab 的 reload recovery
|
|
207
|
+
|
|
208
|
+
Chrome 全天不关、同一沟通 tab 连续跑多批任务时,前端 SPA 状态会在同一 renderer 内累积,常见症状是 `.geek-item.selected` 选中态丢失、依赖「当前选中聊天」的工具(如 `zhipin_exchange_wechat`)失败,且失败率随运行时长上升。
|
|
209
|
+
|
|
210
|
+
recovery 优先级与边界:
|
|
211
|
+
|
|
212
|
+
1. `zhipin_open_chat_page({ forceReload: true })`:只对当前沟通页执行 native CDP `Page.reload`,等价手动 F5,清空当前 document 的 DOM 与页面内 SPA 状态,保留 Chrome 窗口与 profile 登录态;reload 后返回 `usedReload: true` 与 `chatReady`。如果实时页面已不是沟通页,会跳过 reload 并返回 `reloadSkippedReason`。
|
|
213
|
+
2. 通用 `browser_reload_active_tab`:对当前 tracked native page 做同样的 reload,用于非沟通页或不需要确认聊天就绪的场景。
|
|
214
|
+
3. 普通 `zhipin_open_chat_page()`(不带 forceReload)在已处于沟通页时只返回 `alreadyOnChat: true`,**不会**卸载 document,无法清状态。
|
|
215
|
+
4. `roll browser stop` 才能回收 renderer 进程内存,但会关闭浏览器窗口;reload 只清 document 级状态,**不保证** renderer 把内存归还 OS。
|
|
216
|
+
|
|
217
|
+
reload / 页面重开后,所有 `@eN` / `candidateRef` / `jobRef` 一律失效,必须重新 `browser_snapshot` 或重新读列表后再继续。
|