Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Evals: a live dream runner, gated on OMB_EVAL_LIVE, that scores real models on the dream cases
Divya Jyoti7a824e93444a
diff --git a/evals/README.md b/evals/README.mdindex d8a5757f56..26e3e9c8e9 100644--- a/evals/README.md+++ b/evals/README.md@@ -75,6 +75,11 @@ On Claude with tool search on, a turn sends a few agents tools whole and the resnpx vitest run --config evals/vitest.config.ts evals/dream+`evals/dream/run-dream.ts` sends each case to a real model with the dream's own prompt and scores the answer the same way, with time and cost per case. It talks to the engine directly through its driver, with no server, and the server code it loads gets a temporary data folder. It is closed unless `OMB_EVAL_LIVE=1`, never runs in CI, and writes its report under the gitignored `evals/reports/runs/`. The instance uses the live tier's shape:++ OMB_EVAL_LIVE=1 OMB_EVAL_LIVE_INSTANCE='{"instanceId":"claude","driver":"claudeAgent","model":"claude-haiku-5-5","config":{"cli":"/path/to/claude"},"environmentFrom":["HOME","USER","PATH"]}' \+ node --experimental-strip-types evals/dream/run-dream.ts [--only id,id]+## Tier 3 — opt-in live-model smokeLive-model runs never execute by default: `pnpm eval --live` prints one skip line and exits 0 unless the gate is open.diff --git a/evals/dream/live.test.ts b/evals/dream/live.test.tsnew file mode 100644index 0000000000..fd00de6c5f--- /dev/null+++ b/evals/dream/live.test.ts@@ -0,0 +1,47 @@+import { execFileSync } from "node:child_process";+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";+import { describe, expect, it } from "vitest";+import { DREAM_MARKER } from "../../server/memory-dream.ts";+import { reportLines, runCases } from "./live.ts";+import type { DreamCase } from "./score.ts";++const cases = JSON.parse(readFileSync(new URL("./cases.json", import.meta.url), "utf8")) as DreamCase[];+const empty = JSON.stringify({ learned: [], outdated: [], ideas: [] });++describe("the live dream runner, on a fake model", () => {+ it("sends each case the dream's real prompt and scores the answer", async () => {+ const prompts: string[] = [];+ const ticks = [0, 1200, 1200, 2000];+ const rows = await runCases(cases.slice(0, 2), async (prompt) => (prompts.push(prompt), { text: empty, costUsd: 0.01 }), () => ticks.shift()!);+ expect(prompts).toHaveLength(2);+ expect(prompts.every((prompt) => prompt.startsWith(DREAM_MARKER))).toBe(true);+ expect(prompts[0]).toContain("Too wordy again, keep it under 100 words please.");+ expect(rows.map((row) => [row.id, row.score.pass, row.ms, row.costUsd])).toEqual([+ ["short-replies-across-chats", false, 1200, 0.01],+ ["one-chat-is-not-a-pattern", true, 800, 0.01],+ ]);+ });++ it("scores a failed call as an empty answer and says why", async () => {+ const [row] = await runCases(cases.slice(1, 2), async () => { throw new Error("The background model call timed out."); });+ expect(row).toMatchObject({ answer: "", error: "The background model call timed out.", score: { json: false, pass: false } });+ expect(reportLines([row!], "m")[1]).toMatch(/^ERROR .*timed out/);+ });++ it("reports each case and the total", async () => {+ const rows = await runCases(cases.slice(1, 3), async () => ({ text: empty }));+ const lines = reportLines(rows, "claude-haiku-5-5");+ expect(lines[0]).toBe("dream eval on claude-haiku-5-5");+ expect(lines.at(-1)).toMatch(/^2\/2 passed, 0\/0 expected lines found, 0 forbidden, 0 dropped, 0 not JSON/);+ });+});++describe("the live dream entrypoint", () => {+ it("calls no model unless OMB_EVAL_LIVE=1", () => {+ const env = { ...process.env };+ delete env.OMB_EVAL_LIVE;+ const output = execFileSync(process.execPath, ["--experimental-strip-types", "--no-warnings", fileURLToPath(new URL("./run-dream.ts", import.meta.url))], { env, encoding: "utf8" });+ expect(output.trim()).toBe("dream eval: skipped (set OMB_EVAL_LIVE=1; each case is one real model call)");+ });+});diff --git a/evals/dream/live.ts b/evals/dream/live.tsnew file mode 100644index 0000000000..87df2d628a--- /dev/null+++ b/evals/dream/live.ts@@ -0,0 +1,57 @@+import { dreamPrompt } from "../../server/memory-dream.ts";+import { dreamConversationsOf, notebookOf, scoreDream, summarize, type DreamCase, type DreamScore } from "./score.ts";++export interface Generated {+ text: string;+ costUsd?: number;+}++export interface LiveRow {+ id: string;+ score: DreamScore;+ answer: string;+ ms: number;+ costUsd?: number;+ /** The model call failed or timed out; the case is scored on an empty answer. */+ error?: string;+}++/** One call per case, one at a time, with the dream's real prompt; a failed call is scored, never skipped. */+export async function runCases(cases: readonly DreamCase[], generate: (prompt: string) => Promise<Generated>, clock: () => number = Date.now): Promise<LiveRow[]> {+ const rows: LiveRow[] = [];+ for (const testCase of cases) {+ const prompt = dreamPrompt({ botName: "Scout", today: testCase.today, conversations: dreamConversationsOf(testCase), notebook: notebookOf(testCase) });+ const started = clock();+ let generated: Generated = { text: "" };+ let error: string | undefined;+ try {+ generated = await generate(prompt);+ } catch (failure) {+ error = failure instanceof Error ? failure.message : String(failure);+ }+ const ms = clock() - started;+ rows.push({ id: testCase.id, score: scoreDream(testCase, generated.text), answer: generated.text, ms, ...(generated.costUsd === undefined ? {} : { costUsd: generated.costUsd }), ...(error ? { error } : {}) });+ }+ return rows;+}++export function reportLines(rows: readonly LiveRow[], model: string): string[] {+ const lines = rows.map((row) => {+ const s = row.score;+ const mark = row.error ? "ERROR" : s.pass ? "pass " : "FAIL ";+ const notes = [+ !s.json && !row.error ? "not JSON" : "",+ s.violations.length ? `forbidden: ${s.violations.join(" | ")}` : "",+ s.dropped ? `${s.dropped} dropped by the fact checks` : "",+ s.unexpected.length ? `unexpected: ${s.unexpected.join(" | ")}` : "",+ row.error ?? "",+ ].filter(Boolean).join("; ");+ return `${mark} ${row.id.padEnd(40)} found ${s.found}/${s.expected} ${(row.ms / 1000).toFixed(1)}s${row.costUsd === undefined ? "" : ` $${row.costUsd.toFixed(4)}`}${notes ? ` ${notes}` : ""}`;+ });+ const total = summarize(rows);+ return [+ `dream eval on ${model}`,+ ...lines,+ `${total.passed}/${total.cases} passed, ${total.found}/${total.expected} expected lines found, ${total.violations} forbidden, ${total.dropped} dropped, ${total.invalidJson} not JSON, $${total.costUsd.toFixed(4)}, ${(total.ms / 1000).toFixed(1)}s`,+ ];+}diff --git a/evals/dream/run-dream.ts b/evals/dream/run-dream.tsnew file mode 100644index 0000000000..0dcd9d015f--- /dev/null+++ b/evals/dream/run-dream.ts@@ -0,0 +1,64 @@+// Sends each dream case to a real model with the dream's own prompt and scores what runDream would keep.+//+// OMB_EVAL_LIVE=1 OMB_EVAL_LIVE_INSTANCE='{"instanceId":"claude","driver":"claudeAgent","model":"claude-haiku-5-5","config":{"cli":"/path/to/claude"},"environmentFrom":["HOME","USER","PATH"]}' \+// node --experimental-strip-types evals/dream/run-dream.ts [--only id,id]+//+// Each case is one real model call on your account: never in CI, closed unless OMB_EVAL_LIVE=1. The server's data folder is+// a temporary one, so nothing reads or writes ~/.openmausbot.+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";++const HERE = dirname(fileURLToPath(import.meta.url));++async function main(): Promise<void> {+ if (process.env.OMB_EVAL_LIVE !== "1") {+ console.log("dream eval: skipped (set OMB_EVAL_LIVE=1; each case is one real model call)");+ return;+ }+ const dataDir = mkdtempSync(join(tmpdir(), "omb-dream-eval-"));+ process.env.OMB_DATA_DIR = dataDir;+ const { loadLiveInstance } = await import("../live/run-live.ts");+ const { BUILT_IN_DRIVERS } = await import("../../server/drivers/builtIn.ts");+ const { DREAM_TIMEOUT_MS } = await import("../../server/memory-upkeep.ts");+ const { reportLines, runCases } = await import("./live.ts");+ const at = process.argv.indexOf("--only");+ const only = at === -1 ? undefined : process.argv[at + 1]?.split(",");+ const cases = (JSON.parse(readFileSync(join(HERE, "cases.json"), "utf8")) as Parameters<typeof runCases>[0]).filter((item) => !only || only.includes(item.id));+ const live = loadLiveInstance(process.env);+ const driver = BUILT_IN_DRIVERS.find((candidate) => candidate.driverKind === live.driver);+ if (!driver) throw new Error(`no driver ${live.driver}; known: ${BUILT_IN_DRIVERS.map((candidate) => candidate.driverKind).join(", ")}`);+ const environment: Record<string, string> = { ...live.environment };+ for (const name of live.environmentFrom ?? []) if (process.env[name] !== undefined) environment[name] = process.env[name]!;+ const instance = await driver.create({+ instanceId: live.instanceId,+ displayName: live.displayName,+ environment,+ enabled: true,+ config: driver.decodeConfig(live.config ?? driver.defaultConfig()),+ });+ try {+ if (!instance.generateText) throw new Error(`${live.driver} has no one-shot text call, so it cannot dream`);+ const generate = instance.generateText.bind(instance);+ const rows = await runCases(cases, async (prompt) => {+ let costUsd: number | undefined;+ const text = await generate(prompt, { model: live.model, timeoutMs: DREAM_TIMEOUT_MS, onUsage: (usage) => { costUsd = usage.costUsd; } });+ return { text, ...(costUsd === undefined ? {} : { costUsd }) };+ });+ for (const line of reportLines(rows, live.model)) console.log(line);+ const out = join(HERE, "..", "reports", "runs");+ mkdirSync(out, { recursive: true });+ const file = join(out, `dream-${live.model.replace(/[^\w.-]+/g, "_")}-${new Date().toISOString().replace(/[:.]/g, "-")}.json`);+ writeFileSync(file, JSON.stringify({ model: live.model, driver: live.driver, rows }, null, 2));+ console.log(`report: ${file}`);+ } finally {+ await instance.dispose();+ rmSync(dataDir, { recursive: true, force: true });+ }+}++main().catch((error) => {+ console.error(error);+ process.exitCode = 1;+});