Initial commit

This commit is contained in:
Jordan
2026-04-01 23:16:45 +01:00
commit bc4199aed2
201 changed files with 25612 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import { registerNavigateBrowserTool } from './navigate.js';
export function registerNavigationTools(server) {
registerNavigateBrowserTool(server);
}

View File

@@ -0,0 +1,57 @@
import { z } from "zod";
import { withAuth, getSessionCredentials } from "../../auth/index.js";
import { handleToolError } from "../helpers/errorHandler.js";
import { withAuthParams } from "../helpers/authSchema.js";
import { LOCAL_SERVER_URL } from "../../config/index.js";
import axios from "axios";
export function registerNavigateBrowserTool(server) {
server.tool(
"navigate_browser",
`Navigate the user's browser preview to a specific page URL. Use this after creating or modifying a page to show the result to the user. The enlace should be a path like "/servicios/" or "/blog/my-post/".`,
withAuthParams({
enlace: z.string().describe("The URL path to navigate to, e.g. '/servicios/' or '/contacto/'"),
}),
{ readOnlyHint: true, destructiveHint: false },
withAuth(async ({ enlace }, extra) => {
try {
if (!enlace) {
return {
content: [{ type: "text", text: "Error: enlace is required" }],
isError: true,
};
}
// Ensure enlace starts with /
if (!enlace.startsWith("/")) {
enlace = "/" + enlace;
}
const credentials = await getSessionCredentials(extra.sessionId);
const project = credentials.website || process.env.ACAI_WEBSITE || "";
// POST to Python server to set pending navigation
await axios.post(`${LOCAL_SERVER_URL}/api/browser/navigate`, {
project: project,
enlace: enlace,
}, {
headers: { "Content-Type": "application/json" },
timeout: 5000,
});
return {
content: [{
type: "text",
text: JSON.stringify({
success: true,
message: `Browser navigated to ${enlace}`,
enlace: enlace,
})
}],
};
} catch (error) {
return handleToolError(error, "navigate_browser", { enlace });
}
})
);
}