refactor(agent): normalize API naming
This commit is contained in:
+16
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user