Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(cyclops-cs): run Fleets sandboxes with GitHub WIF (#6687)

r33drichardscfcd68869fc8
diff --git a/libs/fleet/e2e/settings.spec.ts b/libs/fleet/e2e/settings.spec.ts
index 8a42aaf6fc..a68c13c87c 100644
--- a/libs/fleet/e2e/settings.spec.ts
+++ b/libs/fleet/e2e/settings.spec.ts
@@ -29,21 +29,59 @@ test.describe("Settings GitHub trust policies", () => {
const workflowSnippet = page.locator("pre").filter({
hasText: "Get GitHub WIF token for Fleets",
})
- await expect(workflowSnippet).toContainText("pip install cua-cli==0.1.13")
+ await expect(workflowSnippet).toContainText(
+ "pip install cua-cli==0.1.14 --extra-index-url https://wheels.cua.ai/simple",
+ )
await expect(workflowSnippet).toContainText('token="$(cua wif-token github)"')
+ await expect(workflowSnippet).toContainText('echo "::add-mask::$token"')
await expect(workflowSnippet).toContainText(
'printf \'token=%s\\n\' "$token" >> "$GITHUB_OUTPUT"',
)
- await expect(workflowSnippet).toContainText("curl --fail-with-body -sSL")
await expect(workflowSnippet).toContainText(
- "https://run.cua.ai/api/namespaces",
+ 'sandbox="replace-with-an-authorized-namespace"',
+ )
+ await expect(workflowSnippet).toContainText(
+ "This exact value is authorized by the repository trust policy.",
)
await expect(workflowSnippet).toContainText("FLEETS_TOKEN")
await expect(workflowSnippet).toContainText("Get GitHub WIF token for Fleets")
+ await expect(workflowSnippet).toContainText("status=$?")
+ await expect(workflowSnippet).toContainText("trap cleanup EXIT")
+ await expect(workflowSnippet).toContainText(
+ 'cua sb delete --force "$sandbox"',
+ )
+ await expect(workflowSnippet).toContainText(
+ 'if [ "$status" -eq 0 ]; then status=1; fi',
+ )
+ await expect(workflowSnippet).toContainText('exit "$status"')
+ await expect(workflowSnippet).toContainText(
+ "296062593712.dkr.ecr.us-west-2.amazonaws.com/desktop-workspace:latest",
+ )
+ await expect(workflowSnippet).toContainText("cua sb launch")
+ await expect(workflowSnippet).toContainText('--name "$sandbox"')
+ await expect(workflowSnippet).toContainText(
+ "cua sb exec \"$sandbox\" sh -lc 'uname -a; id; pwd'",
+ )
+ await expect(workflowSnippet).not.toContainText("curl")
+ await expect(workflowSnippet).not.toContainText("/api/namespaces")
+ await expect(workflowSnippet).not.toContainText("--namespace")
await expect(workflowSnippet).not.toContainText(
"ACTIONS_ID_TOKEN_REQUEST_URL",
)
+ await expect(workflowSnippet).not.toContainText(
+ "ACTIONS_ID_TOKEN_REQUEST_TOKEN",
+ )
await expect(workflowSnippet).not.toContainText("CYCLOPS_CS_TOKEN")
+ await expect(workflowSnippet).not.toContainText("CYCLOPS_TOKEN")
+ await expect(workflowSnippet).not.toContainText("${GITHUB_RUN_ID}")
+ await expect(workflowSnippet).not.toContainText("${GITHUB_RUN_ATTEMPT}")
+
+ const workflowSnippetText = await workflowSnippet.textContent()
+ expect(
+ workflowSnippetText?.match(
+ /sandbox="replace-with-an-authorized-namespace"/g,
+ ) ?? [],
+ ).toHaveLength(1)
})
test("shows GitHub WIF below payment method in a collapsed section", async ({
@@ -64,7 +102,10 @@ test.describe("Settings GitHub trust policies", () => {
await page.goto("/settings")
- const paymentHeading = page.getByRole("heading", { name: "Payment method" })
+ const paymentHeading = page.getByRole("heading", {
+ name: "Payment method",
+ exact: true,
+ })
const githubToggle = page.getByRole("button", {
name: "GitHub Actions OIDC",
})
diff --git a/libs/fleet/src/pages/Settings.tsx b/libs/fleet/src/pages/Settings.tsx
index b40a6a987c..e374348d23 100644
--- a/libs/fleet/src/pages/Settings.tsx
+++ b/libs/fleet/src/pages/Settings.tsx
@@ -174,21 +174,36 @@ steps:
python-version: "3.12"
- name: Install Cua CLI
- run: pip install cua-cli==0.1.13
+ run: pip install cua-cli==0.1.14 --extra-index-url https://wheels.cua.ai/simple
- name: Get GitHub WIF token for Fleets
id: fleets-token
run: |
token="$(cua wif-token github)"
+ echo "::add-mask::$token"
printf 'token=%s\\n' "$token" >> "$GITHUB_OUTPUT"
- - name: Call Fleets
+ - name: Create and use an authorized Fleets sandbox
env:
FLEETS_TOKEN: \${{ steps.fleets-token.outputs.token }}
run: |
- curl --fail-with-body -sSL https://run.cua.ai/api/namespaces \\
- -H "Authorization: Bearer $FLEETS_TOKEN"`
+ set -euo pipefail
+ # This exact value is authorized by the repository trust policy.
+ # Cleanup releases this claim; its pool, template, and namespace persist.
+ sandbox="replace-with-an-authorized-namespace"
+ cleanup() {
+ status=$?
+ if ! cua sb delete --force "$sandbox"; then
+ if [ "$status" -eq 0 ]; then status=1; fi
+ fi
+ exit "$status"
+ }
+ trap cleanup EXIT
+ cua sb launch \\
+ 296062593712.dkr.ecr.us-west-2.amazonaws.com/desktop-workspace:latest \\
+ --name "$sandbox"
+ cua sb exec "$sandbox" sh -lc 'uname -a; id; pwd'`
return (
<SpaceBetween size="l">
{error && (