@reconcrap/boss-recommend-mcp 2.1.23 → 2.1.25

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.
Files changed (67) hide show
  1. package/README.md +5 -0
  2. package/bin/boss-recommend-mcp.js +4 -4
  3. package/package.json +6 -1
  4. package/scripts/install-macos.sh +280 -280
  5. package/scripts/postinstall.cjs +44 -44
  6. package/skills/boss-chat/README.md +43 -42
  7. package/skills/boss-chat/SKILL.md +107 -106
  8. package/skills/boss-recommend-pipeline/README.md +13 -13
  9. package/skills/boss-recommend-pipeline/SKILL.md +47 -47
  10. package/skills/boss-recruit-pipeline/README.md +19 -19
  11. package/skills/boss-recruit-pipeline/SKILL.md +89 -89
  12. package/src/chat-mcp.js +301 -127
  13. package/src/chat-runtime-config.js +7 -5
  14. package/src/core/boss-cards/index.js +199 -199
  15. package/src/core/browser/index.js +302 -145
  16. package/src/core/capture/index.js +2930 -1201
  17. package/src/core/cv-acquisition/index.js +512 -238
  18. package/src/core/cv-capture-target/index.js +513 -299
  19. package/src/core/greet-quota/index.js +71 -71
  20. package/src/core/infinite-list/index.js +31 -31
  21. package/src/core/reporting/legacy-csv.js +12 -12
  22. package/src/core/run/detached-launcher.js +305 -0
  23. package/src/core/run/index.js +109 -55
  24. package/src/core/run/timing.js +33 -33
  25. package/src/core/run/windows-detached-worker.ps1 +106 -0
  26. package/src/core/screening/index.js +2400 -2135
  27. package/src/core/self-heal/index.js +989 -973
  28. package/src/core/self-heal/viewport.js +1505 -564
  29. package/src/detached-worker.js +99 -99
  30. package/src/domains/chat/action-journal.js +536 -0
  31. package/src/domains/chat/cards.js +137 -137
  32. package/src/domains/chat/constants.js +9 -9
  33. package/src/domains/chat/detail.js +1684 -401
  34. package/src/domains/chat/index.js +8 -7
  35. package/src/domains/chat/jobs.js +620 -620
  36. package/src/domains/chat/page-guard.js +157 -122
  37. package/src/domains/chat/roots.js +56 -56
  38. package/src/domains/chat/run-service.js +1801 -760
  39. package/src/domains/common/account-rights-panel.js +314 -314
  40. package/src/domains/common/recovery-settle.js +159 -159
  41. package/src/domains/recommend/actions.js +1219 -472
  42. package/src/domains/recommend/cards.js +243 -243
  43. package/src/domains/recommend/colleague-contact.js +1079 -333
  44. package/src/domains/recommend/constants.js +92 -92
  45. package/src/domains/recommend/detail.js +4037 -136
  46. package/src/domains/recommend/filters.js +608 -590
  47. package/src/domains/recommend/index.js +9 -9
  48. package/src/domains/recommend/jobs.js +571 -542
  49. package/src/domains/recommend/location.js +754 -707
  50. package/src/domains/recommend/refresh.js +677 -392
  51. package/src/domains/recommend/roots.js +80 -80
  52. package/src/domains/recommend/run-service.js +4048 -1447
  53. package/src/domains/recommend/scopes.js +246 -246
  54. package/src/domains/recruit/actions.js +277 -277
  55. package/src/domains/recruit/cards.js +74 -74
  56. package/src/domains/recruit/constants.js +236 -236
  57. package/src/domains/recruit/detail.js +588 -588
  58. package/src/domains/recruit/index.js +9 -9
  59. package/src/domains/recruit/instruction-parser.js +866 -866
  60. package/src/domains/recruit/refresh.js +45 -45
  61. package/src/domains/recruit/roots.js +68 -68
  62. package/src/domains/recruit/run-service.js +1817 -1620
  63. package/src/domains/recruit/search.js +3229 -3229
  64. package/src/index.js +16 -1
  65. package/src/parser.js +1296 -1296
  66. package/src/recommend-mcp.js +1061 -450
  67. package/src/recommend-scheduler.js +75 -75
@@ -32,32 +32,55 @@ function clone(value) {
32
32
  return JSON.parse(JSON.stringify(value));
33
33
  }
34
34
 
35
- function errorDiagnostic(error) {
36
- if (!error) return null;
37
- const diagnostic = {
38
- name: error?.name || "Error",
39
- message: error?.message || String(error)
35
+ const SAFE_CDP_ERROR_FIELDS = [
36
+ "cdp_method",
37
+ "cdp_at",
38
+ "cdp_node_id",
39
+ "cdp_backend_node_id",
40
+ "cdp_search_id",
41
+ "cdp_connection_epoch",
42
+ "cdp_replay_policy",
43
+ "cdp_reconnected",
44
+ "cdp_reconnected_epoch",
45
+ "cdp_replayed_after_reconnect",
46
+ "cdp_replay_suppressed",
47
+ "cdp_outcome_unknown",
48
+ "cdp_reconnect_error"
49
+ ];
50
+
51
+ function appendSafeCdpDiagnostics(diagnostic, error) {
52
+ for (const field of SAFE_CDP_ERROR_FIELDS) {
53
+ if (error?.[field] !== undefined) diagnostic[field] = error[field];
54
+ }
55
+ if (Array.isArray(error?.cdp_param_keys)) {
56
+ diagnostic.cdp_param_keys = error.cdp_param_keys
57
+ .filter((key) => typeof key === "string")
58
+ .slice(0, 20);
59
+ }
60
+ return diagnostic;
61
+ }
62
+
63
+ function errorDiagnostic(error, phase = null) {
64
+ if (!error) return null;
65
+ const diagnostic = {
66
+ name: error?.name || "Error",
67
+ message: error?.message || String(error)
40
68
  };
41
69
  if (error?.code) diagnostic.code = error.code;
42
- if (error?.cdp_method) diagnostic.cdp_method = error.cdp_method;
43
- if (error?.cdp_at) diagnostic.cdp_at = error.cdp_at;
44
- if (Number.isInteger(error?.cdp_node_id)) diagnostic.cdp_node_id = error.cdp_node_id;
45
- if (Number.isInteger(error?.cdp_backend_node_id)) diagnostic.cdp_backend_node_id = error.cdp_backend_node_id;
46
- if (error?.cdp_search_id) diagnostic.cdp_search_id = error.cdp_search_id;
47
- if (Array.isArray(error?.cdp_param_keys)) diagnostic.cdp_param_keys = error.cdp_param_keys.slice(0, 20);
70
+ const diagnosticPhase = error?.phase || phase;
71
+ if (diagnosticPhase) diagnostic.phase = diagnosticPhase;
72
+ appendSafeCdpDiagnostics(diagnostic, error);
48
73
  if (error?.stack) diagnostic.stack = String(error.stack).split(/\r?\n/).slice(0, 12).join("\n");
49
74
  if (error?.cause && error.cause !== error) {
50
- diagnostic.cause = {
75
+ diagnostic.cause = appendSafeCdpDiagnostics({
51
76
  name: error.cause?.name || "Error",
52
77
  message: error.cause?.message || String(error.cause),
53
- code: error.cause?.code || undefined,
54
- cdp_method: error.cause?.cdp_method || undefined,
55
- cdp_at: error.cause?.cdp_at || undefined,
56
- cdp_node_id: Number.isInteger(error.cause?.cdp_node_id) ? error.cause.cdp_node_id : undefined
57
- };
78
+ ...(error.cause?.code ? { code: error.cause.code } : {}),
79
+ ...((error.cause?.phase || diagnosticPhase) ? { phase: error.cause?.phase || diagnosticPhase } : {})
80
+ }, error.cause);
58
81
  }
59
82
  return diagnostic;
60
- }
83
+ }
61
84
 
62
85
  function createDeferred() {
63
86
  let resolve;
@@ -98,17 +121,18 @@ export function createRunLifecycleManager({
98
121
  } = {}) {
99
122
  const runs = new Map();
100
123
 
101
- function emitSnapshot(entry, event = {}) {
102
- if (typeof onSnapshot !== "function") return;
103
- try {
104
- onSnapshot(snapshotFromEntry(entry), {
105
- type: event.type || "update",
106
- at: now(),
107
- ...event
108
- });
109
- } catch {
110
- // Snapshot hooks must never interrupt an active browser run.
111
- }
124
+ function emitSnapshot(entry, event = {}, { required = false } = {}) {
125
+ if (typeof onSnapshot !== "function") return;
126
+ try {
127
+ onSnapshot(snapshotFromEntry(entry), {
128
+ type: event.type || "update",
129
+ at: now(),
130
+ ...event
131
+ });
132
+ } catch (error) {
133
+ if (required) throw error;
134
+ // Snapshot hooks must never interrupt an active browser run.
135
+ }
112
136
  }
113
137
 
114
138
  function getEntry(runId) {
@@ -150,16 +174,30 @@ export function createRunLifecycleManager({
150
174
  emitSnapshot(entry, { type: "progress", progressPatch });
151
175
  return snapshotFromEntry(entry);
152
176
  },
153
- checkpoint(checkpointPatch = {}) {
154
- entry.run.checkpoint = {
155
- ...entry.run.checkpoint,
156
- ...checkpointPatch,
157
- updatedAt: now()
177
+ checkpoint(checkpointPatch = {}) {
178
+ entry.run.checkpoint = {
179
+ ...entry.run.checkpoint,
180
+ ...checkpointPatch,
181
+ updatedAt: now()
158
182
  };
159
183
  touch(entry);
160
- emitSnapshot(entry, { type: "checkpoint", checkpointPatch });
161
- return snapshotFromEntry(entry);
162
- },
184
+ emitSnapshot(entry, { type: "checkpoint", checkpointPatch });
185
+ return snapshotFromEntry(entry);
186
+ },
187
+ checkpointCritical(checkpointPatch = {}) {
188
+ entry.run.checkpoint = {
189
+ ...entry.run.checkpoint,
190
+ ...checkpointPatch,
191
+ updatedAt: now()
192
+ };
193
+ touch(entry);
194
+ emitSnapshot(entry, {
195
+ type: "checkpoint",
196
+ checkpointPatch,
197
+ required: true
198
+ }, { required: true });
199
+ return snapshotFromEntry(entry);
200
+ },
163
201
  async waitIfPaused() {
164
202
  if (entry.controller.signal.aborted) {
165
203
  throw new RunCanceledError();
@@ -180,19 +218,34 @@ export function createRunLifecycleManager({
180
218
  }
181
219
  setStatus(entry, RUN_STATUS_RUNNING);
182
220
  },
183
- async sleep(ms) {
184
- if (entry.controller.signal.aborted) {
185
- throw new RunCanceledError();
186
- }
187
- await new Promise((resolve, reject) => {
188
- const timer = setTimeout(resolve, ms);
189
- const onAbort = () => {
190
- clearTimeout(timer);
191
- reject(new RunCanceledError());
192
- };
193
- entry.controller.signal.addEventListener("abort", onAbort, { once: true });
194
- });
195
- },
221
+ async sleep(ms) {
222
+ if (entry.controller.signal.aborted) {
223
+ throw new RunCanceledError();
224
+ }
225
+ await new Promise((resolve, reject) => {
226
+ let settled = false;
227
+ let timer = null;
228
+ const cleanup = () => {
229
+ entry.controller.signal.removeEventListener("abort", onAbort);
230
+ };
231
+ const onTimer = () => {
232
+ if (settled) return;
233
+ settled = true;
234
+ cleanup();
235
+ resolve();
236
+ };
237
+ const onAbort = () => {
238
+ if (settled) return;
239
+ settled = true;
240
+ clearTimeout(timer);
241
+ cleanup();
242
+ reject(new RunCanceledError());
243
+ };
244
+ timer = setTimeout(onTimer, Math.max(0, Number(ms) || 0));
245
+ entry.controller.signal.addEventListener("abort", onAbort, { once: true });
246
+ if (entry.controller.signal.aborted) onAbort();
247
+ });
248
+ },
196
249
  throwIfCanceled() {
197
250
  if (entry.controller.signal.aborted) {
198
251
  throw new RunCanceledError();
@@ -219,14 +272,15 @@ export function createRunLifecycleManager({
219
272
  if (error instanceof RunCanceledError || entry.controller.signal.aborted || entry.cancelRequested) {
220
273
  setStatus(entry, RUN_STATUS_CANCELED, {
221
274
  completedAt: now(),
222
- error: error instanceof RunCanceledError ? null : errorDiagnostic(error)
275
+ error: error instanceof RunCanceledError ? null : errorDiagnostic(error, entry.run.phase)
223
276
  });
224
277
  return;
225
278
  }
226
- setStatus(entry, RUN_STATUS_FAILED, {
227
- completedAt: now(),
228
- error: errorDiagnostic(error)
229
- });
279
+ setStatus(entry, RUN_STATUS_FAILED, {
280
+ completedAt: now(),
281
+ error: errorDiagnostic(error, entry.run.phase),
282
+ summary: error?.run_summary || entry.run.summary
283
+ });
230
284
  }
231
285
  }
232
286
 
@@ -1,33 +1,33 @@
1
- import path from "node:path";
2
-
3
- export function addTiming(timings, key, value) {
4
- if (!timings || !key) return;
5
- const numeric = Number(value);
6
- if (!Number.isFinite(numeric) || numeric < 0) return;
7
- timings[key] = (Number(timings[key]) || 0) + Math.round(numeric);
8
- }
9
-
10
- export async function measureTiming(timings, key, task) {
11
- const started = Date.now();
12
- try {
13
- return await task();
14
- } finally {
15
- addTiming(timings, key, Date.now() - started);
16
- }
17
- }
18
-
19
- export function imageEvidenceFilePath({
20
- imageOutputDir = "",
21
- domain = "candidate",
22
- runId = "",
23
- index = 0,
24
- extension = "png"
25
- } = {}) {
26
- const dir = String(imageOutputDir || "").trim();
27
- if (!dir) return "";
28
- const safeDomain = String(domain || "candidate").replace(/[^\w.-]+/g, "_");
29
- const safeRunId = String(runId || `${safeDomain}-run`).replace(/[^\w.-]+/g, "_");
30
- const safeIndex = String((Number(index) || 0) + 1).padStart(3, "0");
31
- const safeExt = String(extension || "png").replace(/^\./, "") || "png";
32
- return path.join(dir, safeRunId, `${safeDomain}-candidate-${safeIndex}.${safeExt}`);
33
- }
1
+ import path from "node:path";
2
+
3
+ export function addTiming(timings, key, value) {
4
+ if (!timings || !key) return;
5
+ const numeric = Number(value);
6
+ if (!Number.isFinite(numeric) || numeric < 0) return;
7
+ timings[key] = (Number(timings[key]) || 0) + Math.round(numeric);
8
+ }
9
+
10
+ export async function measureTiming(timings, key, task) {
11
+ const started = Date.now();
12
+ try {
13
+ return await task();
14
+ } finally {
15
+ addTiming(timings, key, Date.now() - started);
16
+ }
17
+ }
18
+
19
+ export function imageEvidenceFilePath({
20
+ imageOutputDir = "",
21
+ domain = "candidate",
22
+ runId = "",
23
+ index = 0,
24
+ extension = "png"
25
+ } = {}) {
26
+ const dir = String(imageOutputDir || "").trim();
27
+ if (!dir) return "";
28
+ const safeDomain = String(domain || "candidate").replace(/[^\w.-]+/g, "_");
29
+ const safeRunId = String(runId || `${safeDomain}-run`).replace(/[^\w.-]+/g, "_");
30
+ const safeIndex = String((Number(index) || 0) + 1).padStart(3, "0");
31
+ const safeExt = String(extension || "png").replace(/^\./, "") || "png";
32
+ return path.join(dir, safeRunId, `${safeDomain}-candidate-${safeIndex}.${safeExt}`);
33
+ }
@@ -0,0 +1,106 @@
1
+ param(
2
+ [Parameter(Mandatory = $true)]
3
+ [string]$NodePath,
4
+
5
+ [Parameter(Mandatory = $true)]
6
+ [string]$WorkerScriptPath,
7
+
8
+ [Parameter(Mandatory = $true)]
9
+ [ValidateSet('chat', 'recruit', 'recommend')]
10
+ [string]$Domain,
11
+
12
+ [Parameter(Mandatory = $true)]
13
+ [ValidatePattern('^[A-Za-z0-9._-]+$')]
14
+ [string]$RunId,
15
+
16
+ [Parameter(Mandatory = $true)]
17
+ [string]$StdoutPath,
18
+
19
+ [Parameter(Mandatory = $true)]
20
+ [string]$StderrPath,
21
+
22
+ [Parameter(Mandatory = $false)]
23
+ [string]$ChatRuntimeHomePath = '',
24
+
25
+ [Parameter(Mandatory = $false)]
26
+ [string]$ScreenConfigPath = ''
27
+ )
28
+
29
+ $ErrorActionPreference = 'Stop'
30
+ $utf8 = [System.Text.UTF8Encoding]::new($false)
31
+
32
+ function Assert-ControlledPath([string]$Value, [string]$Label) {
33
+ if (-not $Value -or -not [System.IO.Path]::IsPathRooted($Value)) {
34
+ throw "$Label must be an absolute path."
35
+ }
36
+ if ($Value.IndexOf([char]0) -ge 0 -or $Value -match '[\r\n"]') {
37
+ throw "$Label contains unsupported characters."
38
+ }
39
+ }
40
+
41
+ try {
42
+ Assert-ControlledPath $NodePath 'NodePath'
43
+ Assert-ControlledPath $WorkerScriptPath 'WorkerScriptPath'
44
+ Assert-ControlledPath $StdoutPath 'StdoutPath'
45
+ Assert-ControlledPath $StderrPath 'StderrPath'
46
+ if ($ChatRuntimeHomePath) {
47
+ Assert-ControlledPath $ChatRuntimeHomePath 'ChatRuntimeHomePath'
48
+ }
49
+ if ($ScreenConfigPath) {
50
+ Assert-ControlledPath $ScreenConfigPath 'ScreenConfigPath'
51
+ }
52
+ if (-not (Test-Path -LiteralPath $NodePath -PathType Leaf)) {
53
+ throw 'NodePath does not exist.'
54
+ }
55
+ if (-not (Test-Path -LiteralPath $WorkerScriptPath -PathType Leaf)) {
56
+ throw 'WorkerScriptPath does not exist.'
57
+ }
58
+ [System.IO.Directory]::CreateDirectory([System.IO.Path]::GetDirectoryName($StdoutPath)) | Out-Null
59
+ [System.IO.Directory]::CreateDirectory([System.IO.Path]::GetDirectoryName($StderrPath)) | Out-Null
60
+
61
+ $startInfo = New-Object System.Diagnostics.ProcessStartInfo
62
+ $startInfo.FileName = $NodePath
63
+ $startInfo.Arguments = ('"{0}" --domain {1} --run-id {2}' -f $WorkerScriptPath, $Domain, $RunId)
64
+ $startInfo.WorkingDirectory = [System.IO.Path]::GetDirectoryName($WorkerScriptPath)
65
+ $startInfo.UseShellExecute = $false
66
+ $startInfo.CreateNoWindow = $true
67
+ $startInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
68
+ $startInfo.RedirectStandardOutput = $true
69
+ $startInfo.RedirectStandardError = $true
70
+ if ($ChatRuntimeHomePath) {
71
+ $startInfo.EnvironmentVariables['BOSS_CHAT_HOME'] = $ChatRuntimeHomePath
72
+ }
73
+ if ($ScreenConfigPath) {
74
+ $startInfo.EnvironmentVariables['BOSS_RECOMMEND_SCREEN_CONFIG'] = $ScreenConfigPath
75
+ }
76
+
77
+ $worker = New-Object System.Diagnostics.Process
78
+ $worker.StartInfo = $startInfo
79
+ if (-not $worker.Start()) {
80
+ throw 'Node detached worker did not start.'
81
+ }
82
+ $stdoutTask = $worker.StandardOutput.ReadToEndAsync()
83
+ $stderrTask = $worker.StandardError.ReadToEndAsync()
84
+ $worker.WaitForExit()
85
+ $stdout = $stdoutTask.GetAwaiter().GetResult()
86
+ $stderr = $stderrTask.GetAwaiter().GetResult()
87
+ if ($stdout) {
88
+ [System.IO.File]::AppendAllText($StdoutPath, $stdout, $utf8)
89
+ }
90
+ if ($stderr) {
91
+ [System.IO.File]::AppendAllText($StderrPath, $stderr, $utf8)
92
+ }
93
+ exit [int]$worker.ExitCode
94
+ } catch {
95
+ try {
96
+ [System.IO.Directory]::CreateDirectory([System.IO.Path]::GetDirectoryName($StderrPath)) | Out-Null
97
+ [System.IO.File]::AppendAllText(
98
+ $StderrPath,
99
+ "[windows-detached-worker] $($_.Exception.Message)$([Environment]::NewLine)",
100
+ $utf8
101
+ )
102
+ } catch {
103
+ # No additional recovery is available if even the controlled log path is unavailable.
104
+ }
105
+ exit 1
106
+ }