๐ The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(ruflo-console): x.ruv.io board and a second terminal for codex, claude and the ruflo CLI (0.4.0)
ruvfeeef5d24651
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.jsonindex c0c59d8baa..350978a968 100644--- a/plugins/ruflo-console/.claude-plugin/plugin.json+++ b/plugins/ruflo-console/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-console",- "description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a; no network by default.",- "version": "0.3.0",+ "description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, an x.ruv.io federation board, a second terminal for codex, claude and the ruflo CLI (each run confirmed), agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a; no network by default.",+ "version": "0.4.0","author": {"name": "ruvnet","url": "https://github.com/ruvnet"@@ -73,7 +73,7 @@"federationNetwork": {"type": "boolean","title": "Ask the federation relay",- "description": "Lets the federation view ask the public relay (wss://relay.ruv.io) for the roster. Off by default: without it the console makes no network request.",+ "description": "Lets the federation and x.ruv.io views ask the public relay (wss://relay.ruv.io) for the roster and the x.ruv.io gateway for its registry. Off by default: without it the console makes no network request.","default": false},"look": {diff --git a/plugins/ruflo-console/hooks/actions.ts b/plugins/ruflo-console/hooks/actions.tsindex 2b1e08d71a..36b2bf0853 100644--- a/plugins/ruflo-console/hooks/actions.ts+++ b/plugins/ruflo-console/hooks/actions.ts@@ -13,6 +13,10 @@ export type ActionSpec = {verify?: (snapshot: Snapshot) => boolean/** Reads only: runs at once, without the confirm step, and shows what the CLI printed. */isReadOnly?: boolean+ /** Not a ruflo CLI call: what runs instead once confirmed (a terminal harness), reporting for itself. */+ run?: () => Promise<void>+ /** The command line the confirm row shows when it is not `ruflo <args>`. */+ shows?: string}export const exec = (tool: string, params: Record<string, string>) => ['mcp', 'exec', '-t', tool, '-p', JSON.stringify(params)] as constdiff --git a/plugins/ruflo-console/hooks/bindings.ts b/plugins/ruflo-console/hooks/bindings.tsindex c343ae84d1..d49d6427d2 100644--- a/plugins/ruflo-console/hooks/bindings.ts+++ b/plugins/ruflo-console/hooks/bindings.ts@@ -4,6 +4,7 @@*/import { claimTask, handoffClaim, releaseClaim, stealClaim, whyNot } from './actions'import { EVENT_KINDS } from './data/events'+import { harnessSpec, whyNotRun } from './harness'import { plain } from './data/parse'import type { Host } from './host'import { filterPalette, paletteEntries } from './palette'@@ -110,6 +111,47 @@ export function actionsOf(state: State, host: Host, runner: Runner, steps: Stepsstate.eventFilter = order[(at + 1) % order.length] ?? 'all'host.invalidate()},+ term: {+ harness: id => {+ state.terminal.harness = id+ host.invalidate()+ },+ draft: text => {+ state.terminal.draft = text+ },+ // Enter asks: the confirm row shows the exact command. Enter again on the same text runs it, as a terminal+ // would; the field keeps the keys throughout (Esc would hand them back to the prompt). y and n work too.+ submit: text => {+ const key = `${state.terminal.harness}\u0000${text.trim()}`+ const asked = state.terminal.asked++ if (asked !== null && asked.key === key && state.pending?.label === asked.label) {+ state.terminal.asked = null+ state.terminal.draft = ''+ void runner.confirm()++ return+ }++ state.terminal.draft = text++ const spec = harnessSpec(state, host, text)++ runner.ask(spec, whyNotRun(state, text) ?? 'nothing to run')+ state.terminal.asked = spec !== null ? { key, label: spec.label } : null+ },+ stop: () => state.terminal.running?.stop(),+ clear: () => {+ state.terminal.lines = []+ host.invalidate()+ },+ // A menu entry elsewhere (x.ruv.io) opens the terminal with its command typed, not run: Enter twice runs it.+ load: (id, text) => {+ state.terminal.harness = id+ state.terminal.draft = text+ setView('terminal')+ },+ },}return actionsdiff --git a/plugins/ruflo-console/hooks/commands.ts b/plugins/ruflo-console/hooks/commands.tsindex d342dae0ec..3d5f0c1c57 100644--- a/plugins/ruflo-console/hooks/commands.ts+++ b/plugins/ruflo-console/hooks/commands.ts@@ -105,7 +105,8 @@ export const HELP = [' /ruflo swarm pane|status|topology|claims|consensus ruflo-swarm (was /ruflo-swarm-*)','','Pane keys (while it holds the keyboard: /ruflo opens it with the keys, or click it; ctrl+x tab reaches the band, not the pane)',- ' 1-9 views ยท g timeline ยท q approvals ยท e events ยท m missions ยท p palette ยท x actions for the selection',+ ' 1-9 views ยท g timeline ยท q approvals ยท e events ยท m missions ยท w x.ruv.io ยท i terminal ยท p palette ยท x actions for the selection',+ ' terminal: c codex ยท l claude ยท u ruflo ยท in the field Enter shows the command, Enter again runs it ยท s stop ยท z clear',' j/k select ยท d drill in ยท b back ยท r refresh ยท h help ยท f event filter ยท y/n confirm',' Esc: a pane /ruflo opened closes; one that opened by itself (panel=auto) only hands the keys back. โ or /ruflo close closes either',' (? and Enter cannot be pane hotkeys in this Claude Code build: use h, and d to drill in)',diff --git a/plugins/ruflo-console/hooks/data/cli.ts b/plugins/ruflo-console/hooks/data/cli.tsindex bf7ba057d8..ceb039eb6b 100644--- a/plugins/ruflo-console/hooks/data/cli.ts+++ b/plugins/ruflo-console/hooks/data/cli.ts@@ -1,7 +1,7 @@/*** The facts that are not on disk, asked of the ruflo CLI with fixed argv and read from its JSON. Every probe here was run- * against @claude-flow/cli 3.50.0 and is local: none reaches the network except `roster`, which runs only when the- * person turns `federationNetwork` on. `plugins list` is never run (it fetches the IPFS registry), nor `verify` (it+ * against @claude-flow/cli 3.50.0 and is local: none reaches the network except `roster` and `registry`, which run only+ * when the person turns `federationNetwork` on. `plugins list` is never run (it fetches the IPFS registry), nor `verify` (it* fetches a manifest from GitHub).*/import { msOf, numberOf, plain, recordOf, stringOf, valuesOf } from './parse'@@ -296,7 +296,7 @@ export type Channels = { channels: { id: string; name?: string; atMs?: number }[export const channelsProbe: Probe<Channels> = {id: 'channels',args: exec('x_federation_channel_list', {}),- views: ['federation'],+ views: ['federation', 'xruv'],everyMs: 60_000,timeoutMs: 30_000,parse: stdout => {@@ -325,7 +325,7 @@ export type Roster = { members: { name: string; detail?: string }[]; relay?: strexport const rosterProbe: Probe<Roster> = {id: 'roster',args: exec('x_federation_roster', {}),- views: ['federation'],+ views: ['federation', 'xruv'],everyMs: 120_000,timeoutMs: 45_000,isNetwork: true,@@ -355,7 +355,69 @@ export const rosterProbe: Probe<Roster> = {},}-export const PROBES = [versionProbe, memoryProbe, namespacesProbe, scoreProbe, flywheelProbe, auditProbe, intelligenceProbe, peersProbe, channelsProbe, rosterProbe] as const+export type Registry = {+ relay?: string+ httpBase?: string+ gatewayPubkey?: string+ swarmTag?: string+ registration?: { isOpen: boolean; endpoint?: string; auth?: string; limits?: string }+ join: string[]+ channels: { name: string; purpose?: string }[]+}++/**+ * The federation's own description of itself (ruv://federation/registry, from the x.ruv.io gateway): reaches the+ * network, so it runs only with `federationNetwork` on. Every string is the gateway's, capped and stripped of control+ * characters, and drawn as data.+ */+export const registryProbe: Probe<Registry> = {+ id: 'registry',+ args: exec('x_federation_registry', {}),+ views: ['xruv'],+ everyMs: 600_000,+ timeoutMs: 45_000,+ isNetwork: true,+ parse: stdout => {+ const value = objectOf(stdout)++ if (value === null) {+ return null+ }++ const reg = recordOf(value.registration)+ const limits = recordOf(reg?.limits)+ const limitText = limits === null ? undefined : Object.entries(limits).slice(0, 4).flatMap(([key, n]) => (numberOf(n) === undefined ? [] : [`${plain(key, 16)} ${numberOf(n)}`])).join(' ยท ')+ const out: Registry = {+ join: (Array.isArray(value.join) ? value.join : []).slice(0, 6).flatMap(step => (typeof step === 'string' ? [plain(step, 200)] : [])),+ channels: (Array.isArray(value.defaultChannels) ? value.defaultChannels : []).slice(0, 8).flatMap(entry => {+ const channel = recordOf(entry)+ const name = stringOf(channel?.channel, 32)+ const purpose = stringOf(channel?.purpose, 120)++ return name === undefined ? [] : [{ name, ...(purpose !== undefined && { purpose }) }]+ }),+ }+ const relay = stringOf(value.relay, 60)+ const httpBase = stringOf(value.httpBase, 60)+ const gatewayPubkey = stringOf(value.gatewayPubkey, 64)+ const swarmTag = stringOf(value.swarmTag, 32)++ if (relay !== undefined) out.relay = relay+ if (httpBase !== undefined) out.httpBase = httpBase+ if (gatewayPubkey !== undefined) out.gatewayPubkey = gatewayPubkey+ if (swarmTag !== undefined) out.swarmTag = swarmTag+ if (reg !== null) {+ const endpoint = stringOf(reg.endpoint, 80)+ const auth = stringOf(reg.authentication, 20)++ out.registration = { isOpen: reg.enabled === true, ...(endpoint !== undefined && { endpoint }), ...(auth !== undefined && { auth }), ...(limitText !== undefined && limitText !== '' && { limits: limitText }) }+ }++ return out+ },+}++export const PROBES = [versionProbe, memoryProbe, namespacesProbe, scoreProbe, flywheelProbe, auditProbe, intelligenceProbe, peersProbe, channelsProbe, rosterProbe, registryProbe] as constexport type ProbeId = (typeof PROBES)[number]['id']diff --git a/plugins/ruflo-console/hooks/harness.ts b/plugins/ruflo-console/hooks/harness.tsnew file mode 100644index 0000000000..ec0f769c8a--- /dev/null+++ b/plugins/ruflo-console/hooks/harness.ts@@ -0,0 +1,169 @@+/**+ * The terminal view's second terminal: a line of text sent to another harness (codex, claude, or one ruflo CLI+ * command), its output streamed into a scrollback. Each harness is a fixed argv; the person's text reaches a model+ * harness on stdin, never as an argument, so it cannot be read as a flag, and the ruflo harness splits it into words+ * with no shell. A run costs money, so it is asked like any other change: y runs it, n drops it.+ */+import type { ActionSpec } from './actions'+import type { Host } from './host'+import { CLI_PREFIXES, push, type HarnessId, type State, type TermLine } from './state'++export const TERM_MAX_LINES = 400+/** The engine kills a spawned child only when the loop ends: the console ends it at ten minutes, as `run` would. */+export const RUN_CAP_MS = 10 * 60_000+const MAX_PROMPT = 4_000++export type Harness = {+ id: HarnessId+ /** The picker's hotkey in the terminal view. */+ key: string+ label: string+ /** What it runs and what it may do, in the words the view shows. */+ about: string+ argv: (state: State, text: string) => readonly string[] | null+ /** True: the text goes on stdin; false: it is part of the argv. */+ isStdin: boolean+}++export const HARNESSES: readonly Harness[] = [+ {+ id: 'codex',+ key: 'c',+ label: 'codex',+ about: 'codex exec in a read-only sandbox: reads this project, writes nothing ยท billed to your OpenAI plan',+ argv: () => ['codex', 'exec', '--sandbox', 'read-only', '--skip-git-repo-check', '-'],+ isStdin: true,+ },+ {+ id: 'claude',+ key: 'l',+ label: 'claude',+ about: 'claude -p in plan mode, at most $1 a run: answers, edits nothing ยท billed to your Claude plan',+ argv: () => ['claude', '-p', '--permission-mode', 'plan', '--max-budget-usd', '1'],+ isStdin: true,+ },+ {+ id: 'ruflo',+ key: 'u',+ label: 'ruflo',+ about: 'one ruflo CLI command, split on spaces with no shell (swarm status, memory search -q auth) ยท local unless it reaches out',+ argv: (state, text) => {+ const words = text.split(/\s+/).filter(word => word !== '')++ return words.length === 0 || words.length > 40 ? null : [...CLI_PREFIXES[state.options.cli], ...words]+ },+ isStdin: false,+ },+]++export const harnessOf = (id: HarnessId): Harness => HARNESSES.find(harness => harness.id === id) ?? (HARNESSES[0] as Harness)++/**+ * One line of a harness's output as the scrollback keeps it: ANSI sequences, control and bidirectional characters+ * gone, tabs as two spaces, indentation kept (unlike `plain`, which folds whitespace for one-line facts).+ */+export function termText(line: string, max = 400): string {+ const cleaned = line+ .replace(/\u001b\][^\u0007\u001b]*(\u0007|\u001b\\)/g, '')+ .replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, '')+ .replace(/\t/g, ' ')+ .replace(/[\u0000-\u001f\u007f-\u009fโ-โโช-โฎโฆ-โฉ]/g, '')+ .trimEnd()++ return cleaned.length <= max ? cleaned : `${cleaned.slice(0, max - 1)}โฆ`+}++function note(state: State, kind: TermLine['kind'], text: string): void {+ for (const line of text.split('\n')) push(state.terminal.lines, { kind, text: termText(line) }, TERM_MAX_LINES)+}++/** Why the field's text cannot be asked now, or null when it can. */+export function whyNotRun(state: State, text: string): string | null {+ if (state.terminal.running !== null) return `${state.terminal.running.label} is still running: stop it first (s)`+ if (text.trim() === '') return 'type something first'+ if (harnessOf(state.terminal.harness).argv(state, text.trim()) === null) return 'that is not one ruflo command (1 to 40 words)'++ return null+}++/** The confirm-gated ask for the field's text, or null (see `whyNotRun`). */+export function harnessSpec(state: State, host: Host, text: string): ActionSpec | null {+ const harness = harnessOf(state.terminal.harness)+ const prompt = text.trim().slice(0, MAX_PROMPT)+ const argv = whyNotRun(state, prompt) === null ? harness.argv(state, prompt) : null++ if (argv === null) return null++ const input = harness.isStdin ? prompt : undefined+ const short = termText(prompt.replace(/\s+/g, ' '), 48)++ return {+ label: `ask ${harness.label}: ${short}`,+ args: argv,+ shows: `${argv.join(' ')}${input !== undefined ? ' (your text on stdin)' : ''}`,+ expect: 'its output in the terminal',+ run: () => runHarness(state, host, harness.label, argv, prompt, input),+ }+}++/** Runs one harness command, streaming each line it writes into the scrollback; s stops it, and so does the cap. */+export async function runHarness(state: State, host: Host, label: string, argv: readonly string[], prompt: string, input: string | undefined): Promise<void> {+ const startedAtMs = Date.now()+ const secs = () => `${Math.round((Date.now() - startedAtMs) / 1000)} s`+ const partial = { out: '', err: '' }+ let isStopped = false++ note(state, 'in', `${label}> ${prompt}`)++ let stream: ReturnType<Host['spawn']>++ try {+ stream = host.spawn(argv, input)+ } catch (error) {+ note(state, 'sys', `${argv[0]} did not start: ${error instanceof Error ? error.message : String(error)}`)+ host.invalidate()++ return+ }++ const stop = () => {+ isStopped = true+ void stream.return(undefined as never).catch(() => undefined)+ }+ const cap = host.after(RUN_CAP_MS, stop)++ state.terminal.running = { label, startedAtMs, stop }+ host.invalidate()++ const flush = () => {+ for (const kind of ['out', 'err'] as const) {+ if (partial[kind] !== '') note(state, kind, partial[kind])+ partial[kind] = ''+ }+ }++ try {+ for await (const chunk of stream) {+ const kind = chunk.stream === 'stderr' ? 'err' : 'out'+ const lines = (partial[kind] + chunk.text).split('\n')++ partial[kind] = lines.pop() ?? ''++ for (const line of lines) push(state.terminal.lines, { kind, text: termText(line) }, TERM_MAX_LINES)+ host.invalidate()+ }++ flush()++ const result = await stream.result++ note(state, 'sys', isStopped ? `stopped after ${secs()}` : result.signal !== null ? `ended by ${result.signal} after ${secs()}` : `exit ${result.code ?? '?'} ยท ${secs()}`)+ } catch (error) {+ flush()+ note(state, 'sys', isStopped ? `stopped after ${secs()}` : `${argv[0]}: ${error instanceof Error ? error.message : String(error)} (is it installed and on PATH?)`)+ } finally {+ cap.cancel()+ state.terminal.running = null+ host.invalidate()+ }+}diff --git a/plugins/ruflo-console/hooks/host.ts b/plugins/ruflo-console/hooks/host.tsindex c60ee44604..471074cd92 100644--- a/plugins/ruflo-console/hooks/host.ts+++ b/plugins/ruflo-console/hooks/host.ts@@ -1,4 +1,4 @@-import type { CommandSpec, PaneOpenArgs, ProcessRunResult, Timer, UiBlitArgs } from 'claude-code'+import type { CommandSpec, HookStream, PaneOpenArgs, ProcessRunResult, ProcessSpawnChunk, ProcessSpawnResult, Timer, UiBlitArgs } from 'claude-code'import type { ReaderFs } from './data/files'import type { RufloRoute, RufloSnapshot } from '../types'@@ -25,6 +25,8 @@ export type Host = {panes: () => Promise<readonly { id: string; isShown: boolean; isFocused: boolean }[]>registerCommand: (spec: CommandSpec) => Promise<unknown>run: (argv: readonly string[], timeoutMs: number) => Promise<ProcessRunResult>+ /** Starts a command and streams what it writes; `input` goes to its stdin, which is then closed. */+ spawn: (argv: readonly string[], input?: string) => HookStream<ProcessSpawnChunk, ProcessSpawnResult>usage: () => Promise<{ costUsd?: number; contextPercent?: number }>/** The ruflo / claude-flow MCP tools the model can call now, and the servers they come from. */rufloTools: () => Promise<{ tools: number; servers: string[] }>diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.tsindex e029acd082..24c27e5bc9 100644--- a/plugins/ruflo-console/hooks/register.ts+++ b/plugins/ruflo-console/hooks/register.ts@@ -43,6 +43,7 @@ function hostOf($: EngineInterface, cwd: string): Host {panes: async () => $.ui.panes(),registerCommand: async spec => $.command.register(spec),run: async (argv, timeoutMs) => $.process.run(argv, { cwd, timeoutMs }),+ spawn: (argv, input) => $.process.spawn({ argv, cwd, ...(input !== undefined && { input }) }),usage: async () => {const usage = await $.session.usage()diff --git a/plugins/ruflo-console/hooks/runner.ts b/plugins/ruflo-console/hooks/runner.tsindex f29b0f7a0d..49fd9e0813 100644--- a/plugins/ruflo-console/hooks/runner.ts+++ b/plugins/ruflo-console/hooks/runner.ts@@ -37,6 +37,13 @@ export function createRunner(state: State, host: Host, deps: RunnerDeps): Runner}async function execute(spec: ActionSpec): Promise<void> {+ // A harness run reports into the terminal and may take minutes: it does not hold the other buttons.+ if (spec.run !== undefined) {+ void spec.run()++ return+ }+state.isActing = truehost.invalidate()@@ -87,7 +94,7 @@ export function createRunner(state: State, host: Host, deps: RunnerDeps): Runner}pendingSpec = spec- state.pending = { label: spec.label, args: spec.args, expect: spec.expect, askedAtMs: Date.now() }+ state.pending = { label: spec.label, args: spec.args, expect: spec.expect, askedAtMs: Date.now(), ...(spec.shows !== undefined && { shows: spec.shows }) }host.invalidate()}diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.tsindex 56ecb3f51e..aa319e43d2 100644--- a/plugins/ruflo-console/hooks/state.ts+++ b/plugins/ruflo-console/hooks/state.ts@@ -9,7 +9,7 @@ import type { RufloRoute, RufloSnapshot } from '../types'export const PLUGIN_NAME = 'ruflo-console'export const PANE_ID = 'ruflo-console'-export type ViewId = 'overview' | 'swarm' | 'claims' | 'federation' | 'plugins' | 'learning' | 'metaharness' | 'memory' | 'cost' | 'timeline' | 'approvals' | 'events' | 'missions' | 'agent'+export type ViewId = 'overview' | 'swarm' | 'claims' | 'federation' | 'plugins' | 'learning' | 'metaharness' | 'memory' | 'cost' | 'timeline' | 'approvals' | 'events' | 'missions' | 'xruv' | 'terminal' | 'agent'/*** The views in tab order, each with its hotkey and the inline height it asks for. Digits are the first nine; the three@@ -34,6 +34,8 @@ export const VIEWS: readonly { id: ViewId; key: string; label: string; short: st{ id: 'approvals', key: 'q', label: 'Approvals', short: 'Apv', icon: 'โ ', blurb: 'decisions waiting for a person: votes, stealable claims, refused mods, budget', rows: 24 },{ id: 'events', key: 'e', label: 'Events', short: 'Evt', icon: '๐ก', blurb: 'every swarm, claim, memory and mod event as it happens (f filters them)', rows: 26 },{ id: 'missions', key: 'm', label: 'Missions', short: 'Msn', icon: '๐ฏ', blurb: 'ADR-406 missions: the plan, task dependencies, acceptance and budget (observe only)', rows: 26 },+ { id: 'xruv', key: 'w', label: 'x.ruv.io', short: 'XRV', icon: '๐ธ', blurb: 'the open agent federation: what it offers, how to join, its channels and who is on', rows: 34 },+ { id: 'terminal', key: 'i', label: 'Terminal', short: 'Trm', icon: '๐ป', blurb: 'a second terminal: ask codex, claude or the ruflo CLI, each run confirmed, its output streamed', rows: 32 },]export const AGENT_VIEW = { id: 'agent' as const, rows: 28 }@@ -103,8 +105,14 @@ export function optionsOf(raw: PluginOptions | undefined): Options {}}-/** A mutating action waiting for the person's second press. */-export type Pending = { label: string; args: readonly string[]; expect: string; askedAtMs: number }+/** A mutating action waiting for the person's second press; `shows` is the command line when it is not a ruflo one. */+export type Pending = { label: string; args: readonly string[]; expect: string; askedAtMs: number; shows?: string }++/** The harnesses the terminal view can ask. */+export type HarnessId = 'codex' | 'claude' | 'ruflo'++/** One line of the terminal's scrollback: what was asked (`in`), what came back, or the console's own note (`sys`). */+export type TermLine = { kind: 'in' | 'out' | 'err' | 'sys'; text: string }/** What an action did: what ran, how it exited, whether the disk shows the change, and anything it printed to show. */export type Outcome = { label: string; ok: boolean; verified: 'yes' | 'no' | 'n/a'; detail: string; atMs: number; lines?: string[] }@@ -166,6 +174,15 @@ export type State = {isRefreshing: boolean/** When the band above the prompt last drew: the disk is re-read on the fast cadence only while it is seen. */barDrawnAtMs: number+ /** The terminal view: the harness picked, the field's text, the scrollback, and the run in flight. */+ terminal: {+ harness: HarnessId+ draft: string+ lines: TermLine[]+ running: { label: string; startedAtMs: number; stop: () => void } | null+ /** The text the last Enter asked about: Enter on the same text again confirms it. */+ asked: { key: string; label: string } | null+ }timers: Map<string, Timer>stats: { renders: number[]; refreshes: number[]; frames: number[] }}@@ -207,6 +224,7 @@ export function newState(raw: PluginOptions | undefined): State {isActing: false,isRefreshing: false,barDrawnAtMs: 0,+ terminal: { harness: 'codex', draft: '', lines: [], running: null, asked: null },timers: new Map(),stats: { renders: [], refreshes: [], frames: [] },}diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.tsindex 69ba19206b..1c30c11c5e 100644--- a/plugins/ruflo-console/hooks/views/common.ts+++ b/plugins/ruflo-console/hooks/views/common.ts@@ -7,7 +7,7 @@ import type { Elements, RenderChildren, RenderElement } from 'claude-code'import type { ProbeResult } from '../data/cli'import type { Grid } from '../gfx/raster'-import type { State, ViewId } from '../state'+import type { HarnessId, State, ViewId } from '../state'export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & { Raster?: Elements['terminal']['Raster']; Input?: Elements['terminal']['Input'] }@@ -37,6 +37,8 @@ export type Actions = {run: (id: string, text?: string) => boolean/** Cycles the events view's filter. */filter: () => void+ /** The terminal view: pick a harness, follow the field, ask to run its text, stop the run, clear the scrollback. */+ term: { harness: (id: HarnessId) => void; draft: (text: string) => void; submit: (text: string) => void; stop: () => void; clear: () => void; load: (id: HarnessId, text: string) => void }}export type Ctx = {diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.tsindex fc430a2a58..a4fcbb2d38 100644--- a/plugins/ruflo-console/hooks/views/pane.ts+++ b/plugins/ruflo-console/hooks/views/pane.ts@@ -21,6 +21,8 @@ import { overviewView } from './overview'import { paletteView } from './palette'import { pluginsView } from './plugins'import { swarmView } from './swarm'+import { terminalView } from './terminal'+import { xruvView } from './xruv'export const NARROW = 44/** Width from which every tab spells its name beside its emoji (the 1-9 row is about 128 columns with names). */@@ -40,6 +42,8 @@ const BODIES: Record<ViewId, (ctx: Ctx) => RenderElement> = {approvals: approvalsView,events: eventsView,missions: missionsView,+ xruv: xruvView,+ terminal: terminalView,agent: agentView,}@@ -51,7 +55,7 @@ function tabs(ctx: Ctx): RenderElement {return text(ctx, `${index < 0 ? 'ยท' : `${index + 1}/${VIEWS.length}`} ${label} ยท /ruflo help`, { bold: true, color: THEME.head })}- // Two rows: the nine data views (1-9), then the four management views (g q e m). Each tab is its emoji; the+ // Two rows: the nine data views (1-9), then the management views and the two boards (g q e m, w x.ruv.io, i terminal). Each tab is its emoji; the// current one is highlighted, and from WIDE_TABS columns every tab also spells its name. The line under the bar// always names the current view and says what it is for. The dock width is the engine's (it keeps where the// divider was left), so the narrow form must fit about 60 columns.@@ -117,7 +121,7 @@ function confirmRow(ctx: Ctx): RenderElement | null {ctx,[text(ctx, `Confirm: ${pending.label}?`, { bold: true, color: THEME.warn }),- text(ctx, `runs: ruflo ${pending.args.join(' ')}`, { dimColor: true }),+ text(ctx, `runs: ${pending.shows ?? `ruflo ${pending.args.join(' ')}`}`, { dimColor: true }),row(ctx, [button(ctx, 'confirm', 'Yes, run it (y)', ctx.act.confirm, { hotkey: 'y', primary: true }), button(ctx, 'cancel', 'Cancel (n)', ctx.act.cancel, { hotkey: 'n' })]),],'confirm',diff --git a/plugins/ruflo-console/hooks/views/terminal.ts b/plugins/ruflo-console/hooks/views/terminal.tsnew file mode 100644index 0000000000..904bfda7f0--- /dev/null+++ b/plugins/ruflo-console/hooks/views/terminal.ts@@ -0,0 +1,79 @@+import type { RenderElement } from 'claude-code'++import { HARNESSES, harnessOf } from '../harness'+import { button, clip, col, row, rule, text, THEME, type Ctx } from './common'++/** Scrollback lines shown under the picker: the newest, so a long answer reads like a terminal's tail. */+export const TERM_ROWS = 16++/**+ * The second terminal: pick a harness (c codex, l claude, u ruflo) and type into the field. Enter shows the exact+ * command, Enter again on the same text runs it (y does too, from outside the field). Output streams in as the harness+ * writes it; s stops a run, z clears the screen. While the field has focus every key types into it.+ */+export function terminalView(ctx: Ctx): RenderElement {+ const { state, nowMs } = ctx+ const term = state.terminal+ const harness = harnessOf(term.harness)+ const rows: RenderElement[] = [rule(ctx, 'Harness', term.running !== null ? `${term.running.label} running ยท ${Math.round((nowMs - term.running.startedAtMs) / 1000)} s` : 'idle')]++ rows.push(+ ctx.kit.Box({+ flexDirection: 'row',+ gap: 1,+ key: 'term-pick',+ children: HARNESSES.map(entry =>+ entry.id === term.harness+ ? ctx.kit.Box({ key: `term-${entry.id}`, children: [ctx.kit.Text({ bold: true, color: THEME.head, children: `[${entry.key}: ${entry.label.toUpperCase()}]` })] })+ : ctx.kit.Button({ key: `term-${entry.id}`, label: entry.label, hotkey: entry.key, plain: true, dimColor: true, onPress: () => ctx.act.term.harness(entry.id) }),+ ),+ }),+ )+ rows.push(text(ctx, ` ${harness.about}`, { color: THEME.info }))+ rows.push(rule(ctx, 'Screen', `${term.lines.length} lines`))++ const tail = term.lines.slice(-TERM_ROWS)++ if (tail.length === 0) {+ rows.push(text(ctx, ' nothing yet: type below, Enter shows the exact command, Enter again runs it', { dimColor: true }))+ }++ for (const line of tail) {+ const props = line.kind === 'in' ? { bold: true, color: THEME.head } : line.kind === 'err' ? { color: THEME.warn } : line.kind === 'sys' ? { dimColor: true, italic: true } : {}++ rows.push(ctx.kit.Text({ wrap: 'truncate-end', ...props, children: clip(line.text === '' ? ' ' : line.text, Math.max(4, ctx.columns)) }))+ }++ if (term.running !== null) {+ // Data, not decoration: the cursor blinks only while a harness is writing back.+ rows.push(text(ctx, Math.floor(nowMs / 500) % 2 === 0 ? 'โ' : ' ', { color: THEME.ok }))+ }++ rows.push(text(ctx, ' '))++ if (ctx.kit.Input !== undefined) {+ rows.push(+ ctx.kit.Input({+ key: 'term-input',+ label: `${harness.label}> `,+ placeholder: harness.id === 'ruflo' ? 'a ruflo command: swarm status, memory search -q auth โฆ' : `ask ${harness.label} about this projectโฆ`,+ value: term.draft,+ submitLabel: 'ask',+ onInput: value => ctx.act.term.draft(value),+ onSubmit: value => ctx.act.term.submit(value),+ }),+ )+ } else {+ rows.push(text(ctx, 'this surface has no text field: the terminal needs Claude Code in a terminal', { dimColor: true }))+ }++ rows.push(+ row(ctx, [+ ...(term.running !== null ? [button(ctx, 'term-stop', 'Stop', ctx.act.term.stop, { hotkey: 's' })] : []),+ button(ctx, 'term-clear', 'Clear', ctx.act.term.clear, { hotkey: 'z' }),+ text(ctx, ' Tab or click to the field ยท Enter shows the command ยท Enter again runs it', { dimColor: true }),+ ]),+ )++ return col(ctx, rows, 'terminal')+}diff --git a/plugins/ruflo-console/hooks/views/xruv.ts b/plugins/ruflo-console/hooks/views/xruv.tsnew file mode 100644index 0000000000..b02c9f7161--- /dev/null+++ b/plugins/ruflo-console/hooks/views/xruv.ts@@ -0,0 +1,103 @@+import type { RenderElement } from 'claude-code'++import type { Channels, Registry, Roster } from '../data/cli'+import { ago, clip, col, isBbs, kv, live, row, rule, sourceLine, text, THEME, type Ctx } from './common'++/** What the open federation offers, as `ruflo federation <sub>` names it; `admin` ones need the gateway's token. */+const MENU: readonly { letter: string; name: string; about: string; command?: string; isAdmin?: boolean }[] = [+ { letter: 'J', name: 'JOIN', about: 'your own key, NIP-98 signed, no invite on open relays', command: 'federation join' },+ { letter: 'R', name: 'ROSTER', about: 'who is online now, one row per pubkey', command: 'federation roster' },+ { letter: 'S', name: 'SYNC', about: 'the last hour of signed swarm messages', command: 'federation sync --limit 20' },+ { letter: 'W', name: 'WORK CLAIMS', about: 'one owner per resource, TTLs and handoffs applied', command: 'federation claims' },+ { letter: 'C', name: 'CHANNELS', about: 'pub: plaintext rooms, prv: encrypted to members', command: 'federation channel --action list' },+ { letter: 'G', name: 'REGISTRY', about: 'relay, NIP-42 tag, gateway key, join steps', command: 'federation registry' },+ { letter: 'I', name: 'INVITES', about: 'use-limited codes for a new member', isAdmin: true },+ { letter: 'A', name: 'ADMIT', about: 'NIP-43 membership for a pubkey', isAdmin: true },+ { letter: 'P', name: 'PUBLISH', about: 'a hub broadcast as the gateway', isAdmin: true },+]++/**+ * The x.ruv.io board: a Wildcat-style main menu of what the open federation offers (each entry opens the terminal+ * with its ruflo command typed, run only after Enter twice), then the registry's own word on how to join and which+ * rooms to sit in, this node's channels, and who is on. The registry and the roster are on the network, so without+ * `federationNetwork` they say how to turn it on and nothing is asked.+ */+export function xruvView(ctx: Ctx): RenderElement {+ const { state, nowMs } = ctx+ const isNet = state.options.federationNetwork+ const registry = live<Registry>(state.probes.get('registry'))+ const channels = live<Channels>(state.probes.get('channels'))+ const roster = live<Roster>(state.probes.get('roster'))+ const rows: RenderElement[] = [rule(ctx, 'Main menu', 'ruflo federation ยท x_federation_* tools')]+ const lead = Math.max(14, Math.min(18, ctx.columns - 40))++ for (const item of MENU) {+ const name = ` ${item.name} `.padEnd(lead, '.')+ const parts: RenderElement[] = [+ ctx.kit.Text({ bold: true, color: THEME.ok, children: ` [${item.letter}]` }),+ ctx.kit.Text({ bold: true, color: item.isAdmin === true ? THEME.warn : THEME.head, children: name }),+ ctx.kit.Text({ color: THEME.info, wrap: 'truncate-end', children: clip(` ${item.about}${item.isAdmin === true ? ' (admin)' : ''}`, Math.max(4, ctx.columns - lead - 22)) }),+ ]++ if (item.command !== undefined) {+ const command = item.command++ parts.push(ctx.kit.Button({ key: `xr-${item.letter}`, label: ' โธ open', plain: true, dimColor: true, onPress: () => ctx.act.term.load('ruflo', command) }))+ }++ rows.push(row(ctx, parts, `xr-row-${item.letter}`))+ }++ rows.push(text(ctx, ' โธ open puts the command in the terminal (i): Enter shows it, Enter again runs it', { dimColor: true }))+ rows.push(rule(ctx, 'How to join', isNet ? 'from the registry ยท gateway text' : 'network off'))++ if (!isNet) {+ rows.push(text(ctx, ' The registry is on x.ruv.io. Turn on federationNetwork in /config (ruflo-console) to ask it.', { dimColor: true }))+ rows.push(text(ctx, ' Or run `npx ruflo federation join`: it makes ~/.ruflo/nostr.key and registers with it.', { dimColor: true }))+ } else if (registry === null) {+ rows.push(text(ctx, ` ${sourceLine(state.probes.get('registry'), nowMs, 'registry').text}`, { dimColor: true }))+ } else {+ rows.push(kv(ctx, 'relay', `${registry.relay ?? 'n/a'}${registry.swarmTag !== undefined ? ` ยท tag #${registry.swarmTag}` : ''}`))+ rows.push(kv(ctx, 'gateway key', registry.gatewayPubkey !== undefined ? `${registry.gatewayPubkey.slice(0, 16)}โฆ` : 'n/a'))+ if (registry.registration !== undefined) {+ const reg = registry.registration++ rows.push(kv(ctx, 'registration', `${reg.isOpen ? 'open' : 'closed'}${reg.auth !== undefined ? ` ยท ${reg.auth}` : ''}${reg.limits !== undefined ? ` ยท ${reg.limits}` : ''}`, reg.isOpen ? THEME.ok : THEME.warn))+ }+ for (const step of registry.join.slice(0, 4)) rows.push(text(ctx, ` ${clip(step, 160)}`, { color: THEME.info }))+ }++ rows.push(rule(ctx, 'Rooms', isNet && registry !== null ? 'default channels' : 'joined here'))++ const defaults = registry?.channels ?? []++ if (defaults.length > 0) {+ for (const room of defaults.slice(0, 5)) {+ rows.push(+ row(ctx, [+ ctx.kit.Text({ bold: true, color: THEME.head, children: ` #${room.name.padEnd(14)} ` }),+ ctx.kit.Text({ dimColor: !isBbs(), color: THEME.info, wrap: 'truncate-end', children: clip(room.purpose ?? '', Math.max(4, ctx.columns - 18)) }),+ ]),+ )+ }+ } else if (channels !== null && channels.channels.length > 0) {+ for (const channel of channels.channels.slice(0, 5)) rows.push(text(ctx, ` # ${channel.name ?? channel.id} ยท ${channel.id.startsWith('prv:') ? 'private' : 'public'} ยท since ${ago(channel.atMs, nowMs)}`))+ } else {+ rows.push(text(ctx, ` ${channels === null ? sourceLine(state.probes.get('channels'), nowMs, 'channels').text : 'no channels joined here yet'}`, { dimColor: true }))+ }++ rows.push(rule(ctx, 'Who is on', isNet ? 'roster ยท unvetted' : 'network off'))++ if (!isNet) {+ rows.push(text(ctx, ' Off: the roster is on the public relay (federationNetwork).', { dimColor: true }))+ } else if (roster === null) {+ rows.push(text(ctx, ` ${sourceLine(state.probes.get('roster'), nowMs, 'roster').text}`, { dimColor: true }))+ } else if (roster.members.length === 0) {+ rows.push(text(ctx, ` nobody announcing on ${roster.relay ?? 'the relay'} (${ago(roster.atMs, nowMs)})`, { dimColor: true }))+ } else {+ for (const member of roster.members.slice(0, 5)) rows.push(text(ctx, ` โ ${member.name}${member.detail !== undefined ? ` โ ${member.detail}` : ''}`))+ rows.push(text(ctx, ` ${roster.members.length} on ยท third-party text, not vetted ยท ${ago(roster.atMs, nowMs)}`, { dimColor: true }))+ }++ return col(ctx, rows, 'xruv')+}diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.shindex 41a7f543c0..fa8d8da457 100755--- a/plugins/ruflo-console/scripts/smoke.sh+++ b/plugins/ruflo-console/scripts/smoke.sh@@ -11,9 +11,9 @@ step() { printf "โ %s ... " "$1"; }ok() { printf "PASS\n"; PASS=$((PASS+1)); }bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }-step "1. plugin.json declares ruflo-console 0.3.0"+step "1. plugin.json declares ruflo-console 0.4.0"grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \- && grep -q '"version": "0.3.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"+ && grep -q '"version": "0.4.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"step "2. hooks.json names exactly one module and no classic hook commands"grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \@@ -33,10 +33,10 @@ http=$(grep -rnE '\$\.http\.' "$HOOKS" || true)outside=$(grep -rnE '\$\.(fs|process|ui|clock|store|env|ruflo|tool|session|settings|command)\.' "$HOOKS" | grep -vE '^[^:]+:[0-9]+:\s*(\*|//|/\*)' | grep -v '/register.ts:' || true)[[ -z "$http" && -z "$outside" ]] && ok || bad "http: $http outside: $outside"-step "6. never runs plugins list or verify (network) and the roster is the one network probe"+step "6. never runs plugins list or verify (network); roster and registry are the two network probes, both opt-in"cmds=$(grep -nE "args: \['(plugins|verify)'" "$HOOKS/data/cli.ts" || true)net=$(grep -c "isNetwork: true" "$HOOKS/data/cli.ts")-[[ -z "$cmds" && "$net" == "1" ]] && grep -q "federationNetwork" "$HOOKS/controller.ts" && ok || bad "cmds: $cmds network probes: $net"+[[ -z "$cmds" && "$net" == "2" ]] && grep -q "federationNetwork" "$HOOKS/controller.ts" && ok || bad "cmds: $cmds network probes: $net"step "7. private key files are never read paths"# The federation folder is listed for its file names (node ids); a key file's path never reaches fs.read.diff --git a/plugins/ruflo-console/tests/behaviour.test.ts b/plugins/ruflo-console/tests/behaviour.test.tsindex dfdace4950..2dcf74a3ac 100644--- a/plugins/ruflo-console/tests/behaviour.test.ts+++ b/plugins/ruflo-console/tests/behaviour.test.ts@@ -149,7 +149,7 @@ describe('behaviour', () => {expect(elementsOf(tree, 'Raster').length === 0).toBe(isNarrow)expect(elementsOf(tree, 'Button').map(keyOf).includes('claim')).toBe(!isNarrow)- if (isNarrow) expect(textOf(tree)).toContain('3/13 Claims')+ if (isNarrow) expect(textOf(tree)).toContain('3/15 Claims')await pane.unmount()}})diff --git a/plugins/ruflo-console/tests/pure.spec.ts b/plugins/ruflo-console/tests/pure.spec.tsindex dd6d3268b1..05411f9e8e 100644--- a/plugins/ruflo-console/tests/pure.spec.ts+++ b/plugins/ruflo-console/tests/pure.spec.ts@@ -116,8 +116,8 @@ describe('CLI JSON', () => {expect(jsonAfter('no json here')).toBeNull()})- it('no probe reaches the network but the opt-in roster; plugins list and verify are never run', () => {- expect(PROBES.filter(probe => probe.isNetwork === true).map(probe => probe.id)).toEqual(['roster'])+ it('no probe reaches the network but the opt-in roster and registry; plugins list and verify are never run', () => {+ expect(PROBES.filter(probe => probe.isNetwork === true).map(probe => probe.id)).toEqual(['roster', 'registry'])for (const probe of PROBES) {expect(probe.args.slice(0, 2).join(' ')).not.toBe('plugins list')diff --git a/plugins/ruflo-console/tests/terminal.spec.ts b/plugins/ruflo-console/tests/terminal.spec.tsnew file mode 100644index 0000000000..1f019c2db5--- /dev/null+++ b/plugins/ruflo-console/tests/terminal.spec.ts@@ -0,0 +1,137 @@+/**+ * The terminal view's harness runner and the x.ruv.io registry probe, under vitest: what argv each harness runs, that+ * the person's text never becomes a flag, how streamed output lands in the scrollback, and how a stop reads.+ */+import { describe, expect, it } from 'vitest'++import { registryProbe } from '../hooks/data/cli'+import { harnessSpec, runHarness, termText, whyNotRun } from '../hooks/harness'+import type { Host } from '../hooks/host'+import { newState } from '../hooks/state'++type Chunk = { stream: 'stdout' | 'stderr'; text: string }++/** A spawn that yields `chunks`, then ends with `code`; `hang` keeps it open until `return()`. */+function fakeSpawn(chunks: Chunk[], code = 0, hang = false) {+ const calls: { argv: readonly string[]; input?: string }[] = []+ const spawn = (argv: readonly string[], input?: string) => {+ calls.push({ argv, ...(input !== undefined && { input }) })++ // As the engine's stream: `return()` kills the child, the loop then ends, and `result` rejects (closed early).+ let release: () => void = () => undefined+ let isClosed = false+ const stream = (async function* () {+ for (const chunk of chunks) yield chunk+ if (hang) await new Promise<void>(resolve => (release = resolve))++ return { code, signal: null }+ })()+ const result = {+ then: (ok: (value: unknown) => void, fail: (error: Error) => void) => (isClosed ? fail(new Error('closed before its end')) : ok({ code, signal: null })),+ }++ return Object.assign(stream, {+ result,+ return: async () => {+ isClosed = true+ release()++ return { done: true, value: undefined }+ },+ }) as never+ }++ return { spawn, calls }+}++const hostWith = (spawn: Host['spawn']): Host => ({ spawn, invalidate: () => undefined, after: () => ({ cancel: () => undefined }) }) as unknown as Host++describe('terminal harnesses', () => {+ it('codex and claude get the text on stdin, never in the argv, and run read-only', () => {+ const state = newState({})+ const host = hostWith(fakeSpawn([]).spawn)+ const codex = harnessSpec(state, host, '--dangerously-bypass-approvals-and-sandbox explain')++ expect(codex?.args).toEqual(['codex', 'exec', '--sandbox', 'read-only', '--skip-git-repo-check', '-'])+ expect(codex?.shows).toContain('(your text on stdin)')++ state.terminal.harness = 'claude'+ expect(harnessSpec(state, host, 'hi')?.args).toEqual(['claude', '-p', '--permission-mode', 'plan', '--max-budget-usd', '1'])+ })++ it('ruflo splits words onto the CLI prefix, with no shell, and refuses empty text or a run in flight', () => {+ const state = newState({})+ const host = hostWith(fakeSpawn([]).spawn)++ state.terminal.harness = 'ruflo'+ expect(harnessSpec(state, host, ' swarm status; rm x ')?.args).toEqual(['npx', '--offline', '-y', '@claude-flow/cli@latest', 'swarm', 'status;', 'rm', 'x'])+ expect(harnessSpec(state, host, ' ')).toBeNull()+ expect(whyNotRun(state, '')).toBe('type something first')++ state.terminal.running = { label: 'codex', startedAtMs: 0, stop: () => undefined }+ expect(harnessSpec(state, host, 'swarm status')).toBeNull()+ expect(whyNotRun(state, 'swarm status')).toContain('still running')+ })++ it('streams output into the scrollback by line, joining pieces split mid-line, and notes the exit', async () => {+ const state = newState({})+ const { spawn, calls } = fakeSpawn([+ { stream: 'stdout', text: 'hel' },+ { stream: 'stdout', text: 'lo\n indented\tline\n' },+ { stream: 'stderr', text: '\u001b[31mwarn\u001b[0m\n' },+ { stream: 'stdout', text: 'tail' },+ ])++ await runHarness(state, hostWith(spawn), 'codex', ['codex', 'exec', '-'], 'say hi', 'say hi')++ expect(calls[0]).toEqual({ argv: ['codex', 'exec', '-'], input: 'say hi' })+ expect(state.terminal.lines.map(line => `${line.kind}:${line.text}`)).toEqual(['in:codex> say hi', 'out:hello', 'out: indented line', 'err:warn', 'out:tail', expect.stringMatching(/^sys:exit 0 ยท \d+ s$/)])+ expect(state.terminal.running).toBeNull()+ })++ it('a stop ends the run and says so', async () => {+ const state = newState({})+ const { spawn } = fakeSpawn([{ stream: 'stdout', text: 'working\n' }], 0, true)+ const run = runHarness(state, hostWith(spawn), 'claude', ['claude', '-p'], 'long', 'long')++ await new Promise(resolve => setTimeout(resolve, 5))+ state.terminal.running?.stop()+ await run++ expect(state.terminal.lines.at(-1)?.text).toMatch(/^stopped after \d+ s$/)+ expect(state.terminal.running).toBeNull()+ })++ it('termText keeps indentation but drops escapes, control and bidi characters', () => {+ expect(termText(' aโฎb\u0007\u001b]0;title\u0007c ')).toBe(' abc')+ expect(termText('x'.repeat(500)).length).toBe(400)+ })+})++describe('x.ruv.io registry probe', () => {+ it('asks the network only with federationNetwork on, and keeps the join steps and rooms as capped data', () => {+ expect(registryProbe.isNetwork).toBe(true)+ expect(registryProbe.views).toEqual(['xruv'])++ const out = registryProbe.parse(+ `Result:\n${JSON.stringify({+ relay: 'wss://relay.ruv.io',+ gatewayPubkey: 'a'.repeat(64),+ swarmTag: 'ruflo-swarm',+ registration: { enabled: true, authentication: 'NIP-98', limits: { ipHourly: 3, daily: 100 } },+ join: ['1. generate a key', '2. \u001b[31mPOST\u001b[0m'],+ defaultChannels: [{ channel: 'pub:help', purpose: 'Questions' }, { purpose: 'no name' }],+ })}`,+ )++ expect(out).toEqual({+ relay: 'wss://relay.ruv.io',+ gatewayPubkey: 'a'.repeat(64),+ swarmTag: 'ruflo-swarm',+ registration: { isOpen: true, auth: 'NIP-98', limits: 'ipHourly 3 ยท daily 100' },+ join: ['1. generate a key', '2. POST'],+ channels: [{ name: 'pub:help', purpose: 'Questions' }],+ })+ expect(registryProbe.parse('not json')).toBeNull()+ })+})diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.tsindex d3d31e5099..32883582d0 100644--- a/plugins/ruflo-console/tests/views.test.ts+++ b/plugins/ruflo-console/tests/views.test.ts@@ -201,4 +201,33 @@ describe('views', () => {expect((await drawn($, 'missions')).text).toContain('n/a โ no .claude-flow/missions/observation.json')})++ test('x.ruv.io: the federation menu with its commands, and no registry or roster asked with the network off', { options: { boot: false } }, async ($, on) => {+ const world = worldOf(on, RUFLO_FILES)++ mock.clock(on)+ await $.session.start(SESSION)++ const { text, rasters } = await drawn($, 'xruv')++ expect(rasters).toEqual(['header', 'title'])+ expect(text).toContain(' JOIN ....')+ expect(text).toContain('WORK CLAIMS')+ expect(text).toContain('Turn on federationNetwork in /config')+ expect(world.runs.some(argv => /x_federation_(registry|roster)/.test(argv.join(' ')))).toBe(false)+ })++ test('terminal: the harness picker, what the pick runs, and the text field; nothing runs unasked', { options: { boot: false } }, async ($, on) => {+ const world = worldOf(on, RUFLO_FILES)++ mock.clock(on)+ await $.session.start(SESSION)++ const { text, tree } = await drawn($, 'terminal')++ expect(text).toContain('[c: CODEX]')+ expect(text).toContain('codex exec in a read-only sandbox')+ expect(elementsOf(tree, 'Input').map(keyOf)).toEqual(['term-input'])+ expect(world.runs.some(argv => argv[0] === 'codex' || argv[0] === 'claude')).toBe(false)+ })})