mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-21 00:21:25 +00:00
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> Co-authored-by: Roo Code <roomote@roocode.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { createElement } from "react"
|
|
|
|
import { type OnboardingResult, OnboardingProviderChoice } from "@/types/index.js"
|
|
import { login } from "@/commands/index.js"
|
|
import { saveSettings } from "@/lib/storage/index.js"
|
|
|
|
export async function runOnboarding(): Promise<OnboardingResult> {
|
|
const { render } = await import("ink")
|
|
const { OnboardingScreen } = await import("../../ui/components/onboarding/index.js")
|
|
|
|
return new Promise<OnboardingResult>((resolve) => {
|
|
const onSelect = async (choice: OnboardingProviderChoice) => {
|
|
await saveSettings({ onboardingProviderChoice: choice })
|
|
|
|
app.unmount()
|
|
|
|
console.log("")
|
|
|
|
if (choice === OnboardingProviderChoice.Roo) {
|
|
const result = await login()
|
|
await saveSettings({ onboardingProviderChoice: choice })
|
|
|
|
resolve({
|
|
choice: OnboardingProviderChoice.Roo,
|
|
token: result.success ? result.token : undefined,
|
|
skipped: false,
|
|
})
|
|
} else {
|
|
console.log("Using your own API key.")
|
|
console.log("Set your API key via --api-key or environment variable.")
|
|
console.log("")
|
|
resolve({ choice: OnboardingProviderChoice.Byok, skipped: false })
|
|
}
|
|
}
|
|
|
|
const app = render(createElement(OnboardingScreen, { onSelect }))
|
|
})
|
|
}
|