@reconcrap/boss-recommend-mcp 2.0.47 → 2.0.49
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/bin/boss-recommend-mcp.js +4 -4
- package/config/screening-config.example.json +27 -27
- package/package.json +1 -1
- package/scripts/postinstall.cjs +44 -44
- package/skills/boss-chat/README.md +39 -39
- package/skills/boss-chat/SKILL.md +93 -93
- package/skills/boss-recommend-pipeline/README.md +12 -12
- package/skills/boss-recommend-pipeline/SKILL.md +180 -180
- package/skills/boss-recruit-pipeline/README.md +17 -17
- package/skills/boss-recruit-pipeline/SKILL.md +58 -58
- package/src/chat-mcp.js +1780 -1780
- package/src/chat-runtime-config.js +749 -749
- package/src/cli.js +3054 -3054
- package/src/core/boss-cards/index.js +199 -199
- package/src/core/browser/index.js +1586 -1453
- package/src/core/capture/index.js +1201 -1201
- package/src/core/cv-acquisition/index.js +238 -238
- package/src/core/cv-capture-target/index.js +299 -299
- package/src/core/greet-quota/index.js +54 -54
- package/src/core/infinite-list/index.js +1326 -1326
- package/src/core/reporting/legacy-csv.js +341 -341
- package/src/core/run/timing.js +33 -33
- package/src/core/self-heal/index.js +973 -973
- package/src/core/self-heal/viewport.js +564 -564
- package/src/domains/chat/cards.js +137 -137
- package/src/domains/chat/constants.js +221 -221
- package/src/domains/chat/detail.js +1668 -1668
- package/src/domains/chat/index.js +7 -7
- package/src/domains/chat/jobs.js +592 -592
- package/src/domains/chat/page-guard.js +98 -98
- package/src/domains/chat/roots.js +56 -56
- package/src/domains/chat/run-service.js +1977 -1977
- package/src/domains/recommend/actions.js +457 -457
- package/src/domains/recommend/cards.js +243 -243
- package/src/domains/recommend/constants.js +165 -165
- package/src/domains/recommend/detail.js +1 -1
- package/src/domains/recommend/filters.js +610 -610
- package/src/domains/recommend/index.js +10 -10
- package/src/domains/recommend/jobs.js +378 -316
- package/src/domains/recommend/refresh.js +491 -472
- package/src/domains/recommend/roots.js +80 -80
- package/src/domains/recommend/run-service.js +50 -29
- package/src/domains/recommend/scopes.js +246 -246
- package/src/domains/recruit/actions.js +277 -277
- package/src/domains/recruit/cards.js +74 -74
- package/src/domains/recruit/constants.js +167 -167
- package/src/domains/recruit/detail.js +461 -461
- package/src/domains/recruit/index.js +9 -9
- package/src/domains/recruit/instruction-parser.js +451 -451
- package/src/domains/recruit/refresh.js +44 -44
- package/src/domains/recruit/roots.js +68 -68
- package/src/domains/recruit/run-service.js +1207 -1207
- package/src/domains/recruit/search.js +1202 -1202
- package/src/recommend-mcp.js +22 -22
- package/src/recruit-mcp.js +1338 -1338
|
@@ -1,316 +1,378 @@
|
|
|
1
|
-
import {
|
|
2
|
-
clickNodeCenter,
|
|
3
|
-
DETERMINISTIC_CLICK_OPTIONS,
|
|
4
|
-
getAttributesMap,
|
|
5
|
-
getNodeBox,
|
|
6
|
-
getOuterHTML,
|
|
7
|
-
pressKey,
|
|
8
|
-
querySelectorAll,
|
|
9
|
-
sleep
|
|
10
|
-
} from "../../core/browser/index.js";
|
|
11
|
-
import {
|
|
12
|
-
htmlToText,
|
|
13
|
-
normalizeText
|
|
14
|
-
} from "../../core/screening/index.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.replace(/\s
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
||
|
|
46
|
-
||
|
|
47
|
-
||
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} catch {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
let
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
1
|
+
import {
|
|
2
|
+
clickNodeCenter,
|
|
3
|
+
DETERMINISTIC_CLICK_OPTIONS,
|
|
4
|
+
getAttributesMap,
|
|
5
|
+
getNodeBox,
|
|
6
|
+
getOuterHTML,
|
|
7
|
+
pressKey,
|
|
8
|
+
querySelectorAll,
|
|
9
|
+
sleep
|
|
10
|
+
} from "../../core/browser/index.js";
|
|
11
|
+
import {
|
|
12
|
+
htmlToText,
|
|
13
|
+
normalizeText
|
|
14
|
+
} from "../../core/screening/index.js";
|
|
15
|
+
import { isStaleRecommendNodeError } from "./detail.js";
|
|
16
|
+
|
|
17
|
+
export const RECOMMEND_JOB_SELECTORS = Object.freeze({
|
|
18
|
+
trigger: ".job-selecter-wrap, [class*=\"job-selecter-wrap\"], .ui-dropmenu",
|
|
19
|
+
option: ".job-selecter-options .job-item, .job-list .job-item, .job-item",
|
|
20
|
+
current: ".job-selecter-options .job-item.curr, .job-list .job-item.curr, .job-item.curr"
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function normalizeJobText(value) {
|
|
24
|
+
return normalizeText(value).replace(/\s+/g, "");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function stripSalaryText(label) {
|
|
28
|
+
return normalizeText(label)
|
|
29
|
+
.replace(/\s*[((]\s*(?:\d+(?:-\d+)?K|面议|\d+-\d+元\/天)\s*[))]\s*$/i, "")
|
|
30
|
+
.replace(/\s+(?:\d+(?:-\d+)?K|面议|\d+-\d+元\/天)\s*$/i, "")
|
|
31
|
+
.trim();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function trimSalarySuffix(label) {
|
|
35
|
+
return stripSalaryText(label);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function jobLabelMatches(optionLabel, targetLabel) {
|
|
39
|
+
const option = normalizeJobText(optionLabel);
|
|
40
|
+
const target = normalizeJobText(targetLabel);
|
|
41
|
+
const optionWithoutSalary = normalizeJobText(stripSalaryText(optionLabel));
|
|
42
|
+
const targetWithoutSalary = normalizeJobText(stripSalaryText(targetLabel));
|
|
43
|
+
if (!option || !target) return false;
|
|
44
|
+
return option === target
|
|
45
|
+
|| option.startsWith(target)
|
|
46
|
+
|| optionWithoutSalary === target
|
|
47
|
+
|| option === targetWithoutSalary
|
|
48
|
+
|| optionWithoutSalary === targetWithoutSalary;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isVisibleBox(box) {
|
|
52
|
+
return Boolean(box && box.rect.width > 4 && box.rect.height > 4);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function readJobOption(client, nodeId, index) {
|
|
56
|
+
let attributes = null;
|
|
57
|
+
let outerHTML = "";
|
|
58
|
+
try {
|
|
59
|
+
[attributes, outerHTML] = await Promise.all([
|
|
60
|
+
getAttributesMap(client, nodeId),
|
|
61
|
+
getOuterHTML(client, nodeId)
|
|
62
|
+
]);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (isStaleRecommendNodeError(error)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
const label = normalizeText(htmlToText(outerHTML));
|
|
70
|
+
let box = null;
|
|
71
|
+
try {
|
|
72
|
+
box = await getNodeBox(client, nodeId);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (!isStaleRecommendNodeError(error)) throw error;
|
|
75
|
+
}
|
|
76
|
+
const className = attributes.class || "";
|
|
77
|
+
return {
|
|
78
|
+
node_id: nodeId,
|
|
79
|
+
index,
|
|
80
|
+
label,
|
|
81
|
+
label_without_salary: trimSalarySuffix(label),
|
|
82
|
+
class_name: className,
|
|
83
|
+
current: /\bcurr\b|\bactive\b|\bselected\b/.test(className),
|
|
84
|
+
visible: isVisibleBox(box),
|
|
85
|
+
center: box?.center || null,
|
|
86
|
+
rect: box?.rect || null
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function readJobTrigger(client, nodeId) {
|
|
91
|
+
let box = null;
|
|
92
|
+
try {
|
|
93
|
+
box = await getNodeBox(client, nodeId);
|
|
94
|
+
} catch {}
|
|
95
|
+
if (!isVisibleBox(box)) return null;
|
|
96
|
+
|
|
97
|
+
let label = "";
|
|
98
|
+
let className = "";
|
|
99
|
+
try {
|
|
100
|
+
const outerHTML = await getOuterHTML(client, nodeId);
|
|
101
|
+
label = normalizeText(htmlToText(outerHTML));
|
|
102
|
+
} catch {}
|
|
103
|
+
try {
|
|
104
|
+
const attributes = await getAttributesMap(client, nodeId);
|
|
105
|
+
className = attributes.class || "";
|
|
106
|
+
} catch {}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
node_id: nodeId,
|
|
110
|
+
center: box.center,
|
|
111
|
+
rect: box.rect,
|
|
112
|
+
label,
|
|
113
|
+
label_without_salary: trimSalarySuffix(label),
|
|
114
|
+
class_name: className,
|
|
115
|
+
visible: true
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function findRecommendJobTrigger(client, frameNodeId) {
|
|
120
|
+
const nodeIds = await querySelectorAll(client, frameNodeId, RECOMMEND_JOB_SELECTORS.trigger);
|
|
121
|
+
for (const nodeId of nodeIds) {
|
|
122
|
+
const trigger = await readJobTrigger(client, nodeId);
|
|
123
|
+
if (trigger) return trigger;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function waitForRecommendJobTrigger(client, frameNodeId, {
|
|
129
|
+
timeoutMs = 8000,
|
|
130
|
+
intervalMs = 250
|
|
131
|
+
} = {}) {
|
|
132
|
+
const started = Date.now();
|
|
133
|
+
while (Date.now() - started <= timeoutMs) {
|
|
134
|
+
const trigger = await findRecommendJobTrigger(client, frameNodeId);
|
|
135
|
+
if (trigger) return trigger;
|
|
136
|
+
await sleep(intervalMs);
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function openRecommendJobDropdown(client, frameNodeId, {
|
|
142
|
+
timeoutMs = 4000,
|
|
143
|
+
triggerTimeoutMs = Math.max(8000, timeoutMs),
|
|
144
|
+
triggerIntervalMs = 250,
|
|
145
|
+
dismissBeforeOpen = true,
|
|
146
|
+
maxAttempts = 3
|
|
147
|
+
} = {}) {
|
|
148
|
+
const trigger = await waitForRecommendJobTrigger(client, frameNodeId, {
|
|
149
|
+
timeoutMs: triggerTimeoutMs,
|
|
150
|
+
intervalMs: triggerIntervalMs
|
|
151
|
+
});
|
|
152
|
+
if (!trigger) {
|
|
153
|
+
throw new Error("Recommend job trigger was not found");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const alreadyOpen = await waitForVisibleRecommendJobOptions(client, frameNodeId, {
|
|
157
|
+
timeoutMs: 300,
|
|
158
|
+
intervalMs: 100
|
|
159
|
+
});
|
|
160
|
+
if (alreadyOpen.visible_options.length) {
|
|
161
|
+
return {
|
|
162
|
+
opened: true,
|
|
163
|
+
already_open: true,
|
|
164
|
+
trigger,
|
|
165
|
+
options: alreadyOpen.options
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const attempts = [];
|
|
170
|
+
const attemptLimit = Math.max(1, Math.floor(Number(maxAttempts) || 1));
|
|
171
|
+
if (dismissBeforeOpen) {
|
|
172
|
+
await closeRecommendJobDropdown(client);
|
|
173
|
+
}
|
|
174
|
+
for (let attempt = 1; attempt <= attemptLimit; attempt += 1) {
|
|
175
|
+
if (attempt > 1) await closeRecommendJobDropdown(client);
|
|
176
|
+
const triggerBox = await clickNodeCenter(client, trigger.node_id, DETERMINISTIC_CLICK_OPTIONS);
|
|
177
|
+
const opened = await waitForVisibleRecommendJobOptions(client, frameNodeId, {
|
|
178
|
+
timeoutMs,
|
|
179
|
+
intervalMs: 200
|
|
180
|
+
});
|
|
181
|
+
attempts.push({
|
|
182
|
+
attempt,
|
|
183
|
+
trigger_box: triggerBox,
|
|
184
|
+
option_count: opened.options.length,
|
|
185
|
+
visible_option_count: opened.visible_options.length
|
|
186
|
+
});
|
|
187
|
+
if (opened.visible_options.length) {
|
|
188
|
+
return {
|
|
189
|
+
opened: true,
|
|
190
|
+
already_open: false,
|
|
191
|
+
trigger,
|
|
192
|
+
options: opened.options,
|
|
193
|
+
attempts
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const error = new Error("Recommend job dropdown did not expose visible options after trigger click");
|
|
198
|
+
error.trigger = trigger;
|
|
199
|
+
error.job_dropdown_attempts = attempts;
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function waitForVisibleRecommendJobOptions(client, frameNodeId, {
|
|
204
|
+
timeoutMs = 4000,
|
|
205
|
+
intervalMs = 200
|
|
206
|
+
} = {}) {
|
|
207
|
+
const started = Date.now();
|
|
208
|
+
let lastOptions = [];
|
|
209
|
+
while (Date.now() - started <= timeoutMs) {
|
|
210
|
+
lastOptions = await listRecommendJobOptions(client, frameNodeId, { openDropdown: false });
|
|
211
|
+
const visibleOptions = lastOptions.filter((option) => option.visible);
|
|
212
|
+
if (visibleOptions.length) {
|
|
213
|
+
return {
|
|
214
|
+
options: lastOptions,
|
|
215
|
+
visible_options: visibleOptions
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
await sleep(intervalMs);
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
options: lastOptions,
|
|
222
|
+
visible_options: []
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export async function listRecommendJobOptions(client, frameNodeId, {
|
|
227
|
+
openDropdown = true
|
|
228
|
+
} = {}) {
|
|
229
|
+
if (openDropdown) {
|
|
230
|
+
await openRecommendJobDropdown(client, frameNodeId);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const nodeIds = await querySelectorAll(client, frameNodeId, RECOMMEND_JOB_SELECTORS.option);
|
|
234
|
+
const options = [];
|
|
235
|
+
const seen = new Set();
|
|
236
|
+
for (let index = 0; index < nodeIds.length; index += 1) {
|
|
237
|
+
const nodeId = nodeIds[index];
|
|
238
|
+
if (seen.has(nodeId)) continue;
|
|
239
|
+
seen.add(nodeId);
|
|
240
|
+
const option = await readJobOption(client, nodeId, index);
|
|
241
|
+
if (!option) continue;
|
|
242
|
+
if (!option.label) continue;
|
|
243
|
+
if (option.label.length > 120) continue;
|
|
244
|
+
options.push(option);
|
|
245
|
+
}
|
|
246
|
+
return options;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export async function closeRecommendJobDropdown(client) {
|
|
250
|
+
if (typeof client?.Input?.dispatchKeyEvent !== "function") {
|
|
251
|
+
return {
|
|
252
|
+
ok: false,
|
|
253
|
+
reason: "dispatch_key_unavailable"
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
await pressKey(client, "Escape", {
|
|
257
|
+
code: "Escape",
|
|
258
|
+
windowsVirtualKeyCode: 27,
|
|
259
|
+
nativeVirtualKeyCode: 27
|
|
260
|
+
});
|
|
261
|
+
await sleep(300);
|
|
262
|
+
return {
|
|
263
|
+
ok: true,
|
|
264
|
+
reason: "escape"
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export async function selectRecommendJob(client, frameNodeId, {
|
|
269
|
+
jobLabel = "",
|
|
270
|
+
settleMs = 6000,
|
|
271
|
+
dropdownTimeoutMs = Math.max(8000, settleMs)
|
|
272
|
+
} = {}) {
|
|
273
|
+
const target = normalizeText(jobLabel);
|
|
274
|
+
if (!target) {
|
|
275
|
+
return {
|
|
276
|
+
requested: "",
|
|
277
|
+
selected: false,
|
|
278
|
+
reason: "no_job_requested",
|
|
279
|
+
options: []
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
let opened = null;
|
|
284
|
+
try {
|
|
285
|
+
opened = await openRecommendJobDropdown(client, frameNodeId, {
|
|
286
|
+
timeoutMs: dropdownTimeoutMs,
|
|
287
|
+
triggerTimeoutMs: dropdownTimeoutMs
|
|
288
|
+
});
|
|
289
|
+
} catch (error) {
|
|
290
|
+
const currentOptions = await listRecommendJobOptions(client, frameNodeId, {
|
|
291
|
+
openDropdown: false
|
|
292
|
+
}).catch(() => []);
|
|
293
|
+
const currentMatch = currentOptions.find((option) => (
|
|
294
|
+
option.current && jobLabelMatches(option.label, target)
|
|
295
|
+
));
|
|
296
|
+
if (currentMatch) {
|
|
297
|
+
await closeRecommendJobDropdown(client);
|
|
298
|
+
return {
|
|
299
|
+
requested: target,
|
|
300
|
+
selected: true,
|
|
301
|
+
already_current: true,
|
|
302
|
+
selected_option: compactJobOption({
|
|
303
|
+
...currentMatch,
|
|
304
|
+
source: "current_option_without_visible_dropdown"
|
|
305
|
+
}),
|
|
306
|
+
options: currentOptions.map(compactJobOption),
|
|
307
|
+
dropdown_error: error?.message || String(error),
|
|
308
|
+
job_dropdown_attempts: error?.job_dropdown_attempts || []
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
throw error;
|
|
312
|
+
}
|
|
313
|
+
const options = opened.options.length
|
|
314
|
+
? opened.options
|
|
315
|
+
: await listRecommendJobOptions(client, frameNodeId, { openDropdown: false });
|
|
316
|
+
const visibleOptions = options.filter((option) => option.visible);
|
|
317
|
+
const hiddenMatches = options.filter((option) => !option.visible && jobLabelMatches(option.label, target));
|
|
318
|
+
const match = visibleOptions.find((option) => jobLabelMatches(option.label, target));
|
|
319
|
+
|
|
320
|
+
if (!match) {
|
|
321
|
+
await closeRecommendJobDropdown(client);
|
|
322
|
+
if (hiddenMatches.length) {
|
|
323
|
+
const error = new Error(`Matched recommend job has no visible clickable option: ${hiddenMatches[0].label}`);
|
|
324
|
+
error.hidden_job_matches = hiddenMatches.map(compactJobOption);
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
requested: target,
|
|
329
|
+
selected: false,
|
|
330
|
+
reason: "job_not_found",
|
|
331
|
+
options: options.map(compactJobOption)
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (match.current) {
|
|
336
|
+
await closeRecommendJobDropdown(client);
|
|
337
|
+
return {
|
|
338
|
+
requested: target,
|
|
339
|
+
selected: true,
|
|
340
|
+
already_current: true,
|
|
341
|
+
selected_option: compactJobOption(match),
|
|
342
|
+
options: options.map(compactJobOption)
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (!match.center) {
|
|
347
|
+
await closeRecommendJobDropdown(client);
|
|
348
|
+
throw new Error(`Matched recommend job has no clickable center: ${match.label}`);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const clickedBox = await clickNodeCenter(client, match.node_id, DETERMINISTIC_CLICK_OPTIONS);
|
|
352
|
+
if (settleMs > 0) await sleep(settleMs);
|
|
353
|
+
return {
|
|
354
|
+
requested: target,
|
|
355
|
+
selected: true,
|
|
356
|
+
already_current: false,
|
|
357
|
+
selected_option: compactJobOption(match),
|
|
358
|
+
click_box: {
|
|
359
|
+
center: clickedBox.center,
|
|
360
|
+
rect: clickedBox.rect
|
|
361
|
+
},
|
|
362
|
+
options: options.map(compactJobOption)
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function compactJobOption(option) {
|
|
367
|
+
return {
|
|
368
|
+
label: option.label,
|
|
369
|
+
label_without_salary: option.label_without_salary,
|
|
370
|
+
current: Boolean(option.current),
|
|
371
|
+
visible: Boolean(option.visible),
|
|
372
|
+
class_name: option.class_name,
|
|
373
|
+
node_id: option.node_id,
|
|
374
|
+
center: option.center,
|
|
375
|
+
rect: option.rect,
|
|
376
|
+
source: option.source || null
|
|
377
|
+
};
|
|
378
|
+
}
|