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

Function archiveSession

source code/bridge/remoteBridgeCore.ts:965–1010  ·  view source on GitHub ↗
(
  sessionId: string,
  baseUrl: string,
  accessToken: string | undefined,
  orgUUID: string,
  timeoutMs: number,
)

Source from the content-addressed store, hash-verified

963 | 'server_5xx'
964
965async function archiveSession(
966 sessionId: string,
967 baseUrl: string,
968 accessToken: string | undefined,
969 orgUUID: string,
970 timeoutMs: number,
971): Promise<ArchiveStatus> {
972 if (!accessToken) return 'no_token'
973 // Archive lives at the compat layer (/v1/sessions/*, not /v1/code/sessions).
974 // compat.parseSessionID only accepts TagSession (session_*), so retag cse_*.
975 // anthropic-beta + x-organization-uuid are required — without them the
976 // compat gateway 404s before reaching the handler.
977 //
978 // Unlike bridgeMain.ts (which caches compatId in sessionCompatIds to keep
979 // in-memory titledSessions/logger keys consistent across a mid-session
980 // gate flip), this compatId is only a server URL path segment — no
981 // in-memory state. Fresh compute matches whatever the server currently
982 // validates: if the gate is OFF, the server has been updated to accept
983 // cse_* and we correctly send it.
984 const compatId = toCompatSessionId(sessionId)
985 try {
986 const response = await axios.post(
987 `${baseUrl}/v1/sessions/${compatId}/archive`,
988 {},
989 {
990 headers: {
991 ...oauthHeaders(accessToken),
992 'anthropic-beta': 'ccr-byoc-2025-07-29',
993 'x-organization-uuid': orgUUID,
994 },
995 timeout: timeoutMs,
996 validateStatus: () => true,
997 },
998 )
999 logForDebugging(
1000 `[remote-bridge] Archive ${compatId} status=${response.status}`,
1001 )
1002 return response.status
1003 } catch (err) {
1004 const msg = errorMessage(err)
1005 logForDebugging(`[remote-bridge] Archive failed: ${msg}`)
1006 return axios.isAxiosError(err) && err.code === 'ECONNABORTED'
1007 ? 'timeout'
1008 : 'error'
1009 }
1010}

Callers 2

initEnvLessBridgeCoreFunction · 0.70
teardownFunction · 0.70

Calls 4

toCompatSessionIdFunction · 0.85
logForDebuggingFunction · 0.85
oauthHeadersFunction · 0.70
errorMessageFunction · 0.50

Tested by

no test coverage detected