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

Function archiveSession

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

Source from the content-addressed store, hash-verified

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

Callers 2

initEnvLessBridgeCoreFunction · 0.70
teardownFunction · 0.70

Calls 5

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

Tested by

no test coverage detected