| 577 | profileCheckpoint('eagerLoadSettings_end'); |
| 578 | } |
| 579 | function initializeEntrypoint(isNonInteractive: boolean): void { |
| 580 | // Skip if already set (e.g., by SDK or other entrypoints) |
| 581 | if (process.env.CLAUDE_CODE_ENTRYPOINT) { |
| 582 | return; |
| 583 | } |
| 584 | const cliArgs = process.argv.slice(2); |
| 585 | |
| 586 | // Check for MCP serve command (handle flags before mcp serve, e.g., --debug mcp serve) |
| 587 | const mcpIndex = cliArgs.indexOf('mcp'); |
| 588 | if (mcpIndex !== -1 && cliArgs[mcpIndex + 1] === 'serve') { |
| 589 | process.env.CLAUDE_CODE_ENTRYPOINT = 'mcp'; |
| 590 | return; |
| 591 | } |
| 592 | if (isEnvTruthy(process.env.CLAUDE_CODE_ACTION)) { |
| 593 | process.env.CLAUDE_CODE_ENTRYPOINT = 'claude-code-github-action'; |
| 594 | return; |
| 595 | } |
| 596 | |
| 597 | // Note: 'local-agent' entrypoint is set by the local agent mode launcher |
| 598 | // via CLAUDE_CODE_ENTRYPOINT env var (handled by early return above) |
| 599 | |
| 600 | // Set based on interactive status |
| 601 | process.env.CLAUDE_CODE_ENTRYPOINT = isNonInteractive ? 'sdk-cli' : 'cli'; |
| 602 | } |
| 603 | |
| 604 | // Set by early argv processing when `claude open <url>` is detected (interactive mode only) |
| 605 | type PendingConnect = { |