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

Function createDefaultEnvironment

src/commands/remote-setup/api.ts:119–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 * machine falls back to env-setup on next load.
118 */
119export async function createDefaultEnvironment(): Promise<boolean> {
120 let accessToken: string, orgUUID: string
121 try {
122 ;({ accessToken, orgUUID } = await prepareApiRequest())
123 } catch {
124 return false
125 }
126
127 if (await hasExistingEnvironment()) {
128 return true
129 }
130
131 // The /private/organizations/{org}/ path rejects CLI OAuth tokens (wrong
132 // auth dep). The public path uses build_flexible_auth — same path
133 // fetchEnvironments() uses. Org is passed via x-organization-uuid header.
134 const url = `${getOauthConfig().BASE_API_URL}/v1/environment_providers/cloud/create`
135 const headers = {
136 ...getOAuthHeaders(accessToken),
137 'x-organization-uuid': orgUUID,
138 }
139
140 try {
141 const response = await axios.post(
142 url,
143 {
144 name: 'Default',
145 kind: 'anthropic_cloud',
146 description: 'Default - trusted network access',
147 config: {
148 environment_type: 'anthropic',
149 cwd: '/home/user',
150 init_script: null,
151 environment: {},
152 languages: [
153 { name: 'python', version: '3.11' },
154 { name: 'node', version: '20' },
155 ],
156 network_config: {
157 allowed_hosts: [],
158 allow_default_hosts: true,
159 },
160 },
161 },
162 { headers, timeout: 15000, validateStatus: () => true },
163 )
164 return response.status >= 200 && response.status < 300
165 } catch {
166 return false
167 }
168}
169
170/** Returns true when the user has valid Claude OAuth credentials. */
171export async function isSignedIn(): Promise<boolean> {

Callers 1

handleConfirmFunction · 0.85

Calls 5

prepareApiRequestFunction · 0.85
hasExistingEnvironmentFunction · 0.85
getOauthConfigFunction · 0.85
getOAuthHeadersFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected