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
feat(api): 20-minute Alexandria feedback window (#4986)
Nicolas204456d0406e
diff --git a/apps/api/src/__tests__/routes/exchange-agent-managed-key.routes.test.ts b/apps/api/src/__tests__/routes/exchange-agent-managed-key.routes.test.tsindex a4c580717..8f34a4274 100644--- a/apps/api/src/__tests__/routes/exchange-agent-managed-key.routes.test.ts+++ b/apps/api/src/__tests__/routes/exchange-agent-managed-key.routes.test.ts@@ -272,7 +272,7 @@ describe("hosted MCP keys on the Exchange routes the agent calls", () => {"alexandria:activity:team-mcp","1","EX",- config.SEARCH_FEEDBACK_MAX_AGE_SEC,+ config.ALEXANDRIA_FEEDBACK_WINDOW_SEC,],]: [],diff --git a/apps/api/src/config.ts b/apps/api/src/config.tsindex 5df5a6bd9..53282ce92 100644--- a/apps/api/src/config.ts+++ b/apps/api/src/config.ts@@ -222,6 +222,11 @@ const configSchema = z.object({FEEDBACK_MAX_AGE_SEC: z.coerce.number().int().positive().default(120),FEEDBACK_DAILY_CAP_CREDITS: z.coerce.number().int().nonnegative().default(50),FEEDBACK_REFUND_ENABLED: z.stringbool().default(true),+ ALEXANDRIA_FEEDBACK_WINDOW_SEC: z.coerce+ .number()+ .int()+ .positive()+ .default(1200),ALEXANDRIA_FEEDBACK_DAILY_CAP_CREDITS: z.coerce.number().int()diff --git a/apps/api/src/controllers/v2/feedback/alexandria.test.ts b/apps/api/src/controllers/v2/feedback/alexandria.test.tsindex 892d9b9ca..6ea07d407 100644--- a/apps/api/src/controllers/v2/feedback/alexandria.test.ts+++ b/apps/api/src/controllers/v2/feedback/alexandria.test.ts@@ -638,7 +638,7 @@ it("rejects feedback outside the window after the team's last Alexandria call",expect(response.body).toEqual({success: false,feedbackErrorCode: "FEEDBACK_WINDOW_EXPIRED",- error: `Alexandria feedback must be submitted within ${config.SEARCH_FEEDBACK_MAX_AGE_SEC} seconds of an Alexandria search, discovery, or execution.`,+ error: `Alexandria feedback must be submitted within ${config.ALEXANDRIA_FEEDBACK_WINDOW_SEC} seconds of an Alexandria search, discovery, or execution.`,});expect(mocks.hasRecentAlexandriaActivity).toHaveBeenCalledWith(teamId);expect(mocks.transaction).not.toHaveBeenCalled();diff --git a/apps/api/src/controllers/v2/feedback/alexandria.ts b/apps/api/src/controllers/v2/feedback/alexandria.tsindex 0bfdc6429..7a9b22e33 100644--- a/apps/api/src/controllers/v2/feedback/alexandria.ts+++ b/apps/api/src/controllers/v2/feedback/alexandria.ts@@ -81,7 +81,7 @@ export async function recordAlexandriaFeedback(return failure(409,"FEEDBACK_WINDOW_EXPIRED",- `Alexandria feedback must be submitted within ${config.SEARCH_FEEDBACK_MAX_AGE_SEC} seconds of an Alexandria search, discovery, or execution.`,+ `Alexandria feedback must be submitted within ${config.ALEXANDRIA_FEEDBACK_WINDOW_SEC} seconds of an Alexandria search, discovery, or execution.`,);}diff --git a/apps/api/src/lib/alexandria-activity.test.ts b/apps/api/src/lib/alexandria-activity.test.tsindex 711792c9d..dafc19c21 100644--- a/apps/api/src/lib/alexandria-activity.test.ts+++ b/apps/api/src/lib/alexandria-activity.test.ts@@ -22,13 +22,24 @@ beforeEach(() => {mocks.set.mockResolvedValue("OK");});-it("opens a feedback window as long as the search feedback window", async () => {- await recordAlexandriaActivity(teamId);+it("opens the Alexandria window, independent of the search feedback window", async () => {+ const original = {+ alexandria: config.ALEXANDRIA_FEEDBACK_WINDOW_SEC,+ search: config.SEARCH_FEEDBACK_MAX_AGE_SEC,+ };+ config.ALEXANDRIA_FEEDBACK_WINDOW_SEC = 1500;+ config.SEARCH_FEEDBACK_MAX_AGE_SEC = 90;+ try {+ await recordAlexandriaActivity(teamId);+ } finally {+ config.ALEXANDRIA_FEEDBACK_WINDOW_SEC = original.alexandria;+ config.SEARCH_FEEDBACK_MAX_AGE_SEC = original.search;+ }expect(mocks.set).toHaveBeenCalledExactlyOnceWith(`alexandria:activity:${teamId}`,"1","EX",- config.SEARCH_FEEDBACK_MAX_AGE_SEC,+ 1500,);});diff --git a/apps/api/src/lib/alexandria-activity.ts b/apps/api/src/lib/alexandria-activity.tsindex a6ae8f202..592bd9c96 100644--- a/apps/api/src/lib/alexandria-activity.ts+++ b/apps/api/src/lib/alexandria-activity.ts@@ -5,8 +5,8 @@ import { logger } from "./logger";const activityKey = (teamId: string) => `alexandria:activity:${teamId}`;/**- * Opens (or extends) the team's Alexandria feedback window, which lasts as long- * as the search feedback window. Never rejects; a failed write is only logged.+ * Opens (or extends) the team's Alexandria feedback window for+ * ALEXANDRIA_FEEDBACK_WINDOW_SEC. Never rejects; a failed write is only logged.*/export async function recordAlexandriaActivity(teamId: string): Promise<void> {try {@@ -14,7 +14,7 @@ export async function recordAlexandriaActivity(teamId: string): Promise<void> {activityKey(teamId),"1","EX",- config.SEARCH_FEEDBACK_MAX_AGE_SEC,+ config.ALEXANDRIA_FEEDBACK_WINDOW_SEC,);} catch (error) {logger.warn("Failed to record Alexandria activity", { error, teamId });