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