feat(archied): read-only run-scoped sandbox view over the harness contract (#1662)
* feat(archied): read-only run-scoped sandbox view over the harness contract Serve RunTarget: the daemon resolves a running task and attempt to its Kit container and follows its output, refusing a finished or unknown task with a stated reason. The dashboard adds a Sandbox tab behind the task log's read authority. Takeover stays out of scope until the sod1 authority is wired. * fix(archied): scope and close sandbox views correctly Forward harness activity into container output, bind containers and dashboard views to their attempt, enforce the asserted org, and report unavailable dependencies and interrupted streams accurately. Refs: archie-core-qi91, archie-core-252tj
This commit is contained in:
1 parent
59be81c7f6
commit
acec5d392d
29 files changed
+838
-139
No files matched your search
@@ -0,0 +1,107 @@
|
||||
<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";
|
||||
|
||||
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;
|
||||
|
||||
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: { background: "#0b0f14", foreground: "#e6edf3" },
|
||||
});
|
||||
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);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
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-sm text-muted-foreground"
|
||||
role="status"
|
||||
>
|
||||
<template v-if="status === 'connecting'">Connecting…</template>
|
||||
<template v-else-if="status === 'closed'">The sandbox view ended.</template>
|
||||
<template v-else>The sandbox view is unavailable.</template>
|
||||
</p>
|
||||
<div
|
||||
ref="host"
|
||||
class="min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-[#0b0f14] p-2"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -7,6 +7,7 @@ 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";
|
||||
@@ -70,5 +71,12 @@ const run = useTaskRun();
|
||||
:state="run.debugState"
|
||||
:attempt="run.attemptNumber"
|
||||
/>
|
||||
|
||||
<SandboxView
|
||||
v-else-if="tab.id === 'sandbox'"
|
||||
:key="`${props.id}:${run.attemptNumber}`"
|
||||
:task-id="props.id"
|
||||
:attempt="run.attemptNumber"
|
||||
/>
|
||||
</TabsContent>
|
||||
</template>
|
||||
@@ -31,6 +31,7 @@ export const RUN_TABS: TaskRunTab[] = [
|
||||
{ id: "changes", label: "Changed files" },
|
||||
{ id: "config", label: "Configuration" },
|
||||
{ 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