From 3bedc9309fc9faa8718250a93407ea0cfaf02231 Mon Sep 17 00:00:00 2001 From: sahajiscoding <135018977+sahajiscoding@users.noreply.github.com> Date: Thu, 15 Oct 2026 06:00:06 +0000 Subject: [PATCH] Add MiroFish-inspired Swarm Lab Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --- app/mirofish/page.tsx | 14 + components/mirofish-console.tsx | 1043 ++++++++++ components/sidebar-nav.tsx | 5 +- founder/mirofish/README.md | 33 + founder/mirofish/agent_log.jsonl | 6 + founder/mirofish/graph.json | 2530 +++++++++++++++++++++++ founder/mirofish/oasis_profiles.json | 1162 +++++++++++ founder/mirofish/ontology.json | 144 ++ founder/mirofish/outline.json | 50 + founder/mirofish/reddit_actions.jsonl | 200 ++ founder/mirofish/report.md | 45 + founder/mirofish/run_state.json | 38 + founder/mirofish/simulation_config.json | 160 ++ founder/mirofish/twitter_actions.jsonl | 200 ++ founder/panel/swarm-reactions.json | 578 ++++++ founder/panel/swarm-reactions.md | 69 + lib/mirofish/engine.ts | 326 +++ lib/mirofish/simulation-data.ts | 164 ++ package.json | 1 + scripts/mirofish-simulate.mjs | 673 ++++++ tests/mirofish-engine.test.ts | 106 + tests/x402-server.test.ts | 22 +- 22 files changed, 7567 insertions(+), 2 deletions(-) create mode 100644 app/mirofish/page.tsx create mode 100644 components/mirofish-console.tsx create mode 100644 founder/mirofish/README.md create mode 100644 founder/mirofish/agent_log.jsonl create mode 100644 founder/mirofish/graph.json create mode 100644 founder/mirofish/oasis_profiles.json create mode 100644 founder/mirofish/ontology.json create mode 100644 founder/mirofish/outline.json create mode 100644 founder/mirofish/reddit_actions.jsonl create mode 100644 founder/mirofish/report.md create mode 100644 founder/mirofish/run_state.json create mode 100644 founder/mirofish/simulation_config.json create mode 100644 founder/mirofish/twitter_actions.jsonl create mode 100644 founder/panel/swarm-reactions.json create mode 100644 founder/panel/swarm-reactions.md create mode 100644 lib/mirofish/engine.ts create mode 100644 lib/mirofish/simulation-data.ts create mode 100644 scripts/mirofish-simulate.mjs create mode 100644 tests/mirofish-engine.test.ts diff --git a/app/mirofish/page.tsx b/app/mirofish/page.tsx new file mode 100644 index 0000000..25ba4cb --- /dev/null +++ b/app/mirofish/page.tsx @@ -0,0 +1,14 @@ +import { MirofishConsole } from "@/components/mirofish-console"; +import { ProtectedAppShell } from "@/components/protected-app-shell"; +import { privateMetadata } from "@/lib/seo"; + +export const metadata = privateMetadata("Swarm Intelligence Lab"); + +/** Authenticated, five-stage MiroFish-inspired scenario console. */ +export default function MirofishPage() { + return ( + + + + ); +} diff --git a/components/mirofish-console.tsx b/components/mirofish-console.tsx new file mode 100644 index 0000000..6ded444 --- /dev/null +++ b/components/mirofish-console.tsx @@ -0,0 +1,1043 @@ +"use client"; + +import { + Activity, + ArrowRight, + ArrowUpRight, + BadgeCheck, + BarChart3, + BrainCircuit, + BookOpen, + Check, + CheckCircle2, + ChevronRight, + Clock3, + Compass, + Database, + FileSearch, + GitBranch, + Globe2, + Layers3, + Lightbulb, + MessageCircle, + MessageSquareText, + Network, + Pause, + Play, + Quote, + Radar, + Radio, + RefreshCw, + RotateCcw, + Search, + Send, + ShieldAlert, + ShieldCheck, + Sparkles, + Target, + Timer, + Users, + Waypoints, + Zap, +} from "lucide-react"; +import { useMemo, useRef, useState, type FormEvent, type ReactNode } from "react"; +import { + answerAgent, + buildScenarioReport, + simulateRound, + surveyProfileSignals, + type ReportSection, + type ScenarioReport, + type SimAction, + type SimPlatform, +} from "@/lib/mirofish/engine"; +import { + evidenceCaveat, + godEyeEvents, + graphEdges, + graphNodes, + scenarioSeed, + seededAgents, + stanceMeta, + type AgentProfile, + type GraphNode, + type GodEyeEvent, +} from "@/lib/mirofish/simulation-data"; + +type ChatLine = { role: "agent" | "delegate"; content: string }; +type ConsoleStep = { id: number; name: string; sub: string; icon: typeof Network }; + +const steps: ConsoleStep[] = [ + { id: 0, name: "Graph Build", sub: "Map the seed", icon: Network }, + { id: 1, name: "Env Setup", sub: "Shape the room", icon: Layers3 }, + { id: 2, name: "Simulation", sub: "Run both feeds", icon: Activity }, + { id: 3, name: "Report Agent", sub: "Read the signals", icon: FileSearch }, + { id: 4, name: "Deep Interaction", sub: "Ask the agents", icon: MessageCircle }, +]; + +const initialActions = simulateRound(1, seededAgents, godEyeEvents[0]); +const initialReport = buildScenarioReport(1, seededAgents, initialActions, godEyeEvents[0]); +const initialSurveyPrompt = "What would most increase confidence in trying MUN Prep?"; + +const graphPointById: Record = { + app_mun_prep: { x: 460, y: 250 }, + offer_trial_3d: { x: 460, y: 55 }, + offer_weekly_199: { x: 700, y: 115 }, + offer_monthly_299: { x: 700, y: 360 }, + feature_research: { x: 460, y: 455 }, + feature_writing: { x: 220, y: 360 }, + feature_debate: { x: 220, y: 135 }, + trust_sources: { x: 315, y: 45 }, + trust_peer_proof: { x: 605, y: 45 }, + concern_coach: { x: 70, y: 250 }, + concern_generic_ai: { x: 850, y: 250 }, +}; + +const coreLabelById: Record = { + app_mun_prep: "MUN Prep", + offer_trial_3d: "3-day trial", + offer_weekly_199: "₹199 · week", + offer_monthly_299: "₹299 · month", + feature_research: "Research", + feature_writing: "Papers + speeches", + feature_debate: "POIs + clauses", + trust_sources: "Source proof", + trust_peer_proof: "Peer proof", + concern_coach: "Coach / school", + concern_generic_ai: "Generic AI", +}; + +const stanceColors: Record = { + "trial-curious": "#8ad1bd", + "needs-evidence": "#f1bb72", + "needs-social-proof": "#e5a4a6", + "coach-led": "#c2b0e6", + "group-adoption": "#91b6e7", + "price-check": "#f2d780", + "value-check": "#a9c79a", +}; + +const stageCopy = [ + { + eyebrow: "01 / Knowledge graph", + title: "Start with the product, not a generic prompt.", + description: "A compact GraphRAG-style map connects the live offer, preparation tools, and the questions carried by the existing synthetic panel.", + }, + { + eyebrow: "02 / Environment setup", + title: "Give the room a memory before it speaks.", + description: "Inspect the four persona dimensions, choose the timeline depth, and see exactly which synthetic profiles are in the sandbox.", + }, + { + eyebrow: "03 / Dual-platform simulation", + title: "Watch the same launch travel two feeds.", + description: "Advance Info Plaza and Topic Community together. Inject a live fact or a clearly marked what-if into the next round.", + }, + { + eyebrow: "04 / ReACT report agent", + title: "Turn the activity into a cautious read.", + description: "Trace the local tool calls, separate signal from evidence, and leave with real-world tests—not a made-up conversion forecast.", + }, + { + eyebrow: "05 / Deep interaction", + title: "Ask one persona—or survey the whole room.", + description: "Interview a memory-grounded agent or aggregate the panel's remembered priorities. Every answer stays in this browser.", + }, +]; + +function getInitials(name: string) { + return name.split(/\s+/).map((part) => part[0]).join("").slice(0, 2).toUpperCase(); +} + +function formatActionLabel(actionType: string) { + return actionType.replace(/_/g, " ").toLowerCase(); +} + +function SentimentPill({ sentiment }: { sentiment: SimAction["sentiment"] }) { + const style: Record = { + open: "border-emerald-200/70 bg-emerald-50 text-emerald-800", + curious: "border-sky-200/80 bg-sky-50 text-sky-800", + conditional: "border-amber-200/80 bg-amber-50 text-amber-900", + skeptical: "border-rose-200/80 bg-rose-50 text-rose-800", + }; + return ( + + {sentiment} + + ); +} + +function SectionHeading({ eyebrow, title, description }: { eyebrow: string; title: string; description: string }) { + return ( +
+
+

{eyebrow}

+

{title}

+
+

{description}

+
+ ); +} + +function Pill({ children, tone = "neutral" }: { children: ReactNode; tone?: "neutral" | "green" | "amber" | "red" }) { + const toneClass = { + neutral: "border-[var(--line)] bg-white/50 text-[var(--muted)]", + green: "border-emerald-200 bg-emerald-50 text-emerald-800", + amber: "border-amber-200 bg-amber-50 text-amber-900", + red: "border-rose-200 bg-rose-50 text-rose-800", + }[tone]; + return {children}; +} + +function MetricCard({ label, value, note, icon: Icon }: { label: string; value: string; note: string; icon: typeof Activity }) { + return ( +
+
+

{label}

+
+

{value}

+

{note}

+
+ ); +} + +function DimensionCard({ label, text, icon: Icon, index }: { label: string; text: string; icon: typeof Activity; index: number }) { + return ( +
+
+ + +
+

Memory {String(index).padStart(2, "0")}

+

{label}

+
+
+

{text}

+
+ ); +} + +function getGraphPositions() { + const agents = graphNodes.filter((node) => node.ui_group === "agent"); + const positions = new Map(); + for (const node of graphNodes) { + if (node.ui_group === "agent") continue; + const point = graphPointById[node.uuid]; + if (point) positions.set(node.uuid, point); + } + agents.forEach((node, index) => { + const angle = (index / Math.max(agents.length, 1)) * Math.PI * 2 - Math.PI / 2; + positions.set(node.uuid, { + x: 460 + Math.cos(angle) * 136, + y: 250 + Math.sin(angle) * 136, + }); + }); + return positions; +} + +const graphPositions = getGraphPositions(); +const graphAgentByNodeId: Map = new Map(seededAgents.map((agent) => [`agent_${agent.id}`, agent] as const)); + +function GraphCanvas({ selectedId }: { selectedId: string }) { + return ( +
+