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

Function createBridgeSession

source code/bridge/createSession.ts:36–182  ·  view source on GitHub ↗
({
  environmentId,
  title,
  events,
  gitRepoUrl,
  branch,
  signal,
  baseUrl: baseUrlOverride,
  getAccessToken,
  permissionMode,
}: {
  environmentId: string
  title?: string
  events: SessionEvent[]
  gitRepoUrl: string | null
  branch: string
  signal: AbortSignal
  baseUrl?: string
  getAccessToken?: () => string | undefined
  permissionMode?: string
})

Source from the content-addressed store, hash-verified

34 * Returns the session ID on success, or null if creation fails (non-fatal).
35 */
36export async function createBridgeSession({
37 environmentId,
38 title,
39 events,
40 gitRepoUrl,
41 branch,
42 signal,
43 baseUrl: baseUrlOverride,
44 getAccessToken,
45 permissionMode,
46}: {
47 environmentId: string
48 title?: string
49 events: SessionEvent[]
50 gitRepoUrl: string | null
51 branch: string
52 signal: AbortSignal
53 baseUrl?: string
54 getAccessToken?: () => string | undefined
55 permissionMode?: string
56}): Promise<string | null> {
57 const { getClaudeAIOAuthTokens } = await import('../utils/auth.js')
58 const { getOrganizationUUID } = await import('../services/oauth/client.js')
59 const { getOauthConfig } = await import('../constants/oauth.js')
60 const { getOAuthHeaders } = await import('../utils/teleport/api.js')
61 const { parseGitHubRepository } = await import('../utils/detectRepository.js')
62 const { getDefaultBranch } = await import('../utils/git.js')
63 const { getMainLoopModel } = await import('../utils/model/model.js')
64 const { default: axios } = await import('axios')
65
66 const accessToken =
67 getAccessToken?.() ?? getClaudeAIOAuthTokens()?.accessToken
68 if (!accessToken) {
69 logForDebugging('[bridge] No access token for session creation')
70 return null
71 }
72
73 const orgUUID = await getOrganizationUUID()
74 if (!orgUUID) {
75 logForDebugging('[bridge] No org UUID for session creation')
76 return null
77 }
78
79 // Build git source and outcome context
80 let gitSource: GitSource | null = null
81 let gitOutcome: GitOutcome | null = null
82
83 if (gitRepoUrl) {
84 const { parseGitRemote } = await import('../utils/detectRepository.js')
85 const parsed = parseGitRemote(gitRepoUrl)
86 if (parsed) {
87 const { host, owner, name } = parsed
88 const revision = branch || (await getDefaultBranch()) || undefined
89 gitSource = {
90 type: 'git_repository',
91 url: `https://${host}/${owner}/${name}`,
92 revision,
93 }

Callers 3

initReplBridgeFunction · 0.85
bridgeMainFunction · 0.85
runBridgeHeadlessFunction · 0.85

Calls 11

getAccessTokenFunction · 0.85
logForDebuggingFunction · 0.85
getOrganizationUUIDFunction · 0.85
parseGitRemoteFunction · 0.85
getDefaultBranchFunction · 0.85
parseGitHubRepositoryFunction · 0.85
getMainLoopModelFunction · 0.85
getOAuthHeadersFunction · 0.85
getOauthConfigFunction · 0.85
extractErrorDetailFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected