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
feat(cyclops): guide first claim workload (#7784)
Francesco Bonaccif63ff1686d67
diff --git a/libs/fleet/e2e/detail-shell.spec.ts b/libs/fleet/e2e/detail-shell.spec.tsindex dadc6fb4b2..5ab48f0899 100644--- a/libs/fleet/e2e/detail-shell.spec.ts+++ b/libs/fleet/e2e/detail-shell.spec.ts@@ -4,6 +4,7 @@ import {mockClaimsApi,mockInstancesApi,mockNamespacesApi,+ type MockPoolService,mockPoolsApi,mockSignedServiceUrlsApi,} from "./fixtures/mock-api"@@ -14,16 +15,68 @@ async function mockFleet(initialSignedUrls: Parameters<typeof mockSignedServiceUrlsApi>[1] = [],signedUrlOptions: Parameters<typeof mockSignedServiceUrlsApi>[2] = {},claimOptions: Parameters<typeof mockClaimsApi>[1] = {},+ poolServices?: MockPoolService[],) {await mockAuth(page)await mockNamespacesApi(page)- await mockPoolsApi(page)+ await mockPoolsApi(page, poolServices)await mockInstancesApi(page)const claims = await mockClaimsApi(page, claimOptions)const signedUrls = await mockSignedServiceUrlsApi(page, initialSignedUrls, signedUrlOptions)return { ...signedUrls, claims }}+test("bound claim provides a copyable first workload for the existing claim", async ({ page }) => {+ await mockFleet(+ page,+ [],+ {},+ {},+ [+ { name: "mcp", targetPort: 8080, protocol: "TCP" },+ { name: "server", targetPort: 8000, protocol: "TCP" },+ ],+ )+ await page.goto("/pools/demo-pool/demo-pool/claims/claim-abc123")++ await expect(page.getByRole("heading", { name: "Run your first workload" })).toBeVisible()+ const snippet = page.locator("pre").filter({ hasText: '"claim": "claim-abc123"' })+ await expect(snippet).toContainText('"namespace": "demo-pool"')+ await expect(snippet).toContainText('"pool": "demo-pool"')+ await expect(snippet).toContainText('"service": "server"')+ await expect(snippet).toContainText('sandbox.shell.run("uname -sr", timeout=30)')+ await expect(page.getByRole("button", { name: "Copy first workload Python code" })).toBeVisible()+ const apiKeyLink = page.getByRole("link", { name: "API key Opens in a new tab" })+ await expect(apiKeyLink).toHaveAttribute("href", "#/user-keys")+ await expect(apiKeyLink).toHaveAttribute("target", "_blank")+})++test("pending claim does not show runnable first workload code", async ({ page }) => {+ await mockFleet(page, [], {}, {+ claims: [{ name: "claim-pending", phase: "Pending" }],+ })+ await page.goto("/pools/demo-pool/demo-pool/claims/claim-pending")++ await expect(page.getByRole("heading", { name: "Run your first workload" })).toHaveCount(0)+ await expect(page.getByRole("button", { name: "Copy first workload Python code" })).toHaveCount(0)+})++test("bound claim explains when its pool lacks the server service", async ({ page }) => {+ await mockFleet(+ page,+ [],+ {},+ {},+ [{ name: "mcp", targetPort: 8080, protocol: "TCP" }],+ )+ await page.goto("/pools/demo-pool/demo-pool/claims/claim-abc123")++ await expect(page.getByRole("heading", { name: "Run your first workload" })).toBeVisible()+ await expect(page.getByText("This pool does not expose the server service")).toBeVisible()+ await expect(page.getByText(/This claim currently exposes: mcp/)).toBeVisible()+ await expect(page.getByRole("button", { name: "Copy first workload Python code" })).toHaveCount(0)+})+for (const viewport of [{ name: "desktop", width: 1440, height: 900 },{ name: "mobile", width: 375, height: 900 },diff --git a/libs/fleet/e2e/fixtures/mock-api.ts b/libs/fleet/e2e/fixtures/mock-api.tsindex ec8ae9d77d..c2fb93fec9 100644--- a/libs/fleet/e2e/fixtures/mock-api.ts+++ b/libs/fleet/e2e/fixtures/mock-api.ts@@ -636,7 +636,18 @@ export async function mockGitHubTrustPoliciesApi(// Pools API mocking (K8s CRD via kubectl-proxy sidecar)// ----------------------------------------------------------------------------export async function mockPoolsApi(page: Page): Promise<void> {+export interface MockPoolService {+ name: string;+ targetPort: number;+ protocol: string;+}++export async function mockPoolsApi(+ page: Page,+ services: MockPoolService[] = [+ { name: "mcp", targetPort: 8080, protocol: "TCP" },+ ],+): Promise<void> {const pool = {apiVersion: "osgym.cua.ai/v1alpha1",kind: "OSGymSandboxWarmPool",@@ -657,7 +668,7 @@ export async function mockPoolsApi(page: Page): Promise<void> {containerDiskImage: "test-image:latest",cpuCores: 4,memory: "4Gi",- services: [{ name: "mcp", targetPort: 8080, protocol: "TCP" }],+ services,},},};diff --git a/libs/fleet/src/components/FirstWorkloadGuide.tsx b/libs/fleet/src/components/FirstWorkloadGuide.tsxnew file mode 100644index 0000000000..5d2a375319--- /dev/null+++ b/libs/fleet/src/components/FirstWorkloadGuide.tsx@@ -0,0 +1,132 @@+import Alert from "@cloudscape-design/components/alert"+import Box from "@cloudscape-design/components/box"+import Container from "@cloudscape-design/components/container"+import CopyToClipboard from "@cloudscape-design/components/copy-to-clipboard"+import Header from "@cloudscape-design/components/header"+import Link from "@cloudscape-design/components/link"+import SpaceBetween from "@cloudscape-design/components/space-between"+import type { PoolService } from "../fleet/models"++const PYTHON_PACKAGE = "cua-sandbox==0.7.0"++export function firstWorkloadScript({+ namespace,+ pool,+ claim,+}: {+ namespace: string+ pool: string+ claim: string+}) {+ const reference = JSON.stringify(+ {+ version: 1,+ provider: "fleet",+ namespace,+ pool,+ claim,+ service: "server",+ },+ null,+ 4,+ )++ return `import asyncio+from cua_sandbox import Sandbox++reference = ${reference}++async def main():+ async with Sandbox.from_dict(reference) as sandbox:+ result = await sandbox.shell.run("uname -sr", timeout=30)+ if result.returncode != 0:+ raise RuntimeError(result.stderr or "Workload failed")+ output = result.stdout.strip()+ if not output:+ raise RuntimeError("Workload returned no output")+ print(output)++asyncio.run(main())`+}++export function FirstWorkloadGuide({+ namespace,+ pool,+ claim,+ services,+}: {+ namespace: string+ pool: string+ claim: string+ services: PoolService[]+}) {+ const hasServer = services.some(service => service.name === "server")++ if (!hasServer) {+ return (+ <Container+ header={+ <Header+ variant="h2"+ description="Connect to this claim and run a command in its sandbox."+ >+ Run your first workload+ </Header>+ }+ >+ <Alert type="warning" header="This pool does not expose the server service">+ Add a service named <code>server</code> to the pool configuration before+ connecting with the Sandbox SDK. This claim currently exposes: {services.length > 0+ ? services.map(service => service.name).join(", ")+ : "no services"}.+ </Alert>+ </Container>+ )+ }++ const script = firstWorkloadScript({ namespace, pool, claim })++ return (+ <Container+ header={+ <Header+ variant="h2"+ description="Connect to this existing claim and run a real command in its sandbox."+ >+ Run your first workload+ </Header>+ }+ >+ <SpaceBetween size="m">+ {/* Preserve the claim-specific instructions while credentials are created. */}+ <Box>+ 1. Create an <Link href="#/user-keys" external externalIconAriaLabel="Opens in a new tab">API key</Link> with access to{" "}+ <code>{namespace}</code>, then set its values as <code>CUA_CLIENT_ID</code>{" "}+ and <code>CUA_CLIENT_SECRET</code> in your environment.+ </Box>+ <Box>+ 2. Install the SDK: <code>pip install {PYTHON_PACKAGE}</code>+ </Box>+ <Box>+ 3. Save and run this Python code. The claim details are already filled in.+ </Box>+ <Box variant="code" padding="m">+ <pre style={{ margin: 0, whiteSpace: "pre-wrap", overflowWrap: "anywhere" }}>+ {script}+ </pre>+ </Box>+ <CopyToClipboard+ variant="button"+ copyButtonText="Copy Python code"+ copyButtonAriaLabel="Copy first workload Python code"+ textToCopy={script}+ copySuccessText="Python code copied"+ copyErrorText="Failed to copy Python code"+ />+ <Alert type="success">+ When the command prints an operating system name, your first workload has completed.+ </Alert>+ </SpaceBetween>+ </Container>+ )+}diff --git a/libs/fleet/src/pages/ClaimDetail.tsx b/libs/fleet/src/pages/ClaimDetail.tsxindex df433f75b9..e45352b8a9 100644--- a/libs/fleet/src/pages/ClaimDetail.tsx+++ b/libs/fleet/src/pages/ClaimDetail.tsx@@ -10,6 +10,7 @@ import SpaceBetween from "@cloudscape-design/components/space-between"import StatusIndicator from "@cloudscape-design/components/status-indicator"import { useFlash } from "../components/FlashContext"import { DesktopPane } from "../components/DesktopPane"+import { FirstWorkloadGuide } from "../components/FirstWorkloadGuide"import { deleteClaim, getClaim } from "../fleet/claims"import type { Claim, PoolService } from "../fleet/models"import { getPool } from "../fleet/pools"@@ -219,6 +220,15 @@ function ClaimDetailContent({</ColumnLayout></Container>+ {isBound && (+ <FirstWorkloadGuide+ namespace={namespace}+ pool={poolName}+ claim={claimName}+ services={services}+ />+ )}+{isBound && sandboxName && services.some(s => s.name === "vnc") && (<Containerheader={