refactor(agent): normalize API naming

This commit is contained in:
2026-06-13 11:15:59 +08:00
parent 8857b18dc9
commit ead76185b7
6 changed files with 39 additions and 21 deletions
+16 -2
View File
@@ -314,6 +314,21 @@ const parseStringArray = (value: unknown) =>
? value.filter((item): item is string => typeof item === "string")
: undefined;
const webSearchFreshnessMap: Record<string, string> = {
no_limit: "noLimit",
one_day: "oneDay",
one_week: "oneWeek",
one_month: "oneMonth",
one_year: "oneYear",
};
const normalizeWebSearchFreshness = (value: unknown) => {
if (typeof value !== "string") {
return undefined;
}
return webSearchFreshnessMap[value] ?? value;
};
const AUTH_EXPIRY_SKEW_MS = 30_000;
function isRuntimeAuthExpired(context: RuntimeSessionContext) {
@@ -369,8 +384,7 @@ app.post("/internal/tools/web-search", async (req, res) => {
: undefined;
const payload = {
query,
freshness:
typeof req.body?.freshness === "string" ? req.body.freshness : undefined,
freshness: normalizeWebSearchFreshness(req.body?.freshness),
summary:
typeof req.body?.summary === "boolean" ? req.body.summary : undefined,
count,