@reconcrap/boss-recommend-mcp 1.3.29 → 1.3.31

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 CHANGED
@@ -68,6 +68,7 @@ MCP 工具:
68
68
  - 在真正开始 search/screen 前,会进行最后一轮全参数总确认(岗位 + 全部筛选参数 + criteria + target_count + post_action + max_greet_count)
69
69
  - npm 全局安装后会自动执行 install:生成 skill、导出 MCP 模板,并自动尝试写入已检测到的外部 agent MCP 配置(含 Trae / trae-cn / Cursor / Claude / OpenClaw)
70
70
  - npm / npx 安装后会自动初始化 `screening-config.json` 模板(优先写入 workspace 的 `config/`,不可写时回退到用户目录)
71
+ - npm 安装流程会预创建运行目录(跨平台):`~/.boss-recommend-mcp`、`~/.boss-recommend-mcp/runs`、`<workspace>/.boss-chat` 及其 `logs/runs/profiles/reports/artifacts`
71
72
  - `post_action` 必须在每次完整运行开始时确认一次
72
73
  - `target_count` 会在每次运行开始时询问一次(可留空,不设上限)
73
74
  - 当 `post_action=greet` 时,必须在运行开始时确认 `max_greet_count`
@@ -3,6 +3,8 @@
3
3
  "apiKey": "replace-with-openai-api-key",
4
4
  "model": "gpt-4.1-mini",
5
5
  "llmThinkingLevel": "low",
6
+ "llmTimeoutMs": 60000,
7
+ "llmMaxRetries": 3,
6
8
  "humanRestEnabled": false,
7
9
  "openaiOrganization": "optional-org-id",
8
10
  "openaiProject": "optional-project-id"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reconcrap/boss-recommend-mcp",
3
- "version": "1.3.29",
3
+ "version": "1.3.31",
4
4
  "description": "Unified MCP pipeline for recommend-page filtering and screening on Boss Zhipin",
5
5
  "keywords": [
6
6
  "boss",
package/src/adapters.js CHANGED
@@ -27,6 +27,8 @@ const LLM_THINKING_LEVEL_FIELDS = [
27
27
  "reasoningEffort",
28
28
  "reasoning_effort"
29
29
  ];
30
+ const DEFAULT_SHARED_LLM_TIMEOUT_MS = 60000;
31
+ const DEFAULT_SHARED_LLM_MAX_RETRIES = 3;
30
32
  const DEFAULT_RECOMMEND_SCREEN_TIMEOUT_MS = 24 * 60 * 60 * 1000;
31
33
  const PAGE_SCOPE_TO_TAB_STATUS = {
32
34
  recommend: "0",
@@ -405,6 +407,19 @@ function resolveLlmThinkingLevel(config = {}) {
405
407
  }
406
408
  return "";
407
409
  }
410
+
411
+ export function resolveSharedLlmTransportConfig(config = {}) {
412
+ const timeoutMs = parsePositiveInteger(config?.llmTimeoutMs)
413
+ || parsePositiveInteger(config?.llm_timeout_ms)
414
+ || DEFAULT_SHARED_LLM_TIMEOUT_MS;
415
+ const maxRetries = parsePositiveInteger(config?.llmMaxRetries)
416
+ || parsePositiveInteger(config?.llm_max_retries)
417
+ || DEFAULT_SHARED_LLM_MAX_RETRIES;
418
+ return {
419
+ llmTimeoutMs: timeoutMs,
420
+ llmMaxRetries: maxRetries
421
+ };
422
+ }
408
423
 
409
424
  function resolveWorkspaceDebugPort(workspaceRoot) {
410
425
  const fromEnv = parsePositiveInteger(process.env.BOSS_RECOMMEND_CHROME_PORT);
@@ -2961,6 +2976,13 @@ export async function runRecommendScreenCli({
2961
2976
  if (llmThinkingLevel) {
2962
2977
  args.push("--thinking-level", llmThinkingLevel);
2963
2978
  }
2979
+ const sharedLlmTransport = resolveSharedLlmTransportConfig(loaded.config);
2980
+ if (sharedLlmTransport.llmTimeoutMs) {
2981
+ args.push("--llm-timeout-ms", String(sharedLlmTransport.llmTimeoutMs));
2982
+ }
2983
+ if (sharedLlmTransport.llmMaxRetries) {
2984
+ args.push("--llm-max-retries", String(sharedLlmTransport.llmMaxRetries));
2985
+ }
2964
2986
  args.push("--human-rest", String(resolveHumanRestEnabled(loaded.config)));
2965
2987
  if (Number.isInteger(screenParams.target_count) && screenParams.target_count > 0) {
2966
2988
  args.push("--targetCount", String(screenParams.target_count));
package/src/boss-chat.js CHANGED
@@ -4,7 +4,7 @@ import process from "node:process";
4
4
  import { spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
- import { getScreenConfigResolution } from "./adapters.js";
7
+ import { getScreenConfigResolution, resolveSharedLlmTransportConfig } from "./adapters.js";
8
8
 
9
9
  const currentFilePath = fileURLToPath(import.meta.url);
10
10
  const packageRoot = path.resolve(path.dirname(currentFilePath), "..");
@@ -364,6 +364,7 @@ function resolveBossChatScreenConfig(workspaceRoot) {
364
364
  apiKey: normalizeText(parsed.apiKey),
365
365
  model: normalizeText(parsed.model),
366
366
  llmThinkingLevel: resolveLlmThinkingLevel(parsed),
367
+ ...resolveSharedLlmTransportConfig(parsed),
367
368
  debugPort: parsePositiveInteger(parsed.debugPort, 9222),
368
369
  humanRestEnabled: resolveHumanRestEnabled(parsed)
369
370
  },
@@ -484,6 +485,12 @@ function buildBossChatCliArgs(command, input, resolvedConfig) {
484
485
  if (resolvedConfig.llmThinkingLevel) {
485
486
  args.push("--thinking-level", resolvedConfig.llmThinkingLevel);
486
487
  }
488
+ if (resolvedConfig.llmTimeoutMs) {
489
+ args.push("--llm-timeout-ms", String(resolvedConfig.llmTimeoutMs));
490
+ }
491
+ if (resolvedConfig.llmMaxRetries) {
492
+ args.push("--llm-max-retries", String(resolvedConfig.llmMaxRetries));
493
+ }
487
494
  return args;
488
495
  }
489
496
 
@@ -504,6 +511,12 @@ function buildBossChatCliArgs(command, input, resolvedConfig) {
504
511
  if (resolvedConfig.llmThinkingLevel) {
505
512
  args.push("--thinking-level", resolvedConfig.llmThinkingLevel);
506
513
  }
514
+ if (resolvedConfig.llmTimeoutMs) {
515
+ args.push("--llm-timeout-ms", String(resolvedConfig.llmTimeoutMs));
516
+ }
517
+ if (resolvedConfig.llmMaxRetries) {
518
+ args.push("--llm-max-retries", String(resolvedConfig.llmMaxRetries));
519
+ }
507
520
  args.push("--port", String(normalized.port || resolvedConfig.debugPort || 9222));
508
521
  if (typeof normalized.safePacing === "boolean") {
509
522
  args.push("--safe-pacing", String(normalized.safePacing));
package/src/cli.js CHANGED
@@ -742,6 +742,70 @@ function ensureUserConfig(options = {}) {
742
742
  throw lastError || new Error("No writable target for screening-config.json");
743
743
  }
744
744
 
745
+ function getBossChatDataDir(workspaceRoot) {
746
+ return path.join(path.resolve(String(workspaceRoot || process.cwd())), ".boss-chat");
747
+ }
748
+
749
+ function collectRuntimeDirectories(options = {}) {
750
+ const workspaceRoot = getWorkspaceRoot(options);
751
+ const stateHome = getStateHome();
752
+ const bossChatRoot = getBossChatDataDir(workspaceRoot);
753
+ const recommendRuntimeDirs = [
754
+ stateHome,
755
+ path.join(stateHome, "runs")
756
+ ];
757
+ const bossChatRuntimeDirs = [
758
+ bossChatRoot,
759
+ path.join(bossChatRoot, "logs"),
760
+ path.join(bossChatRoot, "runs"),
761
+ path.join(bossChatRoot, "profiles"),
762
+ path.join(bossChatRoot, "reports"),
763
+ path.join(bossChatRoot, "artifacts")
764
+ ];
765
+ return {
766
+ workspaceRoot,
767
+ stateHome,
768
+ bossChatRoot,
769
+ directories: dedupePaths([
770
+ ...recommendRuntimeDirs,
771
+ ...bossChatRuntimeDirs
772
+ ]).filter(Boolean)
773
+ };
774
+ }
775
+
776
+ function ensureRuntimeDirectories(options = {}) {
777
+ const { workspaceRoot, stateHome, bossChatRoot, directories } = collectRuntimeDirectories(options);
778
+ const created = [];
779
+ const existed = [];
780
+ const failed = [];
781
+
782
+ for (const directory of directories) {
783
+ try {
784
+ const existedBefore = fs.existsSync(directory);
785
+ ensureDir(directory);
786
+ if (existedBefore) {
787
+ existed.push(directory);
788
+ } else {
789
+ created.push(directory);
790
+ }
791
+ } catch (error) {
792
+ failed.push({
793
+ path: directory,
794
+ message: error?.message || String(error)
795
+ });
796
+ }
797
+ }
798
+
799
+ return {
800
+ workspaceRoot,
801
+ stateHome,
802
+ bossChatRoot,
803
+ created,
804
+ existed,
805
+ failed
806
+ };
807
+ }
808
+
745
809
  function readJsonObjectFile(filePath) {
746
810
  const raw = fs.readFileSync(filePath, "utf8");
747
811
  const parsed = JSON.parse(raw);
@@ -1333,11 +1397,22 @@ function printMcpConfig(options = {}) {
1333
1397
  }
1334
1398
 
1335
1399
  function installAll(options = {}) {
1400
+ const runtimeDirsResult = ensureRuntimeDirectories(options);
1336
1401
  const skillResults = installSkill();
1337
1402
  const configResult = ensureUserConfig(options);
1338
1403
  const mcpTemplateResult = writeMcpConfigFiles({ client: "all" });
1339
1404
  const externalMcpResult = installExternalMcpConfigs(options);
1340
1405
  const externalSkillResult = mirrorSkillToExternalDirs(options);
1406
+ console.log(
1407
+ `Runtime directories prepared: created=${runtimeDirsResult.created.length}, existing=${runtimeDirsResult.existed.length}, failed=${runtimeDirsResult.failed.length}`
1408
+ );
1409
+ console.log(`- recommend runtime: ${runtimeDirsResult.stateHome}`);
1410
+ console.log(`- boss-chat runtime: ${runtimeDirsResult.bossChatRoot}`);
1411
+ if (runtimeDirsResult.failed.length > 0) {
1412
+ for (const item of runtimeDirsResult.failed) {
1413
+ console.warn(`Runtime dir warning: ${item.path} -> ${item.message}`);
1414
+ }
1415
+ }
1341
1416
  console.log(`Bundled skills installed: ${skillResults.length}`);
1342
1417
  for (const item of skillResults) {
1343
1418
  console.log(`- ${item.skill}: ${item.targetDir}`);
@@ -1546,7 +1621,18 @@ export async function runCli(argv = process.argv) {
1546
1621
  }
1547
1622
  break;
1548
1623
  case "init-config": {
1624
+ const runtimeDirsResult = ensureRuntimeDirectories(options);
1549
1625
  const result = ensureUserConfig(options);
1626
+ console.log(
1627
+ `Runtime directories prepared: created=${runtimeDirsResult.created.length}, existing=${runtimeDirsResult.existed.length}, failed=${runtimeDirsResult.failed.length}`
1628
+ );
1629
+ console.log(`- recommend runtime: ${runtimeDirsResult.stateHome}`);
1630
+ console.log(`- boss-chat runtime: ${runtimeDirsResult.bossChatRoot}`);
1631
+ if (runtimeDirsResult.failed.length > 0) {
1632
+ for (const item of runtimeDirsResult.failed) {
1633
+ console.warn(`Runtime dir warning: ${item.path} -> ${item.message}`);
1634
+ }
1635
+ }
1550
1636
  console.log(result.created ? `Config template created at: ${result.path}` : `Config already exists at: ${result.path}`);
1551
1637
  if (Array.isArray(result.patched_keys) && result.patched_keys.length > 0) {
1552
1638
  console.log(`Config patched missing defaults: ${result.patched_keys.join(", ")}`);
@@ -1635,6 +1721,7 @@ export const __testables = {
1635
1721
  getRunFollowUp,
1636
1722
  installSkill,
1637
1723
  isInstalledPackageRoot,
1724
+ ensureRuntimeDirectories,
1638
1725
  runBossChatCliCommand,
1639
1726
  runPipelineOnce
1640
1727
  };
@@ -7,6 +7,7 @@ import {
7
7
  runPipelinePreflight,
8
8
  runRecommendSearchCli,
9
9
  runRecommendScreenCli,
10
+ resolveSharedLlmTransportConfig,
10
11
  __testables as adapterTestables
11
12
  } from "./adapters.js";
12
13
 
@@ -107,6 +108,23 @@ function testResolveScreenTimeoutDefaultsTo24Hours() {
107
108
  }
108
109
  }
109
110
 
111
+ function testResolveSharedLlmTransportConfigShouldUseDefaultsAndOverrides() {
112
+ assert.deepEqual(resolveSharedLlmTransportConfig({}), {
113
+ llmTimeoutMs: 60000,
114
+ llmMaxRetries: 3,
115
+ });
116
+ assert.deepEqual(
117
+ resolveSharedLlmTransportConfig({
118
+ llmTimeoutMs: 90000,
119
+ llmMaxRetries: 5,
120
+ }),
121
+ {
122
+ llmTimeoutMs: 90000,
123
+ llmMaxRetries: 5,
124
+ },
125
+ );
126
+ }
127
+
110
128
  function testBuildRecommendScreenProcessErrorMapsTimeout() {
111
129
  const error = buildRecommendScreenProcessError({ code: -1, error_code: "TIMEOUT" }, 86400000);
112
130
  assert.equal(error?.code, "TIMEOUT");
@@ -155,6 +173,76 @@ async function testResumeRequiresCheckpointFile() {
155
173
  }
156
174
  }
157
175
 
176
+ async function testRecommendScreenCliShouldPassSharedLlmTransportArgs() {
177
+ const workspaceRoot = fs.mkdtempSync(path.join(os.tmpdir(), "boss-recommend-screen-stub-"));
178
+ const screenDir = path.join(workspaceRoot, "boss-recommend-screen-cli");
179
+ const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "boss-recommend-screen-home-"));
180
+ const previousHome = process.env.BOSS_RECOMMEND_HOME;
181
+ fs.mkdirSync(screenDir, { recursive: true });
182
+ fs.writeFileSync(
183
+ path.join(screenDir, "boss-recommend-screen-cli.cjs"),
184
+ [
185
+ "#!/usr/bin/env node",
186
+ "const fs = require('node:fs');",
187
+ "const path = require('node:path');",
188
+ "const argv = process.argv.slice(2);",
189
+ "const parsed = {};",
190
+ "for (let i = 0; i < argv.length; i += 1) {",
191
+ " const token = argv[i];",
192
+ " if (!token.startsWith('--')) continue;",
193
+ " const next = argv[i + 1];",
194
+ " parsed[token.slice(2)] = next && !next.startsWith('--') ? next : true;",
195
+ " if (next && !next.startsWith('--')) i += 1;",
196
+ "}",
197
+ "const output = path.join(process.env.BOSS_RECOMMEND_HOME, 'screen-cli-args.json');",
198
+ "fs.writeFileSync(output, JSON.stringify(parsed, null, 2));",
199
+ "console.log(JSON.stringify({ status: 'COMPLETED', result: { processed_count: 0, output_csv: parsed.output || '' } }));",
200
+ ].join("\n"),
201
+ "utf8",
202
+ );
203
+
204
+ process.env.BOSS_RECOMMEND_HOME = tempHome;
205
+ fs.writeFileSync(
206
+ path.join(tempHome, "screening-config.json"),
207
+ JSON.stringify(
208
+ {
209
+ baseUrl: "https://api.openai.com/v1",
210
+ apiKey: "sk-valid-test",
211
+ model: "gpt-4.1-mini",
212
+ llmTimeoutMs: 75000,
213
+ llmMaxRetries: 6,
214
+ },
215
+ null,
216
+ 2,
217
+ ),
218
+ );
219
+
220
+ try {
221
+ const result = await runRecommendScreenCli({
222
+ workspaceRoot,
223
+ screenParams: {
224
+ criteria: "有 MCP 经验",
225
+ target_count: null,
226
+ post_action: "none",
227
+ max_greet_count: null,
228
+ },
229
+ pageScope: "recommend",
230
+ });
231
+ assert.equal(result.ok, true);
232
+ const parsed = JSON.parse(fs.readFileSync(path.join(tempHome, "screen-cli-args.json"), "utf8"));
233
+ assert.equal(parsed["llm-timeout-ms"], "75000");
234
+ assert.equal(parsed["llm-max-retries"], "6");
235
+ } finally {
236
+ if (previousHome === undefined) {
237
+ delete process.env.BOSS_RECOMMEND_HOME;
238
+ } else {
239
+ process.env.BOSS_RECOMMEND_HOME = previousHome;
240
+ }
241
+ fs.rmSync(workspaceRoot, { recursive: true, force: true });
242
+ fs.rmSync(tempHome, { recursive: true, force: true });
243
+ }
244
+ }
245
+
158
246
  function testPreflightShouldCheckSharpInsteadOfPython() {
159
247
  const preflight = runPipelinePreflight(process.cwd());
160
248
  const keys = new Set((preflight.checks || []).map((item) => item?.key));
@@ -520,8 +608,10 @@ async function main() {
520
608
  testParsePausedStructuredOutput();
521
609
  testParseScreenProgressLineShouldCountFavoriteFailureAsSkipped();
522
610
  testResolveScreenTimeoutDefaultsTo24Hours();
611
+ testResolveSharedLlmTransportConfigShouldUseDefaultsAndOverrides();
523
612
  testBuildRecommendScreenProcessErrorMapsTimeout();
524
613
  await testResumeRequiresCheckpointFile();
614
+ await testRecommendScreenCliShouldPassSharedLlmTransportArgs();
525
615
  testPreflightShouldCheckSharpInsteadOfPython();
526
616
  testPreflightFeaturedShouldRequireFavoriteCalibration();
527
617
  testPreflightRecommendShouldKeepFavoriteCalibrationOptional();