Merge branch 'main' into feat/topbar-nav
This commit is contained in:
commit
bc429cd351
171 files changed
+1900
-11223
No files matched your search
@@ -251,7 +251,6 @@ function onKeydown(event: KeyboardEvent): void {
|
||||
>
|
||||
<p v-if="recordError" class="px-1 text-caption text-danger" role="alert">{{ recordError }}</p>
|
||||
<Button
|
||||
v-else
|
||||
size="sm"
|
||||
:variant="composerText.trim() ? 'default' : 'secondary'"
|
||||
:disabled="!composerText.trim()"
|
||||
|
||||
@@ -72,9 +72,9 @@ function submitPrompt(): void {
|
||||
|
||||
<template>
|
||||
<Popover v-model:open="open">
|
||||
<PopoverTrigger as-child>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
@@ -83,10 +83,10 @@ function submitPrompt(): void {
|
||||
>
|
||||
<Ellipsis />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>More</TooltipContent>
|
||||
</Tooltip>
|
||||
</PopoverTrigger>
|
||||
</PopoverTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>More</TooltipContent>
|
||||
</Tooltip>
|
||||
<PopoverContent align="end" class="grid w-64 gap-0.5 p-1">
|
||||
<template v-if="currentSession">
|
||||
<Button
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { onMounted, onUnmounted, ref, watch, type Ref } from "vue";
|
||||
import { computed, onMounted, onUnmounted, ref, watch, type Ref } from "vue";
|
||||
|
||||
import { api } from "@/lib/api";
|
||||
import { randomUUID } from "@/lib/uuid";
|
||||
@@ -195,7 +195,14 @@ export async function answerAsk(answer: string): Promise<boolean> {
|
||||
export const sessions = ref<ChatSession[]>([]);
|
||||
export const currentSession = ref("");
|
||||
export const messages = ref<ChatMessage[]>([]);
|
||||
export const composerText = ref("");
|
||||
const drafts = ref<Record<string, string>>({});
|
||||
/** The unsent text of the open conversation; each conversation keeps its own. */
|
||||
export const composerText = computed({
|
||||
get: () => drafts.value[currentSession.value] ?? "",
|
||||
set: (value: string) => {
|
||||
drafts.value = { ...drafts.value, [currentSession.value]: value };
|
||||
},
|
||||
});
|
||||
export const statusText = ref("Ready");
|
||||
export const isSending = ref(false);
|
||||
export const isLoadingSession = ref(false);
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* The setup terminal: an xterm.js surface over the WebSocket the webui route
|
||||
* upgrades to a Kit container's PTY
|
||||
* (docs/prds/external-agent-harness.md, "Setup terminal"). The browser cannot
|
||||
* set headers on a WebSocket, so the shared-token gate reads the same
|
||||
* HttpOnly cookie the SSE stream uses.
|
||||
*
|
||||
* The transport is raw bytes in both directions. The component measures its
|
||||
* own box before connecting and sends that size so the remote PTY is created
|
||||
* at the right geometry; live resize is not wired yet.
|
||||
*/
|
||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { Terminal } from "@xterm/xterm";
|
||||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import "@xterm/xterm/css/xterm.css";
|
||||
|
||||
import { setupTerminalURL } from "./harness";
|
||||
import { followTerminalTheme, terminalTheme } from "@/lib/terminalTheme";
|
||||
|
||||
const props = defineProps<{ profile: string }>();
|
||||
// The parent resets its open flag when the session ends, so reopening starts
|
||||
// a new terminal rather than showing a dead one.
|
||||
const emit = defineEmits<{ ended: [] }>();
|
||||
|
||||
const host = ref<HTMLDivElement | null>(null);
|
||||
const status = ref<"connecting" | "open" | "closed" | "failed">("connecting");
|
||||
|
||||
let term: Terminal | null = null;
|
||||
let socket: WebSocket | null = null;
|
||||
let fit: FitAddon | null = null;
|
||||
let observer: ResizeObserver | null = null;
|
||||
let stopTheme: (() => void) | null = null;
|
||||
|
||||
function fitLocal(): void {
|
||||
try {
|
||||
fit?.fit();
|
||||
} catch {
|
||||
// xterm throws when the host has no measurable box yet; the next resize
|
||||
// (or open) retries. Fitting is cosmetic and must not fail the session.
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const mount = host.value;
|
||||
if (!mount) return;
|
||||
|
||||
term = new Terminal({
|
||||
convertEol: true,
|
||||
cursorBlink: true,
|
||||
fontFamily: "'IBM Plex Mono', ui-monospace, monospace",
|
||||
fontSize: 13,
|
||||
theme: terminalTheme(),
|
||||
});
|
||||
fit = new FitAddon();
|
||||
term.loadAddon(fit);
|
||||
term.open(mount);
|
||||
fitLocal();
|
||||
term.focus();
|
||||
|
||||
const ws = new WebSocket(
|
||||
setupTerminalURL(props.profile, window.location, term?.cols ?? 80, term?.rows ?? 24),
|
||||
);
|
||||
socket = ws;
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.onopen = () => {
|
||||
status.value = "open";
|
||||
};
|
||||
ws.onmessage = (event: MessageEvent) => {
|
||||
if (!term) return;
|
||||
if (typeof event.data === "string") {
|
||||
term.write(event.data);
|
||||
} else {
|
||||
term.write(new Uint8Array(event.data as ArrayBuffer));
|
||||
}
|
||||
};
|
||||
ws.onerror = () => {
|
||||
status.value = "failed";
|
||||
};
|
||||
ws.onclose = () => {
|
||||
// A connection that never opened stays "failed": onclose must not
|
||||
// overwrite the real reason with "ended".
|
||||
if (status.value !== "failed") status.value = "closed";
|
||||
emit("ended");
|
||||
};
|
||||
term.onData((data) => {
|
||||
if (ws.readyState === WebSocket.OPEN) ws.send(data);
|
||||
});
|
||||
|
||||
observer = new ResizeObserver(fitLocal);
|
||||
observer.observe(mount);
|
||||
|
||||
stopTheme = followTerminalTheme((t) => {
|
||||
if (term) term.options.theme = t;
|
||||
});
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopTheme?.();
|
||||
stopTheme = null;
|
||||
observer?.disconnect();
|
||||
observer = null;
|
||||
socket?.close();
|
||||
socket = null;
|
||||
term?.dispose();
|
||||
term = null;
|
||||
fit = null;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col gap-2">
|
||||
<p
|
||||
v-if="status !== 'open'"
|
||||
class="text-label text-fg-muted"
|
||||
role="status"
|
||||
>
|
||||
<template v-if="status === 'connecting'">Connecting…</template>
|
||||
<template v-else-if="status === 'closed'">The terminal session ended.</template>
|
||||
<template v-else>Could not open the setup terminal.</template>
|
||||
</p>
|
||||
<div
|
||||
ref="host"
|
||||
class="min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-terminal p-2"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* The harness page's wire shapes and payload building, kept in a plain
|
||||
* module beside the components so it runs under the dashboard's module test
|
||||
* runner (docs/development/frontend-ui.md, "Testing the dashboard").
|
||||
*
|
||||
* The setup terminal is a WebSocket because the browser cannot set headers on
|
||||
* a terminal connection: the shared-token gate reads the same HttpOnly cookie
|
||||
* the SSE stream uses.
|
||||
*/
|
||||
|
||||
/** One credential binding as GET /api/harness/bindings reports it. */
|
||||
export interface HarnessBinding {
|
||||
service: string;
|
||||
captured: boolean;
|
||||
/** RFC 3339; absent when no token set has been captured. */
|
||||
expires_at?: string;
|
||||
updated_at?: string;
|
||||
scopes?: string[];
|
||||
}
|
||||
|
||||
/** The page's whole read. */
|
||||
export interface HarnessState {
|
||||
/** Whether this process can open a setup terminal at all. */
|
||||
terminal: boolean;
|
||||
bindings: HarnessBinding[];
|
||||
/** The agent profiles that name a Kit, i.e. what a terminal can target. */
|
||||
profiles: string[];
|
||||
}
|
||||
|
||||
/** How a captured token reads on the page. */
|
||||
export type BindingStatus = "unconfigured" | "expired" | "expiring" | "ready";
|
||||
|
||||
/** A captured token this close to expiry reads as "expiring". */
|
||||
export const EXPIRING_WINDOW_MS = 30 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* bindingStatus classifies a binding's capture state. A binding with no
|
||||
* captured set is "unconfigured" whatever else it carries; a captured set
|
||||
* with no parseable expiry counts as ready, because the provider did not tell
|
||||
* archie when it lapses and guessing would be wrong.
|
||||
*/
|
||||
export function bindingStatus(
|
||||
binding: HarnessBinding,
|
||||
now: number = Date.now(),
|
||||
): BindingStatus {
|
||||
if (!binding.captured) return "unconfigured";
|
||||
if (!binding.expires_at) return "ready";
|
||||
const expires = Date.parse(binding.expires_at);
|
||||
if (Number.isNaN(expires)) return "ready";
|
||||
if (expires <= now) return "expired";
|
||||
if (expires - now <= EXPIRING_WINDOW_MS) return "expiring";
|
||||
return "ready";
|
||||
}
|
||||
|
||||
/**
|
||||
* setupTerminalURL builds the WebSocket URL for one Kit profile, carrying the
|
||||
* terminal size the browser measured so the remote PTY is created with it.
|
||||
* The location is a parameter rather than window so the module stays runnable
|
||||
* outside a browser.
|
||||
*/
|
||||
export function setupTerminalURL(
|
||||
profile: string,
|
||||
location: Pick<Location, "protocol" | "host">,
|
||||
cols = 80,
|
||||
rows = 24,
|
||||
): string {
|
||||
const scheme = location.protocol === "https:" ? "wss:" : "ws:";
|
||||
const query = new URLSearchParams({
|
||||
profile,
|
||||
cols: String(cols),
|
||||
rows: String(rows),
|
||||
}).toString();
|
||||
return `${scheme}//${location.host}/api/harness/terminal?${query}`;
|
||||
}
|
||||
@@ -416,7 +416,6 @@ export const api = {
|
||||
request<T>(`/api/bindings/${encodeURIComponent(id)}/pause`, { method: "POST" }),
|
||||
bindingResume: <T = unknown>(id: string) =>
|
||||
request<T>(`/api/bindings/${encodeURIComponent(id)}/resume`, { method: "POST" }),
|
||||
harnessBindings: <T = unknown>() => request<T>("/api/harness/bindings"),
|
||||
sources: <T = unknown>(workspace?: string) =>
|
||||
request<T>("/api/sources" + qs({ workspace })),
|
||||
// sourceCreate makes a source in one of the org's workspaces; an empty
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* The xterm palette, read from the --terminal-* theme tokens so a terminal
|
||||
* follows the dashboard theme instead of hard-coded hex. DOM-bound, unlike
|
||||
* the pure helpers in format.ts.
|
||||
*/
|
||||
|
||||
/** Structural subset of xterm's ITheme, so this module need not import @xterm/xterm. */
|
||||
export interface TerminalTheme {
|
||||
background: string;
|
||||
foreground: string;
|
||||
cursor: string;
|
||||
selectionBackground: string;
|
||||
}
|
||||
|
||||
function readToken(name: string): string {
|
||||
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
||||
}
|
||||
|
||||
/** The current terminal palette from the theme tokens in style.css. */
|
||||
export function terminalTheme(): TerminalTheme {
|
||||
return {
|
||||
background: readToken("--terminal-bg"),
|
||||
foreground: readToken("--terminal-fg"),
|
||||
cursor: readToken("--terminal-cursor"),
|
||||
selectionBackground: readToken("--terminal-selection"),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the terminal theme now and again on every theme switch. The
|
||||
* appearance store rewrites data-theme on <html> — including OS-level
|
||||
* changes while the preference is "system" — so watching that one attribute
|
||||
* covers live switching. Returns the stop function.
|
||||
*/
|
||||
export function followTerminalTheme(apply: (theme: TerminalTheme) => void): () => void {
|
||||
apply(terminalTheme());
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
if (mutations.some((m) => m.attributeName === "data-theme")) apply(terminalTheme());
|
||||
});
|
||||
observer.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ["data-theme"],
|
||||
});
|
||||
return () => observer.disconnect();
|
||||
}
|
||||
@@ -402,9 +402,6 @@ const routes = [
|
||||
component: () => import("@/settings/AgentProfilesPage.vue"),
|
||||
meta: { navPath: "/settings", settings: true, label: "Agent profiles", section: "settings" },
|
||||
},
|
||||
// The harness sign-in section lives on the agent-profiles page: its setup
|
||||
// terminal targets the Kit profiles that page edits.
|
||||
{ path: "/settings/harness", redirect: "/settings/agent-profiles", meta: { nav: false } },
|
||||
{ path: "/settings/history", redirect: (to: RouteLocationGeneric) => ({ path: "/org/audit", query: to.query, hash: to.hash }), meta: { nav: false } },
|
||||
{ path: "/settings/audit", redirect: (to: RouteLocationGeneric) => ({ path: "/org/audit", query: to.query, hash: to.hash }), meta: { nav: false } },
|
||||
{
|
||||
|
||||
@@ -1,30 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import type { BadgeVariants } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Table, TableBody, TableEmpty, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from "@/components/ui/tags-input";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { api, ApiError } from "@/lib/api";
|
||||
import { useSettingsStore } from "@/stores/settings";
|
||||
import SetupTerminal from "@/harness/SetupTerminal.vue";
|
||||
import { bindingStatus, type BindingStatus, type HarnessBinding, type HarnessState } from "@/harness/harness";
|
||||
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
||||
import CardAccordion from "./CardAccordion.vue";
|
||||
import HistoryLink from "./HistoryLink.vue";
|
||||
|
||||
interface Profile { image?: string; kit?: string; adapter?: string; tools?: string[] }
|
||||
interface Profile { image?: string; tools?: string[] }
|
||||
const KIND = "agent-profiles";
|
||||
const store = useSettingsStore();
|
||||
|
||||
@@ -45,7 +33,7 @@ function add() {
|
||||
if (unsaved.value || !store.formFor(KIND)) return;
|
||||
const key = name.value.trim();
|
||||
if (!key || profiles.value?.[key]) return;
|
||||
store.setDraftEntry(KIND, key, { image: "", kit: "", adapter: "", tools: [] });
|
||||
store.setDraftEntry(KIND, key, { image: "", tools: [] });
|
||||
// Integer-like names sort first in a JS object, so find where the key landed.
|
||||
open.value = String(entries.value.findIndex(([k]) => k === key));
|
||||
name.value = "";
|
||||
@@ -59,77 +47,9 @@ function patch(key: string, changes: Partial<Profile>) {
|
||||
store.setDraftEntry(KIND, key, { ...profiles.value?.[key], ...changes });
|
||||
}
|
||||
|
||||
// Harness sign-in: the credential bindings' captured OAuth state and the
|
||||
// setup terminal a Kit profile is signed in from, one read of
|
||||
// /api/harness/bindings serving both (the profile list is the agent profiles
|
||||
// above that name a Kit).
|
||||
const harness = ref<HarnessState | null>(null);
|
||||
const harnessLoading = ref(true);
|
||||
const harnessFailure = ref<string | null>(null);
|
||||
// "unconfigured" is a process with no control-plane resource or no token
|
||||
// store (501/503) -- the feature is off, which reads differently from a
|
||||
// process that answered badly.
|
||||
const harnessUnconfigured = ref(false);
|
||||
const kitProfile = ref("");
|
||||
const terminalOpen = ref(false);
|
||||
// A read that started before the route changed must not land after it.
|
||||
let harnessLoad = 0;
|
||||
|
||||
const statuses: Record<BindingStatus, { label: string; variant: BadgeVariants["variant"] }> = {
|
||||
ready: { label: "Ready", variant: "ok" },
|
||||
expiring: { label: "Expiring soon", variant: "warn" },
|
||||
expired: { label: "Expired", variant: "danger" },
|
||||
unconfigured: { label: "Not set up", variant: "idle" },
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void store.load();
|
||||
void loadHarness();
|
||||
});
|
||||
|
||||
async function loadHarness(): Promise<void> {
|
||||
const id = ++harnessLoad;
|
||||
harnessLoading.value = true;
|
||||
harnessFailure.value = null;
|
||||
harnessUnconfigured.value = false;
|
||||
try {
|
||||
const got = await api.harnessBindings<HarnessState>();
|
||||
if (id !== harnessLoad) return;
|
||||
harness.value = {
|
||||
terminal: got.terminal,
|
||||
bindings: got.bindings ?? [],
|
||||
profiles: got.profiles ?? [],
|
||||
};
|
||||
kitProfile.value = harness.value.profiles[0] ?? "";
|
||||
} catch (err) {
|
||||
if (id !== harnessLoad) return;
|
||||
const status = err instanceof ApiError ? err.status : undefined;
|
||||
if (status === 501 || status === 503) {
|
||||
harnessUnconfigured.value = true;
|
||||
} else {
|
||||
harnessFailure.value = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
harness.value = null;
|
||||
} finally {
|
||||
if (id === harnessLoad) harnessLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openTerminal(): void {
|
||||
if (!harness.value?.terminal || !kitProfile.value) return;
|
||||
terminalOpen.value = true;
|
||||
}
|
||||
|
||||
// A capture lands while the terminal runs; re-read so the bindings table
|
||||
// shows the sign-in the session just made.
|
||||
function terminalEnded(): void {
|
||||
terminalOpen.value = false;
|
||||
void loadHarness();
|
||||
}
|
||||
|
||||
function scopes(binding: HarnessBinding): string {
|
||||
return binding.scopes?.length ? binding.scopes.join(", ") : "–";
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
@@ -150,21 +70,6 @@ function scopes(binding: HarnessBinding): string {
|
||||
<Input :id="`${key}-image`" :model-value="profile.image" placeholder="Container image" @update:model-value="(v) => patch(key, { image: String(v) })" />
|
||||
</div>
|
||||
</Field>
|
||||
<Field orientation="responsive">
|
||||
<FieldContent>
|
||||
<FieldLabel :for="`${key}-kit`">Kit</FieldLabel>
|
||||
<FieldDescription>Pinned digest. Used only when Image is empty.</FieldDescription>
|
||||
</FieldContent>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||
<Input :id="`${key}-kit`" :model-value="profile.kit" placeholder="registry/kit@sha256:…" @update:model-value="(v) => patch(key, { kit: String(v) })" />
|
||||
</div>
|
||||
</Field>
|
||||
<Field orientation="responsive">
|
||||
<FieldContent><FieldLabel :for="`${key}-adapter`">Adapter</FieldLabel></FieldContent>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||
<Input :id="`${key}-adapter`" :model-value="profile.adapter" @update:model-value="(v) => patch(key, { adapter: String(v) })" />
|
||||
</div>
|
||||
</Field>
|
||||
<Field orientation="responsive">
|
||||
<FieldContent>
|
||||
<FieldLabel :for="`${key}-tools`">Tools</FieldLabel>
|
||||
@@ -181,76 +86,5 @@ function scopes(binding: HarnessBinding): string {
|
||||
</template>
|
||||
</CardAccordion>
|
||||
|
||||
<Section title="Harness sign-in" class="mt-4">
|
||||
<ReadError v-if="harnessFailure" :message="`Could not load the harness: ${harnessFailure}`" retry-label="Retry" @retry="loadHarness" />
|
||||
<div v-else-if="harnessLoading" class="flex flex-col gap-2">
|
||||
<Skeleton class="h-10 w-full" />
|
||||
<Skeleton class="h-24 w-full" />
|
||||
</div>
|
||||
<Empty v-else-if="harnessUnconfigured">
|
||||
<EmptyHeader><EmptyTitle>Harness bindings are not configured</EmptyTitle></EmptyHeader>
|
||||
</Empty>
|
||||
<template v-else-if="harness">
|
||||
<Alert v-if="!harness.terminal" class="mb-4">
|
||||
<AlertTitle>Setup terminal unavailable</AlertTitle>
|
||||
<AlertDescription>Start the daemon with a container runtime and a harness token to log in to a CLI from here.</AlertDescription>
|
||||
</Alert>
|
||||
<Empty v-else-if="!harness.profiles.length">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No Kit profiles yet</EmptyTitle>
|
||||
<EmptyDescription>Add a profile with a Kit above, then sign its services in from a terminal.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
<div v-else class="flex flex-wrap items-end gap-3">
|
||||
<div class="flex flex-col gap-1 text-label">
|
||||
<Label for="harness-profile" class="text-fg-muted">Profile</Label>
|
||||
<Select v-model="kitProfile">
|
||||
<SelectTrigger id="harness-profile" size="sm" class="min-w-48">
|
||||
<SelectValue placeholder="No profiles configured" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="profileName in harness.profiles" :key="profileName" :value="profileName">
|
||||
{{ profileName }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button :disabled="!kitProfile" @click="openTerminal">Open setup terminal</Button>
|
||||
</div>
|
||||
<p class="text-label text-fg-muted mb-2 mt-6">Credential bindings</p>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Service</TableHead>
|
||||
<TableHead>Status</TableHead>
|
||||
<TableHead>Expires</TableHead>
|
||||
<TableHead>Scopes</TableHead>
|
||||
<TableHead>Updated</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableEmpty v-if="!harness.bindings.length" :colspan="5">No credential bindings.</TableEmpty>
|
||||
<TableRow v-for="binding in harness.bindings" :key="binding.service">
|
||||
<TableCell class="font-medium">{{ binding.service }}</TableCell>
|
||||
<TableCell>
|
||||
<Badge :variant="statuses[bindingStatus(binding)].variant">
|
||||
{{ statuses[bindingStatus(binding)].label }}
|
||||
</Badge>
|
||||
</TableCell>
|
||||
<TableCell><Timestamp :at="binding.expires_at" absolute /></TableCell>
|
||||
<TableCell class="text-fg-muted">{{ scopes(binding) }}</TableCell>
|
||||
<TableCell class="text-fg-muted"><Timestamp :at="binding.updated_at" /></TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</template>
|
||||
</Section>
|
||||
|
||||
<Section v-if="terminalOpen && kitProfile" title="Setup terminal">
|
||||
<template #action><Button variant="outline" size="sm" @click="terminalOpen = false">Close terminal</Button></template>
|
||||
<div class="h-96"><SetupTerminal :profile="kitProfile" @ended="terminalEnded" /></div>
|
||||
</Section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -140,8 +140,6 @@
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-hairline: var(--hairline);
|
||||
/* Terminal (xterm) host box; the palette itself is read via getComputedStyle. */
|
||||
--color-terminal: var(--terminal-bg);
|
||||
|
||||
--color-sidebar: var(--card);
|
||||
--color-sidebar-foreground: var(--card-foreground);
|
||||
@@ -239,12 +237,6 @@
|
||||
--workspace: #16171a;
|
||||
--hairline: #2a2c30;
|
||||
|
||||
/* Terminal well: darker than the card so the stream reads as a well. */
|
||||
--terminal-bg: #0b0f14;
|
||||
--terminal-fg: var(--foreground);
|
||||
--terminal-cursor: var(--foreground);
|
||||
--terminal-selection: #264f78;
|
||||
|
||||
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||
--shadow-md: 0 8px 28px rgba(0, 0, 0, 0.4);
|
||||
--shadow-workspace: none;
|
||||
@@ -309,12 +301,6 @@
|
||||
--workspace: #f5f4f1;
|
||||
--hairline: #d6d3cc;
|
||||
|
||||
/* Paper inset: the light-theme terminal is light, not a dark well. */
|
||||
--terminal-bg: #f5f4f1;
|
||||
--terminal-fg: var(--foreground);
|
||||
--terminal-cursor: var(--foreground);
|
||||
--terminal-selection: #c9d8e8;
|
||||
|
||||
--shadow-sm: 0 1px 2px rgba(31, 31, 29, 0.06);
|
||||
--shadow-md: 0 8px 28px rgba(31, 31, 29, 0.1);
|
||||
--shadow-workspace: none;
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* The run-scoped sandbox view: the live output of a running attempt's
|
||||
* container, read-only (docs/prds/external-agent-harness.md, "Run target").
|
||||
* The server refuses a finished or unknown attempt by writing its reason to
|
||||
* the socket as text, so the operator reads why there is no view in the
|
||||
* terminal itself. No input is sent: this is the peek, not a takeover.
|
||||
*/
|
||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { Terminal } from "@xterm/xterm";
|
||||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import "@xterm/xterm/css/xterm.css";
|
||||
import { followTerminalTheme, terminalTheme } from "@/lib/terminalTheme";
|
||||
|
||||
const props = defineProps<{ taskId: string; attempt: number }>();
|
||||
|
||||
const host = ref<HTMLDivElement | null>(null);
|
||||
const status = ref<"connecting" | "open" | "closed" | "failed">("connecting");
|
||||
|
||||
let term: Terminal | null = null;
|
||||
let socket: WebSocket | null = null;
|
||||
let fit: FitAddon | null = null;
|
||||
let observer: ResizeObserver | null = null;
|
||||
let stopTheme: (() => void) | null = null;
|
||||
|
||||
function fitLocal(): void {
|
||||
try {
|
||||
fit?.fit();
|
||||
} catch {
|
||||
// xterm throws when the host has no measurable box yet; fitting is
|
||||
// cosmetic and must not fail the view.
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const mount = host.value;
|
||||
if (!mount) return;
|
||||
|
||||
term = new Terminal({
|
||||
convertEol: true,
|
||||
disableStdin: true,
|
||||
cursorBlink: false,
|
||||
fontFamily: "'IBM Plex Mono', ui-monospace, monospace",
|
||||
fontSize: 13,
|
||||
theme: terminalTheme(),
|
||||
});
|
||||
fit = new FitAddon();
|
||||
term.loadAddon(fit);
|
||||
term.open(mount);
|
||||
fitLocal();
|
||||
|
||||
const scheme = window.location.protocol === "https:" ? "wss:" : "ws:";
|
||||
const query = new URLSearchParams({ attempt: String(props.attempt) });
|
||||
const ws = new WebSocket(
|
||||
`${scheme}//${window.location.host}/api/tasks/${encodeURIComponent(props.taskId)}/sandbox?${query}`,
|
||||
);
|
||||
socket = ws;
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.onopen = () => {
|
||||
status.value = "open";
|
||||
};
|
||||
ws.onmessage = (event: MessageEvent) => {
|
||||
if (!term) return;
|
||||
if (typeof event.data === "string") status.value = "failed";
|
||||
term.write(
|
||||
typeof event.data === "string"
|
||||
? event.data
|
||||
: new Uint8Array(event.data as ArrayBuffer),
|
||||
);
|
||||
};
|
||||
ws.onerror = () => {
|
||||
status.value = "failed";
|
||||
};
|
||||
ws.onclose = () => {
|
||||
if (status.value !== "failed") status.value = "closed";
|
||||
};
|
||||
|
||||
observer = new ResizeObserver(fitLocal);
|
||||
observer.observe(mount);
|
||||
|
||||
stopTheme = followTerminalTheme((t) => {
|
||||
if (term) term.options.theme = t;
|
||||
});
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopTheme?.();
|
||||
stopTheme = null;
|
||||
observer?.disconnect();
|
||||
observer = null;
|
||||
socket?.close();
|
||||
socket = null;
|
||||
term?.dispose();
|
||||
term = null;
|
||||
fit = null;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-[32rem] min-h-0 flex-col gap-2">
|
||||
<p
|
||||
v-if="status !== 'open'"
|
||||
class="text-label text-fg-muted"
|
||||
role="status"
|
||||
>
|
||||
<template v-if="status === 'connecting'">Connecting…</template>
|
||||
<template v-else-if="status === 'closed'">The sandbox ended.</template>
|
||||
<template v-else>Sandbox unavailable.</template>
|
||||
</p>
|
||||
<div
|
||||
ref="host"
|
||||
class="min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-terminal p-2"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,10 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
|
||||
import { computed } from "vue";
|
||||
|
||||
import { RUN_TABS } from "./task-run";
|
||||
import { useTaskRun } from "./use-task-run";
|
||||
|
||||
/**
|
||||
* The run page's tab bar. It owns no state and renders no panel: the open tab
|
||||
@@ -18,17 +15,12 @@ import { useTaskRun } from "./use-task-run";
|
||||
* ends. Automatic activation is right here because every panel is a local
|
||||
* render, not a fetch: there is no cost to switching.
|
||||
*/
|
||||
const run = useTaskRun();
|
||||
// The sandbox follows a live container; a finished attempt has none to show.
|
||||
const tabs = computed(() =>
|
||||
RUN_TABS.filter((tab) => tab.id !== "sandbox" || run.task?.status === "running"),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabsList variant="line" class="w-full justify-start">
|
||||
<TabsTrigger
|
||||
v-for="tab in tabs"
|
||||
v-for="tab in RUN_TABS"
|
||||
:key="tab.id"
|
||||
:value="tab.id"
|
||||
class="flex-none px-2"
|
||||
|
||||
@@ -7,7 +7,6 @@ import ChangedFiles from "./ChangedFiles.vue";
|
||||
import DebugView from "./DebugView.vue";
|
||||
import PanelError from "./PanelError.vue";
|
||||
import PanelLoading from "./PanelLoading.vue";
|
||||
import SandboxView from "./SandboxView.vue";
|
||||
import TaskLogs from "./TaskLogs.vue";
|
||||
import { RUN_TABS } from "./task-run";
|
||||
import { useTaskRun } from "./use-task-run";
|
||||
@@ -68,11 +67,5 @@ const run = useTaskRun();
|
||||
<AttemptConfig :events="run.events" :attempt="run.attemptNumber" />
|
||||
</div>
|
||||
|
||||
<SandboxView
|
||||
v-else-if="tab.id === 'sandbox'"
|
||||
:key="`${props.id}:${run.attemptNumber}`"
|
||||
:task-id="props.id"
|
||||
:attempt="run.attemptNumber"
|
||||
/>
|
||||
</TabsContent>
|
||||
</template>
|
||||
@@ -30,7 +30,6 @@ export const RUN_TABS: TaskRunTab[] = [
|
||||
{ id: "log", label: "Log" },
|
||||
{ id: "changes", label: "Changes" },
|
||||
{ id: "debug", label: "Debug" },
|
||||
{ id: "sandbox", label: "Sandbox" },
|
||||
];
|
||||
|
||||
const TAB_IDS = new Set(RUN_TABS.map((tab) => tab.id));
|
||||
|
||||
Reference in new issue
Block a user