| 18 | import { onChangeAppState } from '../../state/onChangeAppState.js'; |
| 19 | import { isAnthropicAuthEnabled } from '../../utils/auth.js'; |
| 20 | export async function setupTokenHandler(root: Root): Promise<void> { |
| 21 | logEvent('tengu_setup_token_command', {}); |
| 22 | const showAuthWarning = !isAnthropicAuthEnabled(); |
| 23 | const { |
| 24 | ConsoleOAuthFlow |
| 25 | } = await import('../../components/ConsoleOAuthFlow.js'); |
| 26 | await new Promise<void>(resolve => { |
| 27 | root.render(<AppStateProvider onChangeAppState={onChangeAppState}> |
| 28 | <KeybindingSetup> |
| 29 | <Box flexDirection="column" gap={1}> |
| 30 | <WelcomeV2 /> |
| 31 | {showAuthWarning && <Box flexDirection="column"> |
| 32 | <Text color="warning"> |
| 33 | Warning: You already have authentication configured via |
| 34 | environment variable or API key helper. |
| 35 | </Text> |
| 36 | <Text color="warning"> |
| 37 | The setup-token command will create a new OAuth token which |
| 38 | you can use instead. |
| 39 | </Text> |
| 40 | </Box>} |
| 41 | <ConsoleOAuthFlow onDone={() => { |
| 42 | void resolve(); |
| 43 | }} mode="setup-token" startingMessage="This will guide you through long-lived (1-year) auth token setup for your Claude account. Claude subscription required." /> |
| 44 | </Box> |
| 45 | </KeybindingSetup> |
| 46 | </AppStateProvider>); |
| 47 | }); |
| 48 | root.unmount(); |
| 49 | process.exit(0); |
| 50 | } |
| 51 | |
| 52 | // DoctorWithPlugins wrapper + doctor handler |
| 53 | const DoctorLazy = React.lazy(() => import('../../screens/Doctor.js').then(m => ({ |