| 6 | const __dirname = path.dirname(__filename); |
| 7 | |
| 8 | export const getBinaryPath = () => { |
| 9 | const platform = process.platform; |
| 10 | const arch = process.arch; |
| 11 | |
| 12 | let binaryName = ""; |
| 13 | |
| 14 | if (platform === "darwin") { |
| 15 | if (arch === "arm64") { |
| 16 | binaryName = "docsagent-aarch64-apple-darwin"; |
| 17 | } else if (arch === "x64") { |
| 18 | binaryName = "docsagent-x86_64-apple-darwin"; |
| 19 | } else { |
| 20 | binaryName = "docsagent-universal-apple-darwin"; |
| 21 | } |
| 22 | } else if (platform === "win32") { |
| 23 | binaryName = "docsagent-x86_64-pc-windows-msvc.exe"; |
| 24 | } else if (platform === "linux") { |
| 25 | binaryName = "docsagent-linux-gnu"; |
| 26 | } |
| 27 | |
| 28 | const fullPath = path.join(__dirname, "../bin", binaryName); |
| 29 | |
| 30 | if (!fs.existsSync(fullPath)) { |
| 31 | throw new Error( |
| 32 | `Binary not found for platform "${platform}" and architecture "${arch}". Expected at: ${fullPath}` |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | return fullPath; |
| 37 | }; |