Skip to content

An open-source, faster Devin alternative

TypeScript

feat(web): CVE Swarm security onboarding at ?security=1

Mohamed Habib via Computer314d53b9e2c7
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 81862917..672af25d 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -40,6 +40,9 @@ const ManagedProjectOnboarding = lazy(
() => import('./managed-agents/ProjectOnboarding'),
)
const ManagedTemplateNew = lazy(() => import('./managed-agents/TemplateNew'))
+const ManagedSecurityOnboarding = lazy(
+ () => import('./managed-agents/security/SecurityOnboarding'),
+)
const ModelAccessCallback = lazy(
() => import('./managed-agents/ModelAccessCallback'),
)
@@ -51,6 +54,15 @@ function NewProject() {
return <ManagedProjectOnboarding />
}
+// `app.opencomputer.dev/?security=1` drops into the independent CVE Swarm
+// onboarding path; the param survives the login round-trip via returnTo.
+function HomeRoute() {
+ const [searchParams] = useSearchParams()
+ if (searchParams.get('security') === '1')
+ return <Navigate to="/security" replace />
+ return managedAgentsExperimentEnabled ? <ManagedAgentsHome /> : <Dashboard />
+}
+
export default function App() {
return (
<AuthProvider>
@@ -65,16 +77,8 @@ export default function App() {
</Route>
<Route element={<ProtectedRoute />}>
<Route element={<AppShell />}>
- <Route
- index
- element={
- managedAgentsExperimentEnabled ? (
- <ManagedAgentsHome />
- ) : (
- <Dashboard />
- )
- }
- />
+ <Route index element={<HomeRoute />} />
+ <Route path="security" element={<ManagedSecurityOnboarding />} />
<Route
path="getting-started"
element={
@@ -87,10 +91,7 @@ export default function App() {
/>
<Route path="computer" element={<ManagedComputer />} />
{managedAgentsExperimentEnabled ? (
- <Route
- path="automations"
- element={<ManagedAgentsHome list />}
- />
+ <Route path="automations" element={<ManagedAgentsHome list />} />
) : null}
<Route
path="model-access/callback"
diff --git a/web/src/managed-agents/security/SecurityOnboarding.tsx b/web/src/managed-agents/security/SecurityOnboarding.tsx
new file mode 100644
index 00000000..1e3c2b65
--- /dev/null
+++ b/web/src/managed-agents/security/SecurityOnboarding.tsx
@@ -0,0 +1,553 @@
+import { useMemo, useState } from 'react'
+import { useMutation, useQuery } from '@tanstack/react-query'
+import { useNavigate } from 'react-router-dom'
+import {
+ FolderGit2,
+ Loader2,
+ Radar,
+ Rocket,
+ ShieldCheck,
+ X,
+} from 'lucide-react'
+import { PageHeader } from '@/components/page-header'
+import {
+ Panel,
+ PanelContent,
+ PanelHeader,
+ PanelTitle,
+} from '@/components/panel'
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { Checkbox } from '@/components/ui/checkbox'
+import { cn } from '@/lib/utils'
+import { notifyError } from '@/lib/errors'
+import {
+ addManagedGitHubConnection,
+ createManagedTemplateInstallation,
+ finalizeManagedTemplateInstallation,
+ getManagedGitHubConnections,
+ getManagedTemplateInstallation,
+ inspectManagedTemplate,
+ putAgentRuntimeVariable,
+} from '../api'
+import {
+ installedTemplateAgentId,
+ templatePlaygroundPath,
+} from '../template-continuation'
+import {
+ composeLaunchPrompt,
+ DEFAULT_SWARM_MODEL,
+ SCAN_DECLARATION,
+ SECURITY_SWARM_TEMPLATE_REPOSITORY,
+ SEED_CVES,
+ type SwarmPayload,
+} from './catalog'
+
+const STEPS = ['Connect GitHub', 'Deploy swarm', 'Launch swarm'] as const
+
+type DeployResult = { projectId: string; projectAgentId: string }
+
+async function waitForInstallation(id: string) {
+ const deadline = Date.now() + 10 * 60_000
+ let installation = await getManagedTemplateInstallation(id)
+ while (
+ installation.state !== 'ready' &&
+ installation.state !== 'failed' &&
+ Date.now() < deadline
+ ) {
+ await new Promise((resolve) => setTimeout(resolve, 1_000))
+ installation = await getManagedTemplateInstallation(id)
+ }
+ return installation
+}
+
+export default function SecurityOnboarding() {
+ const navigate = useNavigate()
+
+ // Step 1 — GitHub connection. An active install means the boundary is set.
+ const connections = useQuery({
+ queryKey: ['managed-github-connections'],
+ queryFn: getManagedGitHubConnections,
+ retry: false,
+ })
+ const connected = (connections.data?.connections ?? []).some(
+ (c) => c.state === 'active',
+ )
+
+ const [deployed, setDeployed] = useState<DeployResult | null>(null)
+ const [manualStep, setManualStep] = useState<number | null>(null)
+
+ // Derive the active step from real state, but let the user step forward in
+ // the walkthrough even before a backend action resolves.
+ const derivedStep = deployed ? 2 : connected ? 1 : 0
+ const step = Math.max(derivedStep, manualStep ?? 0)
+
+ const connect = useMutation({
+ mutationFn: () => addManagedGitHubConnection('install'),
+ onSuccess: (url) => window.location.assign(url),
+ onError: (error) =>
+ notifyError("Couldn't start the GitHub install.", error),
+ })
+
+ const deploy = useMutation({
+ mutationFn: async (): Promise<DeployResult> => {
+ const reviewed = await inspectManagedTemplate(
+ SECURITY_SWARM_TEMPLATE_REPOSITORY,
+ )
+ const installation = await createManagedTemplateInstallation({
+ inspectionId: reviewed.id,
+ projectName: 'CVE Swarm',
+ idempotencyKey: crypto.randomUUID(),
+ })
+ // Default the swarm model to GLM for every agent that declares it.
+ for (const requirement of reviewed.requirements.runtimeVariables) {
+ if (!/model/i.test(requirement.name)) continue
+ await putAgentRuntimeVariable({
+ projectId: installation.projectId,
+ environment: 'development',
+ agentId: installedTemplateAgentId({
+ projectAgentId: installation.projectAgentId,
+ localAgentId: requirement.agentId,
+ primaryLocalAgentId: reviewed.agents[0]?.id,
+ }),
+ name: requirement.name,
+ value: DEFAULT_SWARM_MODEL,
+ })
+ }
+ const finalized = await finalizeManagedTemplateInstallation(
+ installation.id,
+ )
+ const ready =
+ finalized.state === 'ready'
+ ? finalized
+ : await waitForInstallation(finalized.id)
+ if (ready.state !== 'ready') {
+ throw new Error(ready.error?.message ?? 'Template installation failed.')
+ }
+ return {
+ projectId: ready.projectId,
+ projectAgentId: installedTemplateAgentId({
+ projectAgentId: ready.projectAgentId,
+ localAgentId: reviewed.template.firstRun?.agent,
+ primaryLocalAgentId: reviewed.agents[0]?.id,
+ }),
+ }
+ },
+ onSuccess: (result) => setDeployed(result),
+ onError: (error) => notifyError("Couldn't deploy the CVE Swarm.", error),
+ })
+
+ function launch(payload: SwarmPayload) {
+ const prompt = composeLaunchPrompt(payload)
+ if (!deployed) return
+ void navigate(templatePlaygroundPath(deployed), {
+ state: { templateFirstRunPrompt: prompt },
+ })
+ }
+
+ return (
+ <div className="mx-auto max-w-3xl px-4 py-10">
+ <PageHeader
+ title="Launch your first CVE swarm"
+ description="Connect the repos you own, deploy the swarm, and prove which of this week's CVEs are actually reachable in your stack — then open a dependency-only fix for the ones that are."
+ className="mb-8"
+ />
+
+ <div className="mb-10">
+ <StepRail steps={STEPS} current={step} />
+ </div>
+
+ <div className="space-y-5">
+ <StepCard
+ index={0}
+ current={step}
+ icon={FolderGit2}
+ title="Connect GitHub"
+ done={connected}
+ >
+ <p className="text-muted-foreground text-sm">
+ Install the OpenComputer GitHub App on the repositories you own. The
+ repos you select here are the hard boundary — the swarm can never
+ touch anything outside this install. It requests only Contents and
+ Pull requests (write) plus Metadata (read).
+ </p>
+ <div className="mt-4 flex items-center gap-3">
+ <Button
+ onClick={() => connect.mutate()}
+ disabled={connect.isPending || connected}
+ >
+ {connect.isPending ? (
+ <Loader2 className="animate-spin" />
+ ) : (
+ <FolderGit2 />
+ )}
+ {connected ? 'GitHub connected' : 'Connect GitHub'}
+ </Button>
+ {connected ? (
+ <span className="text-status-running text-sm">
+ {connections.data?.connections.filter(
+ (c) => c.state === 'active',
+ ).length ?? 0}{' '}
+ install(s) active
+ </span>
+ ) : null}
+ </div>
+ </StepCard>
+
+ <StepCard
+ index={1}
+ current={step}
+ icon={Rocket}
+ title="Deploy the swarm"
+ done={!!deployed}
+ >
+ <p className="text-muted-foreground text-sm">
+ Create your own <code>CVE Swarm</code> project from the template.
+ The default model is <strong>{DEFAULT_SWARM_MODEL}</strong>.
+ Publishing stays off (dry-run fixes) until you turn it on.
+ </p>
+ <div className="mt-4 flex items-center gap-3">
+ <Button
+ onClick={() => deploy.mutate()}
+ disabled={deploy.isPending || !!deployed}
+ >
+ {deploy.isPending ? (
+ <Loader2 className="animate-spin" />
+ ) : (
+ <Rocket />
+ )}
+ {deployed ? 'Swarm deployed' : 'Deploy CVE Swarm'}
+ </Button>
+ {deploy.isError && !deployed ? (
+ <span className="text-muted-foreground text-sm">
+ Couldn't deploy yet — continue below to preview the launch.
+ </span>
+ ) : null}
+ </div>
+ {!deployed && step >= 1 ? (
+ <button
+ type="button"
+ onClick={() => setManualStep(2)}
+ className="text-muted-foreground hover:text-foreground mt-3 text-xs underline underline-offset-4"
+ >
+ Skip to the payload →
+ </button>
+ ) : null}
+ </StepCard>
+
+ <StepCard
+ index={2}
+ current={step}
+ icon={Radar}
+ title="Launch swarm from payload"
+ done={false}
+ >
+ <PayloadBuilder canLaunch={!!deployed} onLaunch={launch} />
+ </StepCard>
+ </div>
+ </div>
+ )
+}
+
+function StepRail({
+ steps,
+ current,
+}: {
+ steps: readonly string[]
+ current: number
+}) {
+ return (
+ <ol className="flex items-center gap-3">
+ {steps.map((label, i) => {
+ const done = i < current
+ const active = i === current
+ return (
+ <li key={label} className="flex flex-1 items-center gap-3">
+ <span
+ className={cn(
+ 'flex size-7 shrink-0 items-center justify-center rounded-full border text-xs font-medium',
+ done || active
+ ? 'border-status-running text-status-running'
+ : 'border-border text-muted-foreground/50',
+ )}
+ >
+ {i + 1}
+ </span>
+ <span
+ className={cn(
+ 'text-sm',
+ active
+ ? 'text-foreground font-medium'
+ : 'text-muted-foreground',
+ )}
+ >
+ {label}
+ </span>
+ {i < steps.length - 1 ? (
+ <span
+ className={cn(
+ 'h-px flex-1',
+ i < current ? 'bg-status-running' : 'bg-border',
+ )}
+ />
+ ) : null}
+ </li>
+ )
+ })}
+ </ol>
+ )
+}
+
+function StepCard({
+ index,
+ current,
+ icon: Icon,
+ title,
+ done,
+ children,
+}: {
+ index: number
+ current: number
+ icon: typeof FolderGit2
+ title: string
+ done: boolean
+ children: React.ReactNode
+}) {
+ const active = index === current
+ return (
+ <Panel
+ className={cn(
+ 'transition-opacity',
+ index > current && !done ? 'opacity-55' : 'opacity-100',
+ )}
+ >
+ <PanelHeader>
+ <PanelTitle className="flex items-center gap-2">
+ <Icon
+ className={cn(
+ 'size-4',
+ active || done ? 'text-status-running' : 'text-muted-foreground',
+ )}
+ />
+ {title}
+ </PanelTitle>
+ </PanelHeader>
+ <PanelContent>{children}</PanelContent>
+ </Panel>
+ )
+}
+
+function PayloadBuilder({
+ canLaunch,
+ onLaunch,
+}: {
+ canLaunch: boolean
+ onLaunch: (payload: SwarmPayload) => void
+}) {
+ const [target, setTarget] = useState('')
+ const [declaration, setDeclaration] = useState(false)
+ const [repoInput, setRepoInput] = useState('')
+ const [repositories, setRepositories] = useState<string[]>([])
+ // Prefill every CVE in this week's feed so a first swarm runs with no typing.
+ const [cveIds, setCveIds] = useState<string[]>(() =>
+ SEED_CVES.map((c) => c.id),
+ )
+ const [preview, setPreview] = useState<string | null>(null)
+
+ const payload: SwarmPayload = useMemo(
+ () => ({
+ target: target.trim(),
+ declarationAccepted: declaration,
+ repositories,
+ cveIds,
+ model: DEFAULT_SWARM_MODEL,
+ }),
+ [target, declaration, repositories, cveIds],
+ )
+
+ const targetValid =
+ payload.target === '' || /^https?:\/\/.+/i.test(payload.target)
+ const ready = declaration && cveIds.length > 0 && targetValid
+
+ function addRepo() {
+ const value = repoInput.trim().replace(/^https?:\/\/github\.com\//i, '')
+ if (!/^[^/\s]+\/[^/\s]+$/.test(value)) return
+ if (!repositories.includes(value)) setRepositories([...repositories, value])
+ setRepoInput('')
+ }
+
+ return (
+ <div className="space-y-5">
+ <Field
+ label="Endpoint to scan"
+ hint="A public URL you operate. Passive only — plain GETs on public paths and banner headers. No payloads, no auth probing. Leave blank to skip the live scan."
+ >
+ <Input
+ type="url"
+ placeholder="https://app.your-domain.com"
+ value={target}
+ onChange={(e) => setTarget(e.target.value)}
+ aria-invalid={!targetValid}
+ />
+ {!targetValid ? (
+ <span className="text-destructive text-xs">
+ Enter a full http(s) URL.
+ </span>
+ ) : null}
+ </Field>
+
+ <Field
+ label="Repositories"
+ hint="Repos from your GitHub install to swarm. Leave empty to scan every connected repository."
+ >
+ <div className="flex gap-2">
+ <Input
+ placeholder="owner/repository"
+ value={repoInput}
+ onChange={(e) => setRepoInput(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault()
+ addRepo()
+ }
+ }}
+ />
+ <Button type="button" variant="outline" onClick={addRepo}>
+ Add
+ </Button>
+ </div>
+ {repositories.length > 0 ? (
+ <div className="mt-2 flex flex-wrap gap-2">
+ {repositories.map((repo) => (
+ <span
+ key={repo}
+ className="bg-muted inline-flex items-center gap-1 rounded-md px-2 py-1 font-mono text-xs"
+ >
+ {repo}
+ <button
+ type="button"
+ onClick={() =>
+ setRepositories(repositories.filter((r) => r !== repo))
+ }
+ className="text-muted-foreground hover:text-foreground"
+ aria-label={`Remove ${repo}`}
+ >
+ <X className="size-3" />
+ </button>
+ </span>
+ ))}
+ </div>
+ ) : null}
+ </Field>
+
+ <Field
+ label="CVEs"
+ hint="This week's feed, pre-selected. Trim to focus a run."
+ >
+ <div className="grid gap-1.5 sm:grid-cols-2">
+ {SEED_CVES.map((cve) => {
+ const checked = cveIds.includes(cve.id)
+ return (
+ <label
+ key={cve.id}
+ htmlFor={`cve-${cve.id}`}
+ className="hover:bg-muted/50 flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-sm"
+ >
+ <Checkbox
+ id={`cve-${cve.id}`}
+ checked={checked}
+ onCheckedChange={(value) =>
+ setCveIds((current) =>
+ value
+ ? [...current, cve.id]
+ : current.filter((id) => id !== cve.id),
+ )
+ }
+ className="mt-0.5"
+ />
+ <span className="min-w-0">
+ <span className="block font-mono text-xs">{cve.id}</span>
+ <span className="text-muted-foreground block truncate">
+ {cve.product} · {cve.severity} {cve.cvss.toFixed(1)}
+ </span>
+ </span>
+ </label>
+ )
+ })}
+ </div>
+ </Field>
+
+ <Field label="Model">
+ <span className="bg-muted inline-flex w-fit items-center gap-2 rounded-md px-2.5 py-1 font-mono text-xs">
+ <ShieldCheck className="size-3.5" />
+ {DEFAULT_SWARM_MODEL}
+ </span>
+ </Field>
+
+ <label
+ htmlFor="swarm-declaration"
+ className="flex cursor-pointer items-start gap-2.5 rounded-md border p-3 text-sm"
+ >
+ <Checkbox
+ id="swarm-declaration"
+ checked={declaration}
+ onCheckedChange={(v) => setDeclaration(v === true)}
+ className="mt-0.5"
+ required
+ />
+ <span>{SCAN_DECLARATION}</span>
+ </label>
+
+ <div className="flex items-center gap-3">
+ <Button
+ disabled={!ready || !canLaunch}
+ onClick={() => onLaunch(payload)}
+ >
+ <Radar />
+ Launch swarm
+ </Button>
+ <Button
+ type="button"
+ variant="outline"
+ disabled={!ready}
+ onClick={() => setPreview(composeLaunchPrompt(payload))}
+ >
+ Preview payload
+ </Button>
+ {!canLaunch ? (
+ <span className="text-muted-foreground text-xs">
+ Deploy the swarm above to launch.
+ </span>
+ ) : null}
+ </div>
+
+ {preview ? (
+ <pre className="bg-muted text-foreground overflow-x-auto rounded-md p-4 font-mono text-xs leading-5 whitespace-pre-wrap">
+ {preview}
+ </pre>
+ ) : null}
+ </div>
+ )
+}
+
+function Field({
+ label,
+ hint,
+ children,
+}: {
+ label: string
+ hint?: string
+ children: React.ReactNode
+}) {
+ return (
+ <div className="space-y-1.5">
+ <span className="text-sm font-medium">{label}</span>
+ {hint ? (
+ <span className="text-muted-foreground block text-xs leading-5">
+ {hint}
+ </span>
+ ) : null}
+ <div className="pt-0.5">{children}</div>
+ </div>
+ )
+}
diff --git a/web/src/managed-agents/security/catalog.ts b/web/src/managed-agents/security/catalog.ts
new file mode 100644
index 00000000..25582de9
--- /dev/null
+++ b/web/src/managed-agents/security/catalog.ts
@@ -0,0 +1,106 @@
+// Static catalog for the CVE Swarm security onboarding (?security=1). These are
+// UI defaults only — the real authorization boundary is the GitHub App install
+// the user connects, and the code-owned safety rails live in the deployed
+// cve-swarm template. Nothing here widens scope; it only prefills the payload.
+
+// The deployable template the security flow installs. Must be a public repo the
+// template-installation backend can inspect.
+export const SECURITY_SWARM_TEMPLATE_REPOSITORY =
+ 'https://github.com/diggerhq/opencomputer-example-cve-swarm'
+
+// Default model for the swarm. GLM via the org's model-access connection.
+export const DEFAULT_SWARM_MODEL = 'GLM-5.3'
+
+// The attestation the operator must accept before a scan can launch. Recorded
+// with the run; the scan stays passive in code regardless.
+export const SCAN_DECLARATION =
+ 'I declare that I own this web application and I am authorized to perform this penetration test.'
+
+export type SeedCve = {
+ readonly id: string
+ readonly product: string
+ readonly severity: 'critical' | 'high' | 'medium' | 'low'
+ readonly cvss: number
+}
+
+// This week's feed, mirroring the launch page and the template's feed.ts. The
+// payload builder opens with all of these pre-selected so a first swarm runs
+// with zero typing.
+export const SEED_CVES: readonly SeedCve[] = [
+ {
+ id: 'CVE-2026-109618',
+ product: 'PHP2Shell',
+ severity: 'critical',
+ cvss: 9.8,
+ },
+ {
+ id: 'CVE-2026-110264',
+ product: 'GitLab CE/EE',
+ severity: 'critical',
+ cvss: 9.6,
+ },
+ {
+ id: 'CVE-2026-96951',
+ product: 'Windows Shell',
+ severity: 'high',
+ cvss: 8.1,
+ },
+ {
+ id: 'CVE-2026-21445',
+ product: 'Oracle Access Manager',
+ severity: 'critical',
+ cvss: 10.0,
+ },
+ {
+ id: 'CVE-2026-21446',
+ product: 'Oracle SOA Suite',
+ severity: 'critical',
+ cvss: 10.0,
+ },
+ {
+ id: 'CVE-2026-21447',
+ product: 'Oracle E-Business Suite',
+ severity: 'critical',
+ cvss: 10.0,
+ },
+]
+
+export type SwarmPayload = {
+ readonly target: string
+ readonly declarationAccepted: boolean
+ readonly repositories: readonly string[]
+ readonly cveIds: readonly string[]
+ readonly model: string
+}
+
+// Compose the controller's first-run input from the payload. This is exactly
+// what the swarm agent receives as its opening instruction when the session
+// starts — the scan → prove → report pipeline, with fixes gated by the
+// template's PUBLISH_ENABLED (dry run by default).
+export function composeLaunchPrompt(payload: SwarmPayload): string {
+ const repos =
+ payload.repositories.length > 0
+ ? payload.repositories.join(', ')
+ : 'all connected repositories'
+ const cves =
+ payload.cveIds.length > 0
+ ? payload.cveIds.join(', ')
+ : "this week's full feed"
+ const lines = [
+ 'Launch a CVE swarm against my own assets.',
+ '',
+ `Declaration: ${SCAN_DECLARATION}`,
+ payload.target
+ ? `Target endpoint (passive scan only): ${payload.target}`
+ : null,
+ `Repositories: ${repos}`,
+ `CVEs: ${cves}`,
+ `Model: ${payload.model}`,
+ '',
+ payload.target
+ ? 'Run scan_surface on the target to fingerprint it passively, then prove_reachability across the repository × CVE matrix, then report_findings once.'
+ : 'Run prove_reachability across the repository × CVE matrix, then report_findings once.',
+ 'For any EXPOSED verdict, open_fix_pull_request (dependency-only, single pin). Honor PUBLISH_ENABLED — dry run unless it is enabled.',
+ ].filter((line): line is string => line !== null)
+ return lines.join('\n')
+}