Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix: write the skill on/off/delete card from the language packs
AdityaUmale4b21ad7ec8c2
diff --git a/server/host/skill-switch-host.ts b/server/host/skill-switch-host.tsindex 730a0b8e1d..0916322ef2 100644--- a/server/host/skill-switch-host.ts+++ b/server/host/skill-switch-host.ts@@ -11,6 +11,7 @@ import { appendDecision } from "../decision-log.ts";import { setImportedSkillEnabled } from "../imported-skills.ts";import { listSkills, readSkillFile, removeSkill, setSkillEnabled } from "../skills.ts";import { skillSwitchCardCopy, skillSwitchStillMatches, skillSwitchTarget, type SkillSwitchTarget, type SwitchableSkill } from "../skill-switch.ts";+import { conversationLanguage } from "../server-lines.ts";import type { BotRecord, Store } from "../store.ts";export interface SkillSwitchHostDeps {@@ -57,7 +58,7 @@ export function createSkillSwitchHost(deps: SkillSwitchHostDeps) {function appendCard(args: { requestId: string; botId: string; threadId: string; action: SkillSwitchAction; name: string; target: SkillSwitchTarget }): string {const { requestId } = args;- const copy = skillSwitchCardCopy(args.action, args.name, args.target.gist);+ const copy = skillSwitchCardCopy(args.action, args.name, args.target.gist, conversationLanguage(args.threadId));const payload: SkillRequestCardData = {version: 1,requestId,@@ -144,7 +145,7 @@ export function createSkillSwitchHost(deps: SkillSwitchHostDeps) {return { claimed: true, status: 422, error: applied.error };}store.patchMessage(args.threadId, messageId, {- card: { ...card, answered: "allow", held: undefined, title: skillSwitchCardCopy(request.action, request.name, "").done },+ card: { ...card, answered: "allow", held: undefined, title: skillSwitchCardCopy(request.action, request.name, "", conversationLanguage(args.threadId)).done },});deps.noteSkillChange(args.botId, args.threadId);decided("user-approved");diff --git a/server/skill-switch.test.ts b/server/skill-switch.test.tsindex 819c6e09e4..dda6109d9e 100644--- a/server/skill-switch.test.ts+++ b/server/skill-switch.test.ts@@ -2,6 +2,8 @@ import { createHash } from "node:crypto";import { describe, expect, it } from "vitest";+import de from "../src/locales/de.json" with { type: "json" };+import { addServerLinePacks } from "./server-lines.ts";import { skillSwitchCardCopy, skillSwitchStillMatches, skillSwitchTarget, type SwitchableSkill } from "./skill-switch.ts";const text = "---\nname: notes\ndescription: Keeps notes\n---\n# Notes\n";@@ -61,4 +63,9 @@ describe("skillSwitchCardCopy", () => {expect(skillSwitchCardCopy("disable", "notes", "Keeps notes")).toMatchObject({ option: "Turn off", subtitle: expect.stringMatching(/^Keeps notes\n\n.*Nothing is deleted\.$/) });expect(skillSwitchCardCopy("delete", "notes", "")).toMatchObject({ title: "Delete skill \"notes\"?", option: "Delete", done: "Skill \"notes\" deleted" });});++ it("writes the card in the person's language but keeps the answer it sends back", () => {+ addServerLinePacks({ de });+ expect(skillSwitchCardCopy("disable", "notes", "", "de")).toMatchObject({ title: "Skill „notes“ ausschalten?", option: "Turn off", done: "Skill „notes“ ausgeschaltet" });+ });});diff --git a/server/skill-switch.ts b/server/skill-switch.tsindex 8e9e79a6a1..96958e32ae 100644--- a/server/skill-switch.ts+++ b/server/skill-switch.ts@@ -1,6 +1,7 @@import { createHash } from "node:crypto";import { redactSecretsInText } from "./redact.ts";+import { serverLine, type ServerLineKey } from "./server-lines.ts";import { STAGED_GIST_MAX } from "./skills.ts";import type { SkillSwitchAction } from "../shared/skill-request.ts";@@ -74,21 +75,25 @@ export function skillSwitchStillMatches(: { error: `skill "${name}" changed after this card was shown; ask the bot to propose it again` };}-export function skillSwitchCardCopy(action: SkillSwitchAction, name: string, gist: string): {+const CARD_LINES = {+ enable: { option: "Turn on", title: "server.skillSwitch.enable.title", body: "server.skillSwitch.enable.body", done: "server.skillSwitch.enable.done" },+ disable: { option: "Turn off", title: "server.skillSwitch.disable.title", body: "server.skillSwitch.disable.body", done: "server.skillSwitch.disable.done" },+ delete: { option: "Delete", title: "server.skillSwitch.delete.title", body: "server.skillSwitch.delete.body", done: "server.skillSwitch.delete.done" },+} as const satisfies Record<SkillSwitchAction, { option: string; title: ServerLineKey; body: ServerLineKey; done: ServerLineKey }>;++/** The card's words in the person's language. The option is the answer the card sends back, so it stays as written. */+export function skillSwitchCardCopy(action: SkillSwitchAction, name: string, gist: string, language?: string): {title: string;subtitle: string;option: string;done: string;} {+ const lines = CARD_LINES[action];const lead = gist ? `${gist}\n\n` : "";- if (action === "enable") {- return { title: `Turn on skill "${name}"?`, option: "Turn on", done: `Skill "${name}" turned on`,- subtitle: `${lead}The bot can use this skill again.` };- }- if (action === "disable") {- return { title: `Turn off skill "${name}"?`, option: "Turn off", done: `Skill "${name}" turned off`,- subtitle: `${lead}The bot stops using this skill until it is turned on again. Nothing is deleted.` };- }- return { title: `Delete skill "${name}"?`, option: "Delete", done: `Skill "${name}" deleted`,- subtitle: `${lead}Removes this skill and all its files from the bot for good. Its SKILL.md is shown below, with any secrets hidden.` };+ return {+ title: serverLine(language, lines.title, { name }),+ subtitle: `${lead}${serverLine(language, lines.body)}`,+ option: lines.option,+ done: serverLine(language, lines.done, { name }),+ };}diff --git a/src/locales/de.json b/src/locales/de.jsonindex 69ff67dbcc..088b5a3c77 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -110,6 +110,15 @@"server.mcp.tested": "MCP-Server {name} getestet","server.mcp.signedOut": "Von MCP-Server {name} abgemeldet","server.mcp.removed": "MCP-Server {name} entfernt",+ "server.skillSwitch.enable.title": "Skill „{name}“ einschalten?",+ "server.skillSwitch.enable.body": "Der Bot kann diesen Skill wieder nutzen.",+ "server.skillSwitch.enable.done": "Skill „{name}“ eingeschaltet",+ "server.skillSwitch.disable.title": "Skill „{name}“ ausschalten?",+ "server.skillSwitch.disable.body": "Der Bot nutzt diesen Skill nicht mehr, bis er wieder eingeschaltet wird. Nichts wird gelöscht.",+ "server.skillSwitch.disable.done": "Skill „{name}“ ausgeschaltet",+ "server.skillSwitch.delete.title": "Skill „{name}“ löschen?",+ "server.skillSwitch.delete.body": "Entfernt diesen Skill mit all seinen Dateien endgültig vom Bot. Seine SKILL.md steht unten, Geheimnisse sind ausgeblendet.",+ "server.skillSwitch.delete.done": "Skill „{name}“ gelöscht","server.mcp.listed": "MCP-Server geprüft","server.mcp.on": "Eingeschaltet","server.mcp.switchedOff": "Ausgeschaltet",diff --git a/src/locales/en.json b/src/locales/en.jsonindex d6f6262d58..5753324a74 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -206,6 +206,15 @@"server.mcp.tested": "Tested MCP server {name}","server.mcp.signedOut": "Signed out of MCP server {name}","server.mcp.removed": "Removed MCP server {name}",+ "server.skillSwitch.enable.title": "Turn on skill \"{name}\"?",+ "server.skillSwitch.enable.body": "The bot can use this skill again.",+ "server.skillSwitch.enable.done": "Skill \"{name}\" turned on",+ "server.skillSwitch.disable.title": "Turn off skill \"{name}\"?",+ "server.skillSwitch.disable.body": "The bot stops using this skill until it is turned on again. Nothing is deleted.",+ "server.skillSwitch.disable.done": "Skill \"{name}\" turned off",+ "server.skillSwitch.delete.title": "Delete skill \"{name}\"?",+ "server.skillSwitch.delete.body": "Removes this skill and all its files from the bot for good. Its SKILL.md is shown below, with any secrets hidden.",+ "server.skillSwitch.delete.done": "Skill \"{name}\" deleted","server.mcp.listed": "Checked MCP servers","server.mcp.on": "Turned on","server.mcp.switchedOff": "Switched off",