Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

962 B
Raw Blame
/**
 * Robust "is this module the entry point" check for a dual bin+import package.
 *
 * `import.meta.url === file://${process.argv[1]}` breaks the moment the binary
 * is invoked through a symlink — which is exactly how npm installs `bin`
 * entries (`node_modules/.bin/hood-mcp -> ../hood-mcp/dist/data-server.js`).
 * Node resolves `import.meta.url` to the symlink's REAL path but leaves
 * `process.argv[1]` as the invoked (symlink) path, so the naive string
 * comparison silently fails and main() never runs — verified by actually
 * running the packed tarball through `node_modules/.bin/hood-mcp` during
 * this package's own E2E test, not a hypothetical.
 */
import { realpathSync } from 'node:fs'
import { fileURLToPath } from 'node:url'

export function isMainModule(moduleUrl: string): boolean {
  if (!process.argv[1]) return false
  try {
    return realpathSync(process.argv[1]) === fileURLToPath(moduleUrl)
  } catch {
    return false
  }
}