Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a deterministic verification core: clinical-trial claims checked against ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI recomputed in code, oracle-tested), code-enforced exact-span grounding, and multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing at scale (unpdf + Docling), agentic workflows, Claude Science connector, compliance/audit, billing, public API, and more. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { NextRequest } from "next/server";
|
|
import { getPool } from "@/lib/db";
|
|
import { withOrg, type Ctx } from "@/lib/api/handler";
|
|
import { ok, fail } from "@/lib/api/response";
|
|
import { requireRole } from "@/lib/authz/rbac";
|
|
import { listTools } from "@/lib/tools/registry";
|
|
import { listRegistrations } from "@/lib/tools/repository";
|
|
import type { ToolDescriptor } from "@/lib/tools/types";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
// GET /api/tools — the catalog of callable tools: PaperTrail's built-in tools
|
|
// plus any tools this org has registered. Org-scoped; any member (viewer+) may
|
|
// read the catalog. Registered tools are appended after the built-ins.
|
|
export const GET = withOrg(async (_req: NextRequest, ctx: Ctx) => {
|
|
try {
|
|
requireRole(ctx, "viewer");
|
|
const pool = getPool();
|
|
const builtins = listTools();
|
|
const registered = await listRegistrations(pool, ctx.org.id);
|
|
|
|
const registeredDescriptors: ToolDescriptor[] = registered.map((r) => ({
|
|
name: r.name,
|
|
description: r.description,
|
|
source: "registered",
|
|
enabled: r.enabled,
|
|
inputSchema: r.inputSchema,
|
|
}));
|
|
|
|
return ok<ToolDescriptor[]>([...builtins, ...registeredDescriptors]);
|
|
} catch (err) {
|
|
if (err instanceof Error && "status" in err) {
|
|
return fail(err.message, (err as { status: number }).status);
|
|
}
|
|
return fail("Failed to load tools.", 500);
|
|
}
|
|
});
|