'use client' import { useState, useCallback, useEffect, type FormEvent } from 'react' import { useAuth } from '../hooks/useAuth' import { Logo } from './Logo' export function Login() { const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const [isSubmitting, setIsSubmitting] = useState(false) const { login, config, bootstrapStandardAgents, redirectToStandardAgents } = useAuth() // Mirror the builder login: platform-connected instances sign in only with // Standard Agents; the password form is for local-password instances. const standardAgentsSignIn = !!config && (config.standardAgentsLogin || config.platformConnected) const showPasswordForm = !!config && !config.hosted && !standardAgentsSignIn && config.localPassword const handleStandardAgents = useCallback(async () => { setError('') if (config?.standardAgentsLogin) { redirectToStandardAgents() return } setIsSubmitting(true) const result = await bootstrapStandardAgents() if (!result.success) { setError(result.error || 'Standard Agents sign-in failed.') setIsSubmitting(false) } }, [config, bootstrapStandardAgents, redirectToStandardAgents]) useEffect(() => { const saError = new URLSearchParams(window.location.search).get('sa_error') if (saError) { setError(saError === 'forbidden' ? "Your Standard Agents account doesn't have access to this instance." : "Standard Agents sign-in didn't complete. Please try again.") } }, []) const handleSubmit = useCallback(async (e: FormEvent) => { e.preventDefault() setError('') setIsSubmitting(true) const result = await login(username, password) if (!result.success) { setError(result.error || 'Login failed') setIsSubmitting(false) } }, [username, password, login]) return (
This instance has no sign-in method available to the chat.
)} {showPasswordForm && ( )}Powered by{' '} Standard Agents