Open-source Grok Bot alternative with a virtual machine that bots can use
Bot Profile Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Make the bot a first-class, addressable, versioned object — one read that returns everything the bot is, one write that changes it, an append-only history that can be rolled back, and a single-bot export that clones an employee without cloning its secrets.
Architecture: No new source of truth. A new assembler module reads the five stores that already own the pieces (store.ts for identity and engine, workspace.ts for memory, skills.ts for skills, routines.ts for schedules, composio.ts for connector intent) and returns one BotProfileDocument. Writes go back through each owning module, never around it. Every accepted write appends a row to a per-bot NDJSON version log, using the same discipline as decision-log.ts.
Tech Stack: TypeScript, Node 24, Vitest, React, zod.
Spec: none — this plan is its own spec.
Global Constraints
See the roadmap. The ones that shape this plan directly:
- Exports never carry credentials, transcripts, memory, grants, absolute paths, engine bindings, or a schedule's active state.
server/package-export.tsalready states this as its contract and this plan does not weaken it. - Imports land disabled.
- Secrets are write-only. The profile read must not become a way to read back a key that
config.tsdeliberately hides.
Depends on: P1 — the profile carries budgetUsd, which P1 introduces.
Background: what "first-class" is missing today
server/bot-profile.ts exists but patches eight cosmetic fields —
BOT_PROFILE_PATCH_FIELDS is name, title, description, notifications, avatarUrl,
avatarCrop, voice, speakReplies. Everything else that makes a bot what it is lives
elsewhere and is not addressable as a unit:
| Piece | Owner today | Reachable as "profile"? |
|---|---|---|
| Identity, engine, computer, autonomy, permissions | BotRecord (server/store.ts:277) |
Partially — 8 of ~25 fields |
| Memory | MEMORY.md + memory/ (server/workspace.ts) |
No |
| Skills | server/skills.ts |
No |
| Playbooks | BotRecord.playbooks |
Only via team export |
| Routines | server/routines.ts, keyed by botId |
No |
| Connector intent | BotRecord.installedPackage.requiredApps |
Only via team export |
And there is no history: no version log, no diff, no rollback. /api/teams/export
(server/index.ts:3424) exports every non-hidden bot — there is no way to export or
clone one.
File map
- Create
server/profile-document.ts: assemble and apply aBotProfileDocument. No I/O of its own beyond the modules it delegates to. - Create
server/profile-document.test.ts. - Create
server/profile-versions.ts: append-only NDJSON history per bot,0600, redacted, fire-and-forget on write. - Create
server/profile-versions.test.ts. - Modify
server/index.ts:GET/PUT /api/bots/:id/profile,GET /api/bots/:id/profile/versions,POST /api/bots/:id/profile/rollback,POST /api/bots/:id/export,POST /api/bots/:id/clone. - Modify
server/package-export.ts: accept a bot subset instead of assuming the whole workspace. - Modify
server/package-export.test.ts. - Modify
src/components/SettingsModal.tsxor the bot profile editor: a History tab. - Create
src/components/ProfileHistory.tsx.
Task 1: The profile document shape and assembler
Files:
- Create:
server/profile-document.ts,server/profile-document.test.ts
Interfaces:
Produces:
export interface BotProfileDocument { identity: { name: string; title: string; description: string; avatarUrl?: string; color: MausColor; voice?: string }; engine: { instanceId: string; model: string; effort?: EffortLevel }; execution: { computer?: "cloud" | "vm" | "local" | "off"; cloudBackend?: CloudBackend; cwd?: string }; autonomy: { autoApprove?: boolean; alwaysAllow: string[]; approvePeerComms?: boolean; chiefOfStaff?: boolean }; budget: { budgetUsd?: number }; connectors: { composio: boolean; required: Array<{ slug: string; label: string; reason: string; optional?: boolean }> }; skills: Array<{ name: string; description: string; enabled: boolean; source?: string; sha256?: string }>; playbooks: InstalledPlaybook[]; routines: Array<{ id: string; name: string; prompt: string; enabled: boolean; schedule: RoutineSchedule; runOn: RoutineRunOn }>; memory: { bytes: number; topics: Array<{ name: string; bytes: number }> }; } export function readProfile(botId: string, deps: ProfileDeps): BotProfileDocument | null;ProfileDepsis an explicit dependency object{ store, routines }so the assembler is testable without booting the harness.workspace.tsandskills.tsare imported directly — they are already pure filesystem modules keyed bybotId.Write a failing test: a bot with two enabled skills, one disabled skill, one playbook, one routine, and a non-empty
MEMORY.mdassembles into a document where every section is populated andmemoryreports byte counts and topic names only.Write a failing test that is the security property:
readProfilenever returns memory content, never returns a Composio key, and never returnsresumeCursors— the provider session ids the companion sidecar already scrubs. Assert by serializing the document and searching for planted sentinel strings.Write a failing test that a missing bot returns
nulland a bot with no skills, routines, or memory returns a document with empty arrays rather thanundefined— a consumer must never have to null-check a section.Run
pnpm vitest run server/profile-document.test.ts; expect FAIL, module not found.Implement
readProfile, delegating tostore.bot(),listSkills()(server/skills.ts:183),listMemoryTopics()andreadMemoryFile()(server/workspace.ts:118,86) for sizes only, androutines.listRoutines()filtered bybotId.Run; expect PASS.
Commit
feat(profile): assemble a complete bot profile document.
Task 2: Applying a profile
Files:
- Modify:
server/profile-document.ts,server/profile-document.test.ts
Interfaces:
Produces:
export type ProfileApplyResult = | { ok: true; changed: string[] } | { ok: false; error: string; field?: string }; export function applyProfile(botId: string, patch: DeepPartial<BotProfileDocument>, deps: ProfileDeps): ProfileApplyResult;changedis a list of dotted paths ("engine.model","autonomy.autoApprove") — Task 3's version log records it and Task 6's UI renders it.Write a failing test: patching
engine.modelalone changes the model and reportschanged: ["engine.model"], leaving every other field untouched.Write a failing test that a patch is all-or-nothing: a patch containing a valid
identity.nameand an invalidbudget.budgetUsdof-5applies neither, and reports the offending field. A half-applied profile is the failure mode that makes rollback untrustworthy.Write a failing test that
applyProfilerefuses to writeskills[].enabledfor a skill whose scan produced warnings and which the person has never enabled — enabling a skill is a human act (server/skills.tspolicy), and the profile API must not become the way around it.Write a failing test that read-only sections (
memory, and the derived parts ofconnectors) are rejected rather than silently ignored, naming the field.Run; expect FAIL.
Implement: validate the whole patch against a zod schema first, collecting the change list; only then delegate each section —
store.patchBotforBotRecordfields,setSkillEnabled(server/skills.ts:261) for skills,routines.update(id, patch)(server/routines.ts:245) for routines. ReuseparseBotProfilePatch(server/bot-profile.ts:69) for the fields it already covers rather than duplicating its rules.Run; expect PASS.
Commit
feat(profile): apply a validated profile patch atomically.
Task 3: The version log
Files:
- Create:
server/profile-versions.ts,server/profile-versions.test.ts
Interfaces:
Produces:
export interface ProfileVersionRow { v: 1; at: number; botId: string; changed: string[]; actor: "user" | "agent" | "import" | "rollback"; before: Partial<BotProfileDocument>; after: Partial<BotProfileDocument>; note?: string; } export function appendProfileVersion(row: Omit<ProfileVersionRow, "v">): void; export function readProfileVersions(botId: string, limit: number): ProfileVersionRow[];Write a failing test: appending three versions and reading with
limit: 2returns the two most recent, newest first.Write a failing test that
before/aftercarry only the changed paths, not whole documents — a full-document history would grow without bound and would archive a copy of every skill body on every rename.Write a failing test that a row whose
aftercontains a key-shaped value is redacted throughredactSecretsbefore it reaches disk, and that the file is created0600.Write a failing test that a corrupt line in the middle of the file is skipped and the surrounding rows still read — an append-only log must survive a torn write.
Write a failing test that an unwritable log does not throw:
appendProfileVersionis fire-and-forget, matchingdecision-log.ts. A history that can take down the edit it is recording is worse than no history.Run
pnpm vitest run server/profile-versions.test.ts; expect FAIL.Implement against
DATA_DIR/profile-versions/<botId>.ndjson, mirroring the rotation and redaction structure ofserver/decision-log.ts:81-120.Run; expect PASS.
Commit
feat(profile): append-only profile version log.
Task 4: Wire the endpoints
Files:
- Modify:
server/index.ts(near the existing/api/bots/:id/skillsblock at:4187) - Test:
server/index.test.ts
Interfaces:
Produces:
GET /api/bots/:id/profile→{ profile };PUT /api/bots/:id/profile→{ profile, changed };GET /api/bots/:id/profile/versions?limit=→{ versions };POST /api/bots/:id/profile/rollback{ at }→{ profile, changed }.Write a failing API test:
GETreturns the assembled document;PUTwith{ engine: { model } }changes it and a subsequentGETreflects it.Write a failing API test that
PUTwrites exactly one version row, and that aPUTwhich changes nothing writes none — a no-op edit must not pollute the history.Write a failing API test for rollback: change the model twice, roll back to the first timestamp, and assert the model is restored, a new row is appended with
actor: "rollback", and the intervening rows are still present. Rollback moves forward through history; it never rewrites it.Write a failing API test that rollback to an unknown timestamp returns 404 and changes nothing.
Write a failing test that an unknown bot id returns 404 on all four routes.
Run
pnpm vitest run server/index.test.ts; expect FAIL.Implement the four routes, calling
appendProfileVersiononly on{ ok: true, changed: [...] }with a non-emptychanged. Rollback reads the versions, replays thebeforeside of every row newer thanatin reverse, and applies the result throughapplyProfileso it passes the same validation as a human edit.Run; expect PASS.
Commit
feat(profile): profile, history, and rollback endpoints.
Task 5: Single-bot export and clone
Files:
- Modify:
server/package-export.ts:27(createBotPackageExport),server/package-export.test.ts - Modify:
server/index.ts - Test:
server/index.test.ts
Interfaces:
Produces:
createBotPackageExport({ name, authorName, bots, groups, routines })unchanged in signature — the caller now passes a subset ofstore.bots. AddPOST /api/bots/:id/export→{ name, markdown }andPOST /api/bots/:id/clone→{ bot }.Write a failing test in
server/package-export.test.ts: exporting a single bot from a three-bot workspace produces a package with one agent, carries that bot's playbooks and routines, and omits rooms whose other members are not in the subset — a room with one member is not a room.Write a failing test that the single-bot export carries skills by reference (
name,sourceURL,sha256) and never by content, and carries no memory at all. This is the deliberate line: a shared persona travels with its procedures and a verifiable pointer to its skills; its accumulated private notes stay home. Assert a planted sentinel fromMEMORY.mddoes not appear in the markdown.Write a failing test that the export carries no
budgetUsd, noalwaysAllow, nocwd, and no engine binding, consistent with the existing export contract.Write a failing API test for clone: cloning a bot produces a new bot with a new id, a fresh empty workspace, the same playbooks and identity, skills present but disabled, routines present but paused (via
routines.disableForBot(botId),server/routines.ts:292), andcomposio: false. A clone starts inert for the same reason an import does.Run both suites; expect FAIL.
Implement.
createBotPackageExportalready filtersbotsand maps rooms throughidToKey; verify the room filter drops rooms with fewer than two resolvable members and add it if not. Clone goes throughapplyProfileso it cannot produce a bot that a human edit could not.Run; expect PASS.
Commit
feat(profile): export and clone one bot.
Task 6: The history UI
Files:
Create:
src/components/ProfileHistory.tsx,src/components/ProfileHistory.test.tsModify: the bot profile editor in
src/components/SettingsModal.tsxWrite a failing test for the pure formatter:
describeChange("engine.model", "claude-opus-5", "claude-sonnet-5")rendersModel · claude-opus-5 → claude-sonnet-5; an added value renders— → value; a cleared value rendersvalue → —; an unknown dotted path falls back to the raw path rather than throwing.Run; expect FAIL.
Implement
describeChangeand the list: newest first, actor and timestamp per row, the changed paths rendered through the formatter, and a "Restore this version" action per row that calls the rollback endpoint.The restore action confirms first, naming what will change — rollback is reversible (it appends rather than rewrites) but it is still a change a person should see coming.
Add an Export and a Duplicate action to the same panel, wired to Task 5's routes. Export hands back markdown; state in the copy that it carries no credentials, conversations, or memory.
Run the focused test,
pnpm typecheck,pnpm check:contrast.Commit
feat(profile): profile history, restore, export, and duplicate UI.
Self-review
Coverage. The roadmap's P2 asks for one addressable object (Tasks 1–2), version history with diff and rollback (Tasks 3–4, 6), and single-bot export/clone (Task 5). All covered.
Type consistency. BotProfileDocument is defined in Task 1 and consumed unchanged
in Tasks 2, 3, 4. ProfileApplyResult.changed (Task 2) is the same string[] that
ProfileVersionRow.changed (Task 3) stores and describeChange (Task 6) renders.
readProfile/applyProfile/appendProfileVersion/readProfileVersions are the only
four functions crossing module boundaries.
The one judgement call worth flagging. Task 5 exports skills by reference and memory not at all. That is a narrower reading of "the employee retains its experience" than the community proposal implies — someone importing a shared persona gets its procedures and a hash-pinned pointer to its skills, but none of what it learned at the previous desk. The alternative, shipping memory in packages, turns every shared bot into an exfiltration path for whatever it wrote down. If the tradeoff should go the other way, it should go there deliberately, as an explicit opt-in with a diff shown before export — not as a default.