MCPcopy Index your code
hub / github.com/codeaashu/claude-code / fetchEnvironments

Function fetchEnvironments

src/utils/teleport/environments.ts:32–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 * @throws Error if the API request fails or no access token is available
31 */
32export async function fetchEnvironments(): Promise<EnvironmentResource[]> {
33 const accessToken = getClaudeAIOAuthTokens()?.accessToken
34 if (!accessToken) {
35 throw new Error(
36 'Claude Code web sessions require authentication with a Claude.ai account. API key authentication is not sufficient. Please run /login to authenticate, or check your authentication status with /status.',
37 )
38 }
39
40 const orgUUID = await getOrganizationUUID()
41 if (!orgUUID) {
42 throw new Error('Unable to get organization UUID')
43 }
44
45 const url = `${getOauthConfig().BASE_API_URL}/v1/environment_providers`
46
47 try {
48 const headers = {
49 ...getOAuthHeaders(accessToken),
50 'x-organization-uuid': orgUUID,
51 }
52
53 const response = await axios.get<EnvironmentListResponse>(url, {
54 headers,
55 timeout: 15000,
56 })
57
58 if (response.status !== 200) {
59 throw new Error(
60 `Failed to fetch environments: ${response.status} ${response.statusText}`,
61 )
62 }
63
64 return response.data.environments
65 } catch (error) {
66 const err = toError(error)
67 logError(err)
68 throw new Error(`Failed to fetch environments: ${err.message}`)
69 }
70}
71
72/**
73 * Creates a default anthropic_cloud environment for users who have none.

Callers 5

teleportToRemoteFunction · 0.85
hasExistingEnvironmentFunction · 0.85
getPromptForCommandFunction · 0.85

Calls 5

getOrganizationUUIDFunction · 0.85
getOauthConfigFunction · 0.85
getOAuthHeadersFunction · 0.85
toErrorFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected