Add animated agent state dashboard
This commit is contained in:
parent
c37da10946
commit
4b169ca42a
3 changed files with 988 additions and 3 deletions
|
|
@ -49,7 +49,38 @@ async function smokeViewport(browser, viewport, screenshotPath) {
|
|||
const page = await browser.newPage({ viewport });
|
||||
await page.goto(url, { waitUntil: "networkidle" });
|
||||
await page.getByRole("heading", { name: "Operator Console" }).waitFor();
|
||||
await page.getByText("prepareCheckpoint").waitFor();
|
||||
await page.getByRole("heading", { name: "Agent State", exact: true }).waitFor();
|
||||
await page.getByRole("button", { name: "Self prepareCheckpoint" }).waitFor();
|
||||
await page.locator(".agentSmokeCanvas").waitFor();
|
||||
await page.waitForTimeout(350);
|
||||
const canvasProbe = await page.locator(".agentSmokeCanvas").evaluate((canvas) => {
|
||||
if (!(canvas instanceof HTMLCanvasElement) || canvas.width === 0 || canvas.height === 0) {
|
||||
return { nonBlank: false, reason: "canvas has no drawable dimensions" };
|
||||
}
|
||||
const gl = canvas.getContext("webgl2");
|
||||
if (gl) {
|
||||
const width = Math.min(6, canvas.width);
|
||||
const height = Math.min(6, canvas.height);
|
||||
const pixels = new Uint8Array(width * height * 4);
|
||||
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
|
||||
return {
|
||||
nonBlank: pixels.some((value) => value !== 0),
|
||||
reason: "webgl2 sample",
|
||||
};
|
||||
}
|
||||
const context = canvas.getContext("2d");
|
||||
if (!context) return { nonBlank: false, reason: "no readable canvas context" };
|
||||
const width = Math.min(6, canvas.width);
|
||||
const height = Math.min(6, canvas.height);
|
||||
const pixels = context.getImageData(0, 0, width, height).data;
|
||||
return {
|
||||
nonBlank: Array.from(pixels).some((value) => value !== 0),
|
||||
reason: "2d sample",
|
||||
};
|
||||
});
|
||||
if (!canvasProbe.nonBlank) {
|
||||
throw new Error(`agent smoke canvas did not render: ${canvasProbe.reason}`);
|
||||
}
|
||||
await page.getByRole("heading", { name: "Environment" }).waitFor();
|
||||
await page.getByText("Unity Editor").waitFor();
|
||||
await page.getByRole("heading", { name: "Rider", exact: true }).waitFor();
|
||||
|
|
|
|||
|
|
@ -14,12 +14,140 @@ import {
|
|||
RefreshCw,
|
||||
} from "lucide-react";
|
||||
import { EpiphanyGraphViewer, validateEpiphanyGraphsState } from "@epiphanygraph/epiphany-graph-viewer";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { loadOperatorSnapshot, runOperatorAction } from "./operatorApi";
|
||||
import type { ArtifactBundle, OperatorAction, OperatorActionResult, OperatorSnapshot, StatusRequest } from "./types";
|
||||
import type { EpiphanyCodeRef, EpiphanyGraphsState } from "@epiphanygraph/epiphany-graph-viewer";
|
||||
|
||||
const roleOrder = ["implementation", "imagination", "modeling", "verification", "reorientation"];
|
||||
const roleOrder = ["implementation", "imagination", "research", "eyes", "modeling", "verification", "reorientation"];
|
||||
const constellationSpecs = [
|
||||
{
|
||||
id: "coordinator",
|
||||
laneId: "coordinator",
|
||||
name: "Self",
|
||||
title: "Coordinator",
|
||||
glyph: "S",
|
||||
shape: "core",
|
||||
color: "#f15f45",
|
||||
glow: "#f7bd58",
|
||||
baseX: 49,
|
||||
baseY: 43,
|
||||
driftX: 1.9,
|
||||
driftY: 1.4,
|
||||
phase: 0.2,
|
||||
},
|
||||
{
|
||||
id: "imagination",
|
||||
laneId: "imagination",
|
||||
name: "Imagination",
|
||||
title: "Planner",
|
||||
glyph: "I",
|
||||
shape: "kite",
|
||||
color: "#9f6ee7",
|
||||
glow: "#eb8fc9",
|
||||
baseX: 29,
|
||||
baseY: 25,
|
||||
driftX: 2.3,
|
||||
driftY: 1.6,
|
||||
phase: 1.4,
|
||||
},
|
||||
{
|
||||
id: "research",
|
||||
laneId: "research",
|
||||
name: "Eyes",
|
||||
title: "Research",
|
||||
glyph: "E",
|
||||
shape: "lens",
|
||||
color: "#2877b8",
|
||||
glow: "#63c5da",
|
||||
baseX: 80,
|
||||
baseY: 23,
|
||||
driftX: 2.1,
|
||||
driftY: 1.7,
|
||||
phase: 2.1,
|
||||
},
|
||||
{
|
||||
id: "modeling",
|
||||
laneId: "modeling",
|
||||
name: "Body",
|
||||
title: "Modeling",
|
||||
glyph: "B",
|
||||
shape: "hex",
|
||||
color: "#2f9b67",
|
||||
glow: "#92d876",
|
||||
baseX: 21,
|
||||
baseY: 58,
|
||||
driftX: 1.8,
|
||||
driftY: 1.5,
|
||||
phase: 3.2,
|
||||
},
|
||||
{
|
||||
id: "implementation",
|
||||
laneId: "implementation",
|
||||
name: "Hands",
|
||||
title: "Implementation",
|
||||
glyph: "H",
|
||||
shape: "capsule",
|
||||
color: "#cf5a2f",
|
||||
glow: "#f1ad4e",
|
||||
baseX: 48,
|
||||
baseY: 64,
|
||||
driftX: 2.6,
|
||||
driftY: 1.2,
|
||||
phase: 4.4,
|
||||
},
|
||||
{
|
||||
id: "verification",
|
||||
laneId: "verification",
|
||||
name: "Soul",
|
||||
title: "Verification",
|
||||
glyph: "V",
|
||||
shape: "diamond",
|
||||
color: "#4e63b6",
|
||||
glow: "#a6a9f4",
|
||||
baseX: 78,
|
||||
baseY: 61,
|
||||
driftX: 1.7,
|
||||
driftY: 1.9,
|
||||
phase: 5.2,
|
||||
},
|
||||
{
|
||||
id: "reorientation",
|
||||
laneId: "reorientation",
|
||||
name: "Life",
|
||||
title: "Continuity",
|
||||
glyph: "L",
|
||||
shape: "seed",
|
||||
color: "#148d87",
|
||||
glow: "#58ddc4",
|
||||
baseX: 63,
|
||||
baseY: 29,
|
||||
driftX: 1.4,
|
||||
driftY: 2.2,
|
||||
phase: 6.0,
|
||||
},
|
||||
] as const;
|
||||
|
||||
const compactConstellationPositions: Record<string, { x: number; y: number }> = {
|
||||
coordinator: { x: 50, y: 10 },
|
||||
imagination: { x: 14, y: 20 },
|
||||
research: { x: 86, y: 20 },
|
||||
reorientation: { x: 50, y: 29 },
|
||||
modeling: { x: 14, y: 38 },
|
||||
verification: { x: 86, y: 38 },
|
||||
implementation: { x: 50, y: 48 },
|
||||
};
|
||||
|
||||
type ConstellationSpec = (typeof constellationSpecs)[number];
|
||||
type ProjectedAgent = ConstellationSpec & {
|
||||
status: string;
|
||||
tone: string;
|
||||
thought: string;
|
||||
detail: string;
|
||||
activity: number;
|
||||
jobs: number;
|
||||
review: string;
|
||||
};
|
||||
const actionButtons: Array<{
|
||||
action: OperatorAction;
|
||||
label: string;
|
||||
|
|
@ -233,6 +361,28 @@ function statusClass(value: unknown): string {
|
|||
return "neutral";
|
||||
}
|
||||
|
||||
function projectedThought(value: unknown, fallback: string): string {
|
||||
const cleaned = text(value, fallback).replace(/\s+/g, " ").trim();
|
||||
if (cleaned.length <= 136) return cleaned;
|
||||
return `${cleaned.slice(0, 132).trim()}...`;
|
||||
}
|
||||
|
||||
function projectedActivity(status: unknown, jobCount = 0): number {
|
||||
const lower = text(status).toLowerCase();
|
||||
const jobBoost = Math.min(jobCount * 0.08, 0.24);
|
||||
if (lower.includes("critical") || lower.includes("running") || lower.includes("launch")) return 1;
|
||||
if (lower.includes("blocked") || lower.includes("needed") || lower.includes("regather")) return 0.82 + jobBoost;
|
||||
if (lower.includes("prepare") || lower.includes("review") || lower.includes("ready")) return 0.68 + jobBoost;
|
||||
if (lower.includes("completed") || lower.includes("continue") || lower.includes("pass")) return 0.48 + jobBoost;
|
||||
if (lower.includes("idle")) return 0.24 + jobBoost;
|
||||
return 0.34 + jobBoost;
|
||||
}
|
||||
|
||||
function findingSummary(result: any): string | undefined {
|
||||
const finding = result?.finding;
|
||||
return finding?.summary ?? finding?.nextSafeMove ?? finding?.mode ?? finding?.verdict ?? result?.note;
|
||||
}
|
||||
|
||||
const emptyGraphState: EpiphanyGraphsState = {
|
||||
architecture: { nodes: [], edges: [] },
|
||||
dataflow: { nodes: [], edges: [] },
|
||||
|
|
@ -570,6 +720,17 @@ export function App() {
|
|||
</section>
|
||||
)}
|
||||
|
||||
<AgentConstellation
|
||||
roles={roles}
|
||||
roleResults={roleResults}
|
||||
reorientResult={reorientResult}
|
||||
coordinator={coordinator}
|
||||
crrc={crrc}
|
||||
pressure={pressure}
|
||||
reorient={reorient}
|
||||
jobs={jobs}
|
||||
/>
|
||||
|
||||
<section className="sectionBand">
|
||||
<SectionHeader title="Environment" icon={<Database size={18} />} />
|
||||
<div className="environmentGrid">
|
||||
|
|
@ -880,6 +1041,424 @@ function Panel({ title, icon, children }: { title: string; icon: React.ReactNode
|
|||
);
|
||||
}
|
||||
|
||||
function AgentConstellation({
|
||||
roles,
|
||||
roleResults,
|
||||
reorientResult,
|
||||
coordinator,
|
||||
crrc,
|
||||
pressure,
|
||||
reorient,
|
||||
jobs,
|
||||
}: {
|
||||
roles: any[];
|
||||
roleResults: any;
|
||||
reorientResult: any;
|
||||
coordinator: any;
|
||||
crrc: any;
|
||||
pressure: any;
|
||||
reorient: any;
|
||||
jobs: any[];
|
||||
}) {
|
||||
const rootRef = useRef<HTMLDivElement | null>(null);
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
const [selectedAgentId, setSelectedAgentId] = useState("coordinator");
|
||||
const agents = useMemo<ProjectedAgent[]>(() => {
|
||||
return constellationSpecs.map((spec) => {
|
||||
const lane = roles.find((role) => text(role.id).toLowerCase() === spec.laneId);
|
||||
const result =
|
||||
roleResults?.[spec.laneId] ??
|
||||
(spec.id === "research" ? roleResults?.eyes ?? roleResults?.research : undefined);
|
||||
const ownedJobs = jobs.filter((job) => {
|
||||
const owner = text(job.ownerRole).toLowerCase();
|
||||
const kind = text(job.kind).toLowerCase();
|
||||
return owner.includes(spec.laneId) || owner.includes(spec.id) || kind.includes(spec.laneId);
|
||||
});
|
||||
let status = text(lane?.status ?? result?.status, "idle");
|
||||
let thought = projectedThought(
|
||||
lane?.note ?? findingSummary(result),
|
||||
"Quiet. Waiting for a bounded signal.",
|
||||
);
|
||||
let detail = text(lane?.ownerRole ?? result?.bindingId, spec.title);
|
||||
let review = result?.finding?.statePatch ? "patch review" : "none";
|
||||
|
||||
if (spec.id === "coordinator") {
|
||||
status = text(coordinator?.action ?? crrc?.action, "unknown");
|
||||
thought = projectedThought(
|
||||
coordinator?.reason ?? crrc?.reason,
|
||||
"No coordinator projection loaded yet.",
|
||||
);
|
||||
detail = `target ${text(coordinator?.targetRole ?? crrc?.recommendedSceneAction, "none")}`;
|
||||
review = text(coordinator?.requiresReview, "false") === "true" ? "required" : "not required";
|
||||
} else if (spec.id === "reorientation") {
|
||||
status = text(lane?.status ?? reorient?.action ?? reorientResult?.status, "idle");
|
||||
thought = projectedThought(
|
||||
lane?.note ?? findingSummary(reorientResult) ?? reorient?.nextAction,
|
||||
"Continuity is quiet.",
|
||||
);
|
||||
detail = `pressure ${text(pressure?.level, "unknown")}`;
|
||||
review = text(reorientResult?.status).toLowerCase() === "completed" ? "read result" : "none";
|
||||
} else if (spec.id === "research" && !lane && !result) {
|
||||
status = "idle";
|
||||
thought = "Watching for proven paths before the machine invents one in a shed.";
|
||||
detail = "future lane";
|
||||
review = "none";
|
||||
}
|
||||
|
||||
return {
|
||||
...spec,
|
||||
status,
|
||||
tone: statusClass(status),
|
||||
thought,
|
||||
detail,
|
||||
activity: Math.min(projectedActivity(status, ownedJobs.length), 1),
|
||||
jobs: ownedJobs.length,
|
||||
review,
|
||||
};
|
||||
});
|
||||
}, [coordinator, crrc, jobs, pressure, reorient, reorientResult, roleResults, roles]);
|
||||
const selectedAgent = agents.find((agent) => agent.id === selectedAgentId) ?? agents[0];
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
const root = rootRef.current;
|
||||
if (!canvas || !root) return;
|
||||
const canvasElement = canvas;
|
||||
const rootElement = root;
|
||||
let frame = 0;
|
||||
const agentData = agents.map((agent) => ({
|
||||
id: agent.id,
|
||||
baseX: agent.baseX,
|
||||
baseY: agent.baseY,
|
||||
driftX: agent.driftX,
|
||||
driftY: agent.driftY,
|
||||
phase: agent.phase,
|
||||
activity: agent.activity,
|
||||
color: hexToRgb(agent.color),
|
||||
}));
|
||||
|
||||
function projectAgent(agent: (typeof agentData)[number], time: number, width: number, height: number) {
|
||||
const compactPosition = width < 540 ? compactConstellationPositions[agent.id] : undefined;
|
||||
const baseX = compactPosition?.x ?? agent.baseX;
|
||||
const baseY = compactPosition?.y ?? agent.baseY;
|
||||
const x =
|
||||
(baseX / 100) * width +
|
||||
Math.sin(time * 0.42 + agent.phase) * agent.driftX * 2.8 +
|
||||
Math.cos(time * 0.19 + agent.phase * 0.7) * agent.activity * 4.5;
|
||||
const y =
|
||||
(baseY / 100) * height +
|
||||
Math.cos(time * 0.35 + agent.phase) * agent.driftY * 3.1 +
|
||||
Math.sin(time * 0.23 + agent.phase * 0.9) * agent.activity * 4;
|
||||
return { ...agent, x, y };
|
||||
}
|
||||
|
||||
function updateProjectedDom(time: number, width: number, height: number) {
|
||||
return agentData.map((agent) => {
|
||||
const projected = projectAgent(agent, time, width, height);
|
||||
const node = rootElement.querySelector<HTMLElement>(`[data-agent-node="${agent.id}"]`);
|
||||
const thought = rootElement.querySelector<HTMLElement>(`[data-agent-thought="${agent.id}"]`);
|
||||
const tilt = Math.sin(time * 0.7 + agent.phase) * 4;
|
||||
for (const element of [node, thought]) {
|
||||
element?.style.setProperty("--agent-x", `${projected.x}px`);
|
||||
element?.style.setProperty("--agent-y", `${projected.y}px`);
|
||||
element?.style.setProperty("--agent-tilt", `${tilt}deg`);
|
||||
}
|
||||
return projected;
|
||||
});
|
||||
}
|
||||
|
||||
function resizeCanvas() {
|
||||
const bounds = canvasElement.getBoundingClientRect();
|
||||
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
||||
const width = Math.max(1, Math.floor(bounds.width * dpr));
|
||||
const height = Math.max(1, Math.floor(bounds.height * dpr));
|
||||
if (canvasElement.width !== width || canvasElement.height !== height) {
|
||||
canvasElement.width = width;
|
||||
canvasElement.height = height;
|
||||
}
|
||||
return { cssWidth: bounds.width, cssHeight: bounds.height, width, height, dpr };
|
||||
}
|
||||
|
||||
const gl = canvasElement.getContext("webgl2", { alpha: true, antialias: false, preserveDrawingBuffer: true });
|
||||
if (!gl) {
|
||||
const context = canvasElement.getContext("2d");
|
||||
if (!context) return;
|
||||
const drawFallback = (millis: number) => {
|
||||
const time = millis / 1000;
|
||||
const { cssWidth, cssHeight, width, height, dpr } = resizeCanvas();
|
||||
const projected = updateProjectedDom(time, cssWidth, cssHeight);
|
||||
context.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
context.clearRect(0, 0, cssWidth, cssHeight);
|
||||
const haze = context.createLinearGradient(0, 0, cssWidth, cssHeight);
|
||||
haze.addColorStop(0, "rgba(38, 53, 46, 0.66)");
|
||||
haze.addColorStop(0.45, "rgba(30, 36, 60, 0.44)");
|
||||
haze.addColorStop(1, "rgba(80, 57, 35, 0.48)");
|
||||
context.fillStyle = haze;
|
||||
context.fillRect(0, 0, cssWidth, cssHeight);
|
||||
for (const agent of projected) {
|
||||
context.strokeStyle = `rgba(${agent.color.map((channel) => Math.floor(channel * 255)).join(", ")}, ${0.18 + agent.activity * 0.22})`;
|
||||
context.lineWidth = 1.2;
|
||||
for (let ring = 0; ring < 3; ring += 1) {
|
||||
context.beginPath();
|
||||
context.arc(agent.x, agent.y, 26 + ring * 34 + Math.sin(time * 2 + ring + agent.phase) * 8, 0, Math.PI * 2);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
frame = requestAnimationFrame(drawFallback);
|
||||
};
|
||||
frame = requestAnimationFrame(drawFallback);
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}
|
||||
|
||||
const vertexSource = `#version 300 es
|
||||
precision highp float;
|
||||
out vec2 v_uv;
|
||||
const vec2 positions[3] = vec2[3](
|
||||
vec2(-1.0, -1.0),
|
||||
vec2(3.0, -1.0),
|
||||
vec2(-1.0, 3.0)
|
||||
);
|
||||
void main() {
|
||||
vec2 position = positions[gl_VertexID];
|
||||
v_uv = position * 0.5 + 0.5;
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
}`;
|
||||
const fragmentSource = `#version 300 es
|
||||
precision highp float;
|
||||
in vec2 v_uv;
|
||||
out vec4 out_color;
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_agents[7];
|
||||
uniform float u_activity[7];
|
||||
uniform vec3 u_colors[7];
|
||||
uniform int u_count;
|
||||
|
||||
float hash(vec2 p) {
|
||||
p = fract(p * vec2(123.34, 456.21));
|
||||
p += dot(p, p + 45.32);
|
||||
return fract(p.x * p.y);
|
||||
}
|
||||
|
||||
float noise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
vec2 u = f * f * (3.0 - 2.0 * f);
|
||||
return mix(
|
||||
mix(hash(i + vec2(0.0, 0.0)), hash(i + vec2(1.0, 0.0)), u.x),
|
||||
mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),
|
||||
u.y
|
||||
);
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
float value = 0.0;
|
||||
float amplitude = 0.5;
|
||||
for (int octave = 0; octave < 5; octave += 1) {
|
||||
value += amplitude * noise(p);
|
||||
p *= 2.04;
|
||||
amplitude *= 0.52;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_uv;
|
||||
vec2 aspect = vec2(u_resolution.x / max(u_resolution.y, 1.0), 1.0);
|
||||
float slow = fbm(uv * vec2(2.4, 1.8) + vec2(u_time * 0.026, -u_time * 0.018));
|
||||
float fine = fbm(uv * 8.0 + slow + vec2(-u_time * 0.055, u_time * 0.04));
|
||||
vec3 color = mix(vec3(0.045, 0.075, 0.068), vec3(0.17, 0.12, 0.18), slow);
|
||||
color += vec3(0.05, 0.045, 0.028) * fine;
|
||||
float alpha = 0.88;
|
||||
|
||||
for (int i = 0; i < 7; i += 1) {
|
||||
if (i >= u_count) {
|
||||
break;
|
||||
}
|
||||
vec2 agent = u_agents[i] / u_resolution;
|
||||
vec2 delta = (uv - agent) * aspect;
|
||||
float radius = length(delta);
|
||||
float pulse = sin(radius * 46.0 - u_time * (2.0 + u_activity[i] * 2.4) + float(i) * 0.9);
|
||||
float wake = smoothstep(0.34, 0.0, radius) * (0.45 + 0.55 * pulse) * u_activity[i];
|
||||
float ember = exp(-radius * 18.0) * (0.45 + u_activity[i] * 0.72);
|
||||
color += u_colors[i] * (wake * 0.13 + ember * 0.42);
|
||||
alpha += wake * 0.03;
|
||||
}
|
||||
|
||||
float vignette = smoothstep(0.82, 0.18, distance(uv, vec2(0.5)));
|
||||
color *= 0.78 + vignette * 0.44;
|
||||
out_color = vec4(color, clamp(alpha, 0.0, 0.96));
|
||||
}`;
|
||||
|
||||
const program = createConstellationProgram(gl, vertexSource, fragmentSource);
|
||||
if (!program) return;
|
||||
const resolutionLocation = gl.getUniformLocation(program, "u_resolution");
|
||||
const timeLocation = gl.getUniformLocation(program, "u_time");
|
||||
const agentsLocation = gl.getUniformLocation(program, "u_agents");
|
||||
const activityLocation = gl.getUniformLocation(program, "u_activity");
|
||||
const colorsLocation = gl.getUniformLocation(program, "u_colors");
|
||||
const countLocation = gl.getUniformLocation(program, "u_count");
|
||||
const vao = gl.createVertexArray();
|
||||
const colorBuffer = new Float32Array(7 * 3);
|
||||
for (let index = 0; index < agentData.length; index += 1) {
|
||||
colorBuffer.set(agentData[index].color, index * 3);
|
||||
}
|
||||
const activityBuffer = new Float32Array(7);
|
||||
const positionBuffer = new Float32Array(7 * 2);
|
||||
|
||||
const draw = (millis: number) => {
|
||||
const time = millis / 1000;
|
||||
const { cssWidth, cssHeight, width, height, dpr } = resizeCanvas();
|
||||
const projected = updateProjectedDom(time, cssWidth, cssHeight);
|
||||
for (let index = 0; index < projected.length; index += 1) {
|
||||
positionBuffer[index * 2] = projected[index].x * dpr;
|
||||
positionBuffer[index * 2 + 1] = (cssHeight - projected[index].y) * dpr;
|
||||
activityBuffer[index] = projected[index].activity;
|
||||
}
|
||||
gl.viewport(0, 0, width, height);
|
||||
gl.clearColor(0, 0, 0, 0);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
gl.useProgram(program);
|
||||
gl.bindVertexArray(vao);
|
||||
gl.uniform2f(resolutionLocation, width, height);
|
||||
gl.uniform1f(timeLocation, time);
|
||||
gl.uniform1i(countLocation, projected.length);
|
||||
gl.uniform2fv(agentsLocation, positionBuffer);
|
||||
gl.uniform1fv(activityLocation, activityBuffer);
|
||||
gl.uniform3fv(colorsLocation, colorBuffer);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
frame = requestAnimationFrame(draw);
|
||||
};
|
||||
|
||||
frame = requestAnimationFrame(draw);
|
||||
return () => {
|
||||
cancelAnimationFrame(frame);
|
||||
gl.deleteVertexArray(vao);
|
||||
gl.deleteProgram(program);
|
||||
};
|
||||
}, [agents]);
|
||||
|
||||
return (
|
||||
<section className="sectionBand agentConstellation" aria-label="Agent state overview">
|
||||
<div className="constellationHeader">
|
||||
<SectionHeader title="Agent State" icon={<Boxes size={18} />} />
|
||||
<div className="constellationSignals" aria-label="Global signals">
|
||||
<Pill tone={statusClass(coordinator?.action ?? crrc?.action)}>
|
||||
{text(coordinator?.action ?? crrc?.action, "unknown")}
|
||||
</Pill>
|
||||
<Pill tone={statusClass(pressure?.level)}>pressure {text(pressure?.level, "unknown")}</Pill>
|
||||
<Pill tone={statusClass(reorient?.action)}>continuity {text(reorient?.action, "unknown")}</Pill>
|
||||
</div>
|
||||
</div>
|
||||
<div className="agentStage" ref={rootRef}>
|
||||
<canvas ref={canvasRef} className="agentSmokeCanvas" aria-hidden="true" />
|
||||
<div className="agentStageVignette" aria-hidden="true" />
|
||||
{agents.map((agent) => (
|
||||
<button
|
||||
className={`agentCharacter ${agent.shape} ${agent.tone} ${selectedAgentId === agent.id ? "selected" : ""}`}
|
||||
key={agent.id}
|
||||
type="button"
|
||||
data-agent-node={agent.id}
|
||||
onClick={() => setSelectedAgentId(agent.id)}
|
||||
title={`${agent.name}: ${agent.thought}`}
|
||||
style={
|
||||
{
|
||||
"--agent-x": `${agent.baseX}%`,
|
||||
"--agent-y": `${agent.baseY}%`,
|
||||
"--agent-color": agent.color,
|
||||
"--agent-glow": agent.glow,
|
||||
"--agent-activity": agent.activity,
|
||||
"--agent-bubble-opacity": 0.38 + agent.activity * 0.28,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<span className="agentGlyph" aria-hidden="true">{agent.glyph}</span>
|
||||
<span className="agentCaption">
|
||||
<strong>{agent.name}</strong>
|
||||
<span>{agent.status}</span>
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
{agents.map((agent) => (
|
||||
<div
|
||||
className={`thoughtBubble ${agent.tone} ${selectedAgentId === agent.id ? "selected" : ""}`}
|
||||
key={`${agent.id}-thought`}
|
||||
data-agent-thought={agent.id}
|
||||
style={
|
||||
{
|
||||
"--agent-x": `${agent.baseX}%`,
|
||||
"--agent-y": `${agent.baseY}%`,
|
||||
"--agent-color": agent.color,
|
||||
"--agent-glow": agent.glow,
|
||||
"--agent-activity": agent.activity,
|
||||
"--agent-bubble-opacity": 0.38 + agent.activity * 0.28,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<strong>{agent.name}</strong>
|
||||
<span>{agent.thought}</span>
|
||||
</div>
|
||||
))}
|
||||
<div className="constellationInspector">
|
||||
<div>
|
||||
<span>{selectedAgent.title}</span>
|
||||
<strong>{selectedAgent.name}</strong>
|
||||
<p>{selectedAgent.thought}</p>
|
||||
</div>
|
||||
<dl className="facts compact">
|
||||
<div><dt>Status</dt><dd><Pill tone={selectedAgent.tone}>{selectedAgent.status}</Pill></dd></div>
|
||||
<div><dt>Detail</dt><dd>{selectedAgent.detail}</dd></div>
|
||||
<div><dt>Jobs</dt><dd>{selectedAgent.jobs}</dd></div>
|
||||
<div><dt>Review</dt><dd>{selectedAgent.review}</dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function createConstellationProgram(gl: WebGL2RenderingContext, vertexSource: string, fragmentSource: string) {
|
||||
const vertexShader = compileConstellationShader(gl, gl.VERTEX_SHADER, vertexSource);
|
||||
const fragmentShader = compileConstellationShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
||||
if (!vertexShader || !fragmentShader) return null;
|
||||
const program = gl.createProgram();
|
||||
if (!program) return null;
|
||||
gl.attachShader(program, vertexShader);
|
||||
gl.attachShader(program, fragmentShader);
|
||||
gl.linkProgram(program);
|
||||
gl.deleteShader(vertexShader);
|
||||
gl.deleteShader(fragmentShader);
|
||||
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
||||
gl.deleteProgram(program);
|
||||
return null;
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
function compileConstellationShader(gl: WebGL2RenderingContext, type: number, source: string) {
|
||||
const shader = gl.createShader(type);
|
||||
if (!shader) return null;
|
||||
gl.shaderSource(shader, source);
|
||||
gl.compileShader(shader);
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
gl.deleteShader(shader);
|
||||
return null;
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
function hexToRgb(hex: string): [number, number, number] {
|
||||
const normalized = hex.replace("#", "");
|
||||
const value = Number.parseInt(normalized.length === 3
|
||||
? normalized.split("").map((char) => `${char}${char}`).join("")
|
||||
: normalized, 16);
|
||||
return [
|
||||
((value >> 16) & 255) / 255,
|
||||
((value >> 8) & 255) / 255,
|
||||
(value & 255) / 255,
|
||||
];
|
||||
}
|
||||
|
||||
function SectionHeader({ title, icon }: { title: string; icon: React.ReactNode }) {
|
||||
return (
|
||||
<div className="sectionHeader">
|
||||
|
|
|
|||
|
|
@ -412,6 +412,309 @@ dd {
|
|||
min-height: 560px;
|
||||
}
|
||||
|
||||
.agentConstellation {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.constellationHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.constellationHeader .sectionHeader {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.constellationSignals {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.agentStage {
|
||||
position: relative;
|
||||
min-height: clamp(500px, 42vw, 560px);
|
||||
overflow: hidden;
|
||||
border: 1px solid #283c35;
|
||||
border-radius: 8px;
|
||||
background:
|
||||
radial-gradient(circle at 24% 28%, rgba(100, 152, 100, 0.26), transparent 30%),
|
||||
radial-gradient(circle at 76% 24%, rgba(101, 89, 160, 0.24), transparent 28%),
|
||||
radial-gradient(circle at 68% 78%, rgba(202, 96, 52, 0.24), transparent 32%),
|
||||
#18251f;
|
||||
isolation: isolate;
|
||||
box-shadow: 0 12px 34px rgba(23, 32, 24, 0.16);
|
||||
}
|
||||
|
||||
.agentSmokeCanvas,
|
||||
.agentStageVignette {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.agentSmokeCanvas {
|
||||
z-index: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.agentStageVignette {
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(13, 22, 19, 0.22), transparent 28%, rgba(8, 12, 10, 0.32)),
|
||||
radial-gradient(circle at 50% 52%, transparent 32%, rgba(6, 13, 11, 0.38) 100%);
|
||||
}
|
||||
|
||||
.agentCharacter,
|
||||
.thoughtBubble {
|
||||
left: var(--agent-x);
|
||||
top: var(--agent-y);
|
||||
}
|
||||
|
||||
.agentCharacter {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
width: 118px;
|
||||
min-height: 92px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: #fbfff8;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
text-shadow: 0 1px 8px rgba(4, 8, 6, 0.72);
|
||||
transform: translate(-50%, -50%) rotate(var(--agent-tilt, 0deg));
|
||||
transition:
|
||||
filter 160ms ease,
|
||||
opacity 160ms ease;
|
||||
}
|
||||
|
||||
.agentCharacter:hover,
|
||||
.agentCharacter:focus-visible,
|
||||
.agentCharacter.selected {
|
||||
filter: drop-shadow(0 0 16px color-mix(in srgb, var(--agent-glow) 78%, transparent));
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.agentCharacter:focus-visible .agentGlyph {
|
||||
outline: 3px solid rgba(255, 255, 255, 0.74);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
.agentGlyph {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.56);
|
||||
color: #ffffff;
|
||||
background:
|
||||
radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.7), transparent 18px),
|
||||
linear-gradient(135deg, var(--agent-glow), var(--agent-color));
|
||||
box-shadow:
|
||||
0 0 24px color-mix(in srgb, var(--agent-color) 62%, transparent),
|
||||
inset 0 -10px 18px rgba(5, 11, 8, 0.24);
|
||||
font-weight: 900;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.agentCharacter.core .agentGlyph {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.agentCharacter.kite .agentGlyph {
|
||||
clip-path: polygon(50% 0, 94% 40%, 50% 100%, 6% 40%);
|
||||
}
|
||||
|
||||
.agentCharacter.lens .agentGlyph {
|
||||
border-radius: 50% 8px 50% 8px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.agentCharacter.lens .agentGlyph::first-letter {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.agentCharacter.hex .agentGlyph {
|
||||
clip-path: polygon(24% 5%, 76% 5%, 100% 50%, 76% 95%, 24% 95%, 0 50%);
|
||||
}
|
||||
|
||||
.agentCharacter.capsule .agentGlyph {
|
||||
width: 68px;
|
||||
border-radius: 28px 12px 28px 12px;
|
||||
}
|
||||
|
||||
.agentCharacter.diamond .agentGlyph {
|
||||
clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
|
||||
}
|
||||
|
||||
.agentCharacter.seed .agentGlyph {
|
||||
border-radius: 52% 52% 52% 12%;
|
||||
transform: rotate(42deg);
|
||||
}
|
||||
|
||||
.agentCaption {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
max-width: 118px;
|
||||
margin-top: 6px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
border-radius: 7px;
|
||||
padding: 5px 7px;
|
||||
background: rgba(15, 25, 22, 0.64);
|
||||
backdrop-filter: blur(7px);
|
||||
}
|
||||
|
||||
.agentCaption strong,
|
||||
.agentCaption span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.agentCaption strong {
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.agentCaption span {
|
||||
color: rgba(245, 255, 245, 0.74);
|
||||
font-size: 0.68rem;
|
||||
font-weight: 800;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.thoughtBubble {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
width: clamp(166px, 18vw, 246px);
|
||||
max-height: 96px;
|
||||
border: 1px solid color-mix(in srgb, var(--agent-color) 48%, rgba(255, 255, 255, 0.74));
|
||||
border-radius: 8px 8px 8px 2px;
|
||||
padding: 9px 11px;
|
||||
color: #172018;
|
||||
background: rgba(249, 252, 246, 0.88);
|
||||
box-shadow: 0 14px 30px rgba(6, 11, 9, 0.26);
|
||||
opacity: var(--agent-bubble-opacity, 0.62);
|
||||
pointer-events: none;
|
||||
transform: translate(-10%, -142%) rotate(var(--agent-tilt, 0deg));
|
||||
animation: thoughtDrift 7600ms ease-in-out infinite;
|
||||
}
|
||||
|
||||
.thoughtBubble.selected {
|
||||
z-index: 4;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.thoughtBubble::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 16px;
|
||||
bottom: -16px;
|
||||
width: 56px;
|
||||
height: 24px;
|
||||
background:
|
||||
radial-gradient(circle at 20% 58%, color-mix(in srgb, var(--agent-color) 44%, transparent), transparent 42%),
|
||||
radial-gradient(circle at 54% 50%, rgba(255, 255, 255, 0.46), transparent 38%),
|
||||
radial-gradient(circle at 82% 44%, color-mix(in srgb, var(--agent-glow) 38%, transparent), transparent 40%);
|
||||
filter: blur(5px);
|
||||
opacity: 0.6;
|
||||
animation: thoughtSmoke 4800ms ease-in-out infinite;
|
||||
}
|
||||
|
||||
.thoughtBubble strong {
|
||||
color: color-mix(in srgb, var(--agent-color) 72%, #172018);
|
||||
font-size: 0.72rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.thoughtBubble span {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
color: #243026;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.28;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
|
||||
.constellationInspector {
|
||||
position: absolute;
|
||||
z-index: 5;
|
||||
right: 16px;
|
||||
bottom: 16px;
|
||||
left: 16px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
|
||||
gap: 14px;
|
||||
align-items: start;
|
||||
border: 1px solid rgba(214, 223, 211, 0.76);
|
||||
border-radius: 8px;
|
||||
padding: 13px 14px;
|
||||
background: rgba(248, 250, 244, 0.9);
|
||||
backdrop-filter: blur(12px);
|
||||
box-shadow: 0 14px 32px rgba(4, 8, 6, 0.24);
|
||||
}
|
||||
|
||||
.constellationInspector > div {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.constellationInspector span {
|
||||
color: #667168;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.constellationInspector strong {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
color: #172018;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.constellationInspector p {
|
||||
margin-top: 6px;
|
||||
color: #3e493f;
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.38;
|
||||
}
|
||||
|
||||
.constellationInspector .facts {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@keyframes thoughtDrift {
|
||||
0%,
|
||||
100% {
|
||||
margin-top: 0;
|
||||
}
|
||||
50% {
|
||||
margin-top: -10px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes thoughtSmoke {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.5;
|
||||
transform: translate(0, 0) scale(0.88);
|
||||
}
|
||||
50% {
|
||||
opacity: 0.2;
|
||||
transform: translate(12px, -8px) scale(1.22);
|
||||
}
|
||||
}
|
||||
|
||||
.draftPicker {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
|
@ -599,6 +902,27 @@ code {
|
|||
.graphSummary {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.constellationHeader {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.constellationSignals {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.agentStage {
|
||||
min-height: 640px;
|
||||
}
|
||||
|
||||
.constellationInspector {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.thoughtBubble {
|
||||
width: min(224px, 34vw);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
|
|
@ -633,4 +957,55 @@ code {
|
|||
gap: 4px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.agentStage {
|
||||
min-height: 700px;
|
||||
}
|
||||
|
||||
.agentCharacter {
|
||||
width: 76px;
|
||||
min-height: 66px;
|
||||
}
|
||||
|
||||
.agentGlyph {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
.agentCharacter.capsule .agentGlyph {
|
||||
width: 46px;
|
||||
}
|
||||
|
||||
.agentCaption {
|
||||
max-width: 76px;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
.agentCaption strong {
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
.agentCaption span {
|
||||
font-size: 0.62rem;
|
||||
}
|
||||
|
||||
.thoughtBubble {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.thoughtBubble.selected {
|
||||
display: grid;
|
||||
left: 50% !important;
|
||||
top: 14px !important;
|
||||
width: min(280px, calc(100vw - 52px));
|
||||
max-height: none;
|
||||
transform: translate(-50%, 0);
|
||||
}
|
||||
|
||||
.constellationInspector {
|
||||
right: 10px;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
padding: 11px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue