| 515 | profileCheckpoint('eagerLoadSettings_end'); |
| 516 | } |
| 517 | function initializeEntrypoint(isNonInteractive: boolean): void { |
| 518 | // Skip if already set (e.g., by SDK or other entrypoints) |
| 519 | if (process.env.CLAUDE_CODE_ENTRYPOINT) { |
| 520 | return; |
| 521 | } |
| 522 | const cliArgs = process.argv.slice(2); |
| 523 | |
| 524 | // Check for MCP serve command (handle flags before mcp serve, e.g., --debug mcp serve) |
| 525 | const mcpIndex = cliArgs.indexOf('mcp'); |
| 526 | if (mcpIndex !== -1 && cliArgs[mcpIndex + 1] === 'serve') { |
| 527 | process.env.CLAUDE_CODE_ENTRYPOINT = 'mcp'; |
| 528 | return; |
| 529 | } |
| 530 | if (isEnvTruthy(process.env.CLAUDE_CODE_ACTION)) { |
| 531 | process.env.CLAUDE_CODE_ENTRYPOINT = 'claude-code-github-action'; |
| 532 | return; |
| 533 | } |
| 534 | |
| 535 | // Note: 'local-agent' entrypoint is set by the local agent mode launcher |
| 536 | // via CLAUDE_CODE_ENTRYPOINT env var (handled by early return above) |
| 537 | |
| 538 | // Set based on interactive status |
| 539 | process.env.CLAUDE_CODE_ENTRYPOINT = isNonInteractive ? 'sdk-cli' : 'cli'; |
| 540 | } |
| 541 | |
| 542 | // Set by early argv processing when `claude open <url>` is detected (interactive mode only) |
| 543 | type PendingConnect = { |