refactor(agent): normalize API naming
This commit is contained in:
@@ -100,7 +100,11 @@ export const createSkillManagerTool = (
|
|||||||
kind: "skill",
|
kind: "skill",
|
||||||
decision: "accepted",
|
decision: "accepted",
|
||||||
detail: "skill listed",
|
detail: "skill listed",
|
||||||
...result,
|
references: result.references,
|
||||||
|
scripts: result.scripts,
|
||||||
|
skill_path: result.skillPath,
|
||||||
|
target: result.target,
|
||||||
|
patterns: result.patterns,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ export default tool({
|
|||||||
.describe("Why web search is required for the current user request."),
|
.describe("Why web search is required for the current user request."),
|
||||||
query: tool.schema.string().describe("Search query text."),
|
query: tool.schema.string().describe("Search query text."),
|
||||||
freshness: tool.schema
|
freshness: tool.schema
|
||||||
.enum(["noLimit", "oneDay", "oneWeek", "oneMonth", "oneYear"])
|
.enum(["no_limit", "one_day", "one_week", "one_month", "one_year"])
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Optional freshness filter. Defaults to noLimit."),
|
.describe("Optional freshness filter. Defaults to no_limit."),
|
||||||
summary: tool.schema
|
summary: tool.schema
|
||||||
.boolean()
|
.boolean()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
+8
-8
@@ -194,8 +194,8 @@ export const buildChatRouter = (
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
chatRouter.get("/session/:sessionId", async (req, res) => {
|
chatRouter.get("/session/:session_id", async (req, res) => {
|
||||||
const sessionId = req.params.sessionId?.trim();
|
const sessionId = req.params.session_id?.trim();
|
||||||
const authContext = getAgentAuthContext(req);
|
const authContext = getAgentAuthContext(req);
|
||||||
const projectId = authContext.projectId;
|
const projectId = authContext.projectId;
|
||||||
const userId = authContext.userId;
|
const userId = authContext.userId;
|
||||||
@@ -238,8 +238,8 @@ export const buildChatRouter = (
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
chatRouter.get("/session/:sessionId/stream", async (req, res) => {
|
chatRouter.get("/session/:session_id/stream", async (req, res) => {
|
||||||
const sessionId = req.params.sessionId?.trim();
|
const sessionId = req.params.session_id?.trim();
|
||||||
const authContext = getAgentAuthContext(req);
|
const authContext = getAgentAuthContext(req);
|
||||||
const projectId = authContext.projectId;
|
const projectId = authContext.projectId;
|
||||||
const userId = authContext.userId;
|
const userId = authContext.userId;
|
||||||
@@ -303,8 +303,8 @@ export const buildChatRouter = (
|
|||||||
res.on("close", cleanup);
|
res.on("close", cleanup);
|
||||||
});
|
});
|
||||||
|
|
||||||
chatRouter.patch("/session/:sessionId/title", async (req, res) => {
|
chatRouter.patch("/session/:session_id/title", async (req, res) => {
|
||||||
const sessionId = req.params.sessionId?.trim();
|
const sessionId = req.params.session_id?.trim();
|
||||||
const title =
|
const title =
|
||||||
typeof req.body?.title === "string" ? req.body.title.trim() : "";
|
typeof req.body?.title === "string" ? req.body.title.trim() : "";
|
||||||
const isTitleManuallyEdited =
|
const isTitleManuallyEdited =
|
||||||
@@ -349,8 +349,8 @@ export const buildChatRouter = (
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
chatRouter.delete("/session/:sessionId", async (req, res) => {
|
chatRouter.delete("/session/:session_id", async (req, res) => {
|
||||||
const sessionId = req.params.sessionId?.trim();
|
const sessionId = req.params.session_id?.trim();
|
||||||
const authContext = getAgentAuthContext(req);
|
const authContext = getAgentAuthContext(req);
|
||||||
const projectId = authContext.projectId;
|
const projectId = authContext.projectId;
|
||||||
const userId = authContext.userId;
|
const userId = authContext.userId;
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ export const registerChatAuxiliaryRoutes = (
|
|||||||
sessionUiStateStore,
|
sessionUiStateStore,
|
||||||
}: RegisterAuxiliaryRoutesOptions,
|
}: RegisterAuxiliaryRoutesOptions,
|
||||||
) => {
|
) => {
|
||||||
chatRouter.get("/render-ref/:renderRef", async (req, res) => {
|
chatRouter.get("/render-ref/:render_ref", async (req, res) => {
|
||||||
const renderRef = req.params.renderRef?.trim();
|
const renderRef = req.params.render_ref?.trim();
|
||||||
const authContext = getAgentAuthContext(req);
|
const authContext = getAgentAuthContext(req);
|
||||||
const userId = authContext.userId;
|
const userId = authContext.userId;
|
||||||
const projectId = authContext.projectId;
|
const projectId = authContext.projectId;
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export const registerChatInteractionRoutes = (
|
|||||||
sessionUiStateStore,
|
sessionUiStateStore,
|
||||||
}: RegisterInteractionRoutesOptions,
|
}: RegisterInteractionRoutesOptions,
|
||||||
) => {
|
) => {
|
||||||
chatRouter.post("/permission/:requestId/reply", async (req, res) => {
|
chatRouter.post("/permission/:request_id/reply", async (req, res) => {
|
||||||
const requestId = req.params.requestId?.trim();
|
const requestId = req.params.request_id?.trim();
|
||||||
const parsed = permissionReplyPayloadSchema.safeParse(req.body);
|
const parsed = permissionReplyPayloadSchema.safeParse(req.body);
|
||||||
if (!requestId) {
|
if (!requestId) {
|
||||||
res.status(400).json({ message: "request_id is required" });
|
res.status(400).json({ message: "request_id is required" });
|
||||||
@@ -174,8 +174,8 @@ export const registerChatInteractionRoutes = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chatRouter.post("/question/:requestId/reply", async (req, res) => {
|
chatRouter.post("/question/:request_id/reply", async (req, res) => {
|
||||||
const requestId = req.params.requestId?.trim();
|
const requestId = req.params.request_id?.trim();
|
||||||
const parsed = questionReplyPayloadSchema.safeParse(req.body);
|
const parsed = questionReplyPayloadSchema.safeParse(req.body);
|
||||||
if (!requestId) {
|
if (!requestId) {
|
||||||
res.status(400).json({ message: "request_id is required" });
|
res.status(400).json({ message: "request_id is required" });
|
||||||
@@ -306,8 +306,8 @@ export const registerChatInteractionRoutes = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chatRouter.post("/question/:requestId/reject", async (req, res) => {
|
chatRouter.post("/question/:request_id/reject", async (req, res) => {
|
||||||
const requestId = req.params.requestId?.trim();
|
const requestId = req.params.request_id?.trim();
|
||||||
const parsed = questionRejectPayloadSchema.safeParse(req.body);
|
const parsed = questionRejectPayloadSchema.safeParse(req.body);
|
||||||
if (!requestId) {
|
if (!requestId) {
|
||||||
res.status(400).json({ message: "request_id is required" });
|
res.status(400).json({ message: "request_id is required" });
|
||||||
|
|||||||
+16
-2
@@ -314,6 +314,21 @@ const parseStringArray = (value: unknown) =>
|
|||||||
? value.filter((item): item is string => typeof item === "string")
|
? value.filter((item): item is string => typeof item === "string")
|
||||||
: undefined;
|
: 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;
|
const AUTH_EXPIRY_SKEW_MS = 30_000;
|
||||||
|
|
||||||
function isRuntimeAuthExpired(context: RuntimeSessionContext) {
|
function isRuntimeAuthExpired(context: RuntimeSessionContext) {
|
||||||
@@ -369,8 +384,7 @@ app.post("/internal/tools/web-search", async (req, res) => {
|
|||||||
: undefined;
|
: undefined;
|
||||||
const payload = {
|
const payload = {
|
||||||
query,
|
query,
|
||||||
freshness:
|
freshness: normalizeWebSearchFreshness(req.body?.freshness),
|
||||||
typeof req.body?.freshness === "string" ? req.body.freshness : undefined,
|
|
||||||
summary:
|
summary:
|
||||||
typeof req.body?.summary === "boolean" ? req.body.summary : undefined,
|
typeof req.body?.summary === "boolean" ? req.body.summary : undefined,
|
||||||
count,
|
count,
|
||||||
|
|||||||
Reference in New Issue
Block a user