@opengeni/react 0.13.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -23
- package/dist/chunk-6BXBGJ3B.js +1956 -0
- package/dist/chunk-6BXBGJ3B.js.map +1 -0
- package/dist/chunk-6UT5OC3P.js +2133 -0
- package/dist/chunk-6UT5OC3P.js.map +1 -0
- package/dist/chunk-EBTT3MYN.js +92 -0
- package/dist/chunk-EBTT3MYN.js.map +1 -0
- package/dist/chunk-HHFA4AFX.js +425 -0
- package/dist/chunk-HHFA4AFX.js.map +1 -0
- package/dist/chunk-LAZ2A743.js +2393 -0
- package/dist/chunk-LAZ2A743.js.map +1 -0
- package/dist/chunk-MRSECXRP.js +563 -0
- package/dist/chunk-MRSECXRP.js.map +1 -0
- package/dist/chunk-TK7G6XLT.js +18 -0
- package/dist/chunk-TK7G6XLT.js.map +1 -0
- package/dist/composer-DvUaa5ki.d.ts +585 -0
- package/dist/composer.d.ts +6 -0
- package/dist/composer.js +56 -0
- package/dist/composer.js.map +1 -0
- package/dist/index.d.ts +642 -1080
- package/dist/index.js +7672 -8005
- package/dist/index.js.map +1 -1
- package/dist/machines.d.ts +412 -3
- package/dist/machines.js +25 -1
- package/dist/noto-sans-arabic-loader-IA2T4X2A.js +21 -0
- package/dist/noto-sans-arabic-loader-IA2T4X2A.js.map +1 -0
- package/dist/noto-sans-jp-loader.generated-HFGLYBR3.js +292 -0
- package/dist/noto-sans-jp-loader.generated-HFGLYBR3.js.map +1 -0
- package/dist/queue-surface-implementation-NQMV2ML3.js +890 -0
- package/dist/queue-surface-implementation-NQMV2ML3.js.map +1 -0
- package/dist/session-Gd4iVPYw.d.ts +425 -0
- package/dist/session-context-DIFFlXKc.d.ts +52 -0
- package/dist/session.d.ts +4 -0
- package/dist/session.js +50 -0
- package/dist/session.js.map +1 -0
- package/dist/use-composer-BCfm4mzX.d.ts +112 -0
- package/package.json +23 -4
- package/src/approvals.ts +5 -3
- package/src/client.ts +50 -1
- package/src/components/approval-surface.tsx +198 -0
- package/src/components/chat-composer.tsx +104 -751
- package/src/components/code-editor.tsx +104 -26
- package/src/components/command-palette.tsx +8 -2
- package/src/components/composer-transcription-control.tsx +211 -0
- package/src/components/composer.tsx +1536 -0
- package/src/components/desktop-viewer.tsx +3 -3
- package/src/components/enrollment-consent.tsx +2 -2
- package/src/components/file-browser.tsx +367 -29
- package/src/components/human-input-form.tsx +417 -0
- package/src/components/machine-card.tsx +82 -16
- package/src/components/machine-health-pill.tsx +68 -0
- package/src/components/machine-metrics.tsx +10 -24
- package/src/components/machines/health.ts +146 -0
- package/src/components/machines/machine-detail.tsx +220 -0
- package/src/components/machines/metric-history-chart.tsx +298 -0
- package/src/components/machines/metric-sparkline.tsx +76 -0
- package/src/components/machines/series.ts +113 -0
- package/src/components/machines-dashboard.tsx +16 -4
- package/src/components/message-timeline.tsx +15 -7
- package/src/components/model-picker.tsx +12 -3
- package/src/components/pierre-diff.tsx +32 -6
- package/src/components/queue-surface-implementation.tsx +1041 -0
- package/src/components/queue-surface-state.tsx +94 -0
- package/src/components/queue-surface.tsx +60 -0
- package/src/components/sandbox-files.tsx +230 -21
- package/src/components/sandbox-terminal.tsx +8 -2
- package/src/components/sandbox-workspace.tsx +489 -135
- package/src/components/session-status.tsx +0 -6
- package/src/components/workbench-changes.tsx +145 -50
- package/src/components/workspace-dock.tsx +329 -68
- package/src/composer.ts +60 -0
- package/src/hooks/internal.ts +115 -34
- package/src/hooks/use-composer.ts +635 -74
- package/src/hooks/use-human-input.ts +131 -0
- package/src/hooks/use-machine-chip.ts +2 -2
- package/src/hooks/use-machines.ts +27 -11
- package/src/hooks/use-sandbox-files.ts +310 -62
- package/src/hooks/use-sandbox-git.ts +154 -40
- package/src/hooks/use-sandbox-terminal.ts +28 -6
- package/src/hooks/use-session-capabilities.ts +38 -9
- package/src/hooks/use-session-control.ts +43 -15
- package/src/hooks/use-session-events.ts +523 -48
- package/src/hooks/use-session-lineage.ts +15 -6
- package/src/hooks/use-session.ts +10 -2
- package/src/hooks/use-slash-commands.ts +38 -38
- package/src/hooks/use-transcription.ts +757 -0
- package/src/hooks/use-turn-queue.ts +273 -77
- package/src/hooks/use-windowed-sections.ts +2 -2
- package/src/hooks/use-workspace-capture.ts +146 -40
- package/src/hooks/use-workspace-edit.ts +50 -14
- package/src/hooks/use-workspace-sessions.ts +3 -0
- package/src/human-input.ts +72 -0
- package/src/index.ts +88 -12
- package/src/lib/noto-sans-arabic-loader.ts +21 -0
- package/src/lib/noto-sans-jp-loader.generated.ts +295 -0
- package/src/lib/use-portal-token-style.ts +51 -0
- package/src/lib/use-unicode-fonts.ts +57 -0
- package/src/machines.ts +16 -0
- package/src/provider.tsx +163 -41
- package/src/session-context.ts +135 -0
- package/src/session.ts +79 -0
- package/src/timeline/parsers.ts +78 -6
- package/src/timeline/projection.ts +36 -6
- package/src/timeline/tool-renderers.tsx +41 -0
- package/src/timeline/turn-summary.tsx +2 -2
- package/src/timeline/types.ts +16 -8
- package/styles/index.css +78 -0
- package/styles/index.d.ts +2 -0
- package/styles/tokens.css +11 -6
- package/styles/tokens.d.ts +2 -0
- package/dist/chunk-NFYVQWIB.js +0 -1377
- package/dist/chunk-NFYVQWIB.js.map +0 -1
- package/dist/machines-CnlMb7E-.d.ts +0 -329
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/machines.ts","../src/lib/cn.ts","../src/components/machine-status-pill.tsx","../src/lib/format.ts","../src/components/machine-metrics.tsx","../src/components/machine-card.tsx","../src/components/machines-dashboard.tsx","../src/components/machine-dock-bar.tsx","../src/components/enrollment-device-flow.tsx","../src/components/enrollment-consent.tsx","../src/hooks/use-machines.ts","../src/provider.tsx","../src/hooks/internal.ts"],"sourcesContent":["// ----------------------------------------------------------------------------\n// Bring-your-own-compute — Machines view-model.\n//\n// The data-contract types (MachineView / MetricSample / MachinesResponse /\n// MachineMetricsSeriesResponse / MachineKind / MachineState) are the\n// orchestrator-owned SHARED DATA CONTRACT that M10 ships in `@opengeni/sdk`\n// (hand-written mirrors of `@opengeni/contracts`, pinned by contract-parity).\n// M9 RE-EXPORTS them here so the dashboard UI imports a single, stable name and\n// never drifts from the API — exactly as the contract intends.\n//\n// (During concurrent M9/M10 development this module briefly carried a local\n// view-model with the same field names; once M10 landed the SDK types we\n// reconciled to re-export them — the field names were identical by design.)\n//\n// Endpoints these model (M10 owns the SDK client methods):\n// GET /v1/workspaces/:ws/machines -> MachinesResponse\n// GET /v1/workspaces/:ws/machines/:enrollmentId/metrics/series?window=1h\n// -> { samples: MetricSample[] }\n// ----------------------------------------------------------------------------\nimport type {\n MachineKind,\n MachineMetricsSeriesResponse,\n MachinesResponse,\n MachineState,\n MachineView,\n MetricSample,\n} from \"@opengeni/sdk\";\n\nexport type {\n MachineKind,\n MachineMetricsSeriesResponse,\n MachinesResponse,\n MachineState,\n MachineView,\n MetricSample,\n};\n\n// --- connection-status grouping (a PURE UI projection — not a contract type) --\n\n/**\n * The three connection-status pill values the UI surfaces across the dashboard,\n * the dock, and the timeline. `consent_required` / `display_unavailable` /\n * `enrolling` are NOT connection states — they map onto a connection state for\n * the pill and carry their own badge separately.\n */\nexport type ConnectionStatus = \"online\" | \"reconnecting\" | \"offline\";\n\n/** Project a machine `state` onto its connection-status pill value. */\nexport function connectionStatusForState(state: MachineState): ConnectionStatus {\n switch (state) {\n case \"online\":\n case \"consent_required\":\n case \"display_unavailable\":\n // The control plane is reachable; the limitation is consent / no display.\n return \"online\";\n case \"reconnecting\":\n case \"enrolling\":\n return \"reconnecting\";\n case \"offline\":\n return \"offline\";\n default: {\n // Exhaustiveness guard — a new state must be classified explicitly.\n const _never: never = state;\n return _never;\n }\n }\n}\n","import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n/* ----------------------------------------------------------------------------\n tailwind-merge, taught our design tokens.\n\n Our type scale and color ramp share the `og-` prefix: `text-og-base` is a\n FONT SIZE, `text-og-fg-muted` is a COLOR. Stock tailwind-merge can't tell\n them apart — it lumps every `text-og-*` into one `font-size` group and, when\n two land in the same class list, drops the earlier one. That silently ate the\n size off rows like `text-og-base text-og-fg-muted`, leaving titles at the\n browser-default 16px. Register the custom font-size scale so the size and the\n color live in different conflict groups and both survive a merge.\n -------------------------------------------------------------------------- */\nconst twMerge = extendTailwindMerge({\n extend: {\n classGroups: {\n \"font-size\": [{ text: [\"og-xs\", \"og-sm\", \"og-base\", \"og-md\"] }],\n },\n },\n});\n\n/** Merge class names with Tailwind-aware conflict resolution. */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","import { cn } from \"../lib/cn\";\nimport {\n type ConnectionStatus,\n connectionStatusForState,\n type MachineState,\n} from \"../types/machines\";\n\nexport type ConnectionStatusMeta = {\n label: string;\n dotClassName: string;\n badgeClassName: string;\n /** Live/transient states breathe; settled states hold still. */\n pulse: boolean;\n};\n\n/** Token-backed meta for the three connection-status pill values. */\nexport const CONNECTION_STATUS_META: Record<ConnectionStatus, ConnectionStatusMeta> = {\n online: {\n label: \"Online\",\n dotClassName: \"bg-og-status-running\",\n badgeClassName: \"text-og-status-running border-og-status-running/30 bg-og-status-running/10\",\n pulse: false,\n },\n reconnecting: {\n label: \"Reconnecting\",\n dotClassName: \"bg-og-status-waiting\",\n badgeClassName: \"text-og-status-waiting border-og-status-waiting/35 bg-og-status-waiting/10\",\n pulse: true,\n },\n offline: {\n label: \"Offline\",\n dotClassName: \"bg-og-status-failed\",\n badgeClassName: \"text-og-fg-subtle border-og-border bg-og-status-failed/10\",\n pulse: false,\n },\n};\n\nexport type MachineStateBadgeMeta = {\n label: string;\n badgeClassName: string;\n};\n\n/**\n * The non-connection state badges that ride ALONGSIDE the connection pill —\n * `consent_required` / `display_unavailable` / `enrolling` describe a capability\n * limitation, not reachability, so they render as their own tinted chip.\n */\nexport const MACHINE_STATE_BADGE_META: Partial<Record<MachineState, MachineStateBadgeMeta>> = {\n consent_required: {\n label: \"Consent required\",\n badgeClassName: \"text-og-status-waiting border-og-status-waiting/35 bg-og-status-waiting/10\",\n },\n display_unavailable: {\n label: \"No display\",\n badgeClassName: \"text-og-fg-muted border-og-border bg-og-surface-2\",\n },\n enrolling: {\n label: \"Enrolling\",\n badgeClassName: \"text-og-accent border-og-accent/30 bg-og-accent-soft\",\n },\n};\n\nexport type ConnectionStatusPillProps = {\n status: ConnectionStatus;\n /** Override the label (\"Online\" -> \"Connected\", ...). */\n label?: string | undefined;\n size?: \"sm\" | \"md\" | undefined;\n className?: string | undefined;\n};\n\n/**\n * The connection-status pill (online / reconnecting / offline) surfaced across\n * the Machines dashboard, the dock header, and the session timeline. Reconnecting\n * breathes (the resiliency-as-headline blip), online/offline hold still.\n */\nexport function ConnectionStatusPill({\n status,\n label,\n size = \"md\",\n className,\n}: ConnectionStatusPillProps) {\n const meta = CONNECTION_STATUS_META[status];\n return (\n <span\n data-connection-status={status}\n className={cn(\n \"og-root inline-flex shrink-0 items-center rounded-full border font-medium\",\n size === \"sm\" ? \"gap-1 px-1.5 py-px text-og-xs\" : \"gap-1.5 px-2 py-0.5 text-og-sm\",\n meta.badgeClassName,\n className,\n )}\n >\n <ConnectionDot status={status} className={size === \"sm\" ? \"size-1\" : \"size-1.5\"} />\n {label ?? meta.label}\n </span>\n );\n}\n\nexport type ConnectionDotProps = {\n status: ConnectionStatus;\n className?: string | undefined;\n};\n\n/** Just the dot — for dense rows, the dock header, and timeline notices. */\nexport function ConnectionDot({ status, className }: ConnectionDotProps) {\n const meta = CONNECTION_STATUS_META[status];\n return (\n <span\n className={cn(\n \"relative inline-flex size-1.5 shrink-0 rounded-full\",\n meta.dotClassName,\n className,\n )}\n >\n {meta.pulse ? (\n <span className={cn(\"absolute inset-0 animate-og-pulse rounded-full\", meta.dotClassName)} />\n ) : null}\n </span>\n );\n}\n\nexport type MachineStatusPillProps = {\n /** The machine's full state — drives the connection pill + any state badge. */\n state: MachineState;\n /** How many live sessions share this lease (renders a \"Shared\" chip when >1). */\n sharedSessionCount?: number | undefined;\n size?: \"sm\" | \"md\" | undefined;\n className?: string | undefined;\n};\n\n/**\n * The composite machine status surface: the connection pill PLUS any\n * consent/display/enrolling badge PLUS a shared-in-use chip. One component the\n * dashboard row, the dock header, and the timeline all reuse so the status\n * language is identical everywhere.\n */\nexport function MachineStatusPill({\n state,\n sharedSessionCount,\n size = \"md\",\n className,\n}: MachineStatusPillProps) {\n const stateBadge = MACHINE_STATE_BADGE_META[state];\n const shared = (sharedSessionCount ?? 0) > 1;\n return (\n <span\n className={cn(\"og-root inline-flex flex-wrap items-center gap-1\", className)}\n data-machine-state={state}\n >\n <ConnectionStatusPill status={connectionStatusForState(state)} size={size} />\n {stateBadge ? (\n <span\n data-state-badge={state}\n className={cn(\n \"inline-flex shrink-0 items-center rounded-full border font-medium\",\n size === \"sm\" ? \"px-1.5 py-px text-og-xs\" : \"px-2 py-0.5 text-og-sm\",\n stateBadge.badgeClassName,\n )}\n >\n {stateBadge.label}\n </span>\n ) : null}\n {shared ? (\n <span\n data-shared-chip\n className={cn(\n \"inline-flex shrink-0 items-center gap-1 rounded-full border font-medium\",\n \"text-og-accent border-og-accent/30 bg-og-accent-soft\",\n size === \"sm\" ? \"px-1.5 py-px text-og-xs\" : \"px-2 py-0.5 text-og-sm\",\n )}\n title={`${sharedSessionCount} sessions are on this machine`}\n >\n Shared · {sharedSessionCount}\n </span>\n ) : null}\n </span>\n );\n}\n","/** Compact relative time: \"now\", \"42s\", \"7m\", \"3h\", \"2d\", then a date. */\nexport function formatRelativeTime(iso: string, now: Date = new Date()): string {\n const then = new Date(iso).getTime();\n if (Number.isNaN(then)) {\n return \"\";\n }\n const seconds = Math.max(0, Math.floor((now.getTime() - then) / 1000));\n if (seconds < 10) {\n return \"now\";\n }\n if (seconds < 60) {\n return `${seconds}s`;\n }\n const minutes = Math.floor(seconds / 60);\n if (minutes < 60) {\n return `${minutes}m`;\n }\n const hours = Math.floor(minutes / 60);\n if (hours < 24) {\n return `${hours}h`;\n }\n const days = Math.floor(hours / 24);\n if (days < 14) {\n return `${days}d`;\n }\n return new Date(iso).toLocaleDateString();\n}\n\n/** Human-readable byte size: \"512 B\", \"8.0 KB\", \"1.4 MB\", \"3 GB\". */\nexport function formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n const units = [\"KB\", \"MB\", \"GB\"] as const;\n let value = bytes / 1024;\n for (const unit of units) {\n if (value < 1024 || unit === \"GB\") {\n return `${value.toFixed(value < 10 ? 1 : 0)} ${unit}`;\n }\n value /= 1024;\n }\n return `${bytes} B`;\n}\n\n/** Single-line preview of arbitrary text, for tiles and collapsed rows. */\nexport function truncate(text: string, maxLength: number): string {\n const collapsed = text.replace(/\\s+/g, \" \").trim();\n if (collapsed.length <= maxLength) {\n return collapsed;\n }\n return `${collapsed.slice(0, Math.max(0, maxLength - 1)).trimEnd()}…`;\n}\n\n/** Render an unknown payload as readable text (pretty JSON when possible). */\nexport function stringifyPayload(value: unknown): string {\n if (value === null || value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n const parsed = tryParseJson(value);\n if (parsed !== undefined && typeof parsed === \"object\") {\n return stringifyPayload(parsed);\n }\n return value;\n }\n try {\n return JSON.stringify(value, null, 2) ?? String(value);\n } catch {\n return String(value);\n }\n}\n\n/** JSON.parse that returns `undefined` instead of throwing. */\nexport function tryParseJson(text: string): unknown {\n const trimmed = text.trim();\n if (!trimmed.startsWith(\"{\") && !trimmed.startsWith(\"[\") && !trimmed.startsWith('\"')) {\n return undefined;\n }\n try {\n return JSON.parse(trimmed) as unknown;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The canonical credit-death sentence. Credit exhaustion is the one failure a\n * user can fix themselves — the copy must say what happened (empty balance),\n * what to do (add credits), and what is safe (nothing was lost). Crucially it\n * must NOT say \"send a message to revive\": a revive turn burns credits the\n * workspace no longer has.\n */\nexport const CREDIT_EXHAUSTION_MESSAGE =\n \"Out of OpenGeni credits — this workspace's balance is empty. Add credits to continue; the conversation is preserved.\";\n\n/**\n * Does this failure/completion payload (or raw error string) mean the\n * workspace ran out of OpenGeni credits? Matches the engine's\n * \"insufficient OpenGeni credits\" text (case-insensitive, substring — it\n * arrives both bare and wrapped in \"Activity task failed: …\") and the\n * budget-exhausted segment limit the engine stamps on a turn it ended early.\n */\nexport function isCreditExhaustion(\n input: { error?: string | null; detail?: string | null; segmentLimit?: string | null } | string,\n): boolean {\n if (typeof input === \"string\") {\n return input.toLowerCase().includes(\"insufficient opengeni credits\");\n }\n if (input.segmentLimit === \"budget_exhausted\") {\n return true;\n }\n for (const text of [input.error, input.detail]) {\n if (typeof text === \"string\" && text.toLowerCase().includes(\"insufficient opengeni credits\")) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Humanize engine/provider failure text before it reaches the timeline or a\n * failure banner. Raw provider errors leak the wrong audience's instructions —\n * \"Incorrect API key … find your API key at platform.openai.com\" tells a\n * managed-deployment USER to fix credentials only an OPERATOR controls (and is\n * flatly wrong for Azure or subscription-backed engines). Auth, quota, and\n * credit-exhaustion failures collapse to one neutral, honest sentence; every\n * other reason passes through untouched. Raw payloads stay available in the\n * debug surfaces.\n */\nexport function humanizeFailureReason(reason: string | null): string | null {\n if (!reason) {\n return reason;\n }\n if (isCreditExhaustion(reason)) {\n return CREDIT_EXHAUSTION_MESSAGE;\n }\n const normalized = reason.toLowerCase();\n const authFailure =\n normalized.includes(\"incorrect api key\") ||\n normalized.includes(\"invalid api key\") ||\n normalized.includes(\"invalid_api_key\") ||\n normalized.includes(\"platform.openai.com/account/api-keys\") ||\n (normalized.includes(\"401\") &&\n (normalized.includes(\"api key\") || normalized.includes(\"unauthorized\")));\n if (authFailure) {\n return \"The model provider rejected this deployment's engine credentials. Sending messages won't help until the deployment's engine configuration is fixed.\";\n }\n const quotaFailure =\n normalized.includes(\"insufficient_quota\") || normalized.includes(\"exceeded your current quota\");\n if (quotaFailure) {\n return \"The model provider refused the request: this deployment's provider quota is exhausted.\";\n }\n return reason;\n}\n","import { cn } from \"../lib/cn\";\nimport { formatBytes } from \"../lib/format\";\nimport type { MetricSample } from \"../types/machines\";\n\nexport type MachineMetricsProps = {\n /** The latest metric sample, or null when the machine hasn't reported yet. */\n metrics: MetricSample | null;\n /** Compact (dashboard row) vs full (the dock detail). */\n density?: \"compact\" | \"full\" | undefined;\n className?: string | undefined;\n};\n\n/** Clamp a 0..100-ish percent into the bar range. */\nfunction pct(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.max(0, Math.min(100, value));\n}\n\n/** A label/value pair with a token-tinted utilisation bar. */\nfunction Meter({\n label,\n value,\n fillPct,\n tone,\n}: {\n label: string;\n value: string;\n fillPct: number;\n tone: \"ok\" | \"warn\" | \"hot\";\n}) {\n const fillClass =\n tone === \"hot\"\n ? \"bg-og-status-failed\"\n : tone === \"warn\"\n ? \"bg-og-status-waiting\"\n : \"bg-og-status-running\";\n return (\n <div className=\"flex min-w-0 flex-col gap-1\" data-metric={label.toLowerCase()}>\n <div className=\"flex items-baseline justify-between gap-2\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-og-fg-subtle\">\n {label}\n </span>\n <span className=\"font-og-mono text-[11px] tabular-nums text-og-fg-muted\">{value}</span>\n </div>\n <div className=\"h-1 w-full overflow-hidden rounded-full bg-og-surface-2\">\n <div\n className={cn(\"h-full rounded-full transition-[width] duration-500\", fillClass)}\n style={{ width: `${pct(fillPct)}%` }}\n />\n </div>\n </div>\n );\n}\n\n/** Map a percent to a calm/warn/hot tone (no color invented — token classes). */\nfunction toneFor(p: number): \"ok\" | \"warn\" | \"hot\" {\n if (p >= 90) return \"hot\";\n if (p >= 70) return \"warn\";\n return \"ok\";\n}\n\n/** The token text color for a tone (matches the `Meter` fill ramp). */\nfunction toneTextClass(tone: \"ok\" | \"warn\" | \"hot\"): string {\n return tone === \"hot\"\n ? \"text-og-status-failed\"\n : tone === \"warn\"\n ? \"text-og-status-waiting\"\n : \"text-og-status-running\";\n}\n\n/**\n * Load average as three labeled mini-stats (1m / 5m / 15m) — an honest triple of\n * numbers, NOT a fake gauge. The whole triple is tinted by `load1`'s tone (load\n * isn't a 0..100 ratio, so we tone it but never draw a bar). Run queue rides\n * alongside as a quiet chip when there's pending work.\n */\nfunction StatTriple({\n load1,\n load5,\n load15,\n runQueue,\n}: {\n load1: number;\n load5: number;\n load15: number;\n runQueue: number;\n}) {\n // Load isn't a percent — tone by load1 against a nominal single-core ceiling\n // (≥0.9/core ≈ saturated). Used only to tint the labels/values, never a bar.\n const tone = toneFor(load1 * 100);\n const stats: Array<{ label: string; value: number }> = [\n { label: \"1m\", value: load1 },\n { label: \"5m\", value: load5 },\n { label: \"15m\", value: load15 },\n ];\n return (\n <div className=\"flex items-center justify-between gap-3\" data-metric=\"load\">\n <div className=\"flex min-w-0 flex-col gap-1\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-og-fg-subtle\">\n Load\n </span>\n <div className=\"flex items-baseline gap-3\">\n {stats.map((s) => (\n <div key={s.label} className=\"flex items-baseline gap-1\">\n <span\n className={cn(\n \"text-[10px] font-medium uppercase tracking-wide\",\n toneTextClass(tone),\n )}\n >\n {s.label}\n </span>\n <span className={cn(\"font-og-mono text-[12px] tabular-nums\", toneTextClass(tone))}>\n {s.value.toFixed(2)}\n </span>\n </div>\n ))}\n </div>\n </div>\n {runQueue > 0 ? (\n <div\n className=\"flex shrink-0 items-baseline gap-1.5 rounded-og-sm bg-og-surface-2 px-2 py-1 text-[11px] text-og-fg-subtle\"\n data-metric=\"runqueue\"\n >\n <span className=\"font-medium uppercase tracking-wide\">Queue</span>\n <span className=\"font-og-mono tabular-nums text-og-fg-muted\">{runQueue}</span>\n </div>\n ) : null}\n </div>\n );\n}\n\n/**\n * Per-machine resource meters: CPU%, load average, memory, disk, and GPU when\n * present. Renders the M2 `machine_metrics_latest` sample. When `metrics` is\n * null the panel shows a quiet \"no samples yet\" placeholder (offline / just\n * enrolled). GPU rows only render when `gpuUtilPct` is non-null.\n */\nexport function MachineMetrics({ metrics, density = \"compact\", className }: MachineMetricsProps) {\n if (!metrics) {\n return (\n <div className={cn(\"text-[11px] text-og-fg-subtle\", className)} data-metrics-empty>\n No metrics yet\n </div>\n );\n }\n\n const memPct =\n metrics.memTotalBytes > 0 ? (metrics.memUsedBytes / metrics.memTotalBytes) * 100 : 0;\n const diskPct =\n metrics.diskTotalBytes > 0 ? (metrics.diskUsedBytes / metrics.diskTotalBytes) * 100 : 0;\n const hasGpu = metrics.gpuUtilPct !== null;\n const gpuMemLabel = metrics.gpuMemBytes !== null ? formatBytes(metrics.gpuMemBytes) : null;\n // Memory & disk are honest used/total ratios → full-width meters; stack them in\n // the dock detail, two-up in the dashboard row.\n const ratioGridClass = density === \"full\" ? \"grid-cols-1\" : \"grid-cols-1 sm:grid-cols-2\";\n\n return (\n <div className={cn(\"flex flex-col gap-3\", className)} data-machine-metrics>\n {/* Resources — used/total ratios with real 0..100% bars. */}\n <div className={cn(\"grid gap-x-4 gap-y-2.5\", ratioGridClass)}>\n <Meter\n label=\"Memory\"\n value={`${formatBytes(metrics.memUsedBytes)} / ${formatBytes(metrics.memTotalBytes)}`}\n fillPct={memPct}\n tone={toneFor(memPct)}\n />\n <Meter\n label=\"Disk\"\n value={`${formatBytes(metrics.diskUsedBytes)} / ${formatBytes(metrics.diskTotalBytes)}`}\n fillPct={diskPct}\n tone={toneFor(diskPct)}\n />\n </div>\n\n {/* Utilization — CPU% (and GPU% when present) as honest percent gauges. */}\n <div className=\"grid grid-cols-2 gap-x-4 gap-y-2.5\">\n <Meter\n label=\"CPU\"\n value={`${metrics.cpuPct.toFixed(0)}%`}\n fillPct={metrics.cpuPct}\n tone={toneFor(metrics.cpuPct)}\n />\n {hasGpu ? (\n <Meter\n label=\"GPU\"\n value={\n gpuMemLabel\n ? `${metrics.gpuUtilPct!.toFixed(0)}% · ${gpuMemLabel}`\n : `${metrics.gpuUtilPct!.toFixed(0)}%`\n }\n fillPct={metrics.gpuUtilPct!}\n tone={toneFor(metrics.gpuUtilPct!)}\n />\n ) : null}\n </div>\n\n {/* Activity — load average as labeled mini-stats (no fake bar) + run queue. */}\n <StatTriple\n load1={metrics.load1}\n load5={metrics.load5}\n load15={metrics.load15}\n runQueue={metrics.runQueue}\n />\n </div>\n );\n}\n","import {\n CpuIcon,\n LaptopIcon,\n MonitorIcon,\n MonitorOffIcon,\n ServerIcon,\n UsersIcon,\n} from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatRelativeTime } from \"../lib/format\";\nimport type { MachineView } from \"../types/machines\";\nimport { MachineMetrics } from \"./machine-metrics\";\nimport { MachineStatusPill } from \"./machine-status-pill\";\n\nexport type MachineCardProps = {\n machine: MachineView;\n /** Attach/swap the session's active sandbox to this machine. */\n onAttach?: ((machine: MachineView) => void) | undefined;\n /** Whether an attach/swap is currently in flight (disables the affordance). */\n attaching?: boolean | undefined;\n className?: string | undefined;\n};\n\nfunction KindIcon({ machine }: { machine: MachineView }) {\n if (machine.isSessionGroup)\n return <ServerIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />;\n if (machine.kind === \"modal\") return <CpuIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />;\n return <LaptopIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />;\n}\n\n/**\n * One machine in the Machines dashboard: name + kind + OS/arch, the composite\n * connection/state/shared status, latest resource meters, last-seen recency, and\n * an attach/swap affordance. The session's currently-active sandbox carries an\n * accent edge + an \"Active\" marker (never an attach button — it's already active).\n */\nexport function MachineCard({ machine, onAttach, attaching, className }: MachineCardProps) {\n const offline = machine.state === \"offline\";\n const attachable = !machine.active && !offline && Boolean(onAttach);\n const shared = machine.sharedSessionCount > 1;\n\n return (\n <div\n data-machine-card={machine.sandboxId}\n data-active={machine.active ? \"true\" : \"false\"}\n className={cn(\n \"og-root relative flex flex-col gap-3 overflow-hidden rounded-og-lg border border-og-border\",\n \"bg-og-surface-1 p-4 shadow-og-sm\",\n machine.active && \"border-og-accent/40\",\n className,\n )}\n >\n {machine.active ? (\n <span aria-hidden className=\"absolute inset-y-0 left-0 w-0.5 bg-og-accent\" />\n ) : null}\n\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n <span className=\"mt-0.5 shrink-0\">\n <KindIcon machine={machine} />\n </span>\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <span className=\"truncate text-og-base font-medium text-og-fg\">{machine.name}</span>\n {machine.active ? (\n <span\n data-active-marker\n className=\"shrink-0 rounded-full border border-og-accent/30 bg-og-accent-soft px-1.5 py-px text-og-xs font-medium text-og-accent\"\n >\n Active\n </span>\n ) : null}\n </div>\n <div className=\"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-og-xs text-og-fg-subtle\">\n <span className=\"capitalize\">\n {machine.isSessionGroup ? \"session sandbox\" : machine.kind}\n </span>\n <span aria-hidden>·</span>\n <span className=\"font-og-mono\">\n {machine.os}/{machine.arch}\n </span>\n <span aria-hidden>·</span>\n <span className=\"inline-flex items-center gap-1\">\n {machine.hasDisplay ? (\n <MonitorIcon className=\"size-3\" aria-hidden />\n ) : (\n <MonitorOffIcon className=\"size-3\" aria-hidden />\n )}\n {machine.hasDisplay ? \"display\" : \"headless\"}\n </span>\n </div>\n </div>\n </div>\n <MachineStatusPill\n state={machine.state}\n sharedSessionCount={machine.sharedSessionCount}\n size=\"sm\"\n className=\"shrink-0\"\n />\n </div>\n\n {shared ? (\n <p\n data-shared-disclosure\n className=\"flex items-center gap-1.5 rounded-og-md border border-og-accent/25 bg-og-accent-soft px-2.5 py-1.5 text-og-xs text-og-fg-muted\"\n >\n <UsersIcon className=\"size-3.5 shrink-0 text-og-accent\" aria-hidden />\n Shared — {machine.sharedSessionCount} sessions are on this machine.\n </p>\n ) : null}\n\n <MachineMetrics metrics={machine.metrics} />\n\n <div className=\"mt-1 flex items-center justify-between gap-3 text-og-xs text-og-fg-subtle\">\n <span>\n {machine.lastSeenAt ? (\n <>Last seen {formatRelativeTime(machine.lastSeenAt)}</>\n ) : (\n \"Never connected\"\n )}\n </span>\n {machine.active ? (\n <span className=\"text-og-accent\">Routing here</span>\n ) : attachable ? (\n <button\n type=\"button\"\n data-attach\n disabled={attaching}\n onClick={() => onAttach?.(machine)}\n className={cn(\n \"rounded-og-sm border border-og-border px-2.5 py-1 text-og-xs font-medium text-og-fg-muted transition-colors pointer-coarse:min-h-10\",\n \"hover:border-og-border-strong hover:text-og-fg disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n >\n {attaching ? \"Switching…\" : \"Attach\"}\n </button>\n ) : (\n <span className=\"text-og-fg-subtle/70\">{offline ? \"Unavailable\" : \"—\"}</span>\n )}\n </div>\n </div>\n );\n}\n","import { type ReactNode } from \"react\";\nimport { LaptopIcon, PlusIcon, RefreshCwIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { MachineView } from \"../types/machines\";\nimport { MachineCard } from \"./machine-card\";\n\nexport type MachinesDashboardProps = {\n machines: MachineView[];\n /** The session's active sandbox id (drives the per-card \"Active\" marker). */\n activeSandboxId?: string | null | undefined;\n loading?: boolean | undefined;\n error?: Error | null | undefined;\n /** Attach/swap the session's active sandbox to a machine. */\n onAttach?: ((machine: MachineView) => void) | undefined;\n /** The sandbox id currently being attached/swapped to (disables that card). */\n attachingSandboxId?: string | null | undefined;\n /** Open the enrollment flow (the \"Enroll a machine\" CTA). */\n onEnroll?: (() => void) | undefined;\n onRefresh?: (() => void) | undefined;\n className?: string | undefined;\n};\n\nfunction EmptyState({ onEnroll }: { onEnroll?: (() => void) | undefined }) {\n return (\n <div\n data-machines-empty\n className=\"flex flex-col items-center justify-center gap-3 rounded-og-lg border border-dashed border-og-border bg-og-surface-1 px-6 py-12 text-center\"\n >\n <span className=\"flex size-10 items-center justify-center rounded-full bg-og-surface-2 text-og-fg-subtle\">\n <LaptopIcon className=\"size-5\" aria-hidden />\n </span>\n <div className=\"space-y-1\">\n <p className=\"text-og-base font-medium text-og-fg\">No machines yet</p>\n <p className=\"max-w-xs text-og-sm text-og-fg-muted\">\n Enroll your own computer to run the agent on it — your files, your terminal, your desktop.\n </p>\n </div>\n {onEnroll ? (\n <button\n type=\"button\"\n data-enroll-cta\n onClick={onEnroll}\n className=\"inline-flex items-center gap-1.5 rounded-og-sm bg-og-accent px-3 py-1.5 text-og-sm font-medium text-og-accent-fg transition-colors hover:bg-og-accent-strong pointer-coarse:min-h-10\"\n >\n <PlusIcon className=\"size-3.5\" aria-hidden />\n Enroll a machine\n </button>\n ) : null}\n </div>\n );\n}\n\nfunction Header({\n count,\n onEnroll,\n onRefresh,\n loading,\n}: {\n count: number;\n onEnroll?: (() => void) | undefined;\n onRefresh?: (() => void) | undefined;\n loading?: boolean | undefined;\n}): ReactNode {\n return (\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"flex items-baseline gap-2\">\n <h2 className=\"text-og-base font-semibold text-og-fg\">Machines</h2>\n <span className=\"font-og-mono text-og-xs text-og-fg-subtle\">{count}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n {onRefresh ? (\n <button\n type=\"button\"\n data-refresh\n onClick={onRefresh}\n title=\"Refresh\"\n className=\"rounded-og-sm p-1.5 text-og-fg-subtle transition-colors hover:bg-og-surface-2 hover:text-og-fg\"\n >\n <RefreshCwIcon className={cn(\"size-3.5\", loading && \"animate-og-spin\")} aria-hidden />\n </button>\n ) : null}\n {onEnroll ? (\n <button\n type=\"button\"\n data-enroll-cta\n onClick={onEnroll}\n className=\"inline-flex items-center gap-1.5 rounded-og-sm border border-og-border px-2.5 py-1 text-og-sm font-medium text-og-fg-muted transition-colors hover:border-og-border-strong hover:text-og-fg pointer-coarse:min-h-10\"\n >\n <PlusIcon className=\"size-3.5\" aria-hidden />\n Enroll machine\n </button>\n ) : null}\n </div>\n </div>\n );\n}\n\n/**\n * The workspace Machines dashboard: the fleet of selfhosted enrollments + the\n * session's managed sandbox, each with its connection-status pill, state badges,\n * latest metrics, and an attach/swap affordance. Renders the empty state (no\n * machines → enroll CTA), a load error, and the populated grid. The component\n * is purely presentational — feed it `MachinesResponse` data via `useMachines`.\n */\nexport function MachinesDashboard({\n machines,\n activeSandboxId,\n loading,\n error,\n onAttach,\n attachingSandboxId,\n onEnroll,\n onRefresh,\n className,\n}: MachinesDashboardProps) {\n const isEmpty = !loading && !error && machines.length === 0;\n\n return (\n <section data-machines-dashboard className={cn(\"og-root flex flex-col gap-3\", className)}>\n <Header count={machines.length} onEnroll={onEnroll} onRefresh={onRefresh} loading={loading} />\n\n {error ? (\n <div\n data-machines-error\n className=\"flex flex-wrap items-center justify-between gap-2 rounded-og-md border border-og-status-failed/30 bg-og-status-failed/10 px-3 py-2 text-og-sm text-og-status-failed\"\n >\n <span>Could not load machines: {error.message}</span>\n {onRefresh ? (\n <button\n type=\"button\"\n data-machines-retry\n onClick={onRefresh}\n disabled={loading}\n className=\"inline-flex items-center gap-1.5 rounded-og-sm border border-og-status-failed/30 px-2 py-1 text-og-xs font-medium transition-colors hover:border-og-status-failed/50 disabled:cursor-not-allowed disabled:opacity-60 pointer-coarse:min-h-10\"\n >\n <RefreshCwIcon className={cn(\"size-3.5\", loading && \"animate-og-spin\")} aria-hidden />\n {loading ? \"Retrying…\" : \"Retry\"}\n </button>\n ) : null}\n </div>\n ) : null}\n\n {loading && machines.length === 0 ? (\n <div data-machines-loading className=\"grid gap-3 sm:grid-cols-2\">\n {[0, 1].map((i) => (\n <div\n key={i}\n className=\"h-36 animate-og-pulse rounded-og-lg border border-og-border bg-og-surface-1\"\n />\n ))}\n </div>\n ) : isEmpty ? (\n <EmptyState onEnroll={onEnroll} />\n ) : (\n <div className=\"grid gap-3 sm:grid-cols-2 xl:grid-cols-3\" data-machines-grid>\n {machines.map((machine) => (\n <MachineCard\n key={machine.sandboxId}\n machine={{\n ...machine,\n active: machine.active || machine.sandboxId === activeSandboxId,\n }}\n onAttach={onAttach}\n attaching={attachingSandboxId === machine.sandboxId}\n />\n ))}\n </div>\n )}\n </section>\n );\n}\n","import { LaptopIcon, CpuIcon, UsersIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { MachineKind, MachineState } from \"../types/machines\";\nimport { ConnectionStatusPill, MACHINE_STATE_BADGE_META } from \"./machine-status-pill\";\nimport { connectionStatusForState } from \"../types/machines\";\n\nexport type MachineDockBarProps = {\n /** The active machine's display name. */\n name: string;\n kind: MachineKind;\n state: MachineState;\n /** Live sessions sharing this whole-machine lease (>1 ⇒ shared disclosure). */\n sharedSessionCount?: number | undefined;\n className?: string | undefined;\n};\n\n/**\n * A slim bar that surfaces WHICH machine the dock surfaces (Files/Terminal/\n * Desktop) are bound to + its connection status. Mounted above the dock tabs so\n * the user always knows whether they are looking at the Modal box or their own\n * machine, and whether it is online / reconnecting / offline. The surfaces below\n * render IDENTICALLY regardless of backend — this bar is the only backend-aware\n * chrome (the dock-parity contract: selfhosted == Modal for the surfaces).\n */\nexport function MachineDockBar({ name, kind, state, className }: MachineDockBarProps) {\n const Icon = kind === \"selfhosted\" ? LaptopIcon : CpuIcon;\n const stateBadge = MACHINE_STATE_BADGE_META[state];\n return (\n <div\n data-machine-dock-bar\n className={cn(\n \"flex shrink-0 items-center justify-between gap-2 border-b border-og-border bg-og-surface-1 px-2.5 py-1\",\n className,\n )}\n >\n <div className=\"flex min-w-0 items-center gap-1.5\">\n <Icon className=\"size-3.5 shrink-0 text-og-fg-subtle\" aria-hidden />\n <span className=\"truncate text-[11px] font-medium text-og-fg\">{name}</span>\n {stateBadge ? (\n <span\n data-state-badge={state}\n className={cn(\n \"shrink-0 rounded-full border px-1.5 py-px text-[10px] font-medium\",\n stateBadge.badgeClassName,\n )}\n >\n {stateBadge.label}\n </span>\n ) : null}\n </div>\n <ConnectionStatusPill\n status={connectionStatusForState(state)}\n size=\"sm\"\n className=\"shrink-0\"\n />\n </div>\n );\n}\n\nexport type SharedMachineDisclosureProps = {\n sharedSessionCount: number;\n /** Compact (inline strip) vs full (a notice block). */\n density?: \"compact\" | \"full\" | undefined;\n className?: string | undefined;\n};\n\n/**\n * The \"shared — another session is on this machine\" disclosure. Surfaced in the\n * dock (and reused on the desktop take-control gate) so the user knows others are\n * driving the same whole-machine lease. Render when `sharedSessionCount > 1`.\n */\nexport function SharedMachineDisclosure({\n sharedSessionCount,\n density = \"compact\",\n className,\n}: SharedMachineDisclosureProps) {\n const others = Math.max(0, sharedSessionCount - 1);\n return (\n <div\n data-shared-disclosure\n className={cn(\n \"flex items-center gap-1.5 border-og-accent/25 bg-og-accent-soft text-og-fg-muted\",\n density === \"full\"\n ? \"rounded-og-md border px-3 py-2 text-[12px]\"\n : \"border-b px-2.5 py-1 text-[11px]\",\n className,\n )}\n >\n <UsersIcon className=\"size-3.5 shrink-0 text-og-accent\" aria-hidden />\n <span>\n Shared — {others === 1 ? \"another session is\" : `${others} other sessions are`} on this\n machine. They see the same terminal, files, and desktop.\n </span>\n </div>\n );\n}\n","import { type ReactNode } from \"react\";\nimport { CopyIcon, ExternalLinkIcon, LaptopIcon, TerminalIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport type { MachineState } from \"../types/machines\";\nimport { ConnectionStatusPill } from \"./machine-status-pill\";\n\n/** The poll state of an in-flight device-flow enrollment. */\nexport type DeviceFlowPhase = \"pending\" | \"authorized\" | \"denied\" | \"expired\" | \"disabled\";\n\nexport type EnrollmentDeviceFlowProps = {\n /** The short user code the agent printed (shown big for the human to confirm). */\n userCode: string;\n /** Where the user approves — the same-origin device page. */\n verificationUri: string;\n /** The complete URI (code pre-filled) for a one-click / QR open. */\n verificationUriComplete?: string | undefined;\n /** The install one-liner the user ran (echoed for context). Optional. */\n installCommand?: string | undefined;\n phase?: DeviceFlowPhase | undefined;\n /** Seconds remaining before the code expires (drives a quiet countdown). */\n expiresInSeconds?: number | undefined;\n onCopyCode?: (() => void) | undefined;\n onCopyInstall?: (() => void) | undefined;\n onOpenVerification?: (() => void) | undefined;\n className?: string | undefined;\n};\n\nconst PHASE_TO_STATE: Record<DeviceFlowPhase, MachineState> = {\n pending: \"enrolling\",\n authorized: \"online\",\n denied: \"offline\",\n expired: \"offline\",\n disabled: \"offline\",\n};\n\nfunction PhaseLabel({ phase }: { phase: DeviceFlowPhase }): ReactNode {\n const text: Record<DeviceFlowPhase, string> = {\n pending: \"Waiting for approval\",\n authorized: \"Connected\",\n denied: \"Denied\",\n expired: \"Code expired\",\n disabled: \"Enrollment disabled\",\n };\n return <span>{text[phase]}</span>;\n}\n\n/**\n * The IN-SESSION device-flow panel: the agent (after the install one-liner) prints\n * a short `userCode` + a `verificationUri`; this surfaces them so the user can open\n * the approve page and confirm the code. Polls in the caller; this renders the\n * pending → authorized/denied/expired progression with a connection pill. This is\n * the FIRST step of the IA flow (device-flow → Machines list → attach/swap).\n */\nexport function EnrollmentDeviceFlow({\n userCode,\n verificationUri,\n verificationUriComplete,\n installCommand,\n phase = \"pending\",\n expiresInSeconds,\n onCopyCode,\n onCopyInstall,\n onOpenVerification,\n className,\n}: EnrollmentDeviceFlowProps) {\n const href = verificationUriComplete ?? verificationUri;\n // Before the one-liner runs the caller passes a placeholder (dashes) for the\n // code — surface that as an explicit waiting state rather than dashes that look\n // like a real code to type.\n const codeIsPlaceholder = !/[A-Za-z0-9]/.test(userCode);\n const awaitingCode = phase === \"pending\" && codeIsPlaceholder;\n return (\n <div\n data-enrollment-device-flow\n className={cn(\n \"og-root flex w-full max-w-md flex-col gap-4 rounded-og-lg border border-og-border bg-og-surface-1 p-5 shadow-og-sm\",\n className,\n )}\n >\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"flex items-center gap-2\">\n <span className=\"flex size-7 items-center justify-center rounded-full bg-og-surface-2 text-og-fg-muted\">\n <LaptopIcon className=\"size-4\" aria-hidden />\n </span>\n <h2 className=\"text-sm font-semibold text-og-fg\">Connect a machine</h2>\n </div>\n <ConnectionStatusPill\n status={\n PHASE_TO_STATE[phase] === \"online\"\n ? \"online\"\n : PHASE_TO_STATE[phase] === \"offline\"\n ? \"offline\"\n : \"reconnecting\"\n }\n label={(<PhaseLabel phase={phase} />) as unknown as string}\n size=\"sm\"\n />\n </div>\n\n {installCommand ? (\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-[11px] font-medium uppercase tracking-wide text-og-fg-subtle\">\n 1 · Run on the machine\n </span>\n <div className=\"flex items-center justify-between gap-2 overflow-hidden rounded-og-md border border-og-border bg-og-bg px-2.5 py-1.5\">\n <code className=\"flex min-w-0 items-center gap-2 overflow-x-auto font-og-mono text-[12px] text-og-fg\">\n <TerminalIcon className=\"size-3.5 shrink-0 text-og-fg-subtle\" aria-hidden />\n {installCommand}\n </code>\n <button\n type=\"button\"\n data-copy-install\n onClick={onCopyInstall}\n title=\"Copy command\"\n className=\"shrink-0 rounded-og-sm p-1.5 text-og-fg-subtle transition-colors hover:bg-og-surface-2 hover:text-og-fg\"\n >\n <CopyIcon className=\"size-4\" aria-hidden />\n </button>\n </div>\n </div>\n ) : null}\n\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-[11px] font-medium uppercase tracking-wide text-og-fg-subtle\">\n {installCommand ? \"2 · Approve the machine\" : \"Approve the machine\"}\n </span>\n <div className=\"flex items-center justify-between gap-3 rounded-og-md border border-og-border bg-og-bg px-3 py-2.5\">\n {awaitingCode ? (\n <span data-user-code className=\"font-og-mono text-[13px] text-og-fg-subtle\">\n Run the command above — your code appears here\n </span>\n ) : (\n <span\n data-user-code\n className=\"select-all font-og-mono text-2xl font-semibold tracking-[0.25em] text-og-fg\"\n >\n {userCode}\n </span>\n )}\n <button\n type=\"button\"\n data-copy-code\n onClick={onCopyCode}\n disabled={awaitingCode}\n title=\"Copy code\"\n className=\"shrink-0 rounded-og-sm p-1.5 text-og-fg-subtle transition-colors hover:bg-og-surface-2 hover:text-og-fg disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-og-fg-subtle\"\n >\n <CopyIcon className=\"size-4\" aria-hidden />\n </button>\n </div>\n </div>\n\n <a\n href={href}\n data-open-verification\n target=\"_blank\"\n rel=\"noreferrer\"\n onClick={onOpenVerification}\n className=\"inline-flex items-center justify-center gap-1.5 rounded-og-sm bg-og-accent px-3 py-2 text-sm font-medium text-og-accent-fg transition-colors hover:bg-og-accent-strong\"\n >\n Open approval page\n <ExternalLinkIcon className=\"size-3.5\" aria-hidden />\n </a>\n\n <p className=\"text-center text-[11px] text-og-fg-subtle\">\n {awaitingCode ? (\n <>\n The one-liner prints a short code. Open{\" \"}\n <span className=\"font-og-mono text-og-fg-muted\">{verificationUri}</span> and confirm the\n code shown there matches.\n </>\n ) : (\n <>\n Confirm code <span className=\"font-og-mono text-og-fg-muted\">{userCode}</span> — the one\n printed by the one-liner — at{\" \"}\n <span className=\"font-og-mono text-og-fg-muted\">{verificationUri}</span>.\n {typeof expiresInSeconds === \"number\" ? (\n <> Expires in {Math.max(0, Math.round(expiresInSeconds / 60))} min.</>\n ) : null}\n </>\n )}\n </p>\n </div>\n );\n}\n","import { type ReactNode, useState } from \"react\";\nimport {\n CircleAlertIcon,\n LaptopIcon,\n MonitorIcon,\n ScreenShareIcon,\n ShieldAlertIcon,\n TerminalIcon,\n UsersIcon,\n} from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\n\n/** The machine identity surfaced to the approver, from the device-flow start. */\nexport type EnrollmentConsentMachine = {\n /** Human-friendly name (hostname by default). */\n machineName: string;\n os: string;\n arch: string;\n /** The agent can offer a display (a real screen / Xvfb is available). */\n canOfferDisplay: boolean;\n /** The agent requests screen control (computer-use). */\n requestsScreenControl: boolean;\n};\n\n/** The phase of the approve page (drives the rendered panel). */\nexport type EnrollmentConsentPhase = \"review\" | \"approving\" | \"approved\" | \"denied\" | \"error\";\n\nexport type EnrollmentConsentProps = {\n /** The short code the user typed / scanned (echoed back for confirmation). */\n userCode: string;\n machine: EnrollmentConsentMachine;\n phase?: EnrollmentConsentPhase | undefined;\n /** Approve with the chosen screen-control consent. */\n onApprove?: ((allowScreenControl: boolean) => void) | undefined;\n onDeny?: (() => void) | undefined;\n /** Error message when phase === \"error\". */\n errorMessage?: string | undefined;\n className?: string | undefined;\n};\n\nfunction Capability({ icon, title, body }: { icon: ReactNode; title: string; body: string }) {\n return (\n <li className=\"flex items-start gap-2.5\">\n <span className=\"mt-0.5 shrink-0 text-og-status-failed\">{icon}</span>\n <span className=\"min-w-0\">\n <span className=\"block text-og-base font-medium text-og-fg\">{title}</span>\n <span className=\"block text-og-sm text-og-fg-muted\">{body}</span>\n </span>\n </li>\n );\n}\n\n/**\n * The user-facing APPROVE page for the device-flow enrollment: a LOUD,\n * un-minimised whole-machine consent. Approving grants the agent FULL access to\n * this machine — exec, files, terminal — and (when toggled) live screen control.\n * The danger framing is deliberate (§18 hardening: whole-machine = loud consent),\n * never buried. Renders review / approving / approved / denied / error phases.\n */\nexport function EnrollmentConsent({\n userCode,\n machine,\n phase = \"review\",\n onApprove,\n onDeny,\n errorMessage,\n className,\n}: EnrollmentConsentProps) {\n const [allowScreenControl, setAllowScreenControl] = useState(machine.requestsScreenControl);\n const busy = phase === \"approving\";\n\n if (phase === \"approved\") {\n return (\n <ConsentResult\n className={className}\n tone=\"ok\"\n title=\"Machine connected\"\n body={`${machine.machineName} is now enrolled in this workspace. You can close this page — it will appear in your Machines dashboard.`}\n />\n );\n }\n if (phase === \"denied\") {\n return (\n <ConsentResult\n className={className}\n tone=\"muted\"\n title=\"Enrollment denied\"\n body={`You declined to connect ${machine.machineName}. The agent has no access to this machine. You can re-run the install one-liner to try again.`}\n />\n );\n }\n if (phase === \"error\") {\n return (\n <ConsentResult\n className={className}\n tone=\"danger\"\n title=\"Could not complete enrollment\"\n body={\n errorMessage ??\n \"The code may have expired. Re-run the install one-liner on the machine for a fresh code.\"\n }\n />\n );\n }\n\n return (\n <div\n data-enrollment-consent\n className={cn(\n \"og-root mx-auto flex w-full max-w-md flex-col gap-5 rounded-og-lg border border-og-status-failed/30 bg-og-surface-1 p-6 shadow-og-md\",\n className,\n )}\n >\n <div className=\"flex items-start gap-3\">\n <span className=\"flex size-9 shrink-0 items-center justify-center rounded-full bg-og-status-failed/15 text-og-status-failed\">\n <ShieldAlertIcon className=\"size-5\" aria-hidden />\n </span>\n <div className=\"min-w-0\">\n <h1 className=\"text-og-md font-semibold text-og-fg\">\n Give the agent your whole machine?\n </h1>\n <p className=\"mt-1 text-og-base text-og-fg-muted\">\n Approving lets the OpenGeni agent run on{\" \"}\n <span className=\"font-medium text-og-fg\">{machine.machineName}</span> with full access.\n This is your real computer — not a sandbox.\n </p>\n </div>\n </div>\n\n <div className=\"flex flex-wrap items-center gap-2 rounded-og-md border border-og-border bg-og-surface-2 px-3 py-2 text-og-sm\">\n <LaptopIcon className=\"size-4 text-og-fg-subtle\" aria-hidden />\n <span className=\"font-medium text-og-fg\">{machine.machineName}</span>\n <span className=\"font-og-mono text-og-fg-subtle\">\n {machine.os}/{machine.arch}\n </span>\n <span aria-hidden className=\"text-og-fg-subtle\">\n ·\n </span>\n <span className=\"text-og-fg-subtle\">\n code <span className=\"font-og-mono font-medium text-og-fg\">{userCode}</span>\n </span>\n </div>\n\n <ul className=\"flex flex-col gap-3\">\n <Capability\n icon={<TerminalIcon className=\"size-4\" aria-hidden />}\n title=\"Read, write & run anything\"\n body=\"The agent can read and modify any file, run any command, and use your git credentials — as if it were you at the keyboard.\"\n />\n {machine.canOfferDisplay ? (\n <Capability\n icon={<MonitorIcon className=\"size-4\" aria-hidden />}\n title=\"See your screen\"\n body=\"The agent can capture this machine's display to watch what it is doing.\"\n />\n ) : null}\n <Capability\n icon={<UsersIcon className=\"size-4\" aria-hidden />}\n title=\"Shared while connected\"\n body=\"Any session in this workspace can use this machine while it is online. Disconnect the agent to revoke access instantly.\"\n />\n </ul>\n\n {machine.canOfferDisplay ? (\n <label\n data-screen-control-toggle\n className=\"flex cursor-pointer items-start gap-3 rounded-og-md border border-og-border bg-og-bg px-3 py-2.5\"\n >\n <input\n type=\"checkbox\"\n checked={allowScreenControl}\n disabled={busy}\n onChange={(e) => setAllowScreenControl(e.target.checked)}\n className=\"mt-0.5 size-4 accent-og-accent\"\n />\n <span className=\"min-w-0\">\n <span className=\"flex items-center gap-1.5 text-og-base font-medium text-og-fg\">\n <ScreenShareIcon className=\"size-3.5 text-og-fg-muted\" aria-hidden />\n Also let the agent control my mouse & keyboard\n </span>\n <span className=\"mt-0.5 block text-og-sm text-og-fg-muted\">\n Optional. Enables computer-use — the agent can move the pointer, type, and click on\n this machine's desktop. Leave off to let it only watch.\n </span>\n </span>\n </label>\n ) : (\n <p className=\"flex items-start gap-2 rounded-og-md border border-og-border bg-og-bg px-3 py-2 text-og-sm text-og-fg-muted\">\n <CircleAlertIcon className=\"mt-px size-3.5 shrink-0 text-og-fg-subtle\" aria-hidden />\n This machine has no display, so screen control isn't available — files, terminal, and git\n only.\n </p>\n )}\n\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n data-deny\n disabled={busy}\n onClick={() => onDeny?.()}\n className=\"flex-1 rounded-og-sm border border-og-border px-3 py-2 text-og-sm font-medium text-og-fg-muted transition-colors hover:border-og-border-strong hover:text-og-fg disabled:opacity-50 pointer-coarse:min-h-10\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n data-approve\n disabled={busy}\n onClick={() => onApprove?.(allowScreenControl)}\n className=\"flex-1 rounded-og-sm bg-og-status-failed px-3 py-2 text-og-sm font-semibold text-og-accent-fg transition-colors hover:opacity-90 disabled:opacity-50 pointer-coarse:min-h-10\"\n >\n {busy ? \"Connecting…\" : \"Grant full access\"}\n </button>\n </div>\n </div>\n );\n}\n\nfunction ConsentResult({\n tone,\n title,\n body,\n className,\n}: {\n tone: \"ok\" | \"muted\" | \"danger\";\n title: string;\n body: string;\n className?: string | undefined;\n}) {\n const ring =\n tone === \"ok\"\n ? \"border-og-status-running/30\"\n : tone === \"danger\"\n ? \"border-og-status-failed/30\"\n : \"border-og-border\";\n const iconClass =\n tone === \"ok\"\n ? \"text-og-status-running\"\n : tone === \"danger\"\n ? \"text-og-status-failed\"\n : \"text-og-fg-subtle\";\n return (\n <div\n data-enrollment-result={tone}\n className={cn(\n \"og-root mx-auto flex w-full max-w-md flex-col items-center gap-3 rounded-og-lg border bg-og-surface-1 p-6 text-center shadow-og-md\",\n ring,\n className,\n )}\n >\n <span\n className={cn(\n \"flex size-10 items-center justify-center rounded-full bg-og-surface-2\",\n iconClass,\n )}\n >\n <LaptopIcon className=\"size-5\" aria-hidden />\n </span>\n <h1 className=\"text-og-md font-semibold text-og-fg\">{title}</h1>\n <p className=\"max-w-sm text-og-base text-og-fg-muted\">{body}</p>\n </div>\n );\n}\n","import { useCallback, useState } from \"react\";\nimport { useOpenGeni, type ClientOverride } from \"../provider\";\nimport { useMutationRunner, usePolledValue } from \"./internal\";\nimport type { MachinesResponse, MachineView, MetricSample } from \"../types/machines\";\n\n/**\n * The slice of the SDK client the Machines surface needs. The method NAMES +\n * SIGNATURES match M10's `OpenGeniClient` (`listMachines`, `machineMetricsSeries`)\n * so the real SDK client satisfies this surface DIRECTLY for the read paths — no\n * adapter needed. It is declared structurally (not a hard `OpenGeniClient` Pick)\n * so a test/demo/Geni-frontend client can stand in, keeping the hook dual-consumer\n * safe (works in apps/web AND the separate Geni frontend).\n *\n * The active-sandbox SWAP is now a typed SDK call (`swapActiveSandbox`, the M7\n * user-authenticated REST equivalent of the `sandbox_swap` MCP tool). The real\n * SDK client satisfies it structurally, so the default attach path is wired\n * WHENEVER a sessionId is in scope (the swap is session-scoped). `attachMachine`\n * stays an OPTIONAL escape hatch for a host that wants to supply its own swap\n * adapter; when neither it nor a sessionId is present, attach is a no-op and the\n * card hides the button.\n */\nexport type MachinesClientLike = {\n /** GET /v1/workspaces/:ws/machines — the dashboard list + active pointer. */\n listMachines: (\n workspaceId: string,\n options?: { sessionId?: string },\n ) => Promise<MachinesResponse>;\n /** GET .../machines/:enrollmentId/metrics/series — the downsampled history. */\n machineMetricsSeries?: (\n workspaceId: string,\n enrollmentId: string,\n options?: { window?: \"15m\" | \"1h\" | \"6h\" | \"24h\" },\n ) => Promise<MetricSample[]>;\n /**\n * POST .../sessions/:sessionId/active-sandbox — swap the session's active\n * sandbox to a machine. The default swap path; the real SDK client provides it.\n */\n swapActiveSandbox?: (\n workspaceId: string,\n sessionId: string,\n request: { target: string },\n ) => Promise<unknown>;\n /**\n * Host-supplied swap adapter (an escape hatch). When present it wins over the\n * default `swapActiveSandbox` path. Session-scoped, like the swap it backs.\n */\n attachMachine?: (workspaceId: string, sessionId: string, sandboxId: string) => Promise<unknown>;\n};\n\nexport type UseMachinesOptions = ClientOverride & {\n pollIntervalMs?: number | undefined;\n enabled?: boolean | undefined;\n /** Scope the list to a session (adds the synthetic Modal group box + pointer). */\n sessionId?: string | undefined;\n /**\n * Override the client with one implementing `MachinesClientLike`. Defaults to\n * the provider client cast to the surface (the real SDK client satisfies the\n * read paths). An app supplies an adapter to wire `attachMachine` (the swap).\n */\n machinesClient?: MachinesClientLike | undefined;\n};\n\nexport type UseMachinesResult = {\n machines: MachineView[];\n activeSandboxId: string | null;\n activeEpoch: number;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Attach/swap the session's active sandbox to a machine (returns the new pointer). */\n attach: (sandboxId: string) => Promise<boolean>;\n /** Whether the host wired an attach/swap path (drives the card affordance). */\n canAttach: boolean;\n /** Fetch a downsampled metric series for one enrolled machine. */\n fetchSeries: (\n enrollmentId: string,\n window?: \"15m\" | \"1h\" | \"6h\" | \"24h\",\n ) => Promise<MetricSample[]>;\n attaching: boolean;\n /** The sandbox id of the in-flight attach (for per-card spinner gating). */\n attachingSandboxId: string | null;\n mutationError: Error | null;\n clearMutationError: () => void;\n};\n\nconst EMPTY: MachinesResponse = { activeSandboxId: null, activeEpoch: 0, machines: [] };\n\n/**\n * The workspace Machines fleet: the selfhosted enrollments + the session's Modal\n * box, each with latest metrics + state, plus the active-sandbox pointer. Polls\n * the M10 `GET /machines` endpoint and exposes attach/swap + a metric-series\n * fetch. Renders via `<MachinesDashboard>`. Dual-consumer safe: it reads only the\n * structural `MachinesClientLike` surface, so it works in apps/web AND the Geni\n * frontend (each provides its own client/adapter).\n */\nexport function useMachines(options: UseMachinesOptions = {}): UseMachinesResult {\n const { client, workspaceId } = useOpenGeni(options);\n const machinesClient = (options.machinesClient ??\n (client as unknown as MachinesClientLike)) satisfies MachinesClientLike;\n const sessionId = options.sessionId;\n\n const load = useCallback(async () => {\n return await machinesClient.listMachines(workspaceId, sessionId ? { sessionId } : undefined);\n }, [machinesClient, workspaceId, sessionId]);\n\n const {\n data: loadedData,\n loading,\n error,\n refresh,\n } = usePolledValue(load, {\n pollIntervalMs: options.pollIntervalMs,\n enabled: options.enabled,\n });\n const { run, mutating, mutationError, clearMutationError } = useMutationRunner();\n // The sandbox id of the in-flight attach (drives the per-card spinner).\n const [attachingSandboxId, setAttachingSandboxId] = useState<string | null>(null);\n\n const data = loadedData ?? EMPTY;\n // The swap is session-scoped: a host adapter (`attachMachine`) wins; otherwise\n // the default `swapActiveSandbox` path is wired whenever a sessionId is in\n // scope. Either way attach needs a sessionId to point at.\n const canAttach =\n sessionId !== undefined &&\n (typeof machinesClient.attachMachine === \"function\" ||\n typeof machinesClient.swapActiveSandbox === \"function\");\n\n const attach = useCallback(\n async (sandboxId: string): Promise<boolean> => {\n if (sessionId === undefined) return false;\n const runSwap = machinesClient.attachMachine\n ? () => machinesClient.attachMachine!(workspaceId, sessionId, sandboxId)\n : machinesClient.swapActiveSandbox\n ? () => machinesClient.swapActiveSandbox!(workspaceId, sessionId, { target: sandboxId })\n : null;\n if (!runSwap) return false;\n setAttachingSandboxId(sandboxId);\n const result = await run(async () => {\n await runSwap();\n return true;\n });\n setAttachingSandboxId(null);\n if (result) await refresh();\n return result === true;\n },\n [machinesClient, workspaceId, sessionId, run, refresh],\n );\n\n const fetchSeries = useCallback(\n async (\n enrollmentId: string,\n window: \"15m\" | \"1h\" | \"6h\" | \"24h\" = \"1h\",\n ): Promise<MetricSample[]> => {\n if (!machinesClient.machineMetricsSeries) return [];\n return await machinesClient.machineMetricsSeries(workspaceId, enrollmentId, { window });\n },\n [machinesClient, workspaceId],\n );\n\n return {\n machines: data.machines,\n activeSandboxId: data.activeSandboxId,\n activeEpoch: data.activeEpoch,\n loading,\n error,\n refresh,\n attach,\n canAttach,\n fetchSeries,\n attaching: mutating,\n attachingSandboxId,\n mutationError,\n clearMutationError,\n };\n}\n","import { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport type { SessionClientLike } from \"./client\";\n\nexport type OpenGeniContextValue = {\n client: SessionClientLike;\n workspaceId: string;\n};\n\nconst OpenGeniContext = createContext<OpenGeniContextValue | null>(null);\n\nexport type OpenGeniProviderProps = {\n client: SessionClientLike;\n workspaceId: string;\n children?: ReactNode;\n};\n\n/**\n * Supplies the OpenGeni client + workspace to all hooks below it. Hooks also\n * accept `{ client, workspaceId }` overrides per call for multi-workspace UIs.\n */\nexport function OpenGeniProvider({ client, workspaceId, children }: OpenGeniProviderProps) {\n const value = useMemo(() => ({ client, workspaceId }), [client, workspaceId]);\n return <OpenGeniContext.Provider value={value}>{children}</OpenGeniContext.Provider>;\n}\n\nexport type ClientOverride = {\n client?: SessionClientLike | undefined;\n workspaceId?: string | undefined;\n};\n\n/** Resolve client + workspace from explicit overrides or the provider. */\nexport function useOpenGeni(override: ClientOverride = {}): OpenGeniContextValue {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n const workspaceId = override.workspaceId ?? context?.workspaceId;\n if (!client || !workspaceId) {\n throw new Error(\n \"@opengeni/react: no OpenGeni client/workspace available. Wrap the tree in <OpenGeniProvider> or pass { client, workspaceId } to the hook.\",\n );\n }\n return { client, workspaceId };\n}\n\n/**\n * Resolve the client only — for hooks that are not workspace-scoped\n * (`useWorkspaces`, `useBillingUsage`).\n */\nexport function useOpenGeniClient(\n override: Pick<ClientOverride, \"client\"> = {},\n): SessionClientLike {\n const context = useContext(OpenGeniContext);\n const client = override.client ?? context?.client;\n if (!client) {\n throw new Error(\n \"@opengeni/react: no OpenGeni client available. Wrap the tree in <OpenGeniProvider> or pass { client } to the hook.\",\n );\n }\n return client;\n}\n","import type { SessionEvent } from \"@opengeni/sdk\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { SessionClientLike } from \"../client\";\n\nexport type AsyncListState<T> = {\n data: T | null;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n};\n\n/**\n * Shared fetch + optional polling loop for the list/read hooks. Stale\n * responses (superseded by a newer load or an unmount) are dropped.\n */\nexport function usePolledValue<T>(\n load: () => Promise<T>,\n options: { pollIntervalMs?: number | undefined; enabled?: boolean | undefined } = {},\n): AsyncListState<T> {\n const enabled = options.enabled ?? true;\n const pollIntervalMs = options.pollIntervalMs;\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState(enabled);\n const [error, setError] = useState<Error | null>(null);\n const generation = useRef(0);\n const loadRef = useRef(load);\n\n // A new loader identity means a new query (different session/workspace/...):\n // drop the previous result instead of showing it as the new query's data.\n useEffect(() => {\n if (loadRef.current !== load) {\n loadRef.current = load;\n setData(null);\n setError(null);\n }\n }, [load]);\n\n const run = useCallback(async () => {\n const ticket = ++generation.current;\n try {\n const result = await load();\n if (ticket === generation.current) {\n setData(result);\n setError(null);\n setLoading(false);\n }\n } catch (cause) {\n if (ticket === generation.current) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n setLoading(false);\n }\n }\n }, [load]);\n\n useEffect(() => {\n if (!enabled) {\n setLoading(false);\n return;\n }\n setLoading(true);\n void run();\n if (pollIntervalMs === undefined || pollIntervalMs <= 0) {\n return () => {\n generation.current += 1;\n };\n }\n const timer = setInterval(() => void run(), pollIntervalMs);\n return () => {\n clearInterval(timer);\n generation.current += 1;\n };\n }, [run, enabled, pollIntervalMs]);\n\n return { data, loading, error, refresh: run };\n}\n\nexport type MutationState = {\n mutating: boolean;\n mutationError: Error | null;\n clearMutationError: () => void;\n};\n\n/**\n * Shared async mutation runner for the write hooks. `run` resolves with the\n * operation's value, or `null` after capturing the error in `mutationError`\n * (callers then roll back optimistic state).\n */\nexport function useMutationRunner(): MutationState & {\n run: <T>(operation: () => Promise<T>) => Promise<T | null>;\n} {\n const [mutating, setMutating] = useState(false);\n const [mutationError, setMutationError] = useState<Error | null>(null);\n const inFlight = useRef(0);\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const run = useCallback(async <T>(operation: () => Promise<T>): Promise<T | null> => {\n inFlight.current += 1;\n if (mounted.current) {\n setMutating(true);\n setMutationError(null);\n }\n try {\n return await operation();\n } catch (cause) {\n if (mounted.current) {\n setMutationError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n return null;\n } finally {\n inFlight.current -= 1;\n if (mounted.current && inFlight.current === 0) {\n setMutating(false);\n }\n }\n }, []);\n return {\n mutating,\n mutationError,\n clearMutationError: useCallback(() => setMutationError(null), []),\n run,\n };\n}\n\nexport type SessionEventFeedOptions = {\n /**\n * Share an existing event log (from `useSessionEvents`) instead of opening\n * a second stream. When omitted the hook tails the session's event stream\n * itself, starting at the current `lastSequence`.\n */\n events?: SessionEvent[] | undefined;\n enabled?: boolean | undefined;\n};\n\n/**\n * Invoke `onEvent` for every session event matching `match` — the live-update\n * primitive behind `useTurnQueue` and `useGoal`. Either watches a shared\n * `events` log or tails the stream directly (reconnect handled by the SDK).\n */\nexport function useSessionEventTrigger(\n client: SessionClientLike,\n workspaceId: string,\n sessionId: string | null | undefined,\n match: (event: SessionEvent) => boolean,\n onEvent: (event: SessionEvent) => void,\n options: SessionEventFeedOptions = {},\n): void {\n const enabled = options.enabled ?? true;\n const events = options.events;\n const sharedFeed = events !== undefined;\n const matchRef = useRef(match);\n matchRef.current = match;\n const onEventRef = useRef(onEvent);\n onEventRef.current = onEvent;\n const consumedRef = useRef(0);\n const feedKeyRef = useRef<string | null>(null);\n\n // Shared-log mode: scan only the unseen tail on every append.\n useEffect(() => {\n if (!sharedFeed || !enabled || !sessionId) {\n return;\n }\n const feedKey = `${workspaceId}\\u0000${sessionId}`;\n const firstSequence = events[0]?.sequence ?? 0;\n // A new session target or a log reset (sequence restarted below the\n // cursor) restarts consumption from the top of the shared log.\n if (feedKeyRef.current !== feedKey || firstSequence > consumedRef.current + 1) {\n feedKeyRef.current = feedKey;\n consumedRef.current = 0;\n }\n for (const event of events) {\n if (event.sequence <= consumedRef.current) {\n continue;\n }\n consumedRef.current = event.sequence;\n if (matchRef.current(event)) {\n onEventRef.current(event);\n }\n }\n }, [sharedFeed, enabled, events, workspaceId, sessionId]);\n\n // Self-stream mode: tail from the session's current lastSequence.\n useEffect(() => {\n if (sharedFeed || !enabled || !sessionId) {\n return;\n }\n const controller = new AbortController();\n void (async () => {\n try {\n const session = await client.getSession(workspaceId, sessionId);\n if (controller.signal.aborted) {\n return;\n }\n const stream = client.streamEvents(workspaceId, sessionId, {\n after: session.lastSequence,\n signal: controller.signal,\n });\n for await (const event of stream) {\n if (matchRef.current(event)) {\n onEventRef.current(event);\n }\n }\n } catch {\n // Live updates are best-effort: the read hooks still expose refresh()\n // and the initial load already populated state.\n }\n })();\n return () => {\n controller.abort();\n };\n }, [sharedFeed, enabled, client, workspaceId, sessionId]);\n}\n\n/** Debounce rapid event bursts into one trailing call (default 150ms). */\nexport function useDebouncedCallback(callback: () => void, delayMs = 150): () => void {\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => {\n return () => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n return useCallback(() => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n callbackRef.current();\n }, delayMs);\n }, [delayMs]);\n}\n"],"mappings":";AAgDO,SAAS,yBAAyB,OAAuC;AAC9E,UAAQ,OAAO;AAAA,IACb,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAEH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAA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IACA,CAAC,gBAAgB,aAAa,WAAW,KAAK,OAAO;AAAA,EACvD;AAEA,QAAM,cAAcA;AAAA,IAClB,OACE,cACA,SAAsC,SACV;AAC5B,UAAI,CAAC,eAAe,qBAAsB,QAAO,CAAC;AAClD,aAAO,MAAM,eAAe,qBAAqB,aAAa,cAAc,EAAE,OAAO,CAAC;AAAA,IACxF;AAAA,IACA,CAAC,gBAAgB,WAAW;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL,UAAU,KAAK;AAAA,IACf,iBAAiB,KAAK;AAAA,IACtB,aAAa,KAAK;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["jsx","jsxs","jsx","jsxs","LaptopIcon","jsx","jsxs","LaptopIcon","LaptopIcon","CpuIcon","UsersIcon","jsx","jsxs","LaptopIcon","CpuIcon","UsersIcon","LaptopIcon","Fragment","jsx","jsxs","LaptopIcon","LaptopIcon","MonitorIcon","TerminalIcon","UsersIcon","jsx","jsxs","LaptopIcon","TerminalIcon","MonitorIcon","UsersIcon","useCallback","useState","jsx","useState","useCallback","useState"]}
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import { OpenGeniClient, MachineState, MetricSample, MachineView, MachineKind, MachinesResponse } from '@opengeni/sdk';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The slice of `OpenGeniClient` the hooks depend on. Structural, so apps can
|
|
7
|
-
* pass the real SDK client, a proxy-backed client that routes through their
|
|
8
|
-
* own API, or a scripted client in tests/demos.
|
|
9
|
-
*/
|
|
10
|
-
type SessionClientLike = Pick<OpenGeniClient, "getClientConfig" | "getSession" | "getSessionLineage" | "updateSession" | "updateSessionPin" | "listSessions" | "listSessionPage" | "sendMessage" | "steerMessage" | "pauseSession" | "resumeSession" | "sendApprovalDecision" | "listEvents" | "streamEvents" | "getQueue" | "cancelQueueItem" | "listTurns" | "getGoal" | "updateGoal" | "deleteGoal" | "clearSessionContext" | "compactSessionContext" | "listScheduledTasks" | "uploadFile" | "getFile" | "createFileDownloadUrl" | "listVariableSets" | "createVariableSet" | "updateVariableSet" | "deleteVariableSet" | "setVariableSetVariable" | "deleteVariableSetVariable" | "listEnvironments" | "createEnvironment" | "updateEnvironment" | "deleteEnvironment" | "setEnvironmentVariable" | "deleteEnvironmentVariable" | "listRigs" | "createRig" | "getRig" | "updateRig" | "deleteRig" | "listRigVersions" | "activateRigVersion" | "listRigChanges" | "proposeRigChange" | "getRigChange" | "verifyRigChange" | "promoteRigChange" | "verifyRig" | "listPacks" | "registerPack" | "enablePack" | "deletePack" | "listWorkspaces" | "createWorkspace" | "updateWorkspace" | "getBillingUsage" | "getClientConfig" | "getStreamCapabilities" | "acknowledgeStream" | "attachViewer" | "heartbeatViewer" | "detachViewer" | "fsList" | "fsRead" | "fsWrite" | "fsDelete" | "fsMove" | "fsMkdir" | "gitStatus" | "gitDiff" | "getWorkspaceCapture" | "getWorkspaceCaptureFile" | "terminalExec" | "terminalPtyOpen" | "terminalPtyWrite" | "terminalPtyResize" | "terminalPtyClose">;
|
|
11
|
-
|
|
12
|
-
type OpenGeniContextValue = {
|
|
13
|
-
client: SessionClientLike;
|
|
14
|
-
workspaceId: string;
|
|
15
|
-
};
|
|
16
|
-
type OpenGeniProviderProps = {
|
|
17
|
-
client: SessionClientLike;
|
|
18
|
-
workspaceId: string;
|
|
19
|
-
children?: ReactNode;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Supplies the OpenGeni client + workspace to all hooks below it. Hooks also
|
|
23
|
-
* accept `{ client, workspaceId }` overrides per call for multi-workspace UIs.
|
|
24
|
-
*/
|
|
25
|
-
declare function OpenGeniProvider({ client, workspaceId, children }: OpenGeniProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
|
-
type ClientOverride = {
|
|
27
|
-
client?: SessionClientLike | undefined;
|
|
28
|
-
workspaceId?: string | undefined;
|
|
29
|
-
};
|
|
30
|
-
/** Resolve client + workspace from explicit overrides or the provider. */
|
|
31
|
-
declare function useOpenGeni(override?: ClientOverride): OpenGeniContextValue;
|
|
32
|
-
/**
|
|
33
|
-
* Resolve the client only — for hooks that are not workspace-scoped
|
|
34
|
-
* (`useWorkspaces`, `useBillingUsage`).
|
|
35
|
-
*/
|
|
36
|
-
declare function useOpenGeniClient(override?: Pick<ClientOverride, "client">): SessionClientLike;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The three connection-status pill values the UI surfaces across the dashboard,
|
|
40
|
-
* the dock, and the timeline. `consent_required` / `display_unavailable` /
|
|
41
|
-
* `enrolling` are NOT connection states — they map onto a connection state for
|
|
42
|
-
* the pill and carry their own badge separately.
|
|
43
|
-
*/
|
|
44
|
-
type ConnectionStatus = "online" | "reconnecting" | "offline";
|
|
45
|
-
/** Project a machine `state` onto its connection-status pill value. */
|
|
46
|
-
declare function connectionStatusForState(state: MachineState): ConnectionStatus;
|
|
47
|
-
|
|
48
|
-
type ConnectionStatusMeta = {
|
|
49
|
-
label: string;
|
|
50
|
-
dotClassName: string;
|
|
51
|
-
badgeClassName: string;
|
|
52
|
-
/** Live/transient states breathe; settled states hold still. */
|
|
53
|
-
pulse: boolean;
|
|
54
|
-
};
|
|
55
|
-
/** Token-backed meta for the three connection-status pill values. */
|
|
56
|
-
declare const CONNECTION_STATUS_META: Record<ConnectionStatus, ConnectionStatusMeta>;
|
|
57
|
-
type MachineStateBadgeMeta = {
|
|
58
|
-
label: string;
|
|
59
|
-
badgeClassName: string;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* The non-connection state badges that ride ALONGSIDE the connection pill —
|
|
63
|
-
* `consent_required` / `display_unavailable` / `enrolling` describe a capability
|
|
64
|
-
* limitation, not reachability, so they render as their own tinted chip.
|
|
65
|
-
*/
|
|
66
|
-
declare const MACHINE_STATE_BADGE_META: Partial<Record<MachineState, MachineStateBadgeMeta>>;
|
|
67
|
-
type ConnectionStatusPillProps = {
|
|
68
|
-
status: ConnectionStatus;
|
|
69
|
-
/** Override the label ("Online" -> "Connected", ...). */
|
|
70
|
-
label?: string | undefined;
|
|
71
|
-
size?: "sm" | "md" | undefined;
|
|
72
|
-
className?: string | undefined;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* The connection-status pill (online / reconnecting / offline) surfaced across
|
|
76
|
-
* the Machines dashboard, the dock header, and the session timeline. Reconnecting
|
|
77
|
-
* breathes (the resiliency-as-headline blip), online/offline hold still.
|
|
78
|
-
*/
|
|
79
|
-
declare function ConnectionStatusPill({ status, label, size, className, }: ConnectionStatusPillProps): react_jsx_runtime.JSX.Element;
|
|
80
|
-
type ConnectionDotProps = {
|
|
81
|
-
status: ConnectionStatus;
|
|
82
|
-
className?: string | undefined;
|
|
83
|
-
};
|
|
84
|
-
/** Just the dot — for dense rows, the dock header, and timeline notices. */
|
|
85
|
-
declare function ConnectionDot({ status, className }: ConnectionDotProps): react_jsx_runtime.JSX.Element;
|
|
86
|
-
type MachineStatusPillProps = {
|
|
87
|
-
/** The machine's full state — drives the connection pill + any state badge. */
|
|
88
|
-
state: MachineState;
|
|
89
|
-
/** How many live sessions share this lease (renders a "Shared" chip when >1). */
|
|
90
|
-
sharedSessionCount?: number | undefined;
|
|
91
|
-
size?: "sm" | "md" | undefined;
|
|
92
|
-
className?: string | undefined;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* The composite machine status surface: the connection pill PLUS any
|
|
96
|
-
* consent/display/enrolling badge PLUS a shared-in-use chip. One component the
|
|
97
|
-
* dashboard row, the dock header, and the timeline all reuse so the status
|
|
98
|
-
* language is identical everywhere.
|
|
99
|
-
*/
|
|
100
|
-
declare function MachineStatusPill({ state, sharedSessionCount, size, className, }: MachineStatusPillProps): react_jsx_runtime.JSX.Element;
|
|
101
|
-
|
|
102
|
-
type MachineMetricsProps = {
|
|
103
|
-
/** The latest metric sample, or null when the machine hasn't reported yet. */
|
|
104
|
-
metrics: MetricSample | null;
|
|
105
|
-
/** Compact (dashboard row) vs full (the dock detail). */
|
|
106
|
-
density?: "compact" | "full" | undefined;
|
|
107
|
-
className?: string | undefined;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Per-machine resource meters: CPU%, load average, memory, disk, and GPU when
|
|
111
|
-
* present. Renders the M2 `machine_metrics_latest` sample. When `metrics` is
|
|
112
|
-
* null the panel shows a quiet "no samples yet" placeholder (offline / just
|
|
113
|
-
* enrolled). GPU rows only render when `gpuUtilPct` is non-null.
|
|
114
|
-
*/
|
|
115
|
-
declare function MachineMetrics({ metrics, density, className }: MachineMetricsProps): react_jsx_runtime.JSX.Element;
|
|
116
|
-
|
|
117
|
-
type MachineCardProps = {
|
|
118
|
-
machine: MachineView;
|
|
119
|
-
/** Attach/swap the session's active sandbox to this machine. */
|
|
120
|
-
onAttach?: ((machine: MachineView) => void) | undefined;
|
|
121
|
-
/** Whether an attach/swap is currently in flight (disables the affordance). */
|
|
122
|
-
attaching?: boolean | undefined;
|
|
123
|
-
className?: string | undefined;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* One machine in the Machines dashboard: name + kind + OS/arch, the composite
|
|
127
|
-
* connection/state/shared status, latest resource meters, last-seen recency, and
|
|
128
|
-
* an attach/swap affordance. The session's currently-active sandbox carries an
|
|
129
|
-
* accent edge + an "Active" marker (never an attach button — it's already active).
|
|
130
|
-
*/
|
|
131
|
-
declare function MachineCard({ machine, onAttach, attaching, className }: MachineCardProps): react_jsx_runtime.JSX.Element;
|
|
132
|
-
|
|
133
|
-
type MachinesDashboardProps = {
|
|
134
|
-
machines: MachineView[];
|
|
135
|
-
/** The session's active sandbox id (drives the per-card "Active" marker). */
|
|
136
|
-
activeSandboxId?: string | null | undefined;
|
|
137
|
-
loading?: boolean | undefined;
|
|
138
|
-
error?: Error | null | undefined;
|
|
139
|
-
/** Attach/swap the session's active sandbox to a machine. */
|
|
140
|
-
onAttach?: ((machine: MachineView) => void) | undefined;
|
|
141
|
-
/** The sandbox id currently being attached/swapped to (disables that card). */
|
|
142
|
-
attachingSandboxId?: string | null | undefined;
|
|
143
|
-
/** Open the enrollment flow (the "Enroll a machine" CTA). */
|
|
144
|
-
onEnroll?: (() => void) | undefined;
|
|
145
|
-
onRefresh?: (() => void) | undefined;
|
|
146
|
-
className?: string | undefined;
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* The workspace Machines dashboard: the fleet of selfhosted enrollments + the
|
|
150
|
-
* session's managed sandbox, each with its connection-status pill, state badges,
|
|
151
|
-
* latest metrics, and an attach/swap affordance. Renders the empty state (no
|
|
152
|
-
* machines → enroll CTA), a load error, and the populated grid. The component
|
|
153
|
-
* is purely presentational — feed it `MachinesResponse` data via `useMachines`.
|
|
154
|
-
*/
|
|
155
|
-
declare function MachinesDashboard({ machines, activeSandboxId, loading, error, onAttach, attachingSandboxId, onEnroll, onRefresh, className, }: MachinesDashboardProps): react_jsx_runtime.JSX.Element;
|
|
156
|
-
|
|
157
|
-
type MachineDockBarProps = {
|
|
158
|
-
/** The active machine's display name. */
|
|
159
|
-
name: string;
|
|
160
|
-
kind: MachineKind;
|
|
161
|
-
state: MachineState;
|
|
162
|
-
/** Live sessions sharing this whole-machine lease (>1 ⇒ shared disclosure). */
|
|
163
|
-
sharedSessionCount?: number | undefined;
|
|
164
|
-
className?: string | undefined;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* A slim bar that surfaces WHICH machine the dock surfaces (Files/Terminal/
|
|
168
|
-
* Desktop) are bound to + its connection status. Mounted above the dock tabs so
|
|
169
|
-
* the user always knows whether they are looking at the Modal box or their own
|
|
170
|
-
* machine, and whether it is online / reconnecting / offline. The surfaces below
|
|
171
|
-
* render IDENTICALLY regardless of backend — this bar is the only backend-aware
|
|
172
|
-
* chrome (the dock-parity contract: selfhosted == Modal for the surfaces).
|
|
173
|
-
*/
|
|
174
|
-
declare function MachineDockBar({ name, kind, state, className }: MachineDockBarProps): react_jsx_runtime.JSX.Element;
|
|
175
|
-
type SharedMachineDisclosureProps = {
|
|
176
|
-
sharedSessionCount: number;
|
|
177
|
-
/** Compact (inline strip) vs full (a notice block). */
|
|
178
|
-
density?: "compact" | "full" | undefined;
|
|
179
|
-
className?: string | undefined;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* The "shared — another session is on this machine" disclosure. Surfaced in the
|
|
183
|
-
* dock (and reused on the desktop take-control gate) so the user knows others are
|
|
184
|
-
* driving the same whole-machine lease. Render when `sharedSessionCount > 1`.
|
|
185
|
-
*/
|
|
186
|
-
declare function SharedMachineDisclosure({ sharedSessionCount, density, className, }: SharedMachineDisclosureProps): react_jsx_runtime.JSX.Element;
|
|
187
|
-
|
|
188
|
-
/** The poll state of an in-flight device-flow enrollment. */
|
|
189
|
-
type DeviceFlowPhase = "pending" | "authorized" | "denied" | "expired" | "disabled";
|
|
190
|
-
type EnrollmentDeviceFlowProps = {
|
|
191
|
-
/** The short user code the agent printed (shown big for the human to confirm). */
|
|
192
|
-
userCode: string;
|
|
193
|
-
/** Where the user approves — the same-origin device page. */
|
|
194
|
-
verificationUri: string;
|
|
195
|
-
/** The complete URI (code pre-filled) for a one-click / QR open. */
|
|
196
|
-
verificationUriComplete?: string | undefined;
|
|
197
|
-
/** The install one-liner the user ran (echoed for context). Optional. */
|
|
198
|
-
installCommand?: string | undefined;
|
|
199
|
-
phase?: DeviceFlowPhase | undefined;
|
|
200
|
-
/** Seconds remaining before the code expires (drives a quiet countdown). */
|
|
201
|
-
expiresInSeconds?: number | undefined;
|
|
202
|
-
onCopyCode?: (() => void) | undefined;
|
|
203
|
-
onCopyInstall?: (() => void) | undefined;
|
|
204
|
-
onOpenVerification?: (() => void) | undefined;
|
|
205
|
-
className?: string | undefined;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* The IN-SESSION device-flow panel: the agent (after the install one-liner) prints
|
|
209
|
-
* a short `userCode` + a `verificationUri`; this surfaces them so the user can open
|
|
210
|
-
* the approve page and confirm the code. Polls in the caller; this renders the
|
|
211
|
-
* pending → authorized/denied/expired progression with a connection pill. This is
|
|
212
|
-
* the FIRST step of the IA flow (device-flow → Machines list → attach/swap).
|
|
213
|
-
*/
|
|
214
|
-
declare function EnrollmentDeviceFlow({ userCode, verificationUri, verificationUriComplete, installCommand, phase, expiresInSeconds, onCopyCode, onCopyInstall, onOpenVerification, className, }: EnrollmentDeviceFlowProps): react_jsx_runtime.JSX.Element;
|
|
215
|
-
|
|
216
|
-
/** The machine identity surfaced to the approver, from the device-flow start. */
|
|
217
|
-
type EnrollmentConsentMachine = {
|
|
218
|
-
/** Human-friendly name (hostname by default). */
|
|
219
|
-
machineName: string;
|
|
220
|
-
os: string;
|
|
221
|
-
arch: string;
|
|
222
|
-
/** The agent can offer a display (a real screen / Xvfb is available). */
|
|
223
|
-
canOfferDisplay: boolean;
|
|
224
|
-
/** The agent requests screen control (computer-use). */
|
|
225
|
-
requestsScreenControl: boolean;
|
|
226
|
-
};
|
|
227
|
-
/** The phase of the approve page (drives the rendered panel). */
|
|
228
|
-
type EnrollmentConsentPhase = "review" | "approving" | "approved" | "denied" | "error";
|
|
229
|
-
type EnrollmentConsentProps = {
|
|
230
|
-
/** The short code the user typed / scanned (echoed back for confirmation). */
|
|
231
|
-
userCode: string;
|
|
232
|
-
machine: EnrollmentConsentMachine;
|
|
233
|
-
phase?: EnrollmentConsentPhase | undefined;
|
|
234
|
-
/** Approve with the chosen screen-control consent. */
|
|
235
|
-
onApprove?: ((allowScreenControl: boolean) => void) | undefined;
|
|
236
|
-
onDeny?: (() => void) | undefined;
|
|
237
|
-
/** Error message when phase === "error". */
|
|
238
|
-
errorMessage?: string | undefined;
|
|
239
|
-
className?: string | undefined;
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* The user-facing APPROVE page for the device-flow enrollment: a LOUD,
|
|
243
|
-
* un-minimised whole-machine consent. Approving grants the agent FULL access to
|
|
244
|
-
* this machine — exec, files, terminal — and (when toggled) live screen control.
|
|
245
|
-
* The danger framing is deliberate (§18 hardening: whole-machine = loud consent),
|
|
246
|
-
* never buried. Renders review / approving / approved / denied / error phases.
|
|
247
|
-
*/
|
|
248
|
-
declare function EnrollmentConsent({ userCode, machine, phase, onApprove, onDeny, errorMessage, className, }: EnrollmentConsentProps): react_jsx_runtime.JSX.Element;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* The slice of the SDK client the Machines surface needs. The method NAMES +
|
|
252
|
-
* SIGNATURES match M10's `OpenGeniClient` (`listMachines`, `machineMetricsSeries`)
|
|
253
|
-
* so the real SDK client satisfies this surface DIRECTLY for the read paths — no
|
|
254
|
-
* adapter needed. It is declared structurally (not a hard `OpenGeniClient` Pick)
|
|
255
|
-
* so a test/demo/Geni-frontend client can stand in, keeping the hook dual-consumer
|
|
256
|
-
* safe (works in apps/web AND the separate Geni frontend).
|
|
257
|
-
*
|
|
258
|
-
* The active-sandbox SWAP is now a typed SDK call (`swapActiveSandbox`, the M7
|
|
259
|
-
* user-authenticated REST equivalent of the `sandbox_swap` MCP tool). The real
|
|
260
|
-
* SDK client satisfies it structurally, so the default attach path is wired
|
|
261
|
-
* WHENEVER a sessionId is in scope (the swap is session-scoped). `attachMachine`
|
|
262
|
-
* stays an OPTIONAL escape hatch for a host that wants to supply its own swap
|
|
263
|
-
* adapter; when neither it nor a sessionId is present, attach is a no-op and the
|
|
264
|
-
* card hides the button.
|
|
265
|
-
*/
|
|
266
|
-
type MachinesClientLike = {
|
|
267
|
-
/** GET /v1/workspaces/:ws/machines — the dashboard list + active pointer. */
|
|
268
|
-
listMachines: (workspaceId: string, options?: {
|
|
269
|
-
sessionId?: string;
|
|
270
|
-
}) => Promise<MachinesResponse>;
|
|
271
|
-
/** GET .../machines/:enrollmentId/metrics/series — the downsampled history. */
|
|
272
|
-
machineMetricsSeries?: (workspaceId: string, enrollmentId: string, options?: {
|
|
273
|
-
window?: "15m" | "1h" | "6h" | "24h";
|
|
274
|
-
}) => Promise<MetricSample[]>;
|
|
275
|
-
/**
|
|
276
|
-
* POST .../sessions/:sessionId/active-sandbox — swap the session's active
|
|
277
|
-
* sandbox to a machine. The default swap path; the real SDK client provides it.
|
|
278
|
-
*/
|
|
279
|
-
swapActiveSandbox?: (workspaceId: string, sessionId: string, request: {
|
|
280
|
-
target: string;
|
|
281
|
-
}) => Promise<unknown>;
|
|
282
|
-
/**
|
|
283
|
-
* Host-supplied swap adapter (an escape hatch). When present it wins over the
|
|
284
|
-
* default `swapActiveSandbox` path. Session-scoped, like the swap it backs.
|
|
285
|
-
*/
|
|
286
|
-
attachMachine?: (workspaceId: string, sessionId: string, sandboxId: string) => Promise<unknown>;
|
|
287
|
-
};
|
|
288
|
-
type UseMachinesOptions = ClientOverride & {
|
|
289
|
-
pollIntervalMs?: number | undefined;
|
|
290
|
-
enabled?: boolean | undefined;
|
|
291
|
-
/** Scope the list to a session (adds the synthetic Modal group box + pointer). */
|
|
292
|
-
sessionId?: string | undefined;
|
|
293
|
-
/**
|
|
294
|
-
* Override the client with one implementing `MachinesClientLike`. Defaults to
|
|
295
|
-
* the provider client cast to the surface (the real SDK client satisfies the
|
|
296
|
-
* read paths). An app supplies an adapter to wire `attachMachine` (the swap).
|
|
297
|
-
*/
|
|
298
|
-
machinesClient?: MachinesClientLike | undefined;
|
|
299
|
-
};
|
|
300
|
-
type UseMachinesResult = {
|
|
301
|
-
machines: MachineView[];
|
|
302
|
-
activeSandboxId: string | null;
|
|
303
|
-
activeEpoch: number;
|
|
304
|
-
loading: boolean;
|
|
305
|
-
error: Error | null;
|
|
306
|
-
refresh: () => Promise<void>;
|
|
307
|
-
/** Attach/swap the session's active sandbox to a machine (returns the new pointer). */
|
|
308
|
-
attach: (sandboxId: string) => Promise<boolean>;
|
|
309
|
-
/** Whether the host wired an attach/swap path (drives the card affordance). */
|
|
310
|
-
canAttach: boolean;
|
|
311
|
-
/** Fetch a downsampled metric series for one enrolled machine. */
|
|
312
|
-
fetchSeries: (enrollmentId: string, window?: "15m" | "1h" | "6h" | "24h") => Promise<MetricSample[]>;
|
|
313
|
-
attaching: boolean;
|
|
314
|
-
/** The sandbox id of the in-flight attach (for per-card spinner gating). */
|
|
315
|
-
attachingSandboxId: string | null;
|
|
316
|
-
mutationError: Error | null;
|
|
317
|
-
clearMutationError: () => void;
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* The workspace Machines fleet: the selfhosted enrollments + the session's Modal
|
|
321
|
-
* box, each with latest metrics + state, plus the active-sandbox pointer. Polls
|
|
322
|
-
* the M10 `GET /machines` endpoint and exposes attach/swap + a metric-series
|
|
323
|
-
* fetch. Renders via `<MachinesDashboard>`. Dual-consumer safe: it reads only the
|
|
324
|
-
* structural `MachinesClientLike` surface, so it works in apps/web AND the Geni
|
|
325
|
-
* frontend (each provides its own client/adapter).
|
|
326
|
-
*/
|
|
327
|
-
declare function useMachines(options?: UseMachinesOptions): UseMachinesResult;
|
|
328
|
-
|
|
329
|
-
export { SharedMachineDisclosure as A, type SharedMachineDisclosureProps as B, type ClientOverride as C, type DeviceFlowPhase as D, EnrollmentConsent as E, type UseMachinesResult as F, connectionStatusForState as G, useMachines as H, useOpenGeni as I, useOpenGeniClient as J, MACHINE_STATE_BADGE_META as M, type OpenGeniContextValue as O, type SessionClientLike as S, type UseMachinesOptions as U, CONNECTION_STATUS_META as a, ConnectionDot as b, type ConnectionDotProps as c, type ConnectionStatus as d, type ConnectionStatusMeta as e, ConnectionStatusPill as f, type ConnectionStatusPillProps as g, type EnrollmentConsentMachine as h, type EnrollmentConsentPhase as i, type EnrollmentConsentProps as j, EnrollmentDeviceFlow as k, type EnrollmentDeviceFlowProps as l, MachineCard as m, type MachineCardProps as n, MachineDockBar as o, type MachineDockBarProps as p, MachineMetrics as q, type MachineMetricsProps as r, type MachineStateBadgeMeta as s, MachineStatusPill as t, type MachineStatusPillProps as u, type MachinesClientLike as v, MachinesDashboard as w, type MachinesDashboardProps as x, OpenGeniProvider as y, type OpenGeniProviderProps as z };
|