Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Train fix (#7883): the folder picker's problems are codes the window words in the person's language
milind-soni3f1d7f2ce297
diff --git a/electron/folder-pickers.mjs b/electron/folder-pickers.mjsindex 2cbed169e9..1d522a88fe 100644--- a/electron/folder-pickers.mjs+++ b/electron/folder-pickers.mjs@@ -22,7 +22,7 @@ export function installFolderPickers({ ipcMain, dialog, windowFor, mainWindow, rconst result = await dialog.showOpenDialog(win, { properties: ["openDirectory"] });const chosen = result.filePaths[0];if (result.canceled || !chosen || !isLocalSender(event)) return null;- const folder = await readChosenSkillFolder(chosen).catch(() => ({ error: "Could not read the skill folder." }));+ const folder = await readChosenSkillFolder(chosen).catch(() => ({ error: "unreadable" }));return isLocalSender(event) ? folder : null;}));}diff --git a/electron/skill-folder-import.mjs b/electron/skill-folder-import.mjsindex f1c771537b..180566d4de 100644--- a/electron/skill-folder-import.mjs+++ b/electron/skill-folder-import.mjs@@ -33,7 +33,8 @@ async function selectedFile(target, expected) {/** The folder must come from the native picker. Only admitted relative names and bounded file contents leave main. */export async function readChosenSkillFolder(chosen) {- const missingSkill = { error: "Choose a folder containing SKILL.md." };+ // Problems are codes; the window words them in the person's language.+ const missingSkill = { error: "missing" };const chosenInfo = await lstat(chosen);if (!chosenInfo.isDirectory()) return missingSkill;const root = await realpath(chosen);@@ -44,7 +45,7 @@ export async function readChosenSkillFolder(chosen) {throw error;});if (!skillMd?.isFile() || skillMd.nlink !== 1) return missingSkill;- if (skillMd.size > SKILL_FOLDER_LIMITS.fileBytes) return { error: "SKILL.md is too large to import." };+ if (skillMd.size > SKILL_FOLDER_LIMITS.fileBytes) return { error: "too-large" };const entries = [];let visited = 0;const walk = async (folder, prefix) => {@@ -66,11 +67,11 @@ export async function readChosenSkillFolder(chosen) {return true;};- if (!await walk(root, "")) return { error: "This folder has too many entries. Choose the folder containing SKILL.md." };+ if (!await walk(root, "")) return { error: "too-many" };const { take, skipped } = planSkillFolder(entries);const entry = take[0];if (entry?.path !== "SKILL.md") return missingSkill;- if (entry.size > SKILL_FOLDER_LIMITS.fileBytes) return { error: "SKILL.md is too large to import." };+ if (entry.size > SKILL_FOLDER_LIMITS.fileBytes) return { error: "too-large" };const files = [];for (const { path, target, info, executable } of take) {files.push({ path, base64: await selectedFile(target, info), executable });diff --git a/electron/skill-folder-import.node-test.mjs b/electron/skill-folder-import.node-test.mjsindex ebfc946975..88695a55cf 100644--- a/electron/skill-folder-import.node-test.mjs+++ b/electron/skill-folder-import.node-test.mjs@@ -39,5 +39,5 @@ test("reads the chosen skill's files within the folder limits and skips links",{ path: "outside", reason: "link" },]);assert.equal(result.skippedCount, 4);- assert.deepEqual(await readChosenSkillFolder(root), { error: "Choose a folder containing SKILL.md." });+ assert.deepEqual(await readChosenSkillFolder(root), { error: "missing" });});diff --git a/shared/skill-import.ts b/shared/skill-import.tsindex d98ea911c8..0cbc7968f9 100644--- a/shared/skill-import.ts+++ b/shared/skill-import.ts@@ -59,4 +59,7 @@ export interface SkillFolderUpload {files: Array<{ path: string; base64: string; executable: boolean }>;}-export type PickedSkillFolder = (SkillFolderUpload & Pick<SkillImportSummary, "skipped" | "skippedCount">) | { error: string };+/** Why a chosen folder could not be read; the window words it. */+export type SkillFolderProblem = "missing" | "too-large" | "too-many" | "unreadable";++export type PickedSkillFolder = (SkillFolderUpload & Pick<SkillImportSummary, "skipped" | "skippedCount">) | { error: SkillFolderProblem };diff --git a/src/components/bot-settings/SkillsSection.tsx b/src/components/bot-settings/SkillsSection.tsxindex 7c53f893e9..d02ddec69d 100644--- a/src/components/bot-settings/SkillsSection.tsx+++ b/src/components/bot-settings/SkillsSection.tsx@@ -2,7 +2,8 @@ import { BookOpen, FolderOpen, Trash2, Users } from "lucide-react";import { t } from "@/lib/i18n";import { relayLink } from "@/lib/relay-server";import { skillImportLines } from "@/lib/skill-import";-import type { SkillImportSummary } from "../../../shared/skill-import";+import type { SkillFolderProblem, SkillImportSummary } from "../../../shared/skill-import";+import type { LocaleKey } from "@/locales";import { useEffect, useRef, useState } from "react";import { type Bot } from "@/state/store";@@ -317,6 +318,13 @@ export function SkillReviewDialog({);}+const SKILL_FOLDER_PROBLEM: Record<SkillFolderProblem, LocaleKey> = {+ missing: "skills.import.folder.missing",+ "too-large": "skills.import.folder.tooLarge",+ "too-many": "skills.import.folder.tooMany",+ unreadable: "skills.import.folder.unreadable",+};+export function useSkillImport(botId: string, { refresh, setError }: Pick<ReturnType<typeof useManagedSkills>, "refresh" | "setError">, failure: string) {const { request: api, draft } = useBotEditor();const bridge = globalThis.window?.ogb;@@ -342,7 +350,7 @@ export function useSkillImport(botId: string, { refresh, setError }: Pick<Returnif (selection.current !== botId || (from === "folder" && !picked)) return;setError("");setImported(null);- if (picked && "error" in picked) throw new Error(picked.error);+ if (picked && "error" in picked) throw new Error(t(SKILL_FOLDER_PROBLEM[picked.error] ?? "skills.import.folder.unreadable"));if (picked && relayLink()) throw new Error(failure);const result = await api<{ imported?: SkillImportSummary[] }>(`/api/bots/${botId}/skills${picked ? "?from=folder" : ""}`, {method: "POST",