import { createFileRoute } from "@tanstack/react-router";
import { useState } from "react";
import { createAgentIdentity, createAgentToken, deleteAgentIdentity, listAgentIdentities } from "~/fns/agents";
import { useAction } from "~/hooks/use-action";
import { Button } from "~/ui/Button";
import { CheckboxField, SelectField, TextAreaField, TextField } from "~/ui/Field";
import { ErrorBanner } from "~/ui/Callout";
import { EmptyState } from "~/ui/EmptyState";
import { Panel } from "~/ui/Panel";
import { RelativeTime } from "~/ui/RelativeTime";
import { SecretReveal } from "~/ui/Callout";
const AREAS = [
{ id: "contents", label: "Contents" },
{ id: "issues", label: "Issues" },
{ id: "pulls", label: "Pull requests" },
{ id: "actions", label: "Actions" },
{ id: "admin", label: "Administration" },
] as const;
const ACCESS = [
{ value: "", label: "No access" },
{ value: "read", label: "Read-only" },
{ value: "write", label: "Read and write" },
] as const;
const EXPIRY = [
{ value: "7", label: "7 days" },
{ value: "30", label: "30 days" },
{ value: "90", label: "90 days" },
{ value: "366", label: "1 year" },
] as const;
export const Route = createFileRoute("/settings/agents")({
loader: () => listAgentIdentities(),
component: AgentsPage,
});
function accessValue(value: FormDataEntryValue | null): "read" | "write" | undefined {
return value === "read" || value === "write" ? value : undefined;