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

Function archiveBridgeSession

source code/bridge/createSession.ts:265–319  ·  view source on GitHub ↗
(
  sessionId: string,
  opts?: {
    baseUrl?: string
    getAccessToken?: () => string | undefined
    timeoutMs?: number
  },
)

Source from the content-addressed store, hash-verified

263 * cleanup; call sites wrap with .catch().
264 */
265export async function archiveBridgeSession(
266 sessionId: string,
267 opts?: {
268 baseUrl?: string
269 getAccessToken?: () => string | undefined
270 timeoutMs?: number
271 },
272): Promise<void> {
273 const { getClaudeAIOAuthTokens } = await import('../utils/auth.js')
274 const { getOrganizationUUID } = await import('../services/oauth/client.js')
275 const { getOauthConfig } = await import('../constants/oauth.js')
276 const { getOAuthHeaders } = await import('../utils/teleport/api.js')
277 const { default: axios } = await import('axios')
278
279 const accessToken =
280 opts?.getAccessToken?.() ?? getClaudeAIOAuthTokens()?.accessToken
281 if (!accessToken) {
282 logForDebugging('[bridge] No access token for session archive')
283 return
284 }
285
286 const orgUUID = await getOrganizationUUID()
287 if (!orgUUID) {
288 logForDebugging('[bridge] No org UUID for session archive')
289 return
290 }
291
292 const headers = {
293 ...getOAuthHeaders(accessToken),
294 'anthropic-beta': 'ccr-byoc-2025-07-29',
295 'x-organization-uuid': orgUUID,
296 }
297
298 const url = `${opts?.baseUrl ?? getOauthConfig().BASE_API_URL}/v1/sessions/${sessionId}/archive`
299 logForDebugging(`[bridge] Archiving session ${sessionId}`)
300
301 const response = await axios.post(
302 url,
303 {},
304 {
305 headers,
306 timeout: opts?.timeoutMs ?? 10_000,
307 validateStatus: s => s < 500,
308 },
309 )
310
311 if (response.status === 200) {
312 logForDebugging(`[bridge] Session ${sessionId} archived successfully`)
313 } else {
314 const detail = extractErrorDetail(response.data)
315 logForDebugging(
316 `[bridge] Session archive failed with status ${response.status}${detail ? `: ${detail}` : ''}`,
317 )
318 }
319}
320
321/**
322 * Update the title of a bridge session via PATCH /v1/sessions/{id}.

Callers 1

initReplBridgeFunction · 0.85

Calls 5

logForDebuggingFunction · 0.85
getOrganizationUUIDFunction · 0.85
getOAuthHeadersFunction · 0.85
getOauthConfigFunction · 0.85
extractErrorDetailFunction · 0.85

Tested by

no test coverage detected