MCPcopy Create free account
hub / github.com/Noumena-Network/code / fetchSession

Function fetchSession

src/utils/teleport/api.ts:308–346  ·  view source on GitHub ↗
(
  sessionId: string,
)

Source from the content-addressed store, hash-verified

306 * @returns The session resource
307 */
308export async function fetchSession(
309 sessionId: string,
310): Promise<SessionResource> {
311 const { accessToken, orgUUID } = await prepareApiRequest()
312
313 const url = buildNoumenaPlatformUrl(`/v1/sessions/${sessionId}`)
314 const headers = {
315 ...getOAuthHeaders(accessToken),
316 'anthropic-beta': 'ccr-byoc-2025-07-29',
317 'x-organization-uuid': orgUUID,
318 }
319
320 const response = await axios.get<SessionResource>(url, {
321 headers,
322 timeout: 15000,
323 validateStatus: status => status < 500,
324 })
325
326 if (response.status !== 200) {
327 // Extract error message from response if available
328 const errorData = response.data as { error?: { message?: string } }
329 const apiMessage = errorData?.error?.message
330
331 if (response.status === 404) {
332 throw new Error(`Session not found: ${sessionId}`)
333 }
334
335 if (response.status === 401) {
336 throw new Error('Session expired. Please run /login to sign in again.')
337 }
338
339 throw new Error(
340 apiMessage ||
341 `Failed to fetch session: ${response.status} ${response.statusText}`,
342 )
343 }
344
345 return response.data
346}
347
348/**
349 * Extracts the first branch name from a session's git repository outcomes

Callers 5

runFunction · 0.85
pollRemoteSessionEventsFunction · 0.85
api.e2e.test.tsFile · 0.85

Calls 3

prepareApiRequestFunction · 0.85
buildNoumenaPlatformUrlFunction · 0.85
getOAuthHeadersFunction · 0.85

Tested by

no test coverage detected