Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(browser): keep the schema error for bad read args; name chat's registered browser tools
AdityaUmalec6a899a9215b
diff --git a/server/drivers/chat-mcp-tools.test.ts b/server/drivers/chat-mcp-tools.test.tsindex 6d99d5eaef..17712de0af 100644--- a/server/drivers/chat-mcp-tools.test.ts+++ b/server/drivers/chat-mcp-tools.test.ts@@ -205,7 +205,7 @@ describe("Chat MCP session", () => {});it.each([- ["browser", "Open the address with agent_browser_open first"],+ ["browser", "Open the address with browser_agent_browser_open first, then call browser_agent_browser_read without url."],["custom", "input schema"],] as const)("names the way to read an address when agent_browser_read's url is hidden (%s)", async (mountAs, error) => {// agent-browser's read with its url hidden by slimBrowserToolList (email bug 1a1cb892)@@ -216,6 +216,9 @@ describe("Chat MCP session", () => {const name = session.definitions[0]!.function.name;expect(() => session.validate(name, { url: "https://example.com/swagger.json" })).toThrow(error);expect(() => session.validate(name, { filter: 7 })).toThrow("input schema");+ // a url of the wrong type, or another bad argument, keeps the schema error+ expect(() => session.validate(name, { url: 7 })).toThrow("input schema");+ expect(() => session.validate(name, { url: "https://example.com", filter: 7 })).toThrow("input schema");expect(() => session.validate(name, {})).not.toThrow();});diff --git a/server/drivers/chat-mcp-tools.ts b/server/drivers/chat-mcp-tools.tsindex 0d74305e37..0e50490f2b 100644--- a/server/drivers/chat-mcp-tools.ts+++ b/server/drivers/chat-mcp-tools.ts@@ -421,6 +421,18 @@ export function loopbackNavigationHint(tool: string, args: unknown, text: stringreturn " That address is the loopback of the machine running this browser, not your own computer: open the site by the LAN address it answers on (for example http://192.168.1.20:8188), which must be reachable from the server, and allow it under Settings → Browser → Open sites on this server.";}+/** agent-browser's read hides `url`: a call whose only misfit is a string url gets the way to read an address instead of the bare schema misfit. */+function readsAddressOnly(tool: RegisteredTool, args: unknown): boolean {+ if (!tool.builtInBrowser || !readsAroundBrowser({ name: tool.name, arguments: args }) || !object(args) || typeof args.url !== "string") return false;+ const { url: _url, ...rest } = args;+ return tool.schema(rest);+}++/** READ_OPEN_PAGE_ONLY with the tool names this chat registered for the browser server. */+function readOpenPageOnly(server: string): string {+ return READ_OPEN_PAGE_ONLY.replace(/agent_browser_(?:open|read)/gu, (tool) => chatToolName(server, tool));+}+function omitBlankDefaults(builtInBrowser: boolean, tool: string, args: unknown) {if (!builtInBrowser) return;normalizeBuiltInBrowserArgs(tool, args);@@ -710,8 +722,7 @@ export async function mountChatTools(integrations: SendTurnInput["integrations"]if (selectionExcludes(tool, args)) throw new Error("Tool selection excludes this tool");omitBlankDefaults(tool.builtInBrowser, tool.name, args);if (!object(args) || (!(tool.searched && isDirectoryTool(tool.name)) && !tool.schema(args))) {- // agent-browser's read hides `url`; name the way to read an address instead of the bare schema misfit.- throw new Error(tool.builtInBrowser && readsAroundBrowser({ name: tool.name, arguments: args }) ? READ_OPEN_PAGE_ONLY : ARGUMENTS_MISFIT);+ throw new Error(readsAddressOnly(tool, args) ? readOpenPageOnly(tool.server) : ARGUMENTS_MISFIT);}};const viewOf = (tool: RegisteredTool, args: Record<string, unknown>, title: string): ChatToolCallView => {