@roll-agent/browser-use-agent 0.17.0 → 0.19.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.
@@ -1,6 +1,5 @@
1
- import type { AgentLLM, AgentLogger } from "@roll-agent/sdk";
2
- import { type CandidateLocationSignal } from "@roll-agent/reply-authority-client";
3
- export declare const LocationSignalAnalysisPathValues: readonly ["llm", "fallback", "profile_only"];
1
+ import type { CandidateLocationSignal } from "@roll-agent/reply-authority-client";
2
+ export declare const LocationSignalAnalysisPathValues: readonly ["llm", "fallback", "profile_only", "speculative", "none"];
4
3
  export type LocationSignalAnalysisPath = (typeof LocationSignalAnalysisPathValues)[number];
5
4
  export declare const LocationSignalInquiryTypeValues: readonly ["location_inquiry", "non_location_inquiry"];
6
5
  export type LocationSignalInquiryType = (typeof LocationSignalInquiryTypeValues)[number];
@@ -9,37 +8,13 @@ export type LocationSignalResolution = {
9
8
  readonly analysisPath: LocationSignalAnalysisPath;
10
9
  readonly inquiryType?: LocationSignalInquiryType;
11
10
  };
12
- export type LocationSignalMessage = {
13
- readonly index: number;
14
- readonly sender: "candidate" | "recruiter" | "system";
15
- readonly content: string;
16
- };
17
- type LocationSignalEvidenceInput = {
18
- readonly latestCandidateMessage: string;
19
- readonly recentMessages: readonly LocationSignalMessage[];
20
- readonly expectedLocation: string;
21
- readonly communicationPosition: string;
22
- };
23
- type ResolveLocationSignalsInput = {
24
- readonly llm: AgentLLM;
25
- readonly logger?: Pick<AgentLogger, "warn"> | undefined;
26
- readonly messages: readonly LocationSignalMessage[];
27
- readonly expectedLocation: string;
28
- readonly communicationPosition: string;
29
- readonly timeoutMs?: number | undefined;
30
- };
31
- export declare function resolveLocationSignalsFromLlmText(input: LocationSignalEvidenceInput & {
32
- readonly llmText: string;
33
- }): CandidateLocationSignal[];
34
- export declare function resolveLocationSignals(input: ResolveLocationSignalsInput): Promise<LocationSignalResolution>;
35
- export declare function clearLocationSignalResolutionCacheForTest(): void;
36
- export declare function resolveLocationSignalsWithLlm(input: ResolveLocationSignalsInput): Promise<CandidateLocationSignal[]>;
11
+ export declare function formatLocationSignalsVisualLabel(resolution: LocationSignalResolution | readonly CandidateLocationSignal[]): string;
12
+ export declare function resolvePreferredBrandId(communicationPosition: string): number | undefined;
37
13
  export declare function resolvePreferredBrand(communicationPosition: string): string | undefined;
38
14
  export declare function resolveExpectedSignals(expectedJobText: string): {
39
15
  expectedLocation: string;
40
16
  expectedPosition: string;
41
17
  };
42
- export declare function formatLocationSignalsVisualLabel(resolution: LocationSignalResolution | readonly CandidateLocationSignal[]): string;
43
18
  export declare function resolveConversationSignals(input: {
44
19
  communicationPosition: string;
45
20
  expectedJobText: string;
@@ -48,5 +23,5 @@ export declare function resolveConversationSignals(input: {
48
23
  expectedLocation: string;
49
24
  expectedPosition: string;
50
25
  preferredBrand?: string;
26
+ preferredBrandId?: number;
51
27
  };
52
- export {};
@@ -29,9 +29,17 @@ export declare const zhipinGenerateReplyPreview: import("@roll-agent/sdk").ToolD
29
29
  error?: string | undefined;
30
30
  confidence?: number | undefined;
31
31
  requestId?: string | undefined;
32
+ expiresAt?: number | undefined;
32
33
  suggestedReply?: string | undefined;
33
34
  stage?: string | undefined;
34
35
  preparedReplyId?: string | undefined;
35
- expiresAt?: number | undefined;
36
+ timing?: {
37
+ totalLatencyMs: number;
38
+ preparedContextHit: boolean;
39
+ replyLatencyMs?: number | undefined;
40
+ turnPlanningLatencyMs?: number | undefined;
41
+ contextBuildingLatencyMs?: number | undefined;
42
+ } | undefined;
43
+ gateRewritten?: boolean | undefined;
36
44
  }>;
37
45
  export {};
@@ -1,3 +1,4 @@
1
+ import { prepareReplyContext } from "@roll-agent/reply-authority-client";
1
2
  import { NativeVisualActivitySession } from "../native-visual-activity-session.ts";
2
3
  import { openZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
3
4
  import type { ZhipinNativePagePort } from "../pages/zhipin/native-page.ts";
@@ -5,7 +6,9 @@ type NativeVisualActivitySessionLike = Pick<NativeVisualActivitySession, "begin"
5
6
  type ZhipinGetCandidateInfoDeps = {
6
7
  readonly openNativePagePort: typeof openZhipinNativePagePort;
7
8
  readonly createNativeVisualActivitySession: (page: ZhipinNativePagePort) => NativeVisualActivitySessionLike;
9
+ readonly prepareReplyContext: typeof prepareReplyContext;
8
10
  };
11
+ export declare function resetPrepareReplyContextCooldownForTests(): void;
9
12
  export declare function setZhipinGetCandidateInfoDepsForTests(override: Partial<ZhipinGetCandidateInfoDeps> | undefined): void;
10
13
  export declare const zhipinGetCandidateInfo: import("@roll-agent/sdk").ToolDefinition<{
11
14
  index?: number | undefined;
@@ -50,5 +53,6 @@ export declare const zhipinGetCandidateInfo: import("@roll-agent/sdk").ToolDefin
50
53
  formattedHistory: string[];
51
54
  error?: string | undefined;
52
55
  preferredBrand?: string | undefined;
56
+ preferredBrandId?: number | undefined;
53
57
  }>;
54
58
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roll-agent/browser-use-agent",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,8 +45,8 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "zod": "^3.25.76",
48
- "@roll-agent/reply-authority-client": "0.2.0",
49
48
  "@roll-agent/sdk": "0.2.0",
49
+ "@roll-agent/reply-authority-client": "0.4.0",
50
50
  "@roll-agent/browser": "0.9.0"
51
51
  },
52
52
  "devDependencies": {
@@ -125,38 +125,45 @@ recommend-list -> 推荐牛人列表,默认向下滚动,去重主键 candid
125
125
  - `no-new-items`:连续滚动没有新去重项。
126
126
  - `max-steps`:达到滚动步数上限。
127
127
 
128
- ## preferredBrand
128
+ ## preferredBrand / preferredBrandId
129
129
 
130
- `zhipin_get_candidate_info` 会从 `candidateInfo.communicationPosition` 中解析:
130
+ `zhipin_get_candidate_info` 会从页面信号中解析:
131
131
 
132
- - `expectedLocation`
133
- - `expectedPosition`
134
- - `preferredBrand`
132
+ - `expectedLocation` / `expectedPosition`(来自期望职位文本)
133
+ - `preferredBrandId` 或 `preferredBrand`(来自 `candidateInfo.communicationPosition`,互斥,最多输出一个)
135
134
 
136
- `preferredBrand` 规则:
135
+ 沟通职位有两种命名格式,解析规则:
137
136
 
138
- - 仅当 `communicationPosition` 含连字符类分隔符时输出:`-` / `-` / `—` / `–`。
139
- - 取分隔符前的第一段,例如 `肯德基-服务员` -> `preferredBrand: "肯德基"`。
140
- - 没有分隔符时不输出。
141
- - 禁止用通用岗位名或 `zhipin_get_candidate_list.company` 伪造品牌。
137
+ - 新格式 `自定义描述…[品牌ID]`(末尾方括号包数字,兼容全角 `【】` / `[]` 与括号内空白):输出 `preferredBrandId`,例如 `咖啡早班店员-接受小白-免费咖啡[10027]` -> `preferredBrandId: 10027`。此时**不输出** `preferredBrand`——新格式第一段是岗位描述,不是品牌名。
138
+ - 老格式 `品牌名-职位`(含连字符类分隔符 `-` / `-` / `—` / `–`,且无 ID 尾缀):取第一段输出 `preferredBrand`,例如 `肯德基-服务员` -> `preferredBrand: "肯德基"`。
139
+ - 两者都不满足时不输出任何品牌字段。
140
+ - 编排器原样透传工具输出即可,不要自行解析 `communicationPosition`;Reply Authority 服务端会以 `candidateInfo.communicationPosition` 为权威再次提取品牌 ID 并与 `preferredBrandId` 对账(不一致以服务端提取为准)。
141
+ - 禁止用通用岗位名或 `zhipin_get_candidate_list.company` 伪造品牌;禁止把新格式的第一段当品牌名。
142
142
 
143
- ## locationSignals
143
+ ## 地点证据(服务端提取)
144
144
 
145
- `zhipin_get_candidate_info` 和 `zhipin_generate_reply_preview` 会在读取聊天记录后输出/透传结构化地点证据 `locationSignals`,供下游 Reply Authority 做 geocode 与门店/岗位距离匹配。
145
+ 地点证据提取已收编进 Reply Authority 服务端的 turn_planning 阶段(RFC pipeline-latency-restructure M1):browser-use 只上送原始对话与候选人资料,服务端 `planTurn` 合并提取地点信号并做逐字证据校验,再交给 geocode 与门店/岗位距离匹配。
146
146
 
147
- 字段形状(与 `@roll-agent/reply-authority-client` 契约一致):
147
+ `zhipin_generate_reply_preview` 通过 SSE `location.resolved` 事件回显服务端提取结果:
148
148
 
149
149
  ```json
150
150
  {
151
- "text": "人民广场",
152
- "source": "candidate_message",
153
- "city": "上海",
154
- "intent": "nearby_store",
155
- "confidence": 0.93
151
+ "type": "location.resolved",
152
+ "inquiryType": "location_inquiry",
153
+ "analysisPath": "llm",
154
+ "signals": [
155
+ {
156
+ "text": "人民广场",
157
+ "source": "candidate_message",
158
+ "city": "上海",
159
+ "intent": "nearby_store",
160
+ "confidence": 0.93
161
+ }
162
+ ]
156
163
  }
157
164
  ```
158
165
 
159
- `source` 取值:
166
+ `source` 取值(与 `@roll-agent/reply-authority-client` 契约一致):
160
167
 
161
168
  | `source` | 含义 |
162
169
  | --- | --- |
@@ -165,23 +172,16 @@ recommend-list -> 推荐牛人列表,默认向下滚动,去重主键 candid
165
172
  | `candidate_expected_location` | 候选人资料里的期望城市/区域(弱信号) |
166
173
  | `communication_position` | 沟通岗位文本中可确认的城市/门店片段 |
167
174
 
168
- `intent` 常见取值:`nearby_store`(附近门店/岗位)、`store_address`(门店地址)、`expected_area`(期望区域)。
175
+ `intent` 常见取值:`nearby_store`(附近门店/岗位)、`store_address`(门店地址)、`expected_area`(期望区域)。`analysisPath` 取值:`llm`(planTurn 合并提取)、`speculative`(词典投机命中)、`none`(无地点信号)。
169
176
 
170
- 抽取规则:
177
+ 规则与边界:
171
178
 
172
- 1. browser-use 通过指挥官 LLM 抽取,并在超时或失败时回退到规则匹配;`text` 必须来自输入原文,不改写成下游门店名。
173
- 2. 多轮对话会扫描全部候选人消息(去重),避免「历史问过地点、最新一句非地点」时丢失证据。
174
- 3. `candidateInfo.expectedLocation` 只作城市边界弱信号(confidence 通常 ≤ 0.6),不能替代候选人本轮追问的具体 POI。
175
- 4. 问候/职位介绍类消息可能跳过 LLM 抽取,仅保留 `expectedLocation` 弱信号。
176
- 5. orchestrator 不要自行构造或改写 `locationSignals`;需要地点证据时调用 `zhipin_get_candidate_info` 或 `zhipin_generate_reply_preview`,由工具自动填充。
177
-
178
- 边界:
179
-
180
- - browser-use **不**调用外部地图、**不**做 geocode、**不**计算门店距离。
181
- - 岗位/门店事实源仍是下游同步的岗位配置;外部地图 POI 不能当作门店或岗位事实。
182
- - `smart-reply-agent.generate_reply` 只校验 schema 并原样转发 `locationSignals`,不做地点推断。
183
-
184
- `zhipin_generate_reply_preview` 会把非空 `locationSignals` 写入 Reply Authority stream input;`zhipin_get_candidate_info` 在 output 中返回同结构数组,便于编排器先读证据再决定是否生成回复。
179
+ 1. browser-use 不抽取地点、不调用外部地图、不做 geocode、不计算门店距离;上送的对话原文是服务端提取的唯一证据源。
180
+ 2. `candidateInfo.expectedLocation` 只作城市边界弱信号(服务端 confidence 封顶 0.6),不能替代候选人本轮追问的具体 POI。
181
+ 3. orchestrator 不要自行构造或改写地点信号:`generate_reply` 请求中的 `locationSignals` 字段已废弃,服务端过渡期内会逐字校验后合并,两个版本周期后忽略。
182
+ 4. `zhipin_get_candidate_info` 输出中的 `locationSignals` 恒为空数组,仅为输出契约兼容保留,不要依赖。
183
+ 5. 岗位/门店事实源仍是下游同步的岗位配置;外部地图 POI 不能当作门店或岗位事实。
184
+ 6. `smart-reply-agent.generate_reply` 只校验 schema 并原样转发(deprecated 字段同样适用),不做地点推断。
185
185
 
186
186
  ## Reply Authority
187
187