()
| 42 | }); |
| 43 | |
| 44 | async function main() { |
| 45 | // Happy path: the npm-installed optional dependency. Fall back to a download |
| 46 | // when the registry didn't deliver it. |
| 47 | var resolved = resolveInstalledBundle() || (await selfHealBundle()); |
| 48 | // Thread the MCP host's pid (our parent) down to the bundled server so its |
| 49 | // orphan watchdog can poll the host directly. Without this, the server can |
| 50 | // only watch THIS shim — and a shim killed during the server's first ~100ms |
| 51 | // of startup used to leave the server orphaned forever (issue #1185). An |
| 52 | // already-set value (an outer launcher) wins. |
| 53 | var env = Object.assign({}, process.env); |
| 54 | if (!env.CODEGRAPH_HOST_PPID) env.CODEGRAPH_HOST_PPID = String(process.ppid); |
| 55 | var res = childProcess.spawnSync(resolved.command, resolved.args, { stdio: 'inherit', windowsHide: true, env: env }); |
| 56 | if (res.error) { |
| 57 | process.stderr.write('codegraph: ' + res.error.message + '\n'); |
| 58 | process.exit(1); |
| 59 | } |
| 60 | process.exit(res.status === null ? 1 : res.status); |
| 61 | } |
| 62 | |
| 63 | // Resolve the launcher from the installed per-platform optionalDependency. |
| 64 | // Returns {command, args} or null if the package isn't installed. |
no test coverage detected