🌊 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
fix(ruflo-console): fixes from the live run
ruv7dcea3a02eb1
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.tsindex bc292cf7f7..7c8d427ca9 100644--- a/plugins/ruflo-console/hooks/controller.ts+++ b/plugins/ruflo-console/hooks/controller.ts@@ -19,6 +19,7 @@ const PENDING_TTL_MS = 30_000const MAX_PARALLEL_PROBES = 2const BAR_FRESH_MS = 10_000const IDLE_REFRESH_MS = 30_000+const TOOLS_RECOUNT_MS = 30_000export type Controller = {refresh: () => Promise<void>@@ -57,6 +58,7 @@ export function createController(state: State, host: Host): Controller {let lastSegment: string | null | undefinedlet lastSpend: number | undefinedlet hasDrawn = false+ let toolsCountedAt = 0const lastAttempt = new Map<string, number>()const persist = () => void host.storeSet(storeKeyOf(state.cwd), { view: state.view }).catch(() => undefined)@@ -76,6 +78,12 @@ export function createController(state: State, host: Host): Controller {/** A read that starts after this call: what an action checks, since a read already running may predate its write. */async function freshRead(): Promise<void> {await inflight?.catch(() => undefined)++ // A file the action just created must not wait out the missing-file backoff.+ for (const [path, held] of state.cache) {+ if ('missingUntilMs' in held) state.cache.delete(path)+ }+await refresh()}@@ -85,6 +93,12 @@ export function createController(state: State, host: Host): Controller {const started = Date.now()try {+ // Claude Code connects MCP servers after the session starts: count the ruflo tools again now and then.+ if (Date.now() - toolsCountedAt >= TOOLS_RECOUNT_MS) {+ toolsCountedAt = Date.now()+ void host.rufloTools().then(counted => void (state.rufloTools = counted), () => undefined)+ }+const [settings, usage, snapshot, route] = await Promise.all([host.settings().catch(() => null),host.usage().catch(() => null),@@ -285,9 +299,10 @@ export function createController(state: State, host: Host): Controller {}function setView(view: State['view']): void {+ state.isHelp = false+if (view !== state.view) {state.view = view- state.isHelp = falsestate.mounted.clear()persist()// A new view asks for its own height inline; the dock ignores it.@@ -351,7 +366,7 @@ export function createController(state: State, host: Host): Controller {const actions: Actions = {view: setView,- refresh: () => void refresh().then(() => probe(true)),+ refresh: () => void freshRead().then(() => probe(true)),help: () => {state.isHelp = !state.isHelphost.invalidate()diff --git a/plugins/ruflo-console/hooks/data/files.ts b/plugins/ruflo-console/hooks/data/files.tsindex 91de7c8439..3a4de3b433 100644--- a/plugins/ruflo-console/hooks/data/files.ts+++ b/plugins/ruflo-console/hooks/data/files.ts@@ -51,16 +51,25 @@ export const NOSTR_KEY = '.ruflo/nostr.key'export type Read = { text: string; mtimeMs: number } | { text: null; reason: 'missing' | 'too-large' | 'refused'; size?: number }/** The text of each file as last read, by path, with the mtime and size it was read at. */-export type ReadCache = Map<string, { mtimeMs: number; size: number; text: string }>+export type ReadCache = Map<string, { mtimeMs: number; size: number; text: string } | { missingUntilMs: number }>++/** A path found missing is not stat-ed again for this long: a file ruflo creates shows up within it. */+export const MISSING_RECHECK_MS = 10_000/** Reads one file, unless its mtime and size match what was read last; stats first, so a huge file is never read. */export async function readBounded(fs: ReaderFs, cache: ReadCache, path: string): Promise<Read> {let stat: { mtimeMs?: number; size?: number } | undefined+ const before = cache.get(path)++ if (before !== undefined && 'missingUntilMs' in before && before.missingUntilMs > Date.now()) {+ return { text: null, reason: 'missing' }+ }+try {stat = await fs.stat(path)} catch {- cache.delete(path)+ cache.set(path, { missingUntilMs: Date.now() + MISSING_RECHECK_MS })return { text: null, reason: 'missing' }}@@ -74,7 +83,7 @@ export async function readBounded(fs: ReaderFs, cache: ReadCache, path: string):return { text: null, reason: 'too-large', size }}- const held = cache.get(path)+ const held = before !== undefined && 'text' in before ? before : undefinedif (held !== undefined && mtimeMs >= 0 && held.mtimeMs === mtimeMs && held.size === size) {return { text: held.text, mtimeMs }@@ -101,7 +110,8 @@ export type DiskRead = { project: Record<ProjectKey, Read>; home: Record<keyof t/** Reads every file in parallel; nothing here rejects. `home` is null when the home directory is unknown. */export async function readDisk(fs: ReaderFs, cache: ReadCache, cwd: string, home: string | null): Promise<DiskRead> {- const before = new Map([...cache].map(([path, held]) => [path, held.mtimeMs]))+ const mtimeOf = (held: ReadCache extends Map<string, infer V> ? V : never) => ('mtimeMs' in held ? held.mtimeMs : -1)+ const before = new Map([...cache].map(([path, held]) => [path, mtimeOf(held)]))const projectKeys = Object.keys(PROJECT) as ProjectKey[]const homeKeys = Object.keys(HOME) as (keyof typeof HOME)[]const missingHome: Read = { text: null, reason: 'missing' }@@ -119,7 +129,7 @@ export async function readDisk(fs: ReaderFs, cache: ReadCache, cwd: string, homelet changed = 0for (const [path, held] of cache) {- if (before.get(path) !== held.mtimeMs) {+ if ('mtimeMs' in held && before.get(path) !== held.mtimeMs) {changed += 1}}diff --git a/plugins/ruflo-console/hooks/gfx/pictures.ts b/plugins/ruflo-console/hooks/gfx/pictures.tsindex 3ed54dac6d..8dffa7d226 100644--- a/plugins/ruflo-console/hooks/gfx/pictures.ts+++ b/plugins/ruflo-console/hooks/gfx/pictures.ts@@ -102,7 +102,12 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number,for (const lag of [0, 0.5]) {const k = (((t / 1400 + i * 0.13 + lag) % 1) + 1) % 1- canvas.dot(p.x + (q.x - p.x) * k, p.y + (q.y - p.y) * k, COLOR.warn)+ const x = p.x + (q.x - p.x) * k+ const y = p.y + (q.y - p.y) * k++ // Two dots wide, so a pulse on a vertical edge stands out of the line rather than sitting on its dots.+ canvas.dot(x, y, COLOR.warn)+ canvas.dot(x + 1, y, COLOR.warn)}})diff --git a/plugins/ruflo-console/hooks/host.ts b/plugins/ruflo-console/hooks/host.tsindex 19f0f07766..348e39d218 100644--- a/plugins/ruflo-console/hooks/host.ts+++ b/plugins/ruflo-console/hooks/host.ts@@ -25,8 +25,8 @@ export type Host = {registerCommand: (spec: CommandSpec) => Promise<unknown>run: (argv: readonly string[], timeoutMs: number) => Promise<ProcessRunResult>usage: () => Promise<{ costUsd?: number; contextPercent?: number }>- /** How many ruflo / claude-flow MCP tools the model can call now. */- rufloTools: () => Promise<number>+ /** The ruflo / claude-flow MCP tools the model can call now, and the servers they come from. */+ rufloTools: () => Promise<{ tools: number; servers: string[] }>settings: () => Promise<unknown>home: () => Promise<string | undefined>rufloSnapshot: () => Promise<RufloSnapshot>diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.tsindex a8b72edf8e..ff94c9b80f 100644--- a/plugins/ruflo-console/hooks/register.ts+++ b/plugins/ruflo-console/hooks/register.ts@@ -10,7 +10,7 @@ import type { Kit } from './views/common'import { picturesOf } from './views/frames'import { NARROW, paneView } from './views/pane'-const RUFLO_TOOL = /^mcp__(?:claude-flow|ruflo|plugin_ruflo[\w-]*)__/+const RUFLO_TOOL = /^mcp__(claude-flow|ruflo|plugin_ruflo[\w-]*)__//*** Binds a Host from `$`, every member spelled `$.noun.method(...)` here and nowhere else, so the engine reads what@@ -45,7 +45,11 @@ function hostOf($: EngineInterface, cwd: string): Host {return { ...(usage.cost?.usd !== undefined && { costUsd: usage.cost.usd }), ...(usage.context?.percent !== undefined && { contextPercent: usage.context.percent }) }},- rufloTools: async () => (await $.tool.list()).filter(tool => RUFLO_TOOL.test(tool.name)).length,+ rufloTools: async () => {+ const names = (await $.tool.list()).flatMap(tool => RUFLO_TOOL.exec(tool.name)?.slice(1, 2) ?? [])++ return { tools: names.length, servers: [...new Set(names)].sort() }+ },settings: async () => $.settings.read(),home: async () => $.env.get('HOME'),// `$.ruflo` exists only where ruflo-mods is seated; validate refuses feature-detecting a noun, so these are@@ -85,7 +89,7 @@ export const register: Register = (on, raw: PluginOptions) => {await Promise.all([bound.registerCommand({ name: 'ruflo-console', description: 'ruflo console: swarms, claims, federation, plugins, learning, MetaHarness, memory', argumentHint: '[view|close|status]' }).catch(() => undefined),bound.storeGet(storeKeyOf(e.cwd)).then(value => restore(state, value), () => undefined),- bound.rufloTools().then(n => void (state.rufloTools = n), () => undefined),+ bound.rufloTools().then(counted => void (state.rufloTools = counted), () => undefined),])control.start()void control.refresh()diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.tsindex 07302705b6..7573e62549 100644--- a/plugins/ruflo-console/hooks/state.ts+++ b/plugins/ruflo-console/hooks/state.ts@@ -93,7 +93,7 @@ export type State = {probes: Map<string, ProbeResult>ruflo: { snapshot: RufloSnapshot | null; route: RufloRoute | null; error: string | null }usage: { costUsd?: number; contextPercent?: number } | null- rufloTools: number | null+ rufloTools: { tools: number; servers: string[] } | nullmods: ModSeen[]/** Tool calls the console saw, per 5 s bucket, newest last: a measured series. */activity: number[]diff --git a/plugins/ruflo-console/hooks/views/overview.ts b/plugins/ruflo-console/hooks/views/overview.tsindex efe9d52a8f..769c7c8b77 100644--- a/plugins/ruflo-console/hooks/views/overview.ts+++ b/plugins/ruflo-console/hooks/views/overview.ts@@ -36,7 +36,16 @@ export function overviewView(ctx: Ctx): RenderElement {daemon?.running === true ? THEME.ok : undefined,),)- rows.push(kv(ctx, 'MCP tools', state.rufloTools === null ? 'n/a' : state.rufloTools > 0 ? `${state.rufloTools} ruflo tools callable now (Claude Code's tool list)` : 'none connected in this session', state.rufloTools !== null && state.rufloTools > 0 ? THEME.ok : undefined))+ const mcp = state.rufloTools++ rows.push(+ kv(+ ctx,+ 'MCP',+ mcp === null ? 'n/a' : mcp.tools > 0 ? `${mcp.servers.length} ruflo server${mcp.servers.length === 1 ? '' : 's'} connected (${mcp.servers.join(', ')}) · ${mcp.tools} tools callable now` : 'no ruflo MCP server connected in this session',+ mcp !== null && mcp.tools > 0 ? THEME.ok : undefined,+ ),+ )rows.push(kv(ctx, 'memory DB', memory !== null ? `${count(memory.total)} entries · ${count(memory.vectors)} vectors · ${memory.backend}${memory.storage !== undefined ? ` · ${memory.storage}` : ''}` : sourceLine(state.probes.get('memory'), nowMs, 'n/a').text))rows.push(kv(diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.tsindex f858f923c3..710060d130 100644--- a/plugins/ruflo-console/hooks/views/pane.ts+++ b/plugins/ruflo-console/hooks/views/pane.ts@@ -29,7 +29,7 @@ const BODIES = {} as constfunction tabs(ctx: Ctx): RenderElement {- const isShort = ctx.columns < 104+ const isShort = ctx.columns < 100if (ctx.columns < NARROW) {const index = VIEWS.findIndex(view => view.id === ctx.state.view)@@ -37,16 +37,17 @@ function tabs(ctx: Ctx): RenderElement {return text(ctx, `${index + 1}/${VIEWS.length} ${VIEWS[index]?.label ?? ''} · 1-8 switch · h help`, { bold: true, color: THEME.head })}- return row(- ctx,- VIEWS.map(view => {+ return ctx.kit.Box({+ flexDirection: 'row',+ gap: 1,+ key: 'tabs',+ children: VIEWS.map(view => {const isCurrent = view.id === ctx.state.viewconst label = isShort ? view.label.slice(0, view.id === 'metaharness' ? 4 : 5) : view.labelreturn ctx.kit.Button({ key: `tab-${view.id}`, label: isCurrent ? `${label}◂` : label, hotkey: view.key, plain: true, ...(isCurrent ? {} : { dimColor: true }), onPress: () => ctx.act.view(view.id) })}),- 'tabs',- )+ })}function help(ctx: Ctx): RenderElement {@@ -102,7 +103,7 @@ function footer(ctx: Ctx): RenderElement {parts.push(row(ctx, [- text(ctx, clip(`${read} · ${keys}`, Math.max(10, ctx.columns - 24)), { dimColor: true }),+ text(ctx, `${clip(`${read} · ${keys}`, Math.max(10, ctx.columns - 34))} `, { dimColor: true }),...(ctx.columns >= NARROW ? [button(ctx, 'refresh', 'Refresh', ctx.act.refresh, { hotkey: 'r' }), button(ctx, 'help', 'Help', ctx.act.help, { hotkey: 'h' }), button(ctx, 'close', 'Close', ctx.act.close, { hotkey: 'x' })] : []),]),)diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.tsindex 1c0036cff3..011072c8d2 100644--- a/plugins/ruflo-console/tests/views.test.ts+++ b/plugins/ruflo-console/tests/views.test.ts@@ -44,7 +44,7 @@ describe('views', () => {expect(text).toContain('v3.50.0 (npx-offline)')expect(text).toContain('running per daemon-state.json')- expect(text).toContain('2 ruflo tools callable now')+ expect(text).toContain('1 ruflo server connected (claude-flow) · 2 tools callable now')expect(text).toContain('1 entries')expect(text).toContain('manifest v3.32.24')expect(text).toContain('signature not checked here')