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

Function archiveBridgeSession

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

Source from the content-addressed store, hash-verified

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

Callers 1

initReplBridgeFunction · 0.85

Calls 6

logForDebuggingFunction · 0.85
getOrganizationUUIDFunction · 0.85
getOAuthHeadersFunction · 0.85
getOauthConfigFunction · 0.85
extractErrorDetailFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected