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): show warm pool instances (#7163)

r33drichardsaaa2dbc6aae0
diff --git a/libs/fleet/backend/auth/authz_k8s.rego b/libs/fleet/backend/auth/authz_k8s.rego
index 60d8be27cf..542ab7a232 100644
--- a/libs/fleet/backend/auth/authz_k8s.rego
+++ b/libs/fleet/backend/auth/authz_k8s.rego
@@ -166,12 +166,11 @@ is_event_k8s_path(path) {
# ── Fleet CRDs, native group ────────────────────────────────────────────────
#
-# apis/osgym.cua.ai/v1alpha1/namespaces/{ns}/{claims,warmpools,templates}
+# apis/osgym.cua.ai/v1alpha1/namespaces/{ns}/{claims,warmpools,templates,sandboxes}
#
# The resources this system exists to manage, and 99% of all observed traffic.
-# Attested by all four sources: the SDK builds exactly these paths, the GitHub
-# allowlist already names the same three, and production shows the full CRUD
-# matrix succeeding.
+# Claims, warm pools, and templates use the existing CRUD matrix. Sandboxes are
+# exposed separately as read-only instance state for the pool detail page.
native_fleet_resources := {
"osgymsandboxclaims",
"osgymsandboxwarmpools",
@@ -185,6 +184,16 @@ k8s_request_allowed {
fleet_crud_shape(parts)
}
+# Sandboxes are the instances behind a warm pool. The pool detail page lists
+# them to show both available and claim-owned capacity, but never mutates them.
+k8s_request_allowed {
+ parts := split(input.params.path, "/")
+ apis_namespaced_group(parts, "osgym.cua.ai", "v1alpha1")
+ parts[5] == "osgymsandboxes"
+ apis_read_shape(parts)
+ input.method == "GET"
+}
+
# ── Fleet CRDs, legacy group ────────────────────────────────────────────────
#
# apis/cua.ai/v1/namespaces/{ns}/osgymworkspacepools
diff --git a/libs/fleet/backend/auth/authz_k8s_test.rego b/libs/fleet/backend/auth/authz_k8s_test.rego
index c2782ca7cb..1740dc014f 100644
--- a/libs/fleet/backend/auth/authz_k8s_test.rego
+++ b/libs/fleet/backend/auth/authz_k8s_test.rego
@@ -721,9 +721,12 @@ test_core_writes_denied if {
not route_allow with input as spa_request("POST", "api/v1/namespaces/ns-a/persistentvolumeclaims")
}
-# Known group, unknown resource; and known resource, unknown verb.
+# Sandbox reads are customer-facing, but sandbox writes and unknown verbs stay
+# outside the allowlist.
test_unenumerated_resource_and_verb_denied if {
- not route_allow with input as spa_request("GET", "apis/osgym.cua.ai/v1alpha1/namespaces/ns-a/osgymsandboxes")
+ route_allow with input as spa_request("GET", "apis/osgym.cua.ai/v1alpha1/namespaces/ns-a/osgymsandboxes")
+ not route_allow with input as spa_request("POST", "apis/osgym.cua.ai/v1alpha1/namespaces/ns-a/osgymsandboxes")
+ not route_allow with input as spa_request("DELETE", "apis/osgym.cua.ai/v1alpha1/namespaces/ns-a/osgymsandboxes/sandbox-1")
not route_allow with input as spa_request("PUT", "apis/osgym.cua.ai/v1alpha1/namespaces/ns-a/osgymsandboxclaims/claim-1")
}
diff --git a/libs/fleet/backend/auth/policy_test.go b/libs/fleet/backend/auth/policy_test.go
index 4e467422d2..7c8fc73c8b 100644
--- a/libs/fleet/backend/auth/policy_test.go
+++ b/libs/fleet/backend/auth/policy_test.go
@@ -306,6 +306,8 @@ func TestK8sAllow_AllowlistVerdicts(t *testing.T) {
{"namespaced claims / non-admin", "apis/osgym.cua.ai/v1alpha1/namespaces/pool-foo/osgymsandboxclaims", false, true},
{"namespaced warm pools / non-admin", "apis/osgym.cua.ai/v1alpha1/namespaces/pool-foo/osgymsandboxwarmpools", false, true},
{"namespaced templates / non-admin", "apis/osgym.cua.ai/v1alpha1/namespaces/pool-foo/osgymsandboxtemplates", false, true},
+ {"namespaced sandboxes / non-admin", "apis/osgym.cua.ai/v1alpha1/namespaces/pool-foo/osgymsandboxes", false, true},
+ {"namespaced sandboxes / admin", "apis/osgym.cua.ai/v1alpha1/namespaces/pool-foo/osgymsandboxes", true, true},
// Unenumerated, and denied for that reason alone -- no exclusion list
// mentions any of them. The Secret read is the one a reviewer is most
@@ -314,7 +316,6 @@ func TestK8sAllow_AllowlistVerdicts(t *testing.T) {
{"namespaced secrets / non-admin", "api/v1/namespaces/pool-foo/secrets/ecr-credentials", false, false},
{"namespaced configmaps / non-admin", "api/v1/namespaces/pool-foo/configmaps", false, false},
{"storage classes / non-admin", "apis/storage.k8s.io/v1/storageclasses", false, false},
- {"sandboxes CRD / admin", "apis/osgym.cua.ai/v1alpha1/namespaces/pool-foo/osgymsandboxes", true, false},
// Events: denied for everyone, admins included. Unlike every infra path
// above, the admin row here is a deny too — that asymmetry is the whole
diff --git a/libs/fleet/e2e/detail-shell.spec.ts b/libs/fleet/e2e/detail-shell.spec.ts
index c3a305f8dd..830779047d 100644
--- a/libs/fleet/e2e/detail-shell.spec.ts
+++ b/libs/fleet/e2e/detail-shell.spec.ts
@@ -2,6 +2,7 @@ import { expect, test } from "@playwright/test"
import {
mockAuth,
mockClaimsApi,
+ mockInstancesApi,
mockNamespacesApi,
mockPoolsApi,
} from "./fixtures/mock-api"
@@ -11,6 +12,7 @@ async function mockFleet(page: Parameters<typeof mockAuth>[0]) {
await mockAuth(page)
await mockNamespacesApi(page)
await mockPoolsApi(page)
+ await mockInstancesApi(page)
await mockClaimsApi(page)
}
@@ -24,8 +26,7 @@ for (const viewport of [
await page.goto("/pools/demo-pool/demo-pool")
await expect(page.getByRole("heading", { name: "demo-pool", level: 1 })).toBeVisible()
- await expect(page.getByRole("heading", { name: "Overview" })).toBeVisible()
- await expect(page.getByRole("heading", { name: "Claims" })).toBeVisible()
+ await expect(page.getByRole("heading", { name: "Instances" })).toBeVisible()
await expectSharedPageShell(page)
})
diff --git a/libs/fleet/e2e/fixtures/mock-api.ts b/libs/fleet/e2e/fixtures/mock-api.ts
index 5540342637..58916bdeb7 100644
--- a/libs/fleet/e2e/fixtures/mock-api.ts
+++ b/libs/fleet/e2e/fixtures/mock-api.ts
@@ -677,6 +677,73 @@ export async function mockPoolsApi(page: Page): Promise<void> {
)
}
+// ---------------------------------------------------------------------------
+// Instances API mocking (OSGymSandbox CRD)
+// ---------------------------------------------------------------------------
+
+export async function mockInstancesApi(page: Page): Promise<void> {
+ await page.route(
+ "**/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/*/osgymsandboxes",
+ async route => {
+ await route.fulfill({
+ contentType: "application/json",
+ body: JSON.stringify({
+ items: [
+ {
+ apiVersion: "osgym.cua.ai/v1alpha1",
+ kind: "OSGymSandbox",
+ metadata: {
+ name: "vm-xyz789",
+ namespace: "demo-pool",
+ creationTimestamp: "2026-05-28T09:55:00Z",
+ annotations: {
+ "osgym.cua.ai/origin-warmpool": "demo-pool",
+ "osgym.cua.ai/origin-warmpool-namespace": "demo-pool",
+ },
+ ownerReferences: [
+ {
+ apiVersion: "osgym.cua.ai/v1alpha1",
+ kind: "OSGymSandboxClaim",
+ name: "claim-abc123",
+ uid: "claim-abc123-uid",
+ controller: true,
+ },
+ ],
+ },
+ status: { phase: "Ready", ready: true },
+ },
+ {
+ apiVersion: "osgym.cua.ai/v1alpha1",
+ kind: "OSGymSandbox",
+ metadata: {
+ name: "vm-ready456",
+ namespace: "demo-pool",
+ creationTimestamp: "2026-05-28T09:58:00Z",
+ labels: { "osgym.cua.ai/warmpool": "demo-pool" },
+ annotations: {
+ "osgym.cua.ai/origin-warmpool": "demo-pool",
+ "osgym.cua.ai/origin-warmpool-namespace": "demo-pool",
+ },
+ },
+ status: { phase: "Ready", ready: true },
+ },
+ {
+ apiVersion: "osgym.cua.ai/v1alpha1",
+ kind: "OSGymSandbox",
+ metadata: {
+ name: "other-pool-instance",
+ namespace: "demo-pool",
+ labels: { "osgym.cua.ai/warmpool": "other-pool" },
+ },
+ status: { phase: "Ready", ready: true },
+ },
+ ],
+ }),
+ })
+ },
+ )
+}
+
// ---------------------------------------------------------------------------
// Claims API mocking (OSGymSandboxClaim CRD)
// ---------------------------------------------------------------------------
diff --git a/libs/fleet/e2e/pools.spec.ts b/libs/fleet/e2e/pools.spec.ts
index bae8bb5f9d..fce962e2b4 100644
--- a/libs/fleet/e2e/pools.spec.ts
+++ b/libs/fleet/e2e/pools.spec.ts
@@ -1,6 +1,7 @@
import { test, expect } from "@playwright/test"
import {
mockAuth,
+ mockInstancesApi,
mockNamespacesApi,
mockPoolsApi,
mockClaimsApi,
@@ -277,7 +278,7 @@ test("local visual preview keeps preview data active on pool detail", async ({
page.getByRole("heading", { name: "prod-web-fleet" }),
).toBeVisible()
await expect(page.getByText("Failed to load pool")).toHaveCount(0)
- await expect(page.getByRole("heading", { name: "Claims" })).toBeVisible()
+ await expect(page.getByRole("heading", { name: "Instances" })).toBeVisible()
})
test.describe("Pool creation", () => {
@@ -431,11 +432,12 @@ test.describe("Pool duplication", () => {
})
})
-test.describe("Pool detail with claims", () => {
- test("pool detail page shows claims section", async ({ page }) => {
+test.describe("Pool detail instances", () => {
+ test("shows warm pool instances and claim state", async ({ page }) => {
await mockAuth(page)
await mockNamespacesApi(page)
await mockPoolsApi(page)
+ await mockInstancesApi(page)
await mockClaimsApi(page)
await page.goto("/pools/demo-pool/demo-pool")
@@ -443,8 +445,7 @@ test.describe("Pool detail with claims", () => {
// The pool name should be shown
await expect(page.getByRole("heading", { name: "demo-pool" })).toBeVisible()
- // The Claims section should be present
- await expect(page.getByRole("heading", { name: "Claims" })).toBeVisible()
+ await expect(page.getByRole("heading", { name: "Instances" })).toBeVisible()
// The "Create claim" button should be visible
await expect(
@@ -454,20 +455,26 @@ test.describe("Pool detail with claims", () => {
"border-radius",
"10px",
)
- await expect(page.getByRole("button", { name: "Refresh claims" })).toHaveCSS(
+ await expect(page.getByRole("button", { name: "Refresh instances" })).toHaveCSS(
"border-radius",
"10px",
)
- await expect(page.getByRole("button", { name: "Refresh claims" })).toHaveCSS(
+ await expect(page.getByRole("button", { name: "Refresh instances" })).toHaveCSS(
"width",
"40px",
)
- // The existing mock claim should be listed
- const claimRow = page.getByRole("row").filter({ hasText: "claim-abc123" })
- await expect(claimRow).toBeVisible()
- await expect(page.getByText("Bound")).toBeVisible()
- await expect(claimRow.getByRole("cell").nth(3)).not.toHaveText("-")
+ const claimedRow = page.getByRole("row").filter({ hasText: "vm-xyz789" })
+ await expect(claimedRow).toContainText("Ready")
+ await expect(claimedRow).toContainText("claim-abc123")
+ await expect(claimedRow).toContainText("Bound")
+ await expect(claimedRow.getByRole("button", { name: "Release" })).toBeVisible()
+
+ const availableRow = page.getByRole("row").filter({ hasText: "vm-ready456" })
+ await expect(availableRow).toContainText("Ready")
+ await expect(availableRow).toContainText("Unclaimed")
+ await expect(availableRow.getByRole("button", { name: "Release" })).toHaveCount(0)
+ await expect(page.getByText("other-pool-instance")).toHaveCount(0)
})
})
diff --git a/libs/fleet/src/pages/PoolDetail.tsx b/libs/fleet/src/pages/PoolDetail.tsx
index 2c45dd22a7..2eb18103b6 100644
--- a/libs/fleet/src/pages/PoolDetail.tsx
+++ b/libs/fleet/src/pages/PoolDetail.tsx
@@ -16,7 +16,8 @@ import Tabs from "@cloudscape-design/components/tabs"
import { useFlash } from "../components/FlashContext"
import { PoolStatusPill } from "../components/PoolStatus"
import { createClaim as createSdkClaim, deleteClaim, listClaims } from "../sdk/claims"
-import type { Claim, PoolData } from "../sdk/models"
+import { listPoolInstances } from "../sdk/instances"
+import type { Claim, PoolData, PoolInstance } from "../sdk/models"
import { deletePool, getPool, updatePoolServices } from "../sdk/pools"
import { derivePoolStatus, tombstonePool } from "../sdk/status"
import { CuaButton } from "../components/CuaButton"
@@ -123,25 +124,12 @@ export function PoolDetail() {
}
>
<SpaceBetween size="l">
- <Container header={<Header variant="h2">Overview</Header>}>
- <ColumnLayout columns={2} variant="text-grid">
- <div>
- <Box variant="awsui-key-label">Status</Box>
- <PoolStatusPill status={status} />
- </div>
- <div>
- <Box variant="awsui-key-label">Namespace</Box>
- <div>{pool.namespace}</div>
- </div>
- </ColumnLayout>
- </Container>
-
<Tabs
tabs={[
{
- label: "Claims",
- id: "claims",
- content: <ClaimsTable pool={pool} />,
+ label: "Instances",
+ id: "instances",
+ content: <InstancesTable pool={pool} />,
},
{
label: "Configuration",
@@ -407,7 +395,23 @@ function ServicesEditor({
)
}
-// ── Claims table ──────────────────────────────────────────────────────────
+// ── Instances table ───────────────────────────────────────────────────────
+
+function instanceStatusType(
+ phase: string,
+): "success" | "pending" | "error" | "info" {
+ switch (phase) {
+ case "Ready":
+ return "success"
+ case "Pending":
+ case "Resetting":
+ return "pending"
+ case "Terminating":
+ return "error"
+ default:
+ return "info"
+ }
+}
function claimStatusType(phase: string): "success" | "pending" | "error" | "info" {
switch (phase) {
@@ -435,9 +439,14 @@ function age(iso: string): string {
return `${Math.floor(hrs / 24)}d`
}
-function ClaimsTable({ pool }: { pool: PoolData }) {
+interface InstanceRow extends PoolInstance {
+ claim?: Claim
+}
+
+function InstancesTable({ pool }: { pool: PoolData }) {
const navigate = useNavigate()
const flash = useFlash()
+ const [instances, setInstances] = useState<PoolInstance[]>([])
const [claims, setClaims] = useState<Claim[]>([])
const [loading, setLoading] = useState(true)
const [showCreate, setShowCreate] = useState(false)
@@ -448,26 +457,30 @@ function ClaimsTable({ pool }: { pool: PoolData }) {
// Pool name = namespace name (1:1 mapping).
const claimNamespace = pool.namespace
- const loadClaims = useCallback(async () => {
+ const loadInstances = useCallback(async () => {
try {
- const list = await listClaims(claimNamespace)
- setClaims(list)
+ const [instanceList, claimList] = await Promise.all([
+ listPoolInstances(claimNamespace, pool.name),
+ listClaims(claimNamespace),
+ ])
+ setInstances(instanceList)
+ setClaims(claimList)
} catch {
// Silently ignore polling errors — the table will show stale data
// until the next successful poll.
} finally {
setLoading(false)
}
- }, [claimNamespace])
+ }, [claimNamespace, pool.name])
// Initial load + 5-second auto-refresh.
useEffect(() => {
- loadClaims()
- timerRef.current = setInterval(loadClaims, 5000)
+ loadInstances()
+ timerRef.current = setInterval(loadInstances, 5000)
return () => {
if (timerRef.current) clearInterval(timerRef.current)
}
- }, [loadClaims])
+ }, [loadInstances])
const createClaim = async () => {
setCreating(true)
@@ -475,7 +488,7 @@ function ClaimsTable({ pool }: { pool: PoolData }) {
const claim = await createSdkClaim(claimNamespace, pool.name)
flash.push({ type: "success", header: `Created claim ${claim.name}` })
setShowCreate(false)
- await loadClaims()
+ await loadInstances()
} catch (e) {
flash.push({
type: "error",
@@ -493,7 +506,7 @@ function ClaimsTable({ pool }: { pool: PoolData }) {
await deleteClaim(claimNamespace, claimName)
flash.push({ type: "success", header: `Released claim ${claimName}` })
setConfirmRelease(null)
- await loadClaims()
+ await loadInstances()
} catch (e) {
flash.push({
type: "error",
@@ -505,22 +518,35 @@ function ClaimsTable({ pool }: { pool: PoolData }) {
}
}
+ const claimsByName = new Map(claims.map(claim => [claim.name, claim]))
+ const claimsBySandbox = new Map(
+ claims
+ .filter(claim => claim.sandboxName)
+ .map(claim => [claim.sandboxName as string, claim]),
+ )
+ const rows: InstanceRow[] = instances.map(instance => ({
+ ...instance,
+ claim:
+ (instance.claimName && claimsByName.get(instance.claimName)) ||
+ claimsBySandbox.get(instance.name),
+ }))
+
return (
<>
<Table
loading={loading}
- items={claims}
+ items={rows}
header={
<Header
variant="h2"
- counter={`(${claims.length})`}
+ counter={`(${rows.length})`}
actions={
<SpaceBetween direction="horizontal" size="xs">
<CuaButton
tone="icon"
- ariaLabel="Refresh claims"
+ ariaLabel="Refresh instances"
iconName="refresh"
- onClick={loadClaims}
+ onClick={loadInstances}
/>
<CuaButton tone="primary" onClick={() => setShowCreate(true)}>
Create claim
@@ -528,62 +554,88 @@ function ClaimsTable({ pool }: { pool: PoolData }) {
</SpaceBetween>
}
>
- Claims
+ Instances
</Header>
}
columnDefinitions={[
{
id: "name",
header: "Name",
- cell: (c: Claim) => (
- <Link
- href={`#/pools/${pool.namespace}/${pool.name}/claims/${c.name}`}
- onFollow={e => {
- e.preventDefault()
- navigate(`/pools/${pool.namespace}/${pool.name}/claims/${c.name}`)
- }}
- >
- {c.name}
- </Link>
- ),
+ cell: (instance: InstanceRow) => instance.name,
sortingField: "name",
},
{
- id: "status",
- header: "Status",
- cell: (c: Claim) => (
- <StatusIndicator type={claimStatusType(c.phase)}>
- {c.phase}
+ id: "instanceStatus",
+ header: "Instance status",
+ cell: (instance: InstanceRow) => (
+ <StatusIndicator type={instanceStatusType(instance.phase)}>
+ {instance.phase}
</StatusIndicator>
),
sortingField: "phase",
},
{
- id: "sandbox",
- header: "VM Name",
- cell: (c: Claim) => c.sandboxName ?? "-",
+ id: "claim",
+ header: "Claim",
+ cell: (instance: InstanceRow) => {
+ const claimName = instance.claim?.name ?? instance.claimName
+ if (!claimName) return "-"
+ return (
+ <Link
+ href={`#/pools/${pool.namespace}/${pool.name}/claims/${claimName}`}
+ onFollow={event => {
+ event.preventDefault()
+ navigate(
+ `/pools/${pool.namespace}/${pool.name}/claims/${claimName}`,
+ )
+ }}
+ >
+ {claimName}
+ </Link>
+ )
+ },
+ },
+ {
+ id: "claimStatus",
+ header: "Claim status",
+ cell: (instance: InstanceRow) => {
+ const claimName = instance.claim?.name ?? instance.claimName
+ const phase =
+ instance.claim?.phase ?? (claimName ? "Claimed" : "Unclaimed")
+ return (
+ <StatusIndicator
+ type={claimName ? claimStatusType(phase) : "stopped"}
+ >
+ {phase}
+ </StatusIndicator>
+ )
+ },
},
{
id: "age",
header: "Age",
- cell: (c: Claim) => age(c.createdAt),
+ cell: (instance: InstanceRow) => age(instance.createdAt),
},
{
id: "actions",
header: "Actions",
- cell: (c: Claim) => (
- <Button
- variant="inline-link"
- onClick={() => setConfirmRelease(c.name)}
- >
- Release
- </Button>
- ),
+ cell: (instance: InstanceRow) => {
+ const claimName = instance.claim?.name ?? instance.claimName
+ if (!claimName) return "-"
+ return (
+ <Button
+ variant="inline-link"
+ onClick={() => setConfirmRelease(claimName)}
+ >
+ Release
+ </Button>
+ )
+ },
},
]}
empty={
<Box textAlign="center" color="text-status-inactive" padding="l">
- No claims. Create one to get a VM from this pool.
+ No instances are currently registered for this pool.
</Box>
}
/>
diff --git a/libs/fleet/src/sdk/instances.ts b/libs/fleet/src/sdk/instances.ts
new file mode 100644
index 0000000000..62c7ad17af
--- /dev/null
+++ b/libs/fleet/src/sdk/instances.ts
@@ -0,0 +1,88 @@
+import { getToken } from "../auth/keycloak"
+import { isLocalVisualPreview } from "../local-visual-preview"
+import type { PoolInstance } from "./models"
+
+const WARM_POOL_LABEL = "osgym.cua.ai/warmpool"
+const ORIGIN_WARM_POOL_ANNOTATION = "osgym.cua.ai/origin-warmpool"
+const ORIGIN_WARM_POOL_NAMESPACE_ANNOTATION =
+ "osgym.cua.ai/origin-warmpool-namespace"
+
+interface SandboxResource {
+ metadata?: {
+ name?: string
+ namespace?: string
+ creationTimestamp?: string
+ labels?: Record<string, string>
+ annotations?: Record<string, string>
+ ownerReferences?: Array<{
+ kind?: string
+ name?: string
+ controller?: boolean
+ }>
+ }
+ status?: {
+ phase?: string
+ }
+}
+
+interface SandboxResourceList {
+ items?: SandboxResource[]
+}
+
+function belongsToPool(
+ sandbox: SandboxResource,
+ namespace: string,
+ poolName: string,
+): boolean {
+ const metadata = sandbox.metadata
+ const labels = metadata?.labels ?? {}
+ const annotations = metadata?.annotations ?? {}
+ const originNamespace = annotations[ORIGIN_WARM_POOL_NAMESPACE_ANNOTATION]
+
+ return (
+ (labels[WARM_POOL_LABEL] === poolName ||
+ annotations[ORIGIN_WARM_POOL_ANNOTATION] === poolName) &&
+ (!originNamespace || originNamespace === namespace)
+ )
+}
+
+function instanceModel(sandbox: SandboxResource): PoolInstance | null {
+ const metadata = sandbox.metadata
+ if (!metadata?.name || !metadata.namespace) return null
+
+ const claimName = metadata.ownerReferences?.find(
+ reference =>
+ reference.kind === "OSGymSandboxClaim" && reference.controller === true,
+ )?.name
+
+ return {
+ name: metadata.name,
+ namespace: metadata.namespace,
+ phase: sandbox.status?.phase ?? "Pending",
+ claimName,
+ createdAt: metadata.creationTimestamp ?? "",
+ }
+}
+
+export async function listPoolInstances(
+ namespace: string,
+ poolName: string,
+): Promise<PoolInstance[]> {
+ if (isLocalVisualPreview()) return []
+
+ const token = await getToken()
+ const response = await fetch(
+ `/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/${encodeURIComponent(namespace)}/osgymsandboxes`,
+ { headers: { Authorization: token ? `Bearer ${token}` : "" } },
+ )
+ if (!response.ok) {
+ const body = await response.text()
+ throw new Error(body || `instance request failed: ${response.status}`)
+ }
+
+ const list = (await response.json()) as SandboxResourceList
+ return (list.items ?? [])
+ .filter(sandbox => belongsToPool(sandbox, namespace, poolName))
+ .map(instanceModel)
+ .filter((instance): instance is PoolInstance => instance !== null)
+}
diff --git a/libs/fleet/src/sdk/models.ts b/libs/fleet/src/sdk/models.ts
index 5c6be58a6e..97359d731f 100644
--- a/libs/fleet/src/sdk/models.ts
+++ b/libs/fleet/src/sdk/models.ts
@@ -48,3 +48,11 @@ export interface Claim {
sandboxService?: string
createdAt: string
}
+
+export interface PoolInstance {
+ name: string
+ namespace: string
+ phase: string
+ claimName?: string
+ createdAt: string
+}