Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Refuse a server that needs the person's computer when none is lent
aivsomkara1e4c605af4e
diff --git a/server/lent-mcp.test.ts b/server/lent-mcp.test.tsindex 8e12202f53..aaee184a2f 100644--- a/server/lent-mcp.test.ts+++ b/server/lent-mcp.test.ts@@ -200,7 +200,16 @@ describe("Test, and adding a server that needs the person's computer", () => {expect(await one.lent.place(address, { principal: null }), "a team Cloud, or a turn that can't use the computer").toEqual({ ok: true, server: address });const kept = { ...address, runsOn: { environmentId: "22222222-2222-4222-8222-222222222222", label: "Studio" } };expect(await one.lent.place(kept, { principal: "cloud-home" })).toEqual({ ok: true, server: kept });- expect(await fixture().lent.place(address, { principal: "cloud-home" }), "nothing lent now: it stays as added").toEqual({ ok: true, server: address });+ });++ it("with no computer lent, refuses a server that needs one and still saves one My Cloud answers", async () => {+ const none = fixture();+ expect(await none.lent.place(address, { principal: "cloud-home" })).toEqual({ ok: false, error: "That address is on the person's own computer, and no computer is lent to My Cloud now. Ask them to lend their Mac or PC, then add it again." });+ const command = { command: "notes-mcp", args: [], env: {}, enabled: true };+ const missing = fixture({ here: here({ program: () => false }) });+ expect(await missing.lent.place(command, { principal: "cloud-home" })).toEqual({ ok: false, error: "This command runs on the person's own computer, and no computer is lent to My Cloud now. Ask them to lend their Mac or PC with its terminal, then add it again." });+ const answered = fixture({ here: here({ answers: async () => true }) });+ expect(await answered.lent.place(address, { principal: "cloud-home" })).toEqual({ ok: true, server: address });});it("with several lent: the one named, else the one the adder is on, else the newest for the person, else the bot asks", async () => {diff --git a/server/lent-mcp.ts b/server/lent-mcp.tsindex af6ea951be..8f61212ee2 100644--- a/server/lent-mcp.ts+++ b/server/lent-mcp.ts@@ -276,7 +276,10 @@ export function createLentMcp(deps: LentMcpDeps) {async place(server: StoredMcpServer, who: { principal: string | null; session?: string; computer?: string; newest?: boolean }): Promise<{ ok: true; server: StoredMcpServer } | { ok: false; error: string }> {if (server.runsOn || !who.principal) return { ok: true, server };const lenders = deps.computers.mcpLenders(who.principal);- if (!lenders.length || !(await needsTheirComputer(server, here))) return { ok: true, server };+ if (!(await needsTheirComputer(server, here))) return { ok: true, server };+ if (!lenders.length) {+ return { ok: false, error: `${isRemoteMcpServer(server) ? "That address is" : "This command runs"} on the person's own computer, and no computer is lent to ${deps.place} now. Ask them to lend their Mac or PC${isRemoteMcpServer(server) ? "" : " with its terminal"}, then add it again.` };+ }const asked = who.computer?.trim().toLowerCase();const named = asked ? lenders.find((lender) => lender.name.toLowerCase() === asked) : undefined;const names = lenders.map((lender) => lender.name).join(", ");