Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
refactor(api): read developerBeta via TeamFlags instead of a cast
Kris Oei9579b97dc0d6
diff --git a/apps/api/src/controllers/v2/research-proxy.ts b/apps/api/src/controllers/v2/research-proxy.tsindex 0a5287c53..4ee0b3682 100644--- a/apps/api/src/controllers/v2/research-proxy.ts+++ b/apps/api/src/controllers/v2/research-proxy.ts@@ -15,6 +15,7 @@ import type {ResearchTableName,} from "../../services/logging/log_job";import type { RequestWithAuth } from "../v1/types";+import type { TeamFlags } from "./types";import { wrap } from "../../routes/shared";import { integrationSchema } from "../../utils/integration";import { requestOrigin } from "../../lib/request-origin";@@ -145,7 +146,7 @@ type ResearchEndpointConfig = {* ungated (the research endpoints). Keyless callers have no acuc and so no* flags, which makes them unentitled by construction.*/- betaGate?: { flag: string; error: string };+ betaGate?: { flag: keyof NonNullable<TeamFlags>; error: string };};type ResearchController = (req: Request, res: Response) => Promise<any>;@@ -253,14 +254,11 @@ function createResearchController(const authedReq = req as RequestWithAuth<any, any, any>;// Beta gate: fail closed before any logging, billing, or upstream call.- if (endpoint.betaGate) {- const flags = authedReq.acuc?.flags as- | Record<string, unknown>- | null- | undefined;- if (flags?.[endpoint.betaGate.flag] !== true) {- return researchError(res, 403, endpoint.betaGate.error);- }+ if (+ endpoint.betaGate &&+ authedReq.acuc?.flags?.[endpoint.betaGate.flag] !== true+ ) {+ return researchError(res, 403, endpoint.betaGate.error);}const started = Date.now();diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.tsindex c5ba383e2..a66318367 100644--- a/apps/api/src/controllers/v2/search.ts+++ b/apps/api/src/controllers/v2/search.ts@@ -87,11 +87,7 @@ export async function searchController(// the key-restriction check below so an unentitled team is never told its// key lacks access to a category that is about to be removed anyway.if (wantsDeveloperCategory(req.body.categories as CategoryOption[])) {- const flags = req.acuc?.flags as- | Record<string, unknown>- | null- | undefined;- if (flags?.developerBeta !== true) {+ if (req.acuc?.flags?.developerBeta !== true) {logger.info("developer category requested without developerBeta flag; dropping",);