@reconcrap/boss-recommend-mcp 2.0.42 → 2.0.44
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/README.md +7 -1
- package/config/screening-config.example.json +10 -0
- package/package.json +1 -2
- package/src/chat-mcp.js +4 -0
- package/src/chat-runtime-config.js +85 -1
- package/src/cli.js +13 -1
- package/src/core/browser/index.js +651 -4
- package/src/core/capture/index.js +118 -14
- package/src/core/infinite-list/index.js +122 -8
- package/src/domains/chat/run-service.js +121 -5
- package/src/domains/recommend/detail.js +237 -41
- package/src/domains/recommend/run-service.js +225 -106
- package/src/domains/recruit/run-service.js +108 -4
- package/src/index.js +58 -0
- package/src/recommend-mcp.js +22 -18
- package/src/recruit-mcp.js +44 -0
- package/scripts/live-recommend-recovery-smoke.js +0 -305
|
@@ -22,12 +22,21 @@ import {
|
|
|
22
22
|
import {
|
|
23
23
|
getRecommendRoots
|
|
24
24
|
} from "./roots.js";
|
|
25
|
-
import {
|
|
26
|
-
findRecommendCardNodeIds,
|
|
27
|
-
readRecommendCardCandidate
|
|
28
|
-
} from "./cards.js";
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
import {
|
|
26
|
+
findRecommendCardNodeIds,
|
|
27
|
+
readRecommendCardCandidate
|
|
28
|
+
} from "./cards.js";
|
|
29
|
+
|
|
30
|
+
const DETAIL_OUTSIDE_CLOSE_BOUNDARY_SELECTORS = Object.freeze([
|
|
31
|
+
".resume-center-side .resume-detail-wrap",
|
|
32
|
+
".resume-detail-wrap",
|
|
33
|
+
".boss-popup__wrapper .boss-popup__body",
|
|
34
|
+
".boss-popup__wrapper .dialog-body",
|
|
35
|
+
".dialog-wrap.active .resume-detail-wrap",
|
|
36
|
+
".geek-detail-modal .resume-detail-wrap"
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
export function matchesRecommendDetailNetwork(url) {
|
|
31
40
|
return DETAIL_NETWORK_PATTERNS.some((pattern) => pattern.test(String(url || "")));
|
|
32
41
|
}
|
|
33
42
|
|
|
@@ -150,10 +159,10 @@ async function readRecommendDetailState(client) {
|
|
|
150
159
|
};
|
|
151
160
|
}
|
|
152
161
|
|
|
153
|
-
export async function waitForRecommendDetailClosed(client, {
|
|
154
|
-
timeoutMs = 4000,
|
|
155
|
-
intervalMs = 250
|
|
156
|
-
} = {}) {
|
|
162
|
+
export async function waitForRecommendDetailClosed(client, {
|
|
163
|
+
timeoutMs = 4000,
|
|
164
|
+
intervalMs = 250
|
|
165
|
+
} = {}) {
|
|
157
166
|
const started = Date.now();
|
|
158
167
|
let lastState = null;
|
|
159
168
|
while (Date.now() - started <= timeoutMs) {
|
|
@@ -171,12 +180,67 @@ export async function waitForRecommendDetailClosed(client, {
|
|
|
171
180
|
closed: false,
|
|
172
181
|
elapsed_ms: Date.now() - started,
|
|
173
182
|
state: lastState
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function compactRect(rect) {
|
|
187
|
+
if (!rect) return null;
|
|
188
|
+
return {
|
|
189
|
+
x: Math.round(Number(rect.x) || 0),
|
|
190
|
+
y: Math.round(Number(rect.y) || 0),
|
|
191
|
+
width: Math.round(Number(rect.width) || 0),
|
|
192
|
+
height: Math.round(Number(rect.height) || 0)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function compactDetailTarget(target) {
|
|
197
|
+
if (!target) return null;
|
|
198
|
+
return {
|
|
199
|
+
root: target.root || "",
|
|
200
|
+
root_node_id: target.root_node_id || null,
|
|
201
|
+
selector: target.selector || "",
|
|
202
|
+
node_id: target.node_id || null,
|
|
203
|
+
rect: compactRect(target.rect)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function compactDetailOpenState(state) {
|
|
208
|
+
if (!state) {
|
|
209
|
+
return {
|
|
210
|
+
open: false,
|
|
211
|
+
popup: null,
|
|
212
|
+
resume_iframe: null,
|
|
213
|
+
iframe_document_node_id: null
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
open: Boolean(state.popup || state.resumeIframe),
|
|
218
|
+
popup: compactDetailTarget(state.popup),
|
|
219
|
+
resume_iframe: compactDetailTarget(state.resumeIframe),
|
|
220
|
+
iframe_document_node_id: state.iframe?.documentNodeId || null
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function verifyRecommendDetailStillOpen(client, {
|
|
225
|
+
settleMs = 350
|
|
226
|
+
} = {}) {
|
|
227
|
+
const firstState = await readRecommendDetailState(client);
|
|
228
|
+
if (settleMs > 0) await sleep(settleMs);
|
|
229
|
+
const secondState = await readRecommendDetailState(client);
|
|
230
|
+
const first = compactDetailOpenState(firstState);
|
|
231
|
+
const second = compactDetailOpenState(secondState);
|
|
232
|
+
const stableOpen = Boolean(first.open && second.open);
|
|
233
|
+
return {
|
|
234
|
+
open: Boolean(second.open),
|
|
235
|
+
stable_open: stableOpen,
|
|
236
|
+
first,
|
|
237
|
+
second
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function findVisibleDetailTarget(client, roots, selectors) {
|
|
242
|
+
for (const root of roots) {
|
|
243
|
+
if (!root?.nodeId) continue;
|
|
180
244
|
for (const selector of selectors) {
|
|
181
245
|
const nodeIds = await querySelectorAll(client, root.nodeId, selector);
|
|
182
246
|
for (const nodeId of nodeIds) {
|
|
@@ -477,15 +541,35 @@ export async function closeRecommendDetail(client, {
|
|
|
477
541
|
closed: closedAfterClick.closed,
|
|
478
542
|
elapsed_ms: closedAfterClick.elapsed_ms
|
|
479
543
|
});
|
|
480
|
-
if (closedAfterClick.closed) {
|
|
481
|
-
return {
|
|
482
|
-
closed: true,
|
|
483
|
-
attempts
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
await
|
|
488
|
-
attempts.push(
|
|
544
|
+
if (closedAfterClick.closed) {
|
|
545
|
+
return {
|
|
546
|
+
closed: true,
|
|
547
|
+
attempts
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const outsideClick = await clickOutsideRecommendDetail(client, closedAfterClick.state || existingState);
|
|
552
|
+
attempts.push(outsideClick);
|
|
553
|
+
if (outsideClick.clicked) {
|
|
554
|
+
const closedAfterOutsideClick = await waitForRecommendDetailClosed(client, {
|
|
555
|
+
timeoutMs: closeWaitMs,
|
|
556
|
+
intervalMs: 250
|
|
557
|
+
});
|
|
558
|
+
attempts.push({
|
|
559
|
+
mode: "wait-closed-after-outside-click",
|
|
560
|
+
closed: closedAfterOutsideClick.closed,
|
|
561
|
+
elapsed_ms: closedAfterOutsideClick.elapsed_ms
|
|
562
|
+
});
|
|
563
|
+
if (closedAfterOutsideClick.closed) {
|
|
564
|
+
return {
|
|
565
|
+
closed: true,
|
|
566
|
+
attempts
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
await pressEscape(client);
|
|
572
|
+
attempts.push({ mode: "Escape-fallback" });
|
|
489
573
|
|
|
490
574
|
const closedAfterEscape = await waitForRecommendDetailClosed(client, {
|
|
491
575
|
timeoutMs: escapeWaitMs,
|
|
@@ -502,13 +586,33 @@ export async function closeRecommendDetail(client, {
|
|
|
502
586
|
attempts
|
|
503
587
|
};
|
|
504
588
|
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const verification = await verifyRecommendDetailStillOpen(client);
|
|
592
|
+
attempts.push({
|
|
593
|
+
mode: "final-close-verification",
|
|
594
|
+
open: verification.open,
|
|
595
|
+
stable_open: verification.stable_open,
|
|
596
|
+
popup: verification.second.popup,
|
|
597
|
+
resume_iframe: verification.second.resume_iframe
|
|
598
|
+
});
|
|
599
|
+
if (!verification.open) {
|
|
600
|
+
return {
|
|
601
|
+
closed: true,
|
|
602
|
+
attempts,
|
|
603
|
+
verification
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return {
|
|
608
|
+
closed: false,
|
|
609
|
+
reason: verification.stable_open
|
|
610
|
+
? "detail_still_visible_after_close_attempts"
|
|
611
|
+
: "detail_visibility_ambiguous_after_close_attempts",
|
|
612
|
+
attempts,
|
|
613
|
+
verification
|
|
614
|
+
};
|
|
615
|
+
}
|
|
512
616
|
|
|
513
617
|
async function findVisibleCloseTarget(client, roots, selectors) {
|
|
514
618
|
let fallback = null;
|
|
@@ -540,15 +644,107 @@ async function findVisibleCloseTarget(client, roots, selectors) {
|
|
|
540
644
|
return fallback;
|
|
541
645
|
}
|
|
542
646
|
|
|
543
|
-
async function pressEscape(client) {
|
|
544
|
-
await pressKey(client, "Escape", {
|
|
545
|
-
code: "Escape",
|
|
546
|
-
windowsVirtualKeyCode: 27,
|
|
547
|
-
nativeVirtualKeyCode: 27
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
647
|
+
async function pressEscape(client) {
|
|
648
|
+
await pressKey(client, "Escape", {
|
|
649
|
+
code: "Escape",
|
|
650
|
+
windowsVirtualKeyCode: 27,
|
|
651
|
+
nativeVirtualKeyCode: 27
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
function clampPointCoordinate(value, min, max) {
|
|
656
|
+
return Math.max(min, Math.min(max, value));
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
async function getClickViewport(client) {
|
|
660
|
+
try {
|
|
661
|
+
const metrics = typeof client?.Page?.getLayoutMetrics === "function"
|
|
662
|
+
? await client.Page.getLayoutMetrics()
|
|
663
|
+
: null;
|
|
664
|
+
const viewport = metrics?.cssLayoutViewport || metrics?.layoutViewport || metrics?.visualViewport || {};
|
|
665
|
+
return {
|
|
666
|
+
width: Number(viewport.clientWidth || viewport.width || 1440),
|
|
667
|
+
height: Number(viewport.clientHeight || viewport.height || 900)
|
|
668
|
+
};
|
|
669
|
+
} catch {
|
|
670
|
+
return {
|
|
671
|
+
width: 1440,
|
|
672
|
+
height: 900
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function getOutsideClickPoint(rect, viewport) {
|
|
678
|
+
if (!rect || rect.width <= 2 || rect.height <= 2) return null;
|
|
679
|
+
const margin = 24;
|
|
680
|
+
const minX = 8;
|
|
681
|
+
const minY = 8;
|
|
682
|
+
const maxX = Math.max(minX, (Number(viewport?.width) || 1440) - 8);
|
|
683
|
+
const maxY = Math.max(minY, (Number(viewport?.height) || 900) - 8);
|
|
684
|
+
const midX = rect.x + rect.width / 2;
|
|
685
|
+
const midY = rect.y + Math.min(Math.max(rect.height * 0.2, 48), Math.max(48, rect.height - 24));
|
|
686
|
+
const candidates = [
|
|
687
|
+
{ side: "left", x: rect.x - margin, y: midY },
|
|
688
|
+
{ side: "right", x: rect.x + rect.width + margin, y: midY },
|
|
689
|
+
{ side: "above", x: midX, y: rect.y - margin },
|
|
690
|
+
{ side: "below", x: midX, y: rect.y + rect.height + margin },
|
|
691
|
+
{ side: "viewport-corner", x: 16, y: 16 }
|
|
692
|
+
];
|
|
693
|
+
|
|
694
|
+
for (const candidate of candidates) {
|
|
695
|
+
const x = clampPointCoordinate(candidate.x, minX, maxX);
|
|
696
|
+
const y = clampPointCoordinate(candidate.y, minY, maxY);
|
|
697
|
+
const insideRect = (
|
|
698
|
+
x >= rect.x
|
|
699
|
+
&& x <= rect.x + rect.width
|
|
700
|
+
&& y >= rect.y
|
|
701
|
+
&& y <= rect.y + rect.height
|
|
702
|
+
);
|
|
703
|
+
if (!insideRect) {
|
|
704
|
+
return {
|
|
705
|
+
...candidate,
|
|
706
|
+
x,
|
|
707
|
+
y
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
async function clickOutsideRecommendDetail(client, detailState) {
|
|
715
|
+
const rootState = detailState?.roots?.length
|
|
716
|
+
? detailState
|
|
717
|
+
: await readRecommendDetailState(client);
|
|
718
|
+
const boundaryTarget = await findVisibleDetailTarget(
|
|
719
|
+
client,
|
|
720
|
+
rootState.roots || [],
|
|
721
|
+
DETAIL_OUTSIDE_CLOSE_BOUNDARY_SELECTORS
|
|
722
|
+
);
|
|
723
|
+
const target = boundaryTarget || rootState.resumeIframe || rootState.popup || null;
|
|
724
|
+
const viewport = await getClickViewport(client);
|
|
725
|
+
const point = getOutsideClickPoint(target?.rect, viewport);
|
|
726
|
+
if (!point) {
|
|
727
|
+
return {
|
|
728
|
+
clicked: false,
|
|
729
|
+
mode: "outside-modal-click",
|
|
730
|
+
reason: "no_outside_click_point",
|
|
731
|
+
selector: target?.selector || null,
|
|
732
|
+
root: target?.root || null
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
await clickPoint(client, point.x, point.y);
|
|
736
|
+
return {
|
|
737
|
+
clicked: true,
|
|
738
|
+
mode: "outside-modal-click",
|
|
739
|
+
selector: target?.selector || null,
|
|
740
|
+
root: target?.root || null,
|
|
741
|
+
side: point.side,
|
|
742
|
+
x: Math.round(point.x),
|
|
743
|
+
y: Math.round(point.y)
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export async function extractRecommendDetailCandidate(client, {
|
|
552
748
|
cardCandidate,
|
|
553
749
|
cardNodeId,
|
|
554
750
|
detailState,
|