|
@@ -75,6 +75,7 @@ export const AuthLoginCommand = cmd({
|
|
|
type: "string",
|
|
type: "string",
|
|
|
}),
|
|
}),
|
|
|
async handler(args) {
|
|
async handler(args) {
|
|
|
|
|
+ UI.empty()
|
|
|
prompts.intro("Add credential")
|
|
prompts.intro("Add credential")
|
|
|
if (args.url) {
|
|
if (args.url) {
|
|
|
const wellknown = await fetch(`${args.url}/.well-known/opencode`).then((x) => x.json())
|
|
const wellknown = await fetch(`${args.url}/.well-known/opencode`).then((x) => x.json())
|
|
@@ -99,7 +100,6 @@ export const AuthLoginCommand = cmd({
|
|
|
prompts.outro("Done")
|
|
prompts.outro("Done")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- UI.empty()
|
|
|
|
|
const providers = await ModelsDev.get()
|
|
const providers = await ModelsDev.get()
|
|
|
const priority: Record<string, number> = {
|
|
const priority: Record<string, number> = {
|
|
|
anthropic: 0,
|
|
anthropic: 0,
|
|
@@ -109,7 +109,7 @@ export const AuthLoginCommand = cmd({
|
|
|
openrouter: 4,
|
|
openrouter: 4,
|
|
|
vercel: 5,
|
|
vercel: 5,
|
|
|
}
|
|
}
|
|
|
- let provider = await prompts.select({
|
|
|
|
|
|
|
+ let provider = await prompts.autocomplete({
|
|
|
message: "Select provider",
|
|
message: "Select provider",
|
|
|
maxItems: 8,
|
|
maxItems: 8,
|
|
|
options: [
|
|
options: [
|
|
@@ -138,7 +138,7 @@ export const AuthLoginCommand = cmd({
|
|
|
if (provider === "other") {
|
|
if (provider === "other") {
|
|
|
provider = await prompts.text({
|
|
provider = await prompts.text({
|
|
|
message: "Enter provider id",
|
|
message: "Enter provider id",
|
|
|
- validate: (x) => (x.match(/^[0-9a-z-]+$/) ? undefined : "a-z, 0-9 and hyphens only"),
|
|
|
|
|
|
|
+ validate: (x) => x && (x.match(/^[0-9a-z-]+$/) ? undefined : "a-z, 0-9 and hyphens only"),
|
|
|
})
|
|
})
|
|
|
if (prompts.isCancel(provider)) throw new UI.CancelledError()
|
|
if (prompts.isCancel(provider)) throw new UI.CancelledError()
|
|
|
provider = provider.replace(/^@ai-sdk\//, "")
|
|
provider = provider.replace(/^@ai-sdk\//, "")
|
|
@@ -192,7 +192,7 @@ export const AuthLoginCommand = cmd({
|
|
|
|
|
|
|
|
const code = await prompts.text({
|
|
const code = await prompts.text({
|
|
|
message: "Paste the authorization code here: ",
|
|
message: "Paste the authorization code here: ",
|
|
|
- validate: (x) => (x.length > 0 ? undefined : "Required"),
|
|
|
|
|
|
|
+ validate: (x) => x && (x.length > 0 ? undefined : "Required"),
|
|
|
})
|
|
})
|
|
|
if (prompts.isCancel(code)) throw new UI.CancelledError()
|
|
if (prompts.isCancel(code)) throw new UI.CancelledError()
|
|
|
|
|
|
|
@@ -228,7 +228,7 @@ export const AuthLoginCommand = cmd({
|
|
|
|
|
|
|
|
const code = await prompts.text({
|
|
const code = await prompts.text({
|
|
|
message: "Paste the authorization code here: ",
|
|
message: "Paste the authorization code here: ",
|
|
|
- validate: (x) => (x.length > 0 ? undefined : "Required"),
|
|
|
|
|
|
|
+ validate: (x) => x && (x.length > 0 ? undefined : "Required"),
|
|
|
})
|
|
})
|
|
|
if (prompts.isCancel(code)) throw new UI.CancelledError()
|
|
if (prompts.isCancel(code)) throw new UI.CancelledError()
|
|
|
|
|
|
|
@@ -301,7 +301,7 @@ export const AuthLoginCommand = cmd({
|
|
|
|
|
|
|
|
const key = await prompts.password({
|
|
const key = await prompts.password({
|
|
|
message: "Enter your API key",
|
|
message: "Enter your API key",
|
|
|
- validate: (x) => (x.length > 0 ? undefined : "Required"),
|
|
|
|
|
|
|
+ validate: (x) => x && (x.length > 0 ? undefined : "Required"),
|
|
|
})
|
|
})
|
|
|
if (prompts.isCancel(key)) throw new UI.CancelledError()
|
|
if (prompts.isCancel(key)) throw new UI.CancelledError()
|
|
|
await Auth.set(provider, {
|
|
await Auth.set(provider, {
|