2026-06-18 12:01:21 +02:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { useOnboarding } from "@onboardjs/react";
|
|
|
|
|
import { Loader2 } from "lucide-react";
|
2026-06-19 10:56:46 +02:00
|
|
|
import { Button } from "@/components/ui/button";
|
2026-06-18 12:01:21 +02:00
|
|
|
import { CodeSnippet } from "@/components/common/code-snippet";
|
2026-06-19 10:56:46 +02:00
|
|
|
import { useGenerateEdgeKey } from "@/features/onboarding/hooks/use-generate-edge-key";
|
2026-06-19 10:25:17 +02:00
|
|
|
import type { OnboardingAgent } from "@/features/onboarding/types";
|
2026-06-18 12:01:21 +02:00
|
|
|
|
|
|
|
|
export const StepAgentKey = () => {
|
2026-06-19 10:56:46 +02:00
|
|
|
const { next, state } = useOnboarding();
|
|
|
|
|
const agents = (state?.context.flowData.agents ?? []) as OnboardingAgent[];
|
2026-06-18 12:01:21 +02:00
|
|
|
|
2026-06-19 10:56:46 +02:00
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-6">
|
|
|
|
|
<div>
|
|
|
|
|
<h1 className="text-2xl font-semibold">Connect your agent</h1>
|
|
|
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
|
|
|
Run the command below on your server. The next step waits for the agent to connect.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
{agents.map((agent) => (
|
|
|
|
|
<AgentKeyBlock key={agent.id} agent={agent} />
|
|
|
|
|
))}
|
|
|
|
|
<Button type="button" onClick={() => next()}>
|
|
|
|
|
I've run the command →
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2026-06-18 12:01:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const AgentKeyBlock = ({ agent }: { agent: OnboardingAgent }) => {
|
2026-06-19 10:56:46 +02:00
|
|
|
const { data, isLoading } = useGenerateEdgeKey(agent.id);
|
2026-06-18 12:01:21 +02:00
|
|
|
|
2026-06-19 10:56:46 +02:00
|
|
|
if (isLoading) {
|
2026-06-18 12:01:21 +02:00
|
|
|
return (
|
2026-06-19 10:56:46 +02:00
|
|
|
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
|
|
|
|
<Loader2 className="size-4 animate-spin" />
|
|
|
|
|
Generating key for {agent.name}…
|
|
|
|
|
</div>
|
2026-06-18 12:01:21 +02:00
|
|
|
);
|
2026-06-19 10:56:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const command = `portabase agent "${agent.name}" --key ${data}`;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-3 p-4 rounded-lg border border-border">
|
|
|
|
|
<p className="text-sm font-medium">{agent.name}</p>
|
|
|
|
|
<CodeSnippet title="Installation Command" code={command} />
|
|
|
|
|
<CodeSnippet title="Agent Key (manual)" code={data ?? ""} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2026-06-18 12:01:21 +02:00
|
|
|
};
|