Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Train fix (#8129): no outputSchema on Pi tools, and images keep main's type check
milind-soniec39f5a5f06f
diff --git a/server/drivers/pi-mcp-extension.test.ts b/server/drivers/pi-mcp-extension.test.tsindex 7e8a261640..679376cdcc 100644--- a/server/drivers/pi-mcp-extension.test.ts+++ b/server/drivers/pi-mcp-extension.test.ts@@ -75,6 +75,7 @@ describe("MCP content conversion", () => {{ type: "resource", resource: { uri: "x://img", mimeType: "image/jpeg", blob: "aW1n" } },{ type: "resource", resource: { uri: "x://bin", mimeType: "application/pdf", blob: "Ymlu" } },{ type: "weird", foo: 1 },+ { type: "image", data: 5, mimeType: "image/png" },"nonsense",])).toEqual([{ type: "text", text: "hi" },@@ -85,6 +86,7 @@ describe("MCP content conversion", () => {{ type: "image", data: "aW1n", mimeType: "image/jpeg" },{ type: "text", text: "[binary resource x://bin (application/pdf) omitted]" },{ type: "text", text: "[unsupported MCP content weird]" },+ { type: "text", text: "[unsupported MCP content image]" },{ type: "text", text: "[unsupported MCP content]" },]);});@@ -534,7 +536,6 @@ describe("Pi MCP extension registration", () => {await extension({ registerTool(tool) { tools.push(tool); }, on(event, handler) { handlers.set(event, handler); } });try {expect(tools.map((tool) => tool.name)).toEqual(["voicenote_show_voice_note"]);- expect(tools[0].outputSchema).toBeDefined();const result = await tools[0].execute("call", {}, undefined, undefined, { ui: { confirm: async () => true } });expect(result.structuredContent).toEqual({ id: "abc" });expect(result.details).toMatchObject({ server: "voicenote", tool: "show_voice_note", meta: { voicenote: { id: "abc" } } });diff --git a/server/drivers/pi-mcp-extension.ts b/server/drivers/pi-mcp-extension.tsindex 798dc1708e..295125bdc0 100644--- a/server/drivers/pi-mcp-extension.ts+++ b/server/drivers/pi-mcp-extension.ts@@ -9,7 +9,7 @@ import { ASK_USER_TOOL, formatQuestionAnswers, MAX_OPTIONS, MAX_QUESTIONS, parseimport { CALL_TOOL, directoryCallTarget, isDirectoryTool } from "../mcp-directory.ts";import { REMOTE_MCP_STARTUP_MS } from "../mcp-http.ts";import { modelVisible, withUiExtension } from "../mcp-app-observer.ts";-import { MCP_RESULT_OUTPUT_SCHEMA, mcpContentToPiContent, type PiToolContent } from "../mcp-tool-content.ts";+import { mcpContentToPiContent, type PiToolContent } from "../mcp-tool-content.ts";import { AGENTS_TOOL_TIMEOUT_SECONDS } from "./agents-tool-limit.ts";interface McpServerDef {@@ -71,8 +71,6 @@ interface PiToolDefinition {label: string;description: string;parameters: TSchema;- /** The MCP `CallToolResult` shape, so a codemode script receives the tool's `structuredContent`. */- outputSchema?: unknown;/** Pi 1.0+: declared to the model and never callable from other tools, as Pi documents for tools that ask the user. */exposure?: "model-only";execute(@@ -741,8 +739,6 @@ export default async function (pi: PiExtensionApi): Promise<void> {label: `${serverName}:${toolName}`,description: typeof tool.description === "string" ? tool.description : `${toolName} (MCP tool from ${serverName})`,parameters,- // The full CallToolResult, so a codemode script receives the MCP `structuredContent`.- outputSchema: MCP_RESULT_OUTPUT_SCHEMA,async execute(_toolCallId, params, signal, _onUpdate, ctx) {const target = directoryTool ? directoryCallTarget(toolName, params) : toolName;if (scope !== undefined && (enforcementFaileddiff --git a/server/mcp-tool-content.ts b/server/mcp-tool-content.tsindex e1ffcce960..2c57ff97e8 100644--- a/server/mcp-tool-content.ts+++ b/server/mcp-tool-content.ts@@ -22,7 +22,9 @@ function oneContentBlock(block: unknown): PiToolContent {case "text":return { type: "text", text: String(block.text ?? "") };case "image":- return { type: "image", data: String(block.data ?? ""), mimeType: String(block.mimeType ?? "") };+ return typeof block.data === "string" && typeof block.mimeType === "string"+ ? { type: "image", data: block.data, mimeType: block.mimeType }+ : { type: "text", text: "[unsupported MCP content image]" };case "audio":// pi's model content has no audio; keep a placeholder so the block is visible, never silent.return { type: "text", text: `[audio ${String(block.mimeType ?? "unknown type")} omitted]` };@@ -47,30 +49,3 @@ function oneContentBlock(block: unknown): PiToolContent {export function mcpContentToPiContent(content: unknown): PiToolContent[] {return (Array.isArray(content) ? content : []).map(oneContentBlock);}--/** Schema of the `CallToolResult` every MCP tool returns: what programmatic callers (pi codemode- * scripts) receive in `structuredContent`. `structuredContent` stays open because a server may- * send any JSON value, including one it declares no schema for. */-export const MCP_RESULT_OUTPUT_SCHEMA = {- type: "object",- properties: {- content: {- type: "array",- items: {- type: "object",- properties: {- type: { enum: ["text", "image", "audio", "resource_link", "resource"] },- text: { type: "string" },- data: { type: "string" },- mimeType: { type: "string" },- },- required: ["type"],- additionalProperties: true,- },- },- structuredContent: {},- isError: { type: "boolean" },- },- required: ["content"],- additionalProperties: true,-} as const;