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

Function doInitialize

source code/utils/tmuxSocket.ts:270–417  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

268}
269
270async function doInitialize(): Promise<void> {
271 const socket = getClaudeSocketName()
272
273 // Create a new session with our custom socket
274 // Pass CLAUDE_CODE_SKIP_PROMPT_HISTORY via -e so it's set in the initial shell environment
275 //
276 // On Windows, the tmux server inherits WSL_INTEROP from the short-lived
277 // wsl.exe that spawns it; once `new-session -d` detaches and wsl.exe exits,
278 // that socket stops servicing requests. Any cli.exe launched inside the pane
279 // then hits `UtilAcceptVsock: accept4 failed 110` (ETIMEDOUT). Observed on
280 // 2026-03-25: server PID 386 (started alongside /init at WSL boot) inherited
281 // /run/WSL/383_interop — init's own socket, which listens but doesn't handle
282 // interop. /run/WSL/1_interop is a stable symlink WSL maintains to the real
283 // handler; pin the server to it so interop survives the spawning wsl.exe.
284 const result = await execTmux([
285 '-L',
286 socket,
287 'new-session',
288 '-d',
289 '-s',
290 'base',
291 '-e',
292 'CLAUDE_CODE_SKIP_PROMPT_HISTORY=true',
293 ...(getPlatform() === 'windows'
294 ? ['-e', 'WSL_INTEROP=/run/WSL/1_interop']
295 : []),
296 ])
297
298 if (result.code !== 0) {
299 // Session might already exist from a previous run with same PID (unlikely but possible)
300 // Check if the session exists
301 const checkResult = await execTmux([
302 '-L',
303 socket,
304 'has-session',
305 '-t',
306 'base',
307 ])
308 if (checkResult.code !== 0) {
309 throw new Error(
310 `Failed to create tmux session on socket ${socket}: ${result.stderr}`,
311 )
312 }
313 }
314
315 // Register cleanup to kill the tmux server on exit
316 registerCleanup(killTmuxServer)
317
318 // Set CLAUDE_CODE_SKIP_PROMPT_HISTORY in the tmux GLOBAL environment (-g).
319 // Without -g this would only apply to the 'base' session, and new sessions
320 // created by TungstenTool (e.g. 'test', 'verify') would not inherit it.
321 // Any Claude Code instance spawned on this socket will inherit this env var,
322 // preventing test/verification sessions from polluting the user's real
323 // command history and --resume session list.
324 await execTmux([
325 '-L',
326 socket,
327 'set-environment',

Callers 1

ensureSocketInitializedFunction · 0.85

Calls 6

getClaudeSocketNameFunction · 0.85
execTmuxFunction · 0.85
getPlatformFunction · 0.85
registerCleanupFunction · 0.85
setClaudeSocketInfoFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected