@reconcrap/boss-recommend-mcp 2.0.56 → 2.0.57

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/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;
@@ -2468,6 +2486,9 @@ async function handleBossChatPrepareRunTool({ workspaceRoot, args }) {
2468
2486
  }
2469
2487
 
2470
2488
  async function handleBossChatStartRunTool({ workspaceRoot, args }) {
2489
+ if (shouldStartChatDetached({ workspaceRoot })) {
2490
+ return startBossChatDetachedRunTool({ workspaceRoot, args });
2491
+ }
2471
2492
  return startBossChatRunTool({ workspaceRoot, args });
2472
2493
  }
2473
2494
 
@@ -2618,9 +2639,15 @@ async function handleRequest(message, workspaceRoot) {
2618
2639
  } else if (toolName === TOOL_BOSS_CHAT_CANCEL_RUN) {
2619
2640
  payload = await handleBossChatCancelRunTool({ workspaceRoot, args });
2620
2641
  } else if (toolName === TOOL_RUN_RECRUIT_PIPELINE) {
2621
- payload = await runRecruitPipelineTool({ workspaceRoot, args });
2642
+ payload = normalizeText(args.execution_mode || "").toLowerCase() === "sync"
2643
+ ? await runRecruitPipelineTool({ workspaceRoot, args })
2644
+ : shouldStartRecruitDetached({ workspaceRoot })
2645
+ ? await startRecruitPipelineDetachedRunTool({ workspaceRoot, args })
2646
+ : await runRecruitPipelineTool({ workspaceRoot, args });
2622
2647
  } else if (toolName === TOOL_START_RECRUIT_PIPELINE_RUN) {
2623
- payload = await startRecruitPipelineRunTool({ workspaceRoot, args });
2648
+ payload = shouldStartRecruitDetached({ workspaceRoot })
2649
+ ? await startRecruitPipelineDetachedRunTool({ workspaceRoot, args })
2650
+ : await startRecruitPipelineRunTool({ workspaceRoot, args });
2624
2651
  } else if (toolName === TOOL_GET_RECRUIT_PIPELINE_RUN) {
2625
2652
  payload = getRecruitPipelineRunTool({ workspaceRoot, args });
2626
2653
  } else if (toolName === TOOL_CANCEL_RECRUIT_PIPELINE_RUN) {
@@ -2781,24 +2808,30 @@ export const __testables = {
2781
2808
  __resetRecommendMcpStateForTests();
2782
2809
  },
2783
2810
  setChatMcpConnectorForTests(nextImpl) {
2811
+ forceChatInProcForTests = typeof nextImpl === "function";
2784
2812
  __setChatMcpConnectorForTests(nextImpl);
2785
2813
  },
2786
2814
  setChatMcpJobReaderForTests(nextImpl) {
2787
2815
  __setChatMcpJobReaderForTests(nextImpl);
2788
2816
  },
2789
2817
  setChatMcpWorkflowForTests(nextImpl) {
2818
+ forceChatInProcForTests = typeof nextImpl === "function";
2790
2819
  __setChatMcpWorkflowForTests(nextImpl);
2791
2820
  },
2792
2821
  resetChatMcpStateForTests() {
2822
+ forceChatInProcForTests = false;
2793
2823
  __resetChatMcpStateForTests();
2794
2824
  },
2795
2825
  setRecruitMcpConnectorForTests(nextImpl) {
2826
+ forceRecruitInProcForTests = typeof nextImpl === "function";
2796
2827
  __setRecruitMcpConnectorForTests(nextImpl);
2797
2828
  },
2798
2829
  setRecruitMcpWorkflowForTests(nextImpl) {
2830
+ forceRecruitInProcForTests = typeof nextImpl === "function";
2799
2831
  __setRecruitMcpWorkflowForTests(nextImpl);
2800
2832
  },
2801
2833
  resetRecruitMcpStateForTests() {
2834
+ forceRecruitInProcForTests = false;
2802
2835
  __resetRecruitMcpStateForTests();
2803
2836
  }
2804
2837
  };