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

Function initEnvLessBridgeCore

src/bridge/remoteBridgeCore.ts:140–887  ·  view source on GitHub ↗
(
  params: EnvLessBridgeParams,
)

Source from the content-addressed store, hash-verified

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