@reconcrap/boss-recommend-mcp 2.0.56 → 2.1.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.
@@ -743,11 +743,12 @@ export async function runChatWorkflow({
743
743
  safeClickPointEnabled: effectiveHumanBehavior.clickMovement,
744
744
  actionCooldownEnabled: effectiveHumanBehavior.actionCooldown
745
745
  });
746
- const humanRestController = createHumanRestController({
747
- enabled: effectiveHumanRestEnabled,
748
- shortRestEnabled: effectiveHumanBehavior.shortRest,
749
- batchRestEnabled: effectiveHumanBehavior.batchRest
750
- });
746
+ const humanRestController = createHumanRestController({
747
+ enabled: effectiveHumanRestEnabled,
748
+ shortRestEnabled: effectiveHumanBehavior.shortRest,
749
+ batchRestEnabled: effectiveHumanBehavior.batchRest,
750
+ restLevel: effectiveHumanBehavior.restLevel
751
+ });
751
752
  const normalizedDetailSource = normalizeDetailSource(detailSource);
752
753
  const normalizedScreeningMode = normalizeScreeningMode(screeningMode);
753
754
  const useLlmScreening = normalizedScreeningMode !== "deterministic";
@@ -966,11 +967,12 @@ export async function runChatWorkflow({
966
967
  context_recoveries: contextRecoveryAttempts,
967
968
  list_end_reason: listEndReason,
968
969
  viewport_checks: viewportGuard.getStats().checks,
969
- viewport_recoveries: viewportGuard.getStats().recoveries,
970
- human_behavior_enabled: effectiveHumanBehavior.enabled,
971
- human_behavior_profile: effectiveHumanBehavior.profile,
972
- human_rest_enabled: effectiveHumanRestEnabled,
973
- human_rest_count: humanRestController.getState().rest_count,
970
+ viewport_recoveries: viewportGuard.getStats().recoveries,
971
+ human_behavior_enabled: effectiveHumanBehavior.enabled,
972
+ human_behavior_profile: effectiveHumanBehavior.profile,
973
+ human_rest_level: effectiveHumanBehavior.restLevel,
974
+ human_rest_enabled: effectiveHumanRestEnabled,
975
+ human_rest_count: humanRestController.getState().rest_count,
974
976
  human_rest_ms: humanRestController.getState().total_rest_ms,
975
977
  last_human_event: lastHumanEvent
976
978
  });
@@ -1771,11 +1773,12 @@ export async function runChatWorkflow({
1771
1773
  context_recoveries: contextRecoveryAttempts,
1772
1774
  list_end_reason: listEndReason || null,
1773
1775
  viewport_checks: viewportGuard.getStats().checks,
1774
- viewport_recoveries: viewportGuard.getStats().recoveries,
1775
- human_behavior_enabled: effectiveHumanBehavior.enabled,
1776
- human_behavior_profile: effectiveHumanBehavior.profile,
1777
- human_rest_enabled: effectiveHumanRestEnabled,
1778
- human_rest_count: humanRestController.getState().rest_count,
1776
+ viewport_recoveries: viewportGuard.getStats().recoveries,
1777
+ human_behavior_enabled: effectiveHumanBehavior.enabled,
1778
+ human_behavior_profile: effectiveHumanBehavior.profile,
1779
+ human_rest_level: effectiveHumanBehavior.restLevel,
1780
+ human_rest_enabled: effectiveHumanRestEnabled,
1781
+ human_rest_count: humanRestController.getState().rest_count,
1779
1782
  human_rest_ms: humanRestController.getState().total_rest_ms,
1780
1783
  last_human_event: lastHumanEvent,
1781
1784
  last_candidate_id: screeningCandidate.id || null,
@@ -1815,10 +1818,11 @@ export async function runChatWorkflow({
1815
1818
  compactResult.human_rest = restResult;
1816
1819
  addTiming(compactResult.timings, "human_rest_ms", restElapsed);
1817
1820
  compactResult.timings.total_ms = Date.now() - candidateStarted;
1818
- runControl.updateProgress({
1819
- human_rest_enabled: effectiveHumanRestEnabled,
1820
- human_rest_count: humanRestController.getState().rest_count,
1821
- human_rest_ms: humanRestController.getState().total_rest_ms,
1821
+ runControl.updateProgress({
1822
+ human_rest_enabled: effectiveHumanRestEnabled,
1823
+ human_rest_level: effectiveHumanBehavior.restLevel,
1824
+ human_rest_count: humanRestController.getState().rest_count,
1825
+ human_rest_ms: humanRestController.getState().total_rest_ms,
1822
1826
  human_rest_last: restResult,
1823
1827
  context_recoveries: contextRecoveryAttempts,
1824
1828
  last_human_event: lastHumanEvent
@@ -1876,9 +1880,10 @@ export function createChatRunService({
1876
1880
  } = {}) {
1877
1881
  const manager = lifecycle || createRunLifecycleManager({ idPrefix, onSnapshot });
1878
1882
 
1879
- function startChatRun({
1880
- client,
1881
- targetUrl = CHAT_TARGET_URL,
1883
+ function startChatRun({
1884
+ runId = "",
1885
+ client,
1886
+ targetUrl = CHAT_TARGET_URL,
1882
1887
  job = "",
1883
1888
  startFrom = "all",
1884
1889
  criteria = "",
@@ -1924,9 +1929,10 @@ export function createChatRunService({
1924
1929
  legacyEnabled: humanRestEnabled === true || llmConfig?.humanRestEnabled === true
1925
1930
  });
1926
1931
  const effectiveHumanRestEnabled = effectiveHumanBehavior.restEnabled;
1927
- return manager.startRun({
1928
- name,
1929
- context: {
1932
+ return manager.startRun({
1933
+ runId,
1934
+ name,
1935
+ context: {
1930
1936
  domain: "chat",
1931
1937
  target_url: targetUrl,
1932
1938
  criteria_present: Boolean(criteria),
@@ -1956,12 +1962,13 @@ export function createChatRunService({
1956
1962
  list_settle_ms: listSettleMs,
1957
1963
  list_fallback_point: listFallbackPoint,
1958
1964
  online_resume_button_timeout_ms: onlineResumeButtonTimeoutMs,
1959
- image_output_dir: imageOutputDir || "",
1960
- human_behavior_enabled: effectiveHumanBehavior.enabled,
1961
- human_behavior_profile: effectiveHumanBehavior.profile,
1962
- human_behavior: effectiveHumanBehavior,
1963
- human_rest_enabled: effectiveHumanRestEnabled
1964
- },
1965
+ image_output_dir: imageOutputDir || "",
1966
+ human_behavior_enabled: effectiveHumanBehavior.enabled,
1967
+ human_behavior_profile: effectiveHumanBehavior.profile,
1968
+ human_behavior: effectiveHumanBehavior,
1969
+ human_rest_level: effectiveHumanBehavior.restLevel,
1970
+ human_rest_enabled: effectiveHumanRestEnabled
1971
+ },
1965
1972
  progress: {
1966
1973
  card_count: 0,
1967
1974
  target_count: targetPassCount || (processUntilListEnd ? "all" : processedLimit),
@@ -1976,10 +1983,11 @@ export function createChatRunService({
1976
1983
  requested: 0,
1977
1984
  request_satisfied: 0,
1978
1985
  request_skipped: 0,
1979
- context_recoveries: 0,
1980
- human_behavior_enabled: effectiveHumanBehavior.enabled,
1981
- human_behavior_profile: effectiveHumanBehavior.profile,
1982
- human_rest_enabled: effectiveHumanRestEnabled,
1986
+ context_recoveries: 0,
1987
+ human_behavior_enabled: effectiveHumanBehavior.enabled,
1988
+ human_behavior_profile: effectiveHumanBehavior.profile,
1989
+ human_rest_level: effectiveHumanBehavior.restLevel,
1990
+ human_rest_enabled: effectiveHumanRestEnabled,
1983
1991
  human_rest_count: 0,
1984
1992
  human_rest_ms: 0,
1985
1993
  last_human_event: null
@@ -690,7 +690,8 @@ export async function runRecommendWorkflow({
690
690
  const humanRestController = createHumanRestController({
691
691
  enabled: effectiveHumanRestEnabled,
692
692
  shortRestEnabled: effectiveHumanBehavior.shortRest,
693
- batchRestEnabled: effectiveHumanBehavior.batchRest
693
+ batchRestEnabled: effectiveHumanBehavior.batchRest,
694
+ restLevel: effectiveHumanBehavior.restLevel
694
695
  });
695
696
  const normalizedFilter = normalizeFilter(filter);
696
697
  const normalizedPostAction = normalizeRecommendPostAction(postAction) || "none";
@@ -790,6 +791,7 @@ export async function runRecommendWorkflow({
790
791
  viewport_recoveries: viewportGuard.getStats().recoveries,
791
792
  human_behavior_enabled: effectiveHumanBehavior.enabled,
792
793
  human_behavior_profile: effectiveHumanBehavior.profile,
794
+ human_rest_level: effectiveHumanBehavior.restLevel,
793
795
  human_rest_enabled: effectiveHumanRestEnabled,
794
796
  human_rest_count: humanRestState.rest_count,
795
797
  human_rest_ms: humanRestState.total_rest_ms,
@@ -1509,6 +1511,7 @@ export async function runRecommendWorkflow({
1509
1511
  addTiming(compactResult.timings, "human_rest_ms", restElapsed);
1510
1512
  compactResult.timings.total_ms = Date.now() - candidateStarted;
1511
1513
  updateRecommendProgress({
1514
+ human_rest_level: effectiveHumanBehavior.restLevel,
1512
1515
  human_rest_last: restResult
1513
1516
  });
1514
1517
  }
@@ -1651,6 +1654,7 @@ export function createRecommendRunService({
1651
1654
  human_behavior_enabled: effectiveHumanBehavior.enabled,
1652
1655
  human_behavior_profile: effectiveHumanBehavior.profile,
1653
1656
  human_behavior: effectiveHumanBehavior,
1657
+ human_rest_level: effectiveHumanBehavior.restLevel,
1654
1658
  human_rest_enabled: effectiveHumanRestEnabled
1655
1659
  },
1656
1660
  progress: {
@@ -1670,6 +1674,7 @@ export function createRecommendRunService({
1670
1674
  context_recoveries: 0,
1671
1675
  human_behavior_enabled: effectiveHumanBehavior.enabled,
1672
1676
  human_behavior_profile: effectiveHumanBehavior.profile,
1677
+ human_rest_level: effectiveHumanBehavior.restLevel,
1673
1678
  human_rest_enabled: effectiveHumanRestEnabled,
1674
1679
  human_rest_count: 0,
1675
1680
  human_rest_ms: 0,
@@ -395,7 +395,8 @@ export async function runRecruitWorkflow({
395
395
  const humanRestController = createHumanRestController({
396
396
  enabled: effectiveHumanRestEnabled,
397
397
  shortRestEnabled: effectiveHumanBehavior.shortRest,
398
- batchRestEnabled: effectiveHumanBehavior.batchRest
398
+ batchRestEnabled: effectiveHumanBehavior.batchRest,
399
+ restLevel: effectiveHumanBehavior.restLevel
399
400
  });
400
401
  const normalizedSearchParams = normalizeSearchParams(searchParams);
401
402
  const normalizedScreeningMode = normalizeScreeningMode(screeningMode);
@@ -485,6 +486,7 @@ export async function runRecruitWorkflow({
485
486
  viewport_recoveries: viewportGuard.getStats().recoveries,
486
487
  human_behavior_enabled: effectiveHumanBehavior.enabled,
487
488
  human_behavior_profile: effectiveHumanBehavior.profile,
489
+ human_rest_level: effectiveHumanBehavior.restLevel,
488
490
  human_rest_enabled: effectiveHumanRestEnabled,
489
491
  human_rest_count: humanRestState.rest_count,
490
492
  human_rest_ms: humanRestState.total_rest_ms,
@@ -1101,6 +1103,7 @@ export async function runRecruitWorkflow({
1101
1103
  addTiming(compactResult.timings, "human_rest_ms", restElapsed);
1102
1104
  compactResult.timings.total_ms = Date.now() - candidateStarted;
1103
1105
  updateRecruitProgress({
1106
+ human_rest_level: effectiveHumanBehavior.restLevel,
1104
1107
  human_rest_last: restResult
1105
1108
  });
1106
1109
  }
@@ -1146,6 +1149,7 @@ export function createRecruitRunService({
1146
1149
  const manager = lifecycle || createRunLifecycleManager({ idPrefix, onSnapshot });
1147
1150
 
1148
1151
  function startRecruitRun({
1152
+ runId = "",
1149
1153
  client,
1150
1154
  targetUrl = "",
1151
1155
  criteria = "",
@@ -1189,6 +1193,7 @@ export function createRecruitRunService({
1189
1193
  });
1190
1194
  const effectiveHumanRestEnabled = effectiveHumanBehavior.restEnabled;
1191
1195
  return manager.startRun({
1196
+ runId,
1192
1197
  name,
1193
1198
  context: {
1194
1199
  domain: "recruit",
@@ -1221,6 +1226,7 @@ export function createRecruitRunService({
1221
1226
  human_behavior_enabled: effectiveHumanBehavior.enabled,
1222
1227
  human_behavior_profile: effectiveHumanBehavior.profile,
1223
1228
  human_behavior: effectiveHumanBehavior,
1229
+ human_rest_level: effectiveHumanBehavior.restLevel,
1224
1230
  human_rest_enabled: effectiveHumanRestEnabled
1225
1231
  },
1226
1232
  progress: {
@@ -1237,6 +1243,7 @@ export function createRecruitRunService({
1237
1243
  context_recoveries: 0,
1238
1244
  human_behavior_enabled: effectiveHumanBehavior.enabled,
1239
1245
  human_behavior_profile: effectiveHumanBehavior.profile,
1246
+ human_rest_level: effectiveHumanBehavior.restLevel,
1240
1247
  human_rest_enabled: effectiveHumanRestEnabled,
1241
1248
  human_rest_count: 0,
1242
1249
  human_rest_ms: 0,
package/src/index.js CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  pauseBossChatRunTool,
22
22
  prepareBossChatRunTool,
23
23
  resumeBossChatRunTool,
24
+ startBossChatDetachedRunTool,
24
25
  startBossChatRunTool
25
26
  } from "./chat-mcp.js";
26
27
  import {
@@ -34,6 +35,7 @@ import {
34
35
  pauseRecruitPipelineRunTool,
35
36
  resumeRecruitPipelineRunTool,
36
37
  runRecruitPipelineTool,
38
+ startRecruitPipelineDetachedRunTool,
37
39
  startRecruitPipelineRunTool,
38
40
  validateRecruitPipelineArgs
39
41
  } from "./recruit-mcp.js";
@@ -135,6 +137,8 @@ const recommendTargetUrl = "https://www.zhipin.com/web/chat/recommend";
135
137
  let runPipelineImpl = null;
136
138
  let runSelfHealImpl = null;
137
139
  let spawnProcessImpl = spawn;
140
+ let forceChatInProcForTests = false;
141
+ let forceRecruitInProcForTests = false;
138
142
  const TERMINAL_RUN_STATES = new Set([RUN_STATE_COMPLETED, RUN_STATE_FAILED, RUN_STATE_CANCELED]);
139
143
 
140
144
  async function getRunPipelineImpl() {
@@ -185,6 +189,20 @@ function shouldStartRecommendDetached({ workspaceRoot = "" } = {}) {
185
189
  return isLikelyAgentRuntime({ workspaceRoot });
186
190
  }
187
191
 
192
+ function shouldStartChatDetached({ workspaceRoot = "" } = {}) {
193
+ if (forceChatInProcForTests) return false;
194
+ if (normalizeText(process.env.BOSS_CHAT_CDP_INPROC || "") === "1") return false;
195
+ if (normalizeText(process.env.BOSS_CHAT_CDP_DETACHED || "") === "1") return true;
196
+ return isLikelyAgentRuntime({ workspaceRoot });
197
+ }
198
+
199
+ function shouldStartRecruitDetached({ workspaceRoot = "" } = {}) {
200
+ if (forceRecruitInProcForTests) return false;
201
+ if (normalizeText(process.env.BOSS_RECRUIT_CDP_INPROC || "") === "1") return false;
202
+ if (normalizeText(process.env.BOSS_RECRUIT_CDP_DETACHED || "") === "1") return true;
203
+ return isLikelyAgentRuntime({ workspaceRoot });
204
+ }
205
+
188
206
  function isUnlimitedTargetCountToken(value) {
189
207
  const token = normalizeText(value).toLowerCase();
190
208
  if (!token) return false;
@@ -290,7 +308,17 @@ function createHumanBehaviorInputSchema(description = "可选,启用可靠性
290
308
  listScrollJitter: { type: "boolean" },
291
309
  shortRest: { type: "boolean" },
292
310
  batchRest: { type: "boolean" },
293
- actionCooldown: { type: "boolean" }
311
+ actionCooldown: { type: "boolean" },
312
+ restLevel: {
313
+ type: "string",
314
+ enum: ["low", "medium", "high"],
315
+ description: "本次 run 的休息强度:low 保持旧策略;medium 约 5 小时/700 人累计休息 30 分钟;high 约 5 小时/700 人累计休息 1 小时"
316
+ },
317
+ rest_level: {
318
+ type: "string",
319
+ enum: ["low", "medium", "high"],
320
+ description: "兼容字段;优先使用 restLevel"
321
+ }
294
322
  },
295
323
  additionalProperties: false,
296
324
  description
@@ -2468,6 +2496,9 @@ async function handleBossChatPrepareRunTool({ workspaceRoot, args }) {
2468
2496
  }
2469
2497
 
2470
2498
  async function handleBossChatStartRunTool({ workspaceRoot, args }) {
2499
+ if (shouldStartChatDetached({ workspaceRoot })) {
2500
+ return startBossChatDetachedRunTool({ workspaceRoot, args });
2501
+ }
2471
2502
  return startBossChatRunTool({ workspaceRoot, args });
2472
2503
  }
2473
2504
 
@@ -2618,9 +2649,15 @@ async function handleRequest(message, workspaceRoot) {
2618
2649
  } else if (toolName === TOOL_BOSS_CHAT_CANCEL_RUN) {
2619
2650
  payload = await handleBossChatCancelRunTool({ workspaceRoot, args });
2620
2651
  } else if (toolName === TOOL_RUN_RECRUIT_PIPELINE) {
2621
- payload = await runRecruitPipelineTool({ workspaceRoot, args });
2652
+ payload = normalizeText(args.execution_mode || "").toLowerCase() === "sync"
2653
+ ? await runRecruitPipelineTool({ workspaceRoot, args })
2654
+ : shouldStartRecruitDetached({ workspaceRoot })
2655
+ ? await startRecruitPipelineDetachedRunTool({ workspaceRoot, args })
2656
+ : await runRecruitPipelineTool({ workspaceRoot, args });
2622
2657
  } else if (toolName === TOOL_START_RECRUIT_PIPELINE_RUN) {
2623
- payload = await startRecruitPipelineRunTool({ workspaceRoot, args });
2658
+ payload = shouldStartRecruitDetached({ workspaceRoot })
2659
+ ? await startRecruitPipelineDetachedRunTool({ workspaceRoot, args })
2660
+ : await startRecruitPipelineRunTool({ workspaceRoot, args });
2624
2661
  } else if (toolName === TOOL_GET_RECRUIT_PIPELINE_RUN) {
2625
2662
  payload = getRecruitPipelineRunTool({ workspaceRoot, args });
2626
2663
  } else if (toolName === TOOL_CANCEL_RECRUIT_PIPELINE_RUN) {
@@ -2781,24 +2818,30 @@ export const __testables = {
2781
2818
  __resetRecommendMcpStateForTests();
2782
2819
  },
2783
2820
  setChatMcpConnectorForTests(nextImpl) {
2821
+ forceChatInProcForTests = typeof nextImpl === "function";
2784
2822
  __setChatMcpConnectorForTests(nextImpl);
2785
2823
  },
2786
2824
  setChatMcpJobReaderForTests(nextImpl) {
2787
2825
  __setChatMcpJobReaderForTests(nextImpl);
2788
2826
  },
2789
2827
  setChatMcpWorkflowForTests(nextImpl) {
2828
+ forceChatInProcForTests = typeof nextImpl === "function";
2790
2829
  __setChatMcpWorkflowForTests(nextImpl);
2791
2830
  },
2792
2831
  resetChatMcpStateForTests() {
2832
+ forceChatInProcForTests = false;
2793
2833
  __resetChatMcpStateForTests();
2794
2834
  },
2795
2835
  setRecruitMcpConnectorForTests(nextImpl) {
2836
+ forceRecruitInProcForTests = typeof nextImpl === "function";
2796
2837
  __setRecruitMcpConnectorForTests(nextImpl);
2797
2838
  },
2798
2839
  setRecruitMcpWorkflowForTests(nextImpl) {
2840
+ forceRecruitInProcForTests = typeof nextImpl === "function";
2799
2841
  __setRecruitMcpWorkflowForTests(nextImpl);
2800
2842
  },
2801
2843
  resetRecruitMcpStateForTests() {
2844
+ forceRecruitInProcForTests = false;
2802
2845
  __resetRecruitMcpStateForTests();
2803
2846
  }
2804
2847
  };