MCPcopy
hub / github.com/codeaashu/claude-code / bridgeMain

Function bridgeMain

src/bridge/bridgeMain.ts:1980–2768  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

1978}
1979
1980export async function bridgeMain(args: string[]): Promise<void> {
1981 const parsed = parseArgs(args)
1982
1983 if (parsed.help) {
1984 await printHelp()
1985 return
1986 }
1987 if (parsed.error) {
1988 // biome-ignore lint/suspicious/noConsole: intentional error output
1989 console.error(`Error: ${parsed.error}`)
1990 // eslint-disable-next-line custom-rules/no-process-exit
1991 process.exit(1)
1992 }
1993
1994 const {
1995 verbose,
1996 sandbox,
1997 debugFile,
1998 sessionTimeoutMs,
1999 permissionMode,
2000 name,
2001 spawnMode: parsedSpawnMode,
2002 capacity: parsedCapacity,
2003 createSessionInDir: parsedCreateSessionInDir,
2004 sessionId: parsedSessionId,
2005 continueSession,
2006 } = parsed
2007 // Mutable so --continue can set it from the pointer file. The #20460
2008 // resume flow below then treats it the same as an explicit --session-id.
2009 let resumeSessionId = parsedSessionId
2010 // When --continue found a pointer, this is the directory it came from
2011 // (may be a worktree sibling, not `dir`). On resume-flow deterministic
2012 // failure, clear THIS file so --continue doesn't keep hitting the same
2013 // dead session. Undefined for explicit --session-id (leaves pointer alone).
2014 let resumePointerDir: string | undefined
2015
2016 const usedMultiSessionFeature =
2017 parsedSpawnMode !== undefined ||
2018 parsedCapacity !== undefined ||
2019 parsedCreateSessionInDir !== undefined
2020
2021 // Validate permission mode early so the user gets an error before
2022 // the bridge starts polling for work.
2023 if (permissionMode !== undefined) {
2024 const { PERMISSION_MODES } = await import('../types/permissions.js')
2025 const valid: readonly string[] = PERMISSION_MODES
2026 if (!valid.includes(permissionMode)) {
2027 // biome-ignore lint/suspicious/noConsole: intentional error output
2028 console.error(
2029 `Error: Invalid permission mode '${permissionMode}'. Valid modes: ${valid.join(', ')}`,
2030 )
2031 // eslint-disable-next-line custom-rules/no-process-exit
2032 process.exit(1)
2033 }
2034 }
2035
2036 const dir = resolve('.')
2037

Callers 2

runFunction · 0.85
mainFunction · 0.85

Calls 15

parseArgsFunction · 0.85
printHelpFunction · 0.85
enableConfigsFunction · 0.85
initSinksFunction · 0.85
logEventAsyncFunction · 0.85
shutdown1PEventLoggingFunction · 0.85
shutdownDatadogFunction · 0.85
setOriginalCwdFunction · 0.85
setCwdStateFunction · 0.85
getBridgeAccessTokenFunction · 0.85

Tested by

no test coverage detected