MCPcopy Create free account
hub / github.com/Noumena-Network/code / bridgeMain

Function bridgeMain

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

Source from the content-addressed store, hash-verified

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

Callers 2

runFunction · 0.85
mainFunction · 0.85

Calls 15

randomUUIDFunction · 0.90
printHelpFunction · 0.85
enableConfigsFunction · 0.85
initSinksFunction · 0.85
shutdown1PEventLoggingFunction · 0.85
shutdownDatadogFunction · 0.85
setCwdStateFunction · 0.85
getBridgeTokenOverrideFunction · 0.85
getBridgeBaseUrlFunction · 0.85

Tested by

no test coverage detected