@reconcrap/boss-recommend-mcp 1.3.11 → 1.3.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reconcrap/boss-recommend-mcp",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "Unified MCP pipeline for recommend-page filtering and screening on Boss Zhipin",
5
5
  "keywords": [
6
6
  "boss",
package/src/boss-chat.js CHANGED
@@ -10,6 +10,8 @@ const currentFilePath = fileURLToPath(import.meta.url);
10
10
  const packageRoot = path.resolve(path.dirname(currentFilePath), "..");
11
11
  const VENDORED_BOSS_CHAT_DIR = path.join(packageRoot, "vendor", "boss-chat-cli");
12
12
  const DEFAULT_BOSS_CHAT_POLL_MS = 1500;
13
+ const PREPARE_BOSS_CHAT_MAX_ATTEMPTS = 3;
14
+ const PREPARE_BOSS_CHAT_RETRY_DELAY_MS = 1200;
13
15
  const BOSS_CHAT_TERMINAL_STATES = new Set(["completed", "failed", "canceled"]);
14
16
  const CHAT_REQUIRED_FIELDS = ["job", "start_from", "target_count", "criteria"];
15
17
  export const TARGET_COUNT_ACCEPTED_EXAMPLES = ["all", -1, 20, "全部候选人"];
@@ -583,7 +585,14 @@ export async function startBossChatRun({ workspaceRoot, input = {} }) {
583
585
  }
584
586
 
585
587
  export async function prepareBossChatRun({ workspaceRoot, input = {} }) {
586
- const payload = (await spawnBossChatCli({ workspaceRoot, command: "prepare-run", input })).payload;
588
+ let payload = null;
589
+ for (let attempt = 1; attempt <= PREPARE_BOSS_CHAT_MAX_ATTEMPTS; attempt += 1) {
590
+ payload = (await spawnBossChatCli({ workspaceRoot, command: "prepare-run", input })).payload;
591
+ if (payload?.status !== "FAILED") break;
592
+ if (attempt >= PREPARE_BOSS_CHAT_MAX_ATTEMPTS) break;
593
+ await sleep(PREPARE_BOSS_CHAT_RETRY_DELAY_MS);
594
+ }
595
+
587
596
  if (payload?.status !== "NEED_INPUT") return payload;
588
597
 
589
598
  const missingFields = getMissingBossChatStartFields(input);
@@ -69,6 +69,11 @@ function createBossChatTestWorkspace() {
69
69
  "const raw = fs.existsSync(statePath) ? fs.readFileSync(statePath, 'utf8') : '{}';",
70
70
  "const state = JSON.parse(raw || '{}');",
71
71
  "state.counter = Number.isInteger(state.counter) ? state.counter : 0;",
72
+ "state.prepare_calls = Number.isInteger(state.prepare_calls) ? state.prepare_calls : 0;",
73
+ "if (!Number.isInteger(state.prepare_fail_budget)) {",
74
+ " const configured = Number.parseInt(process.env.BOSS_CHAT_STUB_PREPARE_FAILS || '0', 10);",
75
+ " state.prepare_fail_budget = Number.isFinite(configured) && configured > 0 ? configured : 0;",
76
+ "}",
72
77
  "state.runs = state.runs && typeof state.runs === 'object' ? state.runs : {};",
73
78
  "state.get_calls = state.get_calls && typeof state.get_calls === 'object' ? state.get_calls : {};",
74
79
  "const argv = process.argv.slice(2);",
@@ -91,6 +96,12 @@ function createBossChatTestWorkspace() {
91
96
  " process.stdout.write(`${JSON.stringify(payload)}\\n`);",
92
97
  "}",
93
98
  "if (command === 'prepare-run') {",
99
+ " state.prepare_calls += 1;",
100
+ " if (state.prepare_fail_budget > 0) {",
101
+ " state.prepare_fail_budget -= 1;",
102
+ " saveAndPrint({ status: 'FAILED', error: { code: 'CHAT_PAGE_NOT_READY', message: 'chat page is still loading' } });",
103
+ " process.exit(1);",
104
+ " }",
94
105
  " state.last_prepare_args = options;",
95
106
  " saveAndPrint({",
96
107
  " status: 'NEED_INPUT',",
@@ -359,6 +370,29 @@ async function testBossChatAdapterShouldResolveSharedConfigAndInvokeLocalCli() {
359
370
  });
360
371
  }
361
372
 
373
+ async function testBossChatPrepareShouldRetryWhenChatPageIsNotReady() {
374
+ await withBossChatWorkspace(async (workspaceRoot) => {
375
+ const previousPrepareFails = process.env.BOSS_CHAT_STUB_PREPARE_FAILS;
376
+ process.env.BOSS_CHAT_STUB_PREPARE_FAILS = "2";
377
+ try {
378
+ const prepared = await prepareBossChatRun({
379
+ workspaceRoot,
380
+ input: {}
381
+ });
382
+ assert.equal(prepared.status, "NEED_INPUT");
383
+ const state = readStubState(workspaceRoot);
384
+ assert.equal(state.prepare_calls, 3);
385
+ assert.equal(state.prepare_fail_budget, 0);
386
+ } finally {
387
+ if (previousPrepareFails === undefined) {
388
+ delete process.env.BOSS_CHAT_STUB_PREPARE_FAILS;
389
+ } else {
390
+ process.env.BOSS_CHAT_STUB_PREPARE_FAILS = previousPrepareFails;
391
+ }
392
+ }
393
+ });
394
+ }
395
+
362
396
  async function testBossChatMcpToolsShouldValidateAndRoute() {
363
397
  await withBossChatWorkspace(async (workspaceRoot) => {
364
398
  const toolsResponse = await handleRequest({
@@ -806,6 +840,7 @@ async function testBossChatAppShouldPersistEvidenceArtifacts() {
806
840
 
807
841
  async function main() {
808
842
  await testBossChatAdapterShouldResolveSharedConfigAndInvokeLocalCli();
843
+ await testBossChatPrepareShouldRetryWhenChatPageIsNotReady();
809
844
  await testBossChatMcpToolsShouldValidateAndRoute();
810
845
  await testBossChatCliShouldSupportRunAndFollowUpParsing();
811
846
  testBossChatLlmEvidenceGateShouldDemoteMissingEvidence();