Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

feat(kits): launch asks what to run on, and offers only what you can run

richard-epsilla077d2cd4158f
diff --git a/gateway/app.py b/gateway/app.py
index f8d6d438..64ddb95e 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -6064,6 +6064,62 @@ async def session_workspace_files(sid: str, request: Request, changed: bool = Fa
_ARCHIVE_MAX_BYTES = 512 * 1024 * 1024 # in-memory zip cap; beyond this, download files singly
+class WorkspaceWrite(BaseModel):
+ content: str | None = None # text
+ content_b64: str | None = None # bytes
+
+
[email protected]("/v1/sessions/{sid}/files/{path:path}")
+async def write_session_file(sid: str, path: str, body: WorkspaceWrite, request: Request) -> dict:
+ """Write or replace one file in a session's workspace.
+
+ This is what lets an app built on a Harness own state the agent also edits — the slides kit
+ keeps deck.json here, so the canvas and the agent read and write the same file rather than two
+ copies that drift.
+
+ Where that file physically lives differs completely by deployment, which is why it goes
+ through BACKING.workspace: a live directory on the data volume self-hosted, the checkpoint
+ tarball in blob storage hosted, where between turns that archive IS the workspace.
+
+ REFUSED WHILE A TURN IS RUNNING, and that is the whole conflict story. Hosted, the live
+ sandbox would overwrite this at its next checkpoint, so the write would appear to succeed and
+ then vanish. Self-hosted, the agent may be editing the same file. Blocking is honest; both
+ sides silently racing is not.
+ """
+ # The SAME ownership check every other session route uses. Hand-rolling a second one is how
+ # this shipped broken: it compared v["org"], but a session vertex carries the owner in
+ # `tenant`, so every write 404'd on a session the caller could plainly read.
+ _org, v = await _owned_session(request, sid)
+
+ live = {"running", "starting"} & {str(v.get("turn_status") or ""), str(v.get("status") or "")}
+ if live:
+ raise uhp_error(409, "session_busy",
+ "The agent is working on this session. Wait for the turn to finish "
+ "before writing to its workspace.")
+
+ if body.content_b64 is not None:
+ try:
+ data = base64.b64decode(body.content_b64)
+ except Exception: # noqa: BLE001
+ raise uhp_error(400, "invalid_request", "content_b64 is not valid base64.") from None
+ elif body.content is not None:
+ data = body.content.encode()
+ else:
+ raise uhp_error(400, "invalid_request", "Provide content or content_b64.")
+
+ if len(data) > _WS_WRITE_MAX:
+ raise uhp_error(413, "payload_too_large",
+ f"A workspace file written this way is limited to {_WS_WRITE_MAX} bytes.")
+
+ ok = await BACKING.workspace.write(sid, path, data)
+ if not ok:
+ # The only ways to get here are a path that tried to leave the workspace and a storage
+ # failure. Both are the caller's problem to see, not something to swallow.
+ raise uhp_error(400, "write_failed",
+ "Could not write that path. It must be inside the session workspace.")
+ return {"session_id": sid, "path": path, "bytes": len(data), "written": True}
+
+
@app.get("/v1/sessions/{sid}/files/archive")
async def session_files_archive(sid: str, request: Request, changed: bool = False, files: str = ""):
"""Every artifact of a session (or one turn) as a single zip, preserving the workspace's
@@ -6540,6 +6596,87 @@ def _kit_skills(kit: dict) -> list[dict]:
return out
+# What to run a kit's Harness on, in preference order. A kit declares its own list in kit.json
+# (`harness.recommended`), because the right pairing is a property of the work: a deck designer and
+# a log analyser do not want the same agent or the same model.
+#
+# This is only the fallback for a kit that declares none. Note it is a preference ORDER, not a
+# pin — which one is used depends on what the person actually connected, since pinning one base
+# strands the common case: someone who wired only DeepSeek launching a kit that says "claude-code"
+# would get a Harness that cannot run a single turn.
+_KIT_BASE_PREFERENCE: tuple[tuple[str, str], ...] = (
+ ("hermes", "deepseek-v4-pro"),
+ ("codex", "gpt-5.6-sol"),
+ ("claude-code", "claude-opus-5"),
+)
+
+
+def _kit_preference(kit: dict) -> list[tuple[str, str]]:
+ """A kit's recommended pairings, or the default order when it names none."""
+ out: list[tuple[str, str]] = []
+ for r in (kit.get("harness") or {}).get("recommended") or []:
+ base, model = str(r.get("base") or ""), str(r.get("model") or "")
+ if base in _BASE_CATALOG:
+ out.append((base, model))
+ else:
+ print(f"[kits] {kit.get('id')}: recommended base {base!r} is not a base — ignored",
+ flush=True)
+ return out or list(_KIT_BASE_PREFERENCE)
+
+
+async def _base_serves(org: str, base: str, model: str) -> bool:
+ """Can this org actually run `model` on `base` right now?
+
+ `_servable_models` returning None means a policy chain is in play, which is provider-level
+ rather than per-model — the backend may attempt its whole catalog, so anything in that
+ catalog counts as available.
+ """
+ b = _BASE_CATALOG.get(base)
+ if not b:
+ return False
+ if model and model not in (_MODEL_CATALOG.get(b["backend"], {}).get("models") or []):
+ return False
+ servable = await _servable_models(org, b["backend"])
+ return servable is None or not model or model in servable
+
+
+async def _kit_choices(org: str, kit: dict) -> list[dict]:
+ """This kit's recommended pairings, each with whether this org can run it.
+
+ Unavailable options are returned rather than filtered out: "Claude Code — connect Anthropic to
+ use this" tells someone what to do next, where a short list just looks like the product only
+ supports two agents.
+ """
+ out: list[dict] = []
+ picked = False
+ for base, model in _kit_preference(kit):
+ b = _BASE_CATALOG.get(base) or {}
+ available = await _base_serves(org, base, model)
+ recommended = available and not picked
+ picked = picked or available
+ out.append({"base": base, "model": model,
+ "baseLabel": b.get("label") or base,
+ "available": available, "recommended": recommended})
+ return out
+
+
+async def _kit_base(org: str, kit: dict) -> tuple[str, str]:
+ """What a launch runs on when the caller expressed no preference: the recommended pairing.
+
+ Falling through every option means nothing is wired up yet. The kit's own base is the last
+ word then, so a launch still produces something coherent to look at rather than failing.
+ """
+ for c in await _kit_choices(org, kit):
+ if c["recommended"]:
+ print(f"[kits] {kit.get('id')}: base {c['base']} ({c['model']})", flush=True)
+ return c["base"], c["model"]
+ spec = kit.get("harness") or {}
+ fallback = str(spec.get("base") or "claude-code")
+ print(f"[kits] {kit.get('id')}: no connected provider serves a preferred model — "
+ f"falling back to {fallback}", flush=True)
+ return fallback, str(spec.get("default_model") or "")
+
+
# ── Built-in skills ───────────────────────────────────────────────────────────────────────────
# Baked into the image from HarnessRouter/skills (see docker/install-skills.sh). Read from disk,
# never hard-coded: the console used to carry its own list of four "built-in skills" that existed
@@ -6727,6 +6864,7 @@ def _harness_props(body: HarnessBody) -> dict:
"timeout_seconds": str(body.timeout_seconds) if body.timeout_seconds else ""}
+_WS_WRITE_MAX = 4 * 1024 * 1024 # an app writing its own state, not an upload path
_SKILL_INLINE_MAX = 48_000 # keep the vertex `skills` prop safely under the 64k value cap
@@ -6943,14 +7081,23 @@ async def list_kits(request: Request) -> dict:
"description": kit.get("description") or "",
"icon": kit.get("icon") or "", "accent": kit.get("accent") or "",
"route": (kit.get("app") or {}).get("route") or "",
- "base": (kit.get("harness") or {}).get("base") or "",
"launched": bool(h),
- "harnessId": (h or {}).get("id") or None})
+ "harnessId": (h or {}).get("id") or None,
+ # What to run it on: this kit's own recommended pairings, each marked with
+ # whether the caller's integrations can serve it. The launch dialog renders
+ # these directly and preselects the one flagged `recommended`.
+ "choices": await _kit_choices(org, kit)})
return {"kits": out}
+class KitLaunchBody(BaseModel):
+ """What to run the kit on. Both optional: no body at all means "use the recommendation"."""
+ base: str = ""
+ model: str = ""
+
+
@app.post("/v1/kits/{kit_id}/launch")
-async def launch_kit(kit_id: str, request: Request) -> dict:
+async def launch_kit(kit_id: str, request: Request, body_in: KitLaunchBody | None = None) -> dict:
"""Provision this kit's Harness, or hand back the one that already exists.
Idempotent on purpose. Launch is a button someone presses twice — because the first press
@@ -6970,9 +7117,24 @@ async def launch_kit(kit_id: str, request: Request) -> dict:
"route": (kit.get("app") or {}).get("route") or "", "created": False}
spec = kit.get("harness") or {}
+ # An explicit choice from the launch dialog wins; no choice means take the recommendation.
+ # It is validated rather than trusted: a pairing nothing can serve produces a Harness whose
+ # every turn fails, and the failure would surface far from the launch that caused it.
+ want_base = (body_in.base if body_in else "").strip()
+ want_model = (body_in.model if body_in else "").strip()
+ if want_base:
+ if want_base not in _BASE_CATALOG:
+ raise uhp_error(400, "invalid_base", f"No base harness '{want_base}'.", "base")
+ if not await _base_serves(org, want_base, want_model):
+ raise uhp_error(400, "model_unavailable",
+ f"Nothing you have connected can run {want_model or 'that model'} "
+ f"on {want_base}.", "model")
+ base, model = want_base, want_model
+ else:
+ base, model = await _kit_base(org, kit)
body = HarnessBody(name=spec.get("name") or kit.get("title") or kit_id,
- base=spec.get("base") or "claude-code",
- default_model=spec.get("default_model") or "",
+ base=base,
+ default_model=model,
system_prompt=spec.get("system_prompt") or "",
skills=_kit_skills(kit),
mcp_servers=spec.get("mcp_servers") or [],
diff --git a/gateway/backing.py b/gateway/backing.py
index 9a2680b0..cfdd49f7 100644
--- a/gateway/backing.py
+++ b/gateway/backing.py
@@ -24,10 +24,15 @@ relational table, or anything else that can look up records by label + property
from __future__ import annotations
import asyncio
+import io
import json
import os
+import pathlib
+import posixpath
import re
import sqlite3
+import tarfile
+import time
import uuid
from pathlib import Path
from typing import Protocol
@@ -58,9 +63,29 @@ class SecretStore(Protocol):
async def put(self, tenant: str, name: str, value: str) -> None: ...
+class WorkspaceFiles(Protocol):
+ """Reading and writing one file inside a session's workspace.
+
+ Two environments, genuinely different storage, one interface:
+
+ * **Self-hosted** — the runner shares this container and the workspace is a live directory on
+ the data volume. A write is a write.
+ * **Hosted** — sandboxes are ephemeral, so between turns a workspace exists ONLY as the
+ checkpoint tarball in blob storage (`sessions/<sid>/workspace.tgz`). A write has to rewrite
+ that archive, because there is no filesystem to write to until the next turn hydrates one.
+
+ This exists so an app built on a Harness can own state the agent also edits — the slides kit
+ keeps deck.json here — without either side needing to know which deployment it is running in.
+ """
+ async def read(self, sid: str, path: str) -> bytes | None: ...
+ async def write(self, sid: str, path: str, data: bytes) -> bool: ...
+
+
class Backing:
- def __init__(self, graph: GraphStore, blob: BlobStore, secrets: SecretStore, mode: str):
+ def __init__(self, graph: GraphStore, blob: BlobStore, secrets: SecretStore, mode: str,
+ workspace: "WorkspaceFiles"):
self.graph, self.blob, self.secrets, self.mode = graph, blob, secrets, mode
+ self.workspace = workspace
# ── local: SQLite graph ───────────────────────────────────────────────────────────
@@ -259,21 +284,155 @@ class FileSecretStore:
# ── selection ─────────────────────────────────────────────────────────────────────
+
+# ── workspace files ───────────────────────────────────────────────────────────────
+def _safe_member(path: str) -> str | None:
+ """A workspace-relative path, or None if it tries to leave the workspace.
+
+ Rejected rather than sanitised: a path that needed cleaning was not the path the caller meant,
+ and silently writing somewhere else is worse than refusing."""
+ p = (path or "").strip().lstrip("/")
+ if not p or p != posixpath.normpath(p) or p.startswith("../") or "\\" in p:
+ return None
+ return p
+
+
+class LocalWorkspaceFiles:
+ """Self-hosted: the workspace is a live directory on the data volume, shared with the runner
+ in this container. Writes land where the agent will read them on its next turn."""
+
+ def __init__(self, root: str):
+ self.root = root
+
+ def _path(self, sid: str, path: str) -> str | None:
+ member = _safe_member(path)
+ if not member or not sid or "/" in sid or sid in (".", ".."):
+ return None
+ base = os.path.realpath(os.path.join(self.root, sid))
+ full = os.path.realpath(os.path.join(base, member))
+ # Resolve first, then prove containment: checking the input for '..' misses symlinks.
+ return full if full == base or full.startswith(base + os.sep) else None
+
+ async def read(self, sid: str, path: str) -> bytes | None:
+ full = self._path(sid, path)
+ if not full:
+ return None
+ try:
+ return await asyncio.to_thread(pathlib.Path(full).read_bytes)
+ except OSError:
+ return None
+
+ async def write(self, sid: str, path: str, data: bytes) -> bool:
+ full = self._path(sid, path)
+ if not full:
+ return False
+
+ def _put() -> bool:
+ try:
+ os.makedirs(os.path.dirname(full), exist_ok=True)
+ # Write beside, then rename: a reader (the agent, mid-turn) sees either the old
+ # file or the new one, never a half-written one.
+ tmp = f"{full}.tmp-{uuid.uuid4().hex[:8]}"
+ with open(tmp, "wb") as fh:
+ fh.write(data)
+ os.replace(tmp, full)
+ return True
+ except OSError:
+ return False
+ return await asyncio.to_thread(_put)
+
+
+class CheckpointWorkspaceFiles:
+ """Hosted: between turns the workspace is only the checkpoint tarball, so a write rewrites
+ that archive — copy every member across, substituting the one being written.
+
+ Rewriting rather than appending is deliberate: tar allows duplicate names and readers take the
+ LAST one, so appending would work until something read the archive differently, and the bug
+ would be a stale file appearing at random."""
+
+ def __init__(self, blob, kb: str, key_for):
+ self.blob, self.kb, self.key_for = blob, kb, key_for
+
+ async def read(self, sid: str, path: str) -> bytes | None:
+ member = _safe_member(path)
+ if not member:
+ return None
+ raw = await self.blob.get(self.kb, self.key_for(sid))
+ if not raw:
+ return None
+
+ def _extract() -> bytes | None:
+ with tarfile.open(fileobj=io.BytesIO(raw), mode="r:gz") as tf:
+ for name in (member, f"./{member}"):
+ try:
+ f = tf.extractfile(name)
+ except KeyError:
+ continue
+ if f:
+ return f.read()
+ return None
+ try:
+ return await asyncio.to_thread(_extract)
+ except Exception: # noqa: BLE001 — a corrupt archive reads as "not there"
+ return None
+
+ async def write(self, sid: str, path: str, data: bytes) -> bool:
+ member = _safe_member(path)
+ if not member:
+ return False
+ key = self.key_for(sid)
+ raw = await self.blob.get(self.kb, key)
+
+ def _rewrite() -> bytes:
+ out = io.BytesIO()
+ wrote = False
+ with tarfile.open(fileobj=out, mode="w:gz") as dst:
+ if raw:
+ with tarfile.open(fileobj=io.BytesIO(raw), mode="r:gz") as src:
+ for m in src.getmembers():
+ name = m.name[2:] if m.name.startswith("./") else m.name
+ if name == member:
+ continue # replaced below
+ f = src.extractfile(m) if m.isfile() else None
+ dst.addfile(m, f)
+ info = tarfile.TarInfo(member)
+ info.size = len(data)
+ info.mtime = int(time.time())
+ info.mode = 0o644
+ dst.addfile(info, io.BytesIO(data))
+ wrote = True
+ return out.getvalue() if wrote else b""
+
+ try:
+ tar = await asyncio.to_thread(_rewrite)
+ except Exception: # noqa: BLE001
+ return False
+ return bool(tar) and await self.blob.put(self.kb, key, tar)
+
+
def make_backing(*, client_getter, vg_url: str, vg_key: str, vg_tenant: str,
vault_url: str, vault_key: str) -> Backing:
"""Build the configured backing. HR_BACKING=vg|local; unset ⇒ vg when VG_GATEWAY_URL is
configured (production), local otherwise (a laptop clone works with zero env)."""
mode = os.environ.get("HR_BACKING", "").strip().lower() or ("vg" if vg_url else "local")
+ # Where a session's workspace actually lives, which is the one thing that differs most between
+ # the two deployments: a live directory this container shares with the runner, or a checkpoint
+ # tarball that is the only copy between turns.
+ ws_root = os.environ.get("HARNESS_WORKSPACE", "/data/workspaces")
+ ws_key = lambda sid: f"sessions/{sid}/workspace.tgz" # noqa: E731 — matches gateway._ws_blob
if mode == "vg":
from backing_vg import VgBlobStore, VgGraphStore, VaultSecretStore
+ blob = VgBlobStore(client_getter, vg_url, vg_key)
return Backing(
graph=VgGraphStore(client_getter, vg_url, vg_key, vg_tenant),
- blob=VgBlobStore(client_getter, vg_url, vg_key),
+ blob=blob,
secrets=VaultSecretStore(client_getter, vault_url, vault_key),
- mode="vg")
+ mode="vg",
+ workspace=CheckpointWorkspaceFiles(blob, os.environ.get("HARNESS_BLOB_KB", "harness-sessions"), ws_key))
data = os.environ.get("HR_DATA_DIR", ".hr-data")
return Backing(
graph=SqliteGraphStore(os.path.join(data, "graph.db")),
blob=FileBlobStore(os.path.join(data, "blobs")),
secrets=FileSecretStore(os.path.join(data, "secrets")),
- mode="local")
+ mode="local",
+ workspace=LocalWorkspaceFiles(ws_root))
diff --git a/ui/src/app/(app)/kits/page.tsx b/ui/src/app/(app)/kits/page.tsx
index 38022485..0f596c46 100644
--- a/ui/src/app/(app)/kits/page.tsx
+++ b/ui/src/app/(app)/kits/page.tsx
@@ -4,6 +4,11 @@
// the image (docker/install-kits.sh), so Launch provisions the Harness and opens an app that is
// already here — nothing is deployed and nothing is configured.
//
+// Launch asks one question first: what to run it on. The kit declares which pairings suit its
+// work (kit.json `harness.recommended`) and the server marks which of those the caller's
+// integrations can actually serve, so the dialog offers real choices and preselects the best
+// available one. "Choose a different one" opens the full catalog as two cascading selects.
+//
// Launch is idempotent server-side, so this page does not have to guard against a second click:
// the second one returns the Harness the first one made.
'use client';
@@ -12,16 +17,25 @@ import { useCallback, useEffect, useState } from 'react';
import { authHeaders } from '@/lib/chat';
import { harnessFetch } from '@/lib/hfetch';
+interface Choice {
+ base: string; model: string; baseLabel: string;
+ available: boolean; recommended: boolean;
+}
interface Kit {
id: string; title: string; tagline: string; description: string;
- icon: string; accent: string; route: string; base: string;
+ icon: string; accent: string; route: string;
launched: boolean; harnessId: string | null;
+ choices: Choice[];
}
+interface BaseModel { id: string; available: boolean }
+interface Base { id: string; label: string; models: BaseModel[] }
export default function KitsPage() {
const [kits, setKits] = useState<Kit[] | null>(null);
+ const [bases, setBases] = useState<Base[]>([]);
const [err, setErr] = useState('');
const [busy, setBusy] = useState('');
+ const [picking, setPicking] = useState<Kit | null>(null);
const reload = useCallback(() => {
harnessFetch('/api/harness/v1/kits', { headers: authHeaders(), cache: 'no-store' })
@@ -33,18 +47,29 @@ export default function KitsPage() {
}, []);
useEffect(() => reload(), [reload]);
- async function launch(kit: Kit) {
+ // Only needed by the "choose a different one" path, but it is one small request and having it
+ // already loaded means that panel opens instantly instead of flashing empty selects.
+ useEffect(() => {
+ harnessFetch('/api/harness/v1/bases', { headers: authHeaders(), cache: 'no-store' })
+ .then(async (r) => (r.ok ? setBases((await r.json()).bases || []) : undefined))
+ .catch(() => {});
+ }, []);
+
+ async function launch(kit: Kit, base?: string, model?: string) {
setBusy(kit.id); setErr('');
try {
- const r = await harnessFetch(`/api/harness/v1/kits/${kit.id}/launch`,
- { method: 'POST', headers: authHeaders() });
+ const r = await harnessFetch(`/api/harness/v1/kits/${kit.id}/launch`, {
+ method: 'POST',
+ headers: authHeaders(),
+ body: JSON.stringify(base ? { base, model: model || '' } : {}),
+ });
if (!r.ok) throw new Error((await r.json().catch(() => null))?.detail || `${r.status}`);
const { route } = await r.json();
// Hard navigation: the kit app is served outside this Next app, from the image.
window.location.href = route || `/kits/${kit.id}`;
} catch (e) {
setErr(e instanceof Error ? e.message : 'launch failed');
- setBusy('');
+ setBusy(''); setPicking(null);
}
}
@@ -84,9 +109,8 @@ export default function KitsPage() {
<p className="kit-desc">{k.description}</p>
</div>
<div className="kit-actions">
- <span className="hr-meta">{k.base}</span>
<button className="button primary" type="button" disabled={busy === k.id}
- onClick={() => void launch(k)}>
+ onClick={() => (k.launched ? void launch(k) : setPicking(k))}>
{busy === k.id ? 'Opening…' : k.launched ? 'Open' : 'Launch'}
</button>
</div>
@@ -94,6 +118,130 @@ export default function KitsPage() {
))}
</div>
)}
+
+ {picking && (
+ <LaunchDialog
+ kit={picking} bases={bases} busy={busy === picking.id}
+ onClose={() => setPicking(null)}
+ onLaunch={(base, model) => void launch(picking, base, model)}
+ />
+ )}
</div></section>
);
}
+
+function LaunchDialog({ kit, bases, busy, onClose, onLaunch }: {
+ kit: Kit; bases: Base[]; busy: boolean;
+ onClose: () => void; onLaunch: (base: string, model: string) => void;
+}) {
+ const recommended = kit.choices.find((c) => c.recommended) || null;
+ const [sel, setSel] = useState<string>(recommended ? `${recommended.base}/${recommended.model}` : '');
+ const [custom, setCustom] = useState(false);
+ const [cBase, setCBase] = useState(bases[0]?.id || '');
+ const [cModel, setCModel] = useState('');
+
+ // Models are per base, so changing the agent has to re-pick the model rather than keep one the
+ // new agent cannot run. First available, not first listed — an unavailable default is a trap.
+ const baseModels = bases.find((b) => b.id === cBase)?.models || [];
+ useEffect(() => {
+ if (!baseModels.some((m) => m.id === cModel && m.available)) {
+ setCModel(baseModels.find((m) => m.available)?.id || '');
+ }
+ }, [cBase, baseModels, cModel]);
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
+ window.addEventListener('keydown', onKey);
+ return () => window.removeEventListener('keydown', onKey);
+ }, [onClose]);
+
+ const nothingAvailable = !kit.choices.some((c) => c.available);
+ const canLaunch = custom ? Boolean(cBase && cModel) : Boolean(sel);
+
+ function go() {
+ if (custom) { onLaunch(cBase, cModel); return; }
+ const [base, ...rest] = sel.split('/');
+ onLaunch(base, rest.join('/'));
+ }
+
+ return (
+ <div className="kit-overlay" role="dialog" aria-modal="true" aria-labelledby="kit-launch-title"
+ onMouseDown={(e) => { if (e.target === e.currentTarget) onClose(); }}>
+ <div className="kit-dialog">
+ <button className="kit-dialog-x" type="button" onClick={onClose} aria-label="Close">
+ <iconify-icon icon="tabler:x"></iconify-icon>
+ </button>
+ <h2 id="kit-launch-title">Launch {kit.title}</h2>
+ <p className="kit-dialog-sub">Choose what it runs on. You can change this later in the
+ Harness settings.</p>
+
+ {nothingAvailable && !custom && (
+ <div className="hr-error" role="alert">
+ None of these can run yet — connect a provider on the Integrations page first.
+ </div>
+ )}
+
+ {!custom && (
+ <div className="kit-choices">
+ {kit.choices.map((c) => {
+ const id = `${c.base}/${c.model}`;
+ return (
+ <label key={id} className={`kit-choice${c.available ? '' : ' is-off'}`}>
+ <input type="radio" name="kit-choice" value={id} checked={sel === id}
+ disabled={!c.available} onChange={() => setSel(id)} />
+ <span className="kit-choice-body">
+ <span className="kit-choice-top">
+ <strong>{c.baseLabel}</strong>
+ {c.recommended && <span className="kit-badge">Recommended</span>}
+ </span>
+ <span className="kit-choice-model">{c.model}</span>
+ {!c.available && (
+ <span className="kit-choice-why">Not connected — add a provider that serves
+ this model to use it.</span>
+ )}
+ </span>
+ </label>
+ );
+ })}
+ </div>
+ )}
+
+ {custom && (
+ <div className="kit-custom">
+ <label className="kit-field">
+ <span>Harness</span>
+ <select value={cBase} onChange={(e) => setCBase(e.target.value)}>
+ {bases.map((b) => <option key={b.id} value={b.id}>{b.label}</option>)}
+ </select>
+ </label>
+ <label className="kit-field">
+ <span>Model</span>
+ <select value={cModel} onChange={(e) => setCModel(e.target.value)}>
+ {baseModels.length === 0 && <option value="">No models</option>}
+ {baseModels.map((m) => (
+ <option key={m.id} value={m.id} disabled={!m.available}>
+ {m.id}{m.available ? '' : ' — not connected'}
+ </option>
+ ))}
+ </select>
+ </label>
+ {cBase && !baseModels.some((m) => m.available) && (
+ <p className="kit-choice-why">Nothing you have connected can run this harness.</p>
+ )}
+ </div>
+ )}
+
+ <div className="kit-dialog-actions">
+ <button className="button ghost" type="button" onClick={() => setCustom((v) => !v)}>
+ {custom ? 'Back to recommended' : 'Choose a different one'}
+ </button>
+ <span className="kit-dialog-spacer" />
+ <button className="button" type="button" onClick={onClose}>Cancel</button>
+ <button className="button primary" type="button" disabled={busy || !canLaunch} onClick={go}>
+ {busy ? 'Launching…' : 'Launch'}
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/ui/src/app/hr.css b/ui/src/app/hr.css
index 6b791da5..d203ced4 100644
--- a/ui/src/app/hr.css
+++ b/ui/src/app/hr.css
@@ -799,4 +799,52 @@ body.hr-resizing iframe { pointer-events: none; }
.kit-desc { font-size: 12.5px; line-height: 1.5; color: var(--mute); margin: 0; }
.kit-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding-top: 4px; border-top: 1px solid var(--line); margin-top: 2px; }
-@media (max-width: 720px) { .kit-grid { grid-template-columns: 1fr; } }
+.kit-actions { justify-content: flex-end; }
+
+/* ── Launch dialog: pick the agent + model before provisioning ─────────────────────── */
+.kit-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
+ padding: 24px; background: rgba(16, 18, 26, .5);
+ backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
+.kit-dialog { position: relative; width: min(100%, 460px); max-height: calc(100vh - 48px);
+ overflow: auto; padding: 26px; background: var(--surface); border: 1px solid var(--line);
+ border-radius: 16px; box-shadow: 0 30px 60px -18px rgba(30, 50, 120, .34); }
+.kit-dialog h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: var(--ink); }
+.kit-dialog-sub { margin: 0 0 18px; font-size: 12.5px; line-height: 1.5; color: var(--mute); }
+.kit-dialog-x { position: absolute; top: 14px; right: 14px; width: 28px; height: 28px; display: grid;
+ place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--mute);
+ cursor: pointer; }
+.kit-dialog-x:hover { background: var(--surface-subtle); color: var(--ink); }
+
+.kit-choices { display: flex; flex-direction: column; gap: 8px; }
+.kit-choice { display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--line);
+ border-radius: 11px; cursor: pointer; transition: border-color .12s, background .12s; }
+.kit-choice:hover:not(.is-off) { border-color: var(--brand); background: var(--surface-subtle); }
+.kit-choice:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
+/* Still readable, still explains itself — just not selectable. */
+.kit-choice.is-off { opacity: .55; cursor: default; }
+.kit-choice input { margin-top: 3px; accent-color: var(--brand); }
+.kit-choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
+.kit-choice-top { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); }
+.kit-choice-model { font-size: 12px; color: var(--mute); font-family: var(--mono, monospace); }
+.kit-choice-why { font-size: 11.5px; line-height: 1.45; color: var(--mute); margin: 4px 0 0; }
+.kit-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
+ color: var(--brand); background: var(--brand-50, var(--surface-subtle)); padding: 2px 7px;
+ border-radius: 999px; }
+
+.kit-custom { display: flex; flex-direction: column; gap: 12px; }
+.kit-field { display: flex; flex-direction: column; gap: 5px; }
+.kit-field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
+.kit-field select { width: 100%; padding: 9px 11px; font: inherit; font-size: 13px; color: var(--ink);
+ background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
+
+.kit-dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
+.kit-dialog-spacer { flex: 1; }
+
+@media (max-width: 720px) {
+ .kit-grid { grid-template-columns: 1fr; }
+ .kit-dialog { padding: 20px; }
+ /* Stack so the primary action never gets squeezed off the edge. */
+ .kit-dialog-actions { flex-wrap: wrap; }
+ .kit-dialog-spacer { display: none; }
+ .kit-dialog-actions .button { flex: 1 1 auto; justify-content: center; }
+}