MCPcopy Index your code
hub / github.com/codeaashu/claude-code / installChromeNativeHostManifest

Function installChromeNativeHostManifest

src/utils/claudeInChrome/setup.ts:191–266  ·  view source on GitHub ↗
(
  manifestBinaryPath: string,
)

Source from the content-addressed store, hash-verified

189}
190
191export async function installChromeNativeHostManifest(
192 manifestBinaryPath: string,
193): Promise<void> {
194 const manifestDirs = getNativeMessagingHostsDirs()
195 if (manifestDirs.length === 0) {
196 throw Error('Claude in Chrome Native Host not supported on this platform')
197 }
198
199 const manifest = {
200 name: NATIVE_HOST_IDENTIFIER,
201 description: 'Claude Code Browser Extension Native Host',
202 path: manifestBinaryPath,
203 type: 'stdio',
204 allowed_origins: [
205 `chrome-extension://fcoeoabgfenejglbffodgkkbkcdhcgfn/`, // PROD_EXTENSION_ID
206 ...(process.env.USER_TYPE === 'ant'
207 ? [
208 'chrome-extension://dihbgbndebgnbjfmelmegjepbnkhlgni/', // DEV_EXTENSION_ID
209 'chrome-extension://dngcpimnedloihjnnfngkgjoidhnaolf/', // ANT_EXTENSION_ID
210 ]
211 : []),
212 ],
213 }
214
215 const manifestContent = jsonStringify(manifest, null, 2)
216 let anyManifestUpdated = false
217
218 // Install manifest to all browser directories
219 for (const manifestDir of manifestDirs) {
220 const manifestPath = join(manifestDir, NATIVE_HOST_MANIFEST_NAME)
221
222 // Check if content matches to avoid unnecessary writes
223 const existingContent = await readFile(manifestPath, 'utf-8').catch(
224 () => null,
225 )
226 if (existingContent === manifestContent) {
227 continue
228 }
229
230 try {
231 await mkdir(manifestDir, { recursive: true })
232 await writeFile(manifestPath, manifestContent)
233 logForDebugging(
234 `[Claude in Chrome] Installed native host manifest at: ${manifestPath}`,
235 )
236 anyManifestUpdated = true
237 } catch (error) {
238 // Log but don't fail - the browser might not be installed
239 logForDebugging(
240 `[Claude in Chrome] Failed to install manifest at ${manifestPath}: ${error}`,
241 )
242 }
243 }
244
245 // Windows requires registry entries pointing to the manifest for each browser
246 if (getPlatform() === 'windows') {
247 const manifestPath = join(manifestDirs[0]!, NATIVE_HOST_MANIFEST_NAME)
248 registerWindowsNativeHosts(manifestPath)

Callers 1

setupClaudeInChromeFunction · 0.85

Calls 9

jsonStringifyFunction · 0.85
readFileFunction · 0.85
mkdirFunction · 0.85
logForDebuggingFunction · 0.85
getPlatformFunction · 0.85
openInChromeFunction · 0.85

Tested by

no test coverage detected