'use client'; import { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import type { AgentCredentials } from '@/features/agent-registration/credentials'; import type { IntegrationCatalogItem } from '@/features/agent-registration/integrations'; import { buildInstallInstructions, SDK_LANGUAGES, SHELLS, type SdkLanguage, type Shell, } from '@/features/agent-registration/install-instructions'; import CopyControl from './CopyControl'; interface ConnectStepProps { readonly integration: IntegrationCatalogItem; readonly credentials: AgentCredentials; readonly token: string; readonly onBack: () => void; readonly onDone: () => void; } export default function ConnectStep({ integration, credentials, token, onBack, onDone, }: ConnectStepProps) { const { t } = useTranslation(); const [language, setLanguage] = useState('node'); const [shell, setShell] = useState('posix'); const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ?? 'http://localhost:8787'; const instructions = useMemo( () => buildInstallInstructions(language, { integration, identity: { agentId: credentials.agentId, kid: credentials.kid, orgId: credentials.orgId, }, baseUrl, privateKey: credentials.privateKey, token, }, shell), [baseUrl, credentials, integration, language, shell, token], ); const PostInstallList = instructions.postInstall?.kind === 'alternatives' ? 'ul' : 'ol'; return (
{t('agentRegistration.integration')} {integration.name}
{SDK_LANGUAGES.map((item) => ( ))}
{integration.mode === 'hooks' && (
{SHELLS.map((item) => ( ))}
)}

{integration.mode === 'hooks' ? t('agentRegistration.install') : t('agentRegistration.configure')}

          {instructions.setup}
        
{t('agentRegistration.privateKey')}
{t('agentRegistration.apiToken')}

{t(`agentRegistration.secretDelivery.${instructions.secretDelivery}`)}

{instructions.usage && (

{t('agentRegistration.record')}

            {instructions.usage}
          
)} {instructions.verify && (

{t('agentRegistration.verify')}

{instructions.verify}
)} {instructions.postInstall && ( {instructions.postInstall.steps.map((step, index) => (
  • {step.variant ?? String(index + 1).padStart(2, '0')} {t(`agentRegistration.postInstallSteps.${step.key}`, { integration: integration.name, })} {step.command && ( {step.command} )} {step.command && ( )}
  • ))}
    )}
    ); }