Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(cli): write JSON team exports as JSON
Afloatd66019cb7e1d
diff --git a/server/headless/team-apply.test.ts b/server/headless/team-apply.test.tsindex 6e8c605d52..4903f7aa00 100644--- a/server/headless/team-apply.test.ts+++ b/server/headless/team-apply.test.ts@@ -309,7 +309,7 @@ describe("team export", () => {expect(skillFilePath("room-lead", "launch-report")).toBe("skills/room-lead/launch-report/SKILL.md");});- it("gives bots whose names make the same folder name their own skill folders", async () => {+ it.each(["yaml", "json", "JSON"])("keeps each bot's skill files when a %s export is read back", async (extension) => {expect(botSkillDirs(["Room Lead", "!!!", "Room-Lead", "Room Lead 2"])).toEqual(["room-lead", "bot", "room-lead-2", "room-lead-2-2"]);const skill = (body: string) => `---\nname: common\ndescription: Shared.\n---\n${body}\n`;const { client, state } = workspace({ bots: [{ id: "bot-a", name: "Dev A" }, { id: "bot-b", name: "Dev-A" }, { id: "bot-c", name: "Dev A 2" }] });@@ -318,11 +318,12 @@ describe("team export", () => {state.skills["bot-c"] = { common: { text: skill("third"), enabled: true } };const dir = mkdtempSync(join(tmpdir(), "omb-team-export-"));try {- const out = join(dir, "team.yaml");+ const out = join(dir, `team.${extension}`);const ctx = { verb: "team export", flags: { out }, positionals: [], env: {}, io: { out: () => undefined, err: () => undefined, readStdin: async () => "" },output: new Output({ out: () => undefined, err: () => undefined, readStdin: async () => "" }, {}), client: async () => client,signal: new AbortController().signal, defaultWaitMs: 1_000 } as VerbContext;await teamExportVerb(ctx);+ if (extension === "yaml") expect(readFileSync(out, "utf8")).toMatch(/^# Written by openmausbot team export/);const back = loadTeamFile(out);expect(back.bots.map((bot) => [bot.name, bot.skills.map((s) => s.text.trim().split("\n").at(-1))])).toEqual([["Dev A", ["first"]], ["Dev-A", ["second"]], ["Dev A 2", ["third"]],@@ -332,7 +333,7 @@ describe("team export", () => {}});- it("takes a key written into a soul, a brief or a skill out of the file, and apply leaves those as they are", async () => {+ it.each(["yaml", "json", "JSON"])("redacts secrets in a %s export and leaves them unchanged when applied", async (extension) => {const KEY = "sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789";const { client, writes, state } = workspace();await reconcile(client, file(), options());@@ -341,7 +342,7 @@ describe("team export", () => {state.skills["bot-1"]!["launch-report"]!.text = `---\nname: launch-report\ndescription: Write it.\n---\nUpload with ${KEY}\n`;const dir = mkdtempSync(join(tmpdir(), "omb-team-export-"));try {- const out = join(dir, "team.yaml");+ const out = join(dir, `team.${extension}`);const ctx = { verb: "team export", flags: { out }, positionals: [], env: {}, io: { out: () => undefined, err: () => undefined, readStdin: async () => "" },output: new Output({ out: () => undefined, err: () => undefined, readStdin: async () => "" }, {}), client: async () => client,signal: new AbortController().signal, defaultWaitMs: 1_000 } as VerbContext;diff --git a/server/headless/team-apply.ts b/server/headless/team-apply.tsindex 3884d03381..5aedf953a6 100644--- a/server/headless/team-apply.ts+++ b/server/headless/team-apply.ts@@ -478,7 +478,10 @@ export async function teamExportVerb(ctx: VerbContext): Promise<VerbOutcome> {const document = { version: 1, ...(Object.keys(engines).length ? { engines } : {}), ...(teamEntries.length ? { teams: teamEntries } : {}),bots: botEntries, ...(roomEntries.length ? { rooms: roomEntries } : {}) };if (!botEntries.length) throw new HeadlessError("no bots to export", EXIT.failed);- writeFileSync(resolve(out), `# Written by openmausbot team export on ${new Date().toISOString().slice(0, 10)}.\n# Engine keys are placeholders (SET_ME): set them before applying this elsewhere.\n${stringifyYaml(document, { lineWidth: 0 })}`);+ const serialized = /\.json$/i.test(out)+ ? `${JSON.stringify(document, null, 2)}\n`+ : `# Written by openmausbot team export on ${new Date().toISOString().slice(0, 10)}.\n# Engine keys are placeholders (SET_ME): set them before applying this elsewhere.\n${stringifyYaml(document, { lineWidth: 0 })}`;+ writeFileSync(resolve(out), serialized);return {result: { ok: true, file: resolve(out), teams: teamEntries.length, bots: botEntries.length, rooms: roomEntries.length, skills, engines: Object.keys(engines), skipped, redacted },exitCode: EXIT.done,