diff --git a/packages/core/package.json b/packages/core/package.json index 9347cf5e72..fb61646d5a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -20,8 +20,7 @@ "typecheck": "tsc --noEmit" }, "files": [ - "dist", - "vendor" + "dist" ], "dependencies": { "@a2a-js/sdk": "0.3.11", diff --git a/scripts/build_binary.js b/scripts/build_binary.js index 7d0fd815c1..92532a45b0 100644 --- a/scripts/build_binary.js +++ b/scripts/build_binary.js @@ -179,6 +179,27 @@ try { process.exit(1); } +// 2b. Copy host-platform ripgrep binary into the bundle for the SEA. +// (npm tarballs omit these to stay under the registry upload limit.) +const ripgrepVendorSrc = join(root, 'packages/core/vendor/ripgrep'); +const ripgrepVendorDest = join(bundleDir, 'vendor', 'ripgrep'); +if (existsSync(ripgrepVendorSrc)) { + const rgBinName = `rg-${process.platform}-${process.arch}${ + process.platform === 'win32' ? '.exe' : '' + }`; + const rgSrc = join(ripgrepVendorSrc, rgBinName); + if (existsSync(rgSrc)) { + mkdirSync(ripgrepVendorDest, { recursive: true }); + cpSync(rgSrc, join(ripgrepVendorDest, rgBinName), { dereference: true }); + console.log(`Copied ${rgBinName} to bundle/vendor/ripgrep/`); + } else { + console.warn( + `Warning: bundled ripgrep binary not found for ${process.platform}/${process.arch} at ${rgSrc}. ` + + `The SEA will fall back to system grep at runtime.`, + ); + } +} + // 3. Stage & Sign Native Modules const includeNativeModules = process.env.BUNDLE_NATIVE_MODULES !== 'false'; console.log(`Include Native Modules: ${includeNativeModules}`); @@ -304,6 +325,23 @@ if (existsSync(policyDir)) { } } +// Add ripgrep binary (copied in step 2b). Must be registered here so that +// sea-launch.cjs extracts it to runtimeDir/vendor/ripgrep/ on startup; the +// runtime resolver in packages/core/src/tools/ripGrep.ts uses __dirname- +// relative paths to find it. +if (existsSync(ripgrepVendorDest)) { + const rgFiles = globSync('*', { cwd: ripgrepVendorDest, nodir: true }); + for (const rgFile of rgFiles) { + const fsPath = join(ripgrepVendorDest, rgFile); + const relativePath = join('vendor', 'ripgrep', rgFile); + const content = readFileSync(fsPath); + const hash = sha256(content); + const assetKey = `vendor:${rgFile}`; + assets[assetKey] = fsPath; + manifest.files.push({ key: assetKey, path: relativePath, hash: hash }); + } +} + // Add assets from Staging if (includeNativeModules) { addAssetsFromDir('node_modules/@lydell', 'node_modules/@lydell'); diff --git a/scripts/copy_bundle_assets.js b/scripts/copy_bundle_assets.js index f1ea297ba9..658c0a57c0 100644 --- a/scripts/copy_bundle_assets.js +++ b/scripts/copy_bundle_assets.js @@ -108,19 +108,7 @@ if (!existsSync(bundleMcpSrc)) { cpSync(bundleMcpSrc, bundleMcpDest, { recursive: true, dereference: true }); console.log('Copied bundled chrome-devtools-mcp to bundle/bundled/'); -// 7. Copy pre-built ripgrep vendor binaries -const ripgrepVendorSrc = join(root, 'packages/core/vendor/ripgrep'); -const ripgrepVendorDest = join(bundleDir, 'vendor', 'ripgrep'); -if (existsSync(ripgrepVendorSrc)) { - mkdirSync(ripgrepVendorDest, { recursive: true }); - cpSync(ripgrepVendorSrc, ripgrepVendorDest, { - recursive: true, - dereference: true, - }); - console.log('Copied ripgrep vendor binaries to bundle/vendor/ripgrep/'); -} - -// 8. Copy Extension Examples +// 7. Copy Extension Examples const extensionExamplesSrc = join( root, 'packages/cli/src/commands/extensions/examples',