Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
// SPDX-License-Identifier: FSL-1.1-MIT
// Copyright (c) 2026 Cua AI, Inc.
/**
* The demo host's sharing: who each Space is shared with, in memory. The
* daemon's presence prompt is a short wait here; nothing reaches a relay.
*/
import type { ShareEntry } from "../../contracts/share";
import type { ShareHandlers } from "../../ops/share";
export function demoShares(): Map<string, ShareEntry[]> {
return new Map([
["local:design-review", [{ who: "[email protected]", role: "editor", connected: true }]],
// The Space with a thread (`demo/thread.ts`): the people in it.
[
"relay:linux-box/ubuntu-build",
[
{ who: "[email protected]", role: "editor", connected: true },
{ who: "[email protected]", role: "viewer", connected: false },
],
],
]);
}
export function demoShareHandlers({ wait, stepMs, teamFull }: { wait(ms: number): Promise<void>; stepMs: number; teamFull?: boolean }): ShareHandlers {
const shares = demoShares();
const list = (spaceId: string) => (shares.get(spaceId) ?? []).map((s) => ({ ...s }));
return {
"sharing.list": async ({ spaceId }) => list(spaceId),
"sharing.share": async ({ spaceId, who, role }) => {
// `?demo=team-full`: the owner's refusal when a team has a computer per seat.
if (teamFull && who.startsWith("team:")) throw new Error("Your team has as many computers as it has seats. https://app.cua.ai/buy/teams");
// The daemon asks for presence before the relay hears of it.
await wait(stepMs);
const rest = (shares.get(spaceId) ?? []).filter((s) => s.who !== who);
const was = shares.get(spaceId)?.find((s) => s.who === who);
shares.set(spaceId, [...rest, { who, role, connected: was?.connected ?? false }]);
return list(spaceId);
},
"sharing.removals": async () => [],
"sharing.ackRemovals": async () => null,
"sharing.unshare": async ({ spaceId, who }) => {
shares.set(
spaceId,
(shares.get(spaceId) ?? []).filter((s) => s.who !== who),
);
return list(spaceId);
},
};
}