MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / initEnvLessBridgeCore

Function initEnvLessBridgeCore

source code/bridge/remoteBridgeCore.ts:142–889  ·  view source on GitHub ↗
(
  params: EnvLessBridgeParams,
)

Source from the content-addressed store, hash-verified

140 * as a generic "initialization failed" state.
141 */
142export async function initEnvLessBridgeCore(
143 params: EnvLessBridgeParams,
144): Promise<ReplBridgeHandle | null> {
145 const {
146 baseUrl,
147 orgUUID,
148 title,
149 getAccessToken,
150 onAuth401,
151 toSDKMessages,
152 initialHistoryCap,
153 initialMessages,
154 onInboundMessage,
155 onUserMessage,
156 onPermissionResponse,
157 onInterrupt,
158 onSetModel,
159 onSetMaxThinkingTokens,
160 onSetPermissionMode,
161 onStateChange,
162 outboundOnly,
163 tags,
164 } = params
165
166 const cfg = await getEnvLessBridgeConfig()
167
168 // ── 1. Create session (POST /v1/code/sessions, no env_id) ───────────────
169 const accessToken = getAccessToken()
170 if (!accessToken) {
171 logForDebugging('[remote-bridge] No OAuth token')
172 return null
173 }
174
175 const createdSessionId = await withRetry(
176 () =>
177 createCodeSession(baseUrl, accessToken, title, cfg.http_timeout_ms, tags),
178 'createCodeSession',
179 cfg,
180 )
181 if (!createdSessionId) {
182 onStateChange?.('failed', 'Session creation failed — see debug log')
183 logBridgeSkip('v2_session_create_failed', undefined, true)
184 return null
185 }
186 const sessionId: string = createdSessionId
187 logForDebugging(`[remote-bridge] Created session ${sessionId}`)
188 logForDiagnosticsNoPII('info', 'bridge_repl_v2_session_created')
189
190 // ── 2. Fetch bridge credentials (POST /bridge → worker_jwt, expires_in, api_base_url) ──
191 const credentials = await withRetry(
192 () =>
193 fetchRemoteCredentials(
194 sessionId,
195 baseUrl,
196 accessToken,
197 cfg.http_timeout_ms,
198 ),
199 'fetchRemoteCredentials',

Callers 1

initReplBridgeFunction · 0.85

Calls 15

addMethod · 0.95
startMethod · 0.95
getEnvLessBridgeConfigFunction · 0.85
getAccessTokenFunction · 0.85
logForDebuggingFunction · 0.85
createCodeSessionFunction · 0.85
onStateChangeFunction · 0.85
logBridgeSkipFunction · 0.85
logForDiagnosticsNoPIIFunction · 0.85
buildCCRv2SdkUrlFunction · 0.85
createV2ReplTransportFunction · 0.85

Tested by

no test coverage detected