Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

A bot with no MCP server on another computer never asks the lending gate

milind-soni9289d737e155
diff --git a/server/lent-mcp.test.ts b/server/lent-mcp.test.ts
index a56c80467d..8e12202f53 100644
--- a/server/lent-mcp.test.ts
+++ b/server/lent-mcp.test.ts
@@ -104,6 +104,15 @@ describe("a server that runs on the person's computer, in a turn", () => {
expect(say({})).toEqual([["local"], { notes: "notes starts a program on your Mac (Ada's Mac), which doesn't let My Cloud run programs right now: turn on \"Let Clouds run commands on this Mac\" from the OpenMausBot icon on that Mac." }]);
});
+ it("a bot with no server on another computer costs its turn nothing: the lending gate isn't asked", () => {
+ const asked = vi.fn(() => "cloud-home");
+ const lent = createLentMcp({ cfg: () => ({ mcpServers: { web: { type: "http", url: "https://mcp.example.com/mcp", headers: {}, enabled: true } } }), computers: { runsOn: vi.fn(), mcpLenders: vi.fn(), request: vi.fn() } as unknown as LentMcpDeps["computers"],
+ policy: (servers) => servers, bot: () => ({ id: "kiwi" }), principal: asked, notice: vi.fn(), refusal: vi.fn(), mint: vi.fn(), active: () => true, origin: "http://127.0.0.1:1", personal: true, place: "My Cloud" });
+ expect(lent.mounts({ id: "kiwi" }, TURN)).toEqual({});
+ expect(lent.lines({ id: "kiwi" }, TURN)).toEqual(new Map());
+ expect(asked).not.toHaveBeenCalled();
+ });
+
it("mounts nothing for a turn that can't use the lent computer, and says why", () => {
const { lent, minted } = fixture({ principal: null });
expect(lent.mounts({ id: "kiwi" }, TURN)).toEqual({});
diff --git a/server/lent-mcp.ts b/server/lent-mcp.ts
index c2385b42ea..af6ea951be 100644
--- a/server/lent-mcp.ts
+++ b/server/lent-mcp.ts
@@ -218,11 +218,12 @@ export function createLentMcp(deps: LentMcpDeps) {
/** A turn's servers that run on a lent computer it may use now, as servers at this server's address. One it can't
* reach is left out, and lines() says why. */
mounts(bot: Bot, turn: Turn): Record<string, McpServerSpec> {
- const principal = deps.principal(turn);
+ const elsewhere = Object.entries(servers(bot));
+ const principal = elsewhere.length ? deps.principal(turn) : null;
if (!principal) return {};
const mounted: Record<string, McpServerSpec> = {};
let token: string | null = null;
- for (const [name, server] of Object.entries(servers(bot))) {
+ for (const [name, server] of elsewhere) {
const state = lentState(deps.computers, principal, server);
if (state.kind !== "ready") continue;
token ??= deps.mint(turn);
@@ -234,9 +235,10 @@ export function createLentMcp(deps: LentMcpDeps) {
/** What the bot is told about each of its servers that runs elsewhere and that its turn can't reach now, by name. */
lines(bot: Bot, turn: Turn): Map<string, string> {
- const principal = deps.principal(turn);
+ const elsewhere = Object.entries(servers(bot));
+ const principal = elsewhere.length ? deps.principal(turn) : null;
const said = new Map<string, string>();
- for (const [name, server] of Object.entries(servers(bot))) {
+ for (const [name, server] of elsewhere) {
const state = lentState(deps.computers, principal, server);
if (state.kind === "ready") continue;
const refusal = principal ? null : deps.notice(turn);