{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.15_tsx@4.22.4_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js","../src/service.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import { spawn, type ChildProcess, type SpawnOptions } from 'node:child_process';\nimport { resolve } from 'node:path';\n\nexport type McpServiceKind = 'http' | 'stdio';\n\nexport interface McpServiceEntrypoints {\n  packageRoot: string;\n  http: string;\n  stdio: string;\n}\n\nexport interface StartMcpServiceOptions {\n  args?: readonly string[];\n  cwd?: string;\n  env?: NodeJS.ProcessEnv;\n  execPath?: string;\n  inheritEnv?: boolean;\n  stdio?: SpawnOptions['stdio'];\n  windowsHide?: boolean;\n}\n\n/**\n * Resolve the packaged executable entrypoints without importing either server.\n * The optional directory keeps the resolver deterministic in tests and embedders.\n */\nexport function resolveMcpServiceEntrypoints(moduleDir = __dirname): McpServiceEntrypoints {\n  const packageRoot = resolve(moduleDir, '..');\n  return {\n    packageRoot,\n    http: resolve(packageRoot, 'bin', 'holoscript-mcp-http.cjs'),\n    stdio: resolve(packageRoot, 'bin', 'holoscript-mcp.cjs'),\n  };\n}\n\n/**\n * Start a packaged MCP executable only when the caller explicitly requests it.\n * Importing this module performs no service, socket, timer, or child-process work.\n */\nexport function startMcpService(\n  kind: McpServiceKind,\n  options: StartMcpServiceOptions = {}\n): ChildProcess {\n  const entrypoints = resolveMcpServiceEntrypoints();\n  const entrypoint = kind === 'http' ? entrypoints.http : entrypoints.stdio;\n  const env = options.inheritEnv === false\n    ? { ...options.env }\n    : { ...process.env, ...options.env };\n\n  return spawn(options.execPath ?? process.execPath, [entrypoint, ...(options.args ?? [])], {\n    cwd: options.cwd ?? entrypoints.packageRoot,\n    env,\n    stdio: options.stdio ?? 'pipe',\n    windowsHide: options.windowsHide ?? true,\n  });\n}\n\nexport function startMcpHttpService(options: StartMcpServiceOptions = {}): ChildProcess {\n  return startMcpService('http', options);\n}\n\nexport function startMcpStdioService(options: StartMcpServiceOptions = {}): ChildProcess {\n  return startMcpService('stdio', options);\n}\n"],"mappings":";;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,cAAc,MAAM,cAAc,YAAY,GAAG;AACvD,IAAM,aAAa,MAAM,KAAK,QAAQ,YAAY,CAAC;AAE5C,IAAM,YAA4B,2BAAW;;;ACPpD,SAAS,aAAmD;AAC5D,SAAS,eAAe;AAwBjB,SAAS,6BAA6B,YAAY,WAAkC;AACzF,QAAM,cAAc,QAAQ,WAAW,IAAI;AAC3C,SAAO;AAAA,IACL;AAAA,IACA,MAAM,QAAQ,aAAa,OAAO,yBAAyB;AAAA,IAC3D,OAAO,QAAQ,aAAa,OAAO,oBAAoB;AAAA,EACzD;AACF;AAMO,SAAS,gBACd,MACA,UAAkC,CAAC,GACrB;AACd,QAAM,cAAc,6BAA6B;AACjD,QAAM,aAAa,SAAS,SAAS,YAAY,OAAO,YAAY;AACpE,QAAM,MAAM,QAAQ,eAAe,QAC/B,EAAE,GAAG,QAAQ,IAAI,IACjB,EAAE,GAAG,QAAQ,KAAK,GAAG,QAAQ,IAAI;AAErC,SAAO,MAAM,QAAQ,YAAY,QAAQ,UAAU,CAAC,YAAY,GAAI,QAAQ,QAAQ,CAAC,CAAE,GAAG;AAAA,IACxF,KAAK,QAAQ,OAAO,YAAY;AAAA,IAChC;AAAA,IACA,OAAO,QAAQ,SAAS;AAAA,IACxB,aAAa,QAAQ,eAAe;AAAA,EACtC,CAAC;AACH;AAEO,SAAS,oBAAoB,UAAkC,CAAC,GAAiB;AACtF,SAAO,gBAAgB,QAAQ,OAAO;AACxC;AAEO,SAAS,qBAAqB,UAAkC,CAAC,GAAiB;AACvF,SAAO,gBAAgB,SAAS,OAAO;AACzC;","names":[]}