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

Function createCodeSession

source code/bridge/codeSessionApi.ts:28–82  ·  view source on GitHub ↗
(
  baseUrl: string,
  accessToken: string,
  title: string,
  timeoutMs: number,
  tags?: string[],
)

Source from the content-addressed store, hash-verified

26}
27
28export async function createCodeSession(
29 baseUrl: string,
30 accessToken: string,
31 title: string,
32 timeoutMs: number,
33 tags?: string[],
34): Promise<string | null> {
35 const url = `${baseUrl}/v1/code/sessions`
36 let response
37 try {
38 response = await axios.post(
39 url,
40 // bridge: {} is the positive signal for the oneof runner — omitting it
41 // (or sending environment_id: "") now 400s. BridgeRunner is an empty
42 // message today; it's a placeholder for future bridge-specific options.
43 { title, bridge: {}, ...(tags?.length ? { tags } : {}) },
44 {
45 headers: oauthHeaders(accessToken),
46 timeout: timeoutMs,
47 validateStatus: s => s < 500,
48 },
49 )
50 } catch (err: unknown) {
51 logForDebugging(
52 `[code-session] Session create request failed: ${errorMessage(err)}`,
53 )
54 return null
55 }
56
57 if (response.status !== 200 && response.status !== 201) {
58 const detail = extractErrorDetail(response.data)
59 logForDebugging(
60 `[code-session] Session create failed ${response.status}${detail ? `: ${detail}` : ''}`,
61 )
62 return null
63 }
64
65 const data: unknown = response.data
66 if (
67 !data ||
68 typeof data !== 'object' ||
69 !('session' in data) ||
70 !data.session ||
71 typeof data.session !== 'object' ||
72 !('id' in data.session) ||
73 typeof data.session.id !== 'string' ||
74 !data.session.id.startsWith('cse_')
75 ) {
76 logForDebugging(
77 `[code-session] No session.id (cse_*) in response: ${jsonStringify(data).slice(0, 200)}`,
78 )
79 return null
80 }
81 return data.session.id
82}
83
84/**
85 * Credentials from POST /bridge. JWT is opaque — do not decode.

Callers 1

initEnvLessBridgeCoreFunction · 0.85

Calls 5

logForDebuggingFunction · 0.85
extractErrorDetailFunction · 0.85
jsonStringifyFunction · 0.85
oauthHeadersFunction · 0.70
errorMessageFunction · 0.50

Tested by

no test coverage detected