import { useState } from "react"; import { Link, useParams } from "react-router"; import { api, ApiError, type PackageDetail, type Project } from "../api"; import { useFetch, fmtBytes, fmtDate, short } from "../hooks"; import { Badge, ErrorBox, JobStatus, JsonTree, KV, Loading, Tabs } from "../components/ui"; import { DebtTable, EndpointRow, EvidenceList, LifecycleButtons } from "../components/shared"; export default function AkpDetail() { const { id } = useParams(); const { data, error, loading, reload } = useFetch(`akps/${id}`); const projects = useFetch<{ projects: Project[] }>("projects"); const [tab, setTab] = useState("Files"); const [file, setFile] = useState<{ name: string; text: string } | null>(null); const [fileErr, setFileErr] = useState(null); const [job, setJob] = useState<{ id: string; label: string } | null>(null); if (loading) return ; if (error) return ; if (!data) return null; const k = data; const m = k.manifest as { static_scan?: { ok: boolean; findings: string[] }; credential_env?: string | null; files?: Record; knowledge_debt?: string[] }; const open = async (name: string) => { setFileErr(null); try { setFile({ name, text: await api(`/api/v1/akps/${k.id}/files/${name}`, { raw: true }) }); } catch (e) { setFileErr(e as ApiError); } }; const run = async (kind: "verify" | "compile") => { const r = await api<{ job_id: string }>(`akps/${k.id}/${kind}`, { body: { live: true } }); setJob({ id: r.job_id, label: kind }); }; const projs = projects.data?.projects.map((p) => ({ slug: p.slug, name: `${p.name} (${p.policy_mode})` })) ?? [{ slug: "default", name: "default" }]; return (

{k.akp_id} v{k.version} {k.opaque && }

{k.api_name} · {k.provider_name} · {k.superseded_by && <> · superseded by {short(k.superseded_by)}}
Download bundle.zip
{k.hash}], ["Contract", {k.api_version_label}], ["Contract hash", {k.contract_hash}], ["License", (k.license?.name as string) ?? ], ["Snapshots", (k.license?.snapshots as string) ?? "metadata_only"], ["Credential", m.credential_env ? {m.credential_env} (vault reference{k.credential_ref_id ? "" : " not bound"}) : "none (public API)"], ["Static scan", m.static_scan ? : "—"], ["Created", `${fmtDate(k.created_at)}${k.created_by ? ` by ${k.created_by}` : ""}`]]} /> {m.static_scan && !m.static_scan.ok &&
{m.static_scan.findings.join("\n")}
}

Lifecycle

{ await api(`akps/${k.id}/lifecycle`, { body: { to, reason } }); reload(); }} />
{tab === "Files" && (

Generated files (content-addressed)

{k.files.map((f) =>
{f.language}{fmtBytes(f.size_bytes)} · {short(f.sha256, 10)}
)}

{file ? file.name : "Viewer"}

{file ?
{file.text}
:
Select a file to view its content.
}
)} {tab === "Operations" &&
{k.endpoints.map((e) => )}
} {tab === "Evidence" && } {tab === "Debt" && } {tab === "Manifest" &&
} {tab === "README" &&
{k.readme}
}
); }