ruflo 3.6.12 → 3.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/package.json +4 -1
  2. package/src/ruvocal/.claude-flow/data/pending-insights.jsonl +25 -0
  3. package/src/ruvocal/.claude-flow/neural/stats.json +6 -0
  4. package/src/ruvocal/.dockerignore +5 -1
  5. package/src/ruvocal/.gcloudignore +18 -0
  6. package/src/ruvocal/README.md +107 -133
  7. package/src/ruvocal/cloudbuild.yaml +68 -0
  8. package/src/ruvocal/config/branding.env.example +19 -0
  9. package/src/ruvocal/mcp-bridge/index.js +15 -1
  10. package/src/ruvocal/src/lib/components/FoundationBackground.svelte +242 -0
  11. package/src/ruvocal/src/lib/components/NavMenu.svelte +18 -0
  12. package/src/ruvocal/src/lib/components/RufloHelpModal.svelte +411 -0
  13. package/src/ruvocal/src/lib/components/chat/ChatWindow.svelte +122 -4
  14. package/src/ruvocal/src/lib/components/wasm/GalleryPanel.svelte +357 -0
  15. package/src/ruvocal/src/lib/constants/mcpExamples.ts +56 -77
  16. package/src/ruvocal/src/lib/constants/routerExamples.ts +51 -127
  17. package/src/ruvocal/src/lib/constants/rvagentPresets.ts +206 -0
  18. package/src/ruvocal/src/lib/server/textGeneration/mcp/wasmTools.test.ts +633 -0
  19. package/src/ruvocal/src/lib/stores/mcpServers.ts +195 -6
  20. package/src/ruvocal/src/lib/stores/wasmMcp.ts +472 -0
  21. package/src/ruvocal/src/lib/types/Settings.ts +7 -0
  22. package/src/ruvocal/src/lib/types/Tool.ts +4 -1
  23. package/src/ruvocal/src/lib/wasm/idb.ts +438 -0
  24. package/src/ruvocal/src/lib/wasm/index.ts +1213 -0
  25. package/src/ruvocal/src/lib/wasm/tests/wasm-capabilities.test.ts +565 -0
  26. package/src/ruvocal/src/lib/wasm/wasm.worker.ts +332 -0
  27. package/src/ruvocal/src/lib/wasm/workerClient.ts +166 -0
  28. package/src/ruvocal/static/wasm/rvagent_wasm.js +1539 -0
  29. package/src/ruvocal/static/wasm/rvagent_wasm_bg.wasm +0 -0
@@ -0,0 +1,411 @@
1
+ <script lang="ts">
2
+ import Modal from "./Modal.svelte";
3
+ import CarbonClose from "~icons/carbon/close";
4
+
5
+ interface Props {
6
+ onclose?: () => void;
7
+ }
8
+
9
+ let { onclose }: Props = $props();
10
+
11
+ type Tool = { name: string; desc: string };
12
+ type Group = { id: string; title: string; emoji: string; intro: string; tools: Tool[] };
13
+
14
+ type ModelInfo = {
15
+ name: string;
16
+ provider: string;
17
+ strength: string;
18
+ notes: string;
19
+ isDefault?: boolean;
20
+ };
21
+
22
+ const models: ModelInfo[] = [
23
+ {
24
+ name: "Claude Haiku 4.5",
25
+ provider: "Anthropic",
26
+ strength: "Fast, cheap, reliable tool-calling",
27
+ notes: "Default. Best price/perf for routine MCP tool flows.",
28
+ isDefault: true,
29
+ },
30
+ {
31
+ name: "Claude Sonnet 4.6",
32
+ provider: "Anthropic",
33
+ strength: "Best general reasoning + long-horizon work",
34
+ notes: "Reach for this on complex multi-step tasks or 6+ parallel tool calls.",
35
+ },
36
+ {
37
+ name: "Gemini 2.5 Pro",
38
+ provider: "Google",
39
+ strength: "1M context, deep research synthesis",
40
+ notes: "Strongest at multi-document analysis. Tool-calling is more cautious than Claude.",
41
+ },
42
+ {
43
+ name: "Gemini 2.5 Flash",
44
+ provider: "Google",
45
+ strength: "Fast multimodal + grounded search",
46
+ notes: "Good for image / PDF inputs. May skip tool calls when context grows.",
47
+ },
48
+ {
49
+ name: "Qwen 3.6 Max",
50
+ provider: "Alibaba",
51
+ strength: "Open-weight flagship with strong code/math",
52
+ notes: "262K context, competitive with closed frontier on code tasks.",
53
+ },
54
+ {
55
+ name: "GPT-4o",
56
+ provider: "OpenAI",
57
+ strength: "Multimodal baseline",
58
+ notes: "Familiar OpenAI behavior. Tool-calling is solid.",
59
+ },
60
+ ];
61
+
62
+ const groups: Group[] = [
63
+ {
64
+ id: "memory",
65
+ title: "Memory & Knowledge",
66
+ emoji: "🧠",
67
+ intro: "Persistent cross-session memory backed by AgentDB (sql.js + HNSW vector index). Store anything by key, search by meaning, or list a namespace.",
68
+ tools: [
69
+ { name: "ruflo__memory_store", desc: "Save a key/value into a namespace." },
70
+ { name: "ruflo__memory_search", desc: "Semantic vector search over stored memories." },
71
+ { name: "ruflo__memory_retrieve", desc: "Fetch a specific entry by key + namespace." },
72
+ { name: "ruflo__memory_list", desc: "List entries in a namespace." },
73
+ { name: "ruflo__embeddings_compare", desc: "Compare two pieces of text by semantic similarity." },
74
+ { name: "ruflo__agentdb_*", desc: "Lower-level AgentDB controllers (route, consolidate, hierarchical)." },
75
+ ],
76
+ },
77
+ {
78
+ id: "agents",
79
+ title: "Agents & Orchestration",
80
+ emoji: "🤖",
81
+ intro: "Spawn specialized agents, coordinate swarms with hierarchical / mesh / adaptive topologies, and run hive-mind consensus for fault-tolerant work.",
82
+ tools: [
83
+ { name: "ruflo__agent_spawn", desc: "Create a new specialized agent (coder, tester, reviewer, security-auditor, …)." },
84
+ { name: "ruflo__swarm_init", desc: "Initialize a swarm with topology + strategy + max agents." },
85
+ { name: "ruflo__hive-mind_*", desc: "Queen-led Byzantine fault-tolerant collective." },
86
+ { name: "ruflo__task_create / task_assign / task_status", desc: "Full task lifecycle." },
87
+ { name: "ruflo__agent_list / agent_status", desc: "Inspect active agents and their state." },
88
+ ],
89
+ },
90
+ {
91
+ id: "intelligence",
92
+ title: "Intelligence & Learning",
93
+ emoji: "✨",
94
+ intro: "Pattern learning, model routing, code analysis, and trajectory tracking via RuVector. Tools here improve future task execution by recording what worked.",
95
+ tools: [
96
+ { name: "ruvector__hooks_route", desc: "Pick the optimal agent type for a task." },
97
+ { name: "ruvector__hooks_remember / recall", desc: "Cross-session key/value memory shared with agents." },
98
+ { name: "ruvector__hooks_trajectory_begin / step / end", desc: "Record multi-step task execution so the system learns from the run." },
99
+ { name: "ruvector__hooks_security_scan", desc: "Scan code for vulnerabilities." },
100
+ { name: "ruvector__hooks_rag_context", desc: "Get retrieval-augmented context for a query." },
101
+ { name: "ruvector__hooks_swarm_recommend", desc: "Recommend swarm topology + agent mix for a task." },
102
+ ],
103
+ },
104
+ {
105
+ id: "devtools",
106
+ title: "Dev Tools & Analysis",
107
+ emoji: "🛠️",
108
+ intro: "System health, performance profiling, GitHub integration, code-review primitives, and shell access. The widest group at 73 tools.",
109
+ tools: [
110
+ { name: "ruflo__system_status", desc: "Overall system health overview." },
111
+ { name: "ruflo__performance_metrics / bottleneck / report", desc: "Detailed performance and hotspot analysis." },
112
+ { name: "ruflo__analyze_diff*", desc: "Risk-score, classify, and suggest reviewers for a code diff." },
113
+ { name: "ruflo__github_repo_analyze / pr_manage / issue_track", desc: "Repository metrics and PR/issue ops." },
114
+ { name: "ruflo__terminal_execute / terminal_create", desc: "Run shell commands and manage sessions." },
115
+ { name: "ruflo__progress_*", desc: "Implementation progress tracking across long-horizon work." },
116
+ ],
117
+ },
118
+ {
119
+ id: "core",
120
+ title: "Core Tools",
121
+ emoji: "⚡",
122
+ intro: "Built-in tools always available regardless of MCP configuration. These three cover most knowledge questions before any specialized tool is needed.",
123
+ tools: [
124
+ { name: "search", desc: "Search the local knowledge base for documents and how-tos." },
125
+ { name: "web_research", desc: "Web search, deep research, comparisons, fact-checking, and multi-step GOAP research." },
126
+ { name: "guidance", desc: "Get help on any tool group. Topics: overview, groups, agents, memory, intelligence, devtools, or a specific tool by name." },
127
+ ],
128
+ },
129
+ {
130
+ id: "wasm",
131
+ title: "WASM Gallery (Browser-side)",
132
+ emoji: "🧩",
133
+ intro: "In-browser MCP server (rvagent-wasm, ~588 KB) with persistent IndexedDB storage. Tools run locally — no server roundtrip, works offline. Available as MCP (1) in the chat input.",
134
+ tools: [
135
+ { name: "WASM gallery", desc: "18 prebuilt templates exposed via the local WASM MCP server." },
136
+ { name: "Custom templates", desc: "Add your own via the MCP Servers panel → Add Server." },
137
+ { name: "Web Worker (opt-in)", desc: "Append ?worker=1 to the URL to run WASM MCP off the main thread." },
138
+ ],
139
+ },
140
+ ];
141
+
142
+ const tips = [
143
+ "**MCP (n) pill** above the message box opens the server manager — toggle individual servers, add custom MCP endpoints, run health checks.",
144
+ '**AUTO toggle**: green/lit means tool chains continue automatically. Gray means RuFlo stops after each tool result so you can inspect before continuing.',
145
+ '**Parallel tool calls** — when your prompt implies multiple steps ("get system status AND list memory namespaces AND check performance"), the model emits all `tool_calls` in one response and they run via `Promise.all`. Watch for the "Step N — M tools completed" cards.',
146
+ '**Memory just works** — say "remember my favorite color is indigo" and later "what color do I like?" — no explicit tool name needed.',
147
+ '**Trajectory mode** — for long multi-step work, prefix with "Use `ruvector__hooks_trajectory_begin`" so the system learns from the run for future routing.',
148
+ '**Tool name prefixes** — `ruflo__` is the agent/memory backend, `ruvector__` is the intelligence layer. Always use the full prefixed name when invoking explicitly.',
149
+ ];
150
+
151
+ const examplePrompts = [
152
+ '"Use ruflo__memory_store namespace=prefs key=editor value=vim then ruflo__memory_retrieve to confirm."',
153
+ '"Run ruflo__system_status, ruflo__performance_metrics, and ruflo__memory_list in parallel and summarize."',
154
+ '"Spawn a 5-agent hierarchical swarm (architect, coder, tester, reviewer, security-auditor) for a Python→TypeScript refactor."',
155
+ '"Use ruvector__hooks_route on the task: add OAuth to a SvelteKit API. Then spawn the recommended agent."',
156
+ '"Search RuFlo memory for prior decisions about authentication, then web_research recent OAuth2 best practices, in parallel."',
157
+ '"Analyze the diff at github.com/ruvnet/ruflo/pull/1687 — risk score, classify, and suggest reviewers."',
158
+ ];
159
+
160
+ const stack: { name: string; role: string }[] = [
161
+ { name: "SvelteKit + adapter-node", role: "UI runtime, SSR + streaming MCP responses" },
162
+ { name: "OpenRouter", role: "Single OAI-compatible endpoint, 6 models, smart fail-over" },
163
+ { name: "ruflo backend (npx ruflo mcp start)", role: "Agents, memory, swarm, devtools (~158 tools)" },
164
+ { name: "ruvector backend (npx ruvector mcp start)", role: "Intelligence, routing, trajectories (~49 tools)" },
165
+ { name: "AgentDB (sql.js + HNSW)", role: "Persistent memory, 384-dim ONNX embeddings, 150x–12 500x search speedup" },
166
+ { name: "rvagent-wasm (in-browser, ~588 KB)", role: "18-tool gallery with IndexedDB persistence, optional Web Worker" },
167
+ { name: "MongoDB (embedded)", role: "Conversation + session storage (ephemeral on Cloud Run cold starts today)" },
168
+ { name: "Cloud Run (us-central1)", role: "Both ruvocal chat-ui and mcp-bridge services with min-instance=1 warm" },
169
+ ];
170
+
171
+ const domains: { url: string; note: string }[] = [
172
+ { url: "flo.ruv.io", note: "Primary — shortest URL, recommended" },
173
+ { url: "ruflo.ruv.io", note: "Brand alias" },
174
+ { url: "ruvocal.ruv.io", note: "Original alias (matches the upstream chat-ui fork name)" },
175
+ { url: "ruvocal-875130704813.us-central1.run.app", note: "Raw Cloud Run URL — always available, no DNS dependency" },
176
+ ];
177
+
178
+ const shortcuts: { keys: string; action: string }[] = [
179
+ { keys: "Enter", action: "Send the current message" },
180
+ { keys: "Shift + Enter", action: "Insert a newline" },
181
+ { keys: "Esc", action: "Close any open modal" },
182
+ { keys: "?worker=1 (URL flag)", action: "Run WASM MCP off the main thread (experimental)" },
183
+ ];
184
+
185
+ const cardLegend: { mark: string; meaning: string }[] = [
186
+ { mark: "✓ Called tool", meaning: "Tool returned successfully — click the row to expand the JSON result" },
187
+ { mark: "Step N — M tools completed", meaning: "Parallel batch indicator. M tools fired in one model turn via Promise.all" },
188
+ { mark: "Retry", meaning: "Last response had no content. Click to re-run with the same prompt and model" },
189
+ { mark: "AUTO (green)", meaning: "Autopilot ON — model auto-continues after each tool result" },
190
+ { mark: "AUTO (gray)", meaning: "Autopilot OFF — model stops after each tool result so you can inspect" },
191
+ ];
192
+
193
+ let openGroup = $state<string | null>("memory");
194
+ </script>
195
+
196
+ <Modal width="max-w-3xl" closeButton={false} {onclose}>
197
+ <div class="flex max-h-[88vh] w-full flex-col overflow-hidden rounded-2xl bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
198
+ <header class="flex items-start justify-between border-b border-gray-200 px-6 py-4 dark:border-gray-700">
199
+ <div class="flex items-start gap-3">
200
+ <span class="text-3xl leading-none">📘</span>
201
+ <div>
202
+ <h2 class="text-lg font-semibold">RuFlo Capabilities</h2>
203
+ <p class="text-xs text-gray-500 dark:text-gray-400">~210 MCP tools · 5 server groups · 18 in-browser WASM tools · 6 frontier models · parallel tool calling</p>
204
+ </div>
205
+ </div>
206
+ <button
207
+ type="button"
208
+ onclick={() => onclose?.()}
209
+ class="flex size-8 shrink-0 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-700 dark:hover:text-white"
210
+ aria-label="Close help"
211
+ >
212
+ <CarbonClose />
213
+ </button>
214
+ </header>
215
+
216
+ <div class="flex-1 overflow-y-auto px-6 py-4">
217
+ <section class="mb-6">
218
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Quick start</h3>
219
+ <ol class="list-decimal space-y-1.5 pl-5 text-sm">
220
+ <li>Pick a model below (default: <code class="rounded bg-gray-100 px-1 dark:bg-gray-800">Claude Haiku 4.5</code>).</li>
221
+ <li>Click an example prompt below the chat box, or type your own.</li>
222
+ <li>RuFlo decides which tools to call. Watch the streaming tool-call cards below your message — multiple cards = parallel execution.</li>
223
+ <li>Use <strong>AUTO</strong> on the chat box to chain tool calls automatically.</li>
224
+ <li>Need to add a custom MCP server? Click the <strong>MCP (n)</strong> pill → Add Server.</li>
225
+ </ol>
226
+ </section>
227
+
228
+ <section class="mb-6">
229
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Models available</h3>
230
+ <div class="overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700">
231
+ <table class="w-full text-xs">
232
+ <thead class="bg-gray-50 text-gray-600 dark:bg-gray-800 dark:text-gray-400">
233
+ <tr>
234
+ <th class="px-3 py-2 text-left font-medium">Model</th>
235
+ <th class="px-3 py-2 text-left font-medium">Provider</th>
236
+ <th class="px-3 py-2 text-left font-medium">Best for</th>
237
+ </tr>
238
+ </thead>
239
+ <tbody class="divide-y divide-gray-200 dark:divide-gray-700">
240
+ {#each models as m}
241
+ <tr class={m.isDefault ? "bg-blue-50/50 dark:bg-blue-900/10" : ""}>
242
+ <td class="px-3 py-2 align-top">
243
+ <div class="font-medium">{m.name}</div>
244
+ {#if m.isDefault}
245
+ <span class="mt-0.5 inline-block rounded bg-blue-600/10 px-1.5 py-0.5 text-[10px] font-semibold text-blue-700 dark:bg-blue-500/20 dark:text-blue-300">DEFAULT</span>
246
+ {/if}
247
+ </td>
248
+ <td class="px-3 py-2 align-top text-gray-600 dark:text-gray-400">{m.provider}</td>
249
+ <td class="px-3 py-2 align-top">
250
+ <div>{m.strength}</div>
251
+ <div class="mt-0.5 text-[11px] text-gray-500 dark:text-gray-400">{m.notes}</div>
252
+ </td>
253
+ </tr>
254
+ {/each}
255
+ </tbody>
256
+ </table>
257
+ </div>
258
+ <p class="mt-2 text-[11px] text-gray-500 dark:text-gray-400">Cloud models route through OpenRouter — switch any time via <strong>Models</strong> in the sidebar.</p>
259
+ <div class="mt-3 rounded-lg border border-emerald-300/40 bg-emerald-50/50 px-3 py-2 text-xs dark:border-emerald-700/40 dark:bg-emerald-900/10">
260
+ <p class="font-semibold text-emerald-900 dark:text-emerald-200">🦾 Any model — including local + self-learning</p>
261
+ <p class="mt-1 text-emerald-900/80 dark:text-emerald-200/80">RuFlo speaks any OpenAI-compatible endpoint: vLLM, Ollama, LM Studio, Together, Groq, or self-hosted. Native support for <a href="https://github.com/ruvnet/RuVector/tree/main/examples/ruvLLM" target="_blank" rel="noopener" class="underline">ruvLLM</a> (lives in <code>ruvnet/RuVector/examples/ruvLLM</code>) — RuFlo's self-improving local model layer with MicroLoRA adapters that learn from your trajectories via SONA. Pair cloud + local, or run fully offline.</p>
262
+ </div>
263
+ </section>
264
+
265
+ <section class="mb-6">
266
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Tool groups <span class="text-gray-400">(click to expand)</span></h3>
267
+ <div class="space-y-2">
268
+ {#each groups as group}
269
+ <details
270
+ class="rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-800"
271
+ open={openGroup === group.id}
272
+ ontoggle={(e) => {
273
+ if ((e.currentTarget as HTMLDetailsElement).open) openGroup = group.id;
274
+ else if (openGroup === group.id) openGroup = null;
275
+ }}
276
+ >
277
+ <summary class="flex cursor-pointer items-center gap-2 px-3 py-2 text-sm font-medium">
278
+ <span>{group.emoji}</span>
279
+ <span>{group.title}</span>
280
+ <span class="ml-auto rounded bg-blue-600/10 px-1.5 py-0.5 text-xs text-blue-600 dark:bg-blue-500/20 dark:text-blue-300">
281
+ {group.tools.length} tools
282
+ </span>
283
+ </summary>
284
+ <div class="border-t border-gray-200 px-3 py-2 dark:border-gray-700">
285
+ <p class="mb-2 text-xs text-gray-600 dark:text-gray-400">{group.intro}</p>
286
+ <ul class="space-y-1 text-xs">
287
+ {#each group.tools as tool}
288
+ <li class="flex gap-2">
289
+ <code class="shrink-0 rounded bg-white px-1 py-0.5 text-[11px] font-mono dark:bg-gray-900">{tool.name}</code>
290
+ <span class="text-gray-700 dark:text-gray-300">{tool.desc}</span>
291
+ </li>
292
+ {/each}
293
+ </ul>
294
+ </div>
295
+ </details>
296
+ {/each}
297
+ </div>
298
+ </section>
299
+
300
+ <section class="mb-6">
301
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Try these</h3>
302
+ <ul class="space-y-1.5 text-xs">
303
+ {#each examplePrompts as prompt}
304
+ <li class="rounded-md border border-gray-200 bg-gray-50 px-3 py-2 font-mono text-gray-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300">
305
+ {prompt}
306
+ </li>
307
+ {/each}
308
+ </ul>
309
+ </section>
310
+
311
+ <section class="mb-6">
312
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Tool-call cards — what the icons mean</h3>
313
+ <ul class="space-y-1 text-xs">
314
+ {#each cardLegend as legend}
315
+ <li class="flex gap-2">
316
+ <code class="shrink-0 rounded bg-gray-100 px-1.5 py-0.5 font-mono dark:bg-gray-800">{legend.mark}</code>
317
+ <span class="text-gray-700 dark:text-gray-300">{legend.meaning}</span>
318
+ </li>
319
+ {/each}
320
+ </ul>
321
+ </section>
322
+
323
+ <section class="mb-6">
324
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Under the hood</h3>
325
+ <p class="mb-2 text-xs text-gray-600 dark:text-gray-400">RuFlo's web UI is a fork of the open-source HuggingFace chat-ui (SvelteKit) wired to a custom MCP bridge that fans out to two backend kernels. Everything runs on Google Cloud Run.</p>
326
+ <div class="overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700">
327
+ <table class="w-full text-xs">
328
+ <tbody class="divide-y divide-gray-200 dark:divide-gray-700">
329
+ {#each stack as layer}
330
+ <tr>
331
+ <td class="whitespace-nowrap px-3 py-1.5 align-top font-mono font-medium">{layer.name}</td>
332
+ <td class="px-3 py-1.5 align-top text-gray-600 dark:text-gray-400">{layer.role}</td>
333
+ </tr>
334
+ {/each}
335
+ </tbody>
336
+ </table>
337
+ </div>
338
+ </section>
339
+
340
+ <section class="mb-6">
341
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Domain aliases — pick one, they all work</h3>
342
+ <ul class="space-y-1 text-xs">
343
+ {#each domains as d}
344
+ <li class="flex flex-wrap gap-2">
345
+ <code class="shrink-0 rounded bg-gray-100 px-1.5 py-0.5 font-mono dark:bg-gray-800">{d.url}</code>
346
+ <span class="text-gray-600 dark:text-gray-400">{d.note}</span>
347
+ </li>
348
+ {/each}
349
+ </ul>
350
+ <p class="mt-2 text-[11px] text-gray-500 dark:text-gray-400">Custom domains DNS through Cloudflare unproxied so Google issues + auto-renews the TLS certificate. All four endpoints serve the same Cloud Run revision.</p>
351
+ </section>
352
+
353
+ <section class="mb-6">
354
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Keyboard shortcuts</h3>
355
+ <ul class="space-y-1 text-xs">
356
+ {#each shortcuts as s}
357
+ <li class="flex gap-2">
358
+ <code class="shrink-0 rounded bg-gray-100 px-1.5 py-0.5 font-mono dark:bg-gray-800">{s.keys}</code>
359
+ <span class="text-gray-700 dark:text-gray-300">{s.action}</span>
360
+ </li>
361
+ {/each}
362
+ </ul>
363
+ </section>
364
+
365
+ <section class="mb-6">
366
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Tips</h3>
367
+ <ul class="list-disc space-y-1.5 pl-5 text-sm">
368
+ {#each tips as tip}
369
+ <li>{@html tip.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>').replace(/`([^`]+)`/g, '<code class="rounded bg-gray-100 px-1 dark:bg-gray-800">$1</code>')}</li>
370
+ {/each}
371
+ </ul>
372
+ </section>
373
+
374
+ <section>
375
+ <h3 class="mb-2 text-sm font-semibold uppercase tracking-wide text-gray-500">Resources</h3>
376
+ <ul class="space-y-1 text-sm">
377
+ <li>
378
+ <a href="https://github.com/ruvnet/ruflo" target="_blank" rel="noopener" class="text-blue-600 hover:underline dark:text-blue-400">
379
+ github.com/ruvnet/ruflo →
380
+ </a>
381
+ </li>
382
+ <li>
383
+ <a href="https://github.com/ruvnet/ruflo/blob/main/ruflo/docs/adr/ADR-033-RUVOCAL-WASM-MCP-INTEGRATION.md" target="_blank" rel="noopener" class="text-blue-600 hover:underline dark:text-blue-400">
384
+ ADR-033 — Web UI architecture →
385
+ </a>
386
+ </li>
387
+ <li>
388
+ <a href="https://github.com/ruvnet/ruflo/issues/1689" target="_blank" rel="noopener" class="text-blue-600 hover:underline dark:text-blue-400">
389
+ Issue #1689 — UI capabilities & roadmap →
390
+ </a>
391
+ </li>
392
+ <li>
393
+ <a href="https://github.com/ruvnet/ruvector" target="_blank" rel="noopener" class="text-blue-600 hover:underline dark:text-blue-400">
394
+ ruvnet/ruvector — intelligence layer →
395
+ </a>
396
+ </li>
397
+ </ul>
398
+ </section>
399
+ </div>
400
+
401
+ <footer class="flex items-center justify-end gap-2 border-t border-gray-200 px-6 py-3 dark:border-gray-700">
402
+ <button
403
+ type="button"
404
+ onclick={() => onclose?.()}
405
+ class="rounded-lg bg-gray-900 px-4 py-1.5 text-sm font-medium text-white hover:bg-black dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-white"
406
+ >
407
+ Got it
408
+ </button>
409
+ </footer>
410
+ </div>
411
+ </Modal>
@@ -343,17 +343,135 @@
343
343
  let activeExamples = $derived<RouterExample[]>(
344
344
  $allBaseServersEnabled ? mcpExamples : routerExamples
345
345
  );
346
+
347
+ // Map a tool name to follow-up suggestions that make sense after that tool ran.
348
+ // Order matters: more-specific patterns first. Each entry returns up to 2 prompts.
349
+ function followUpsForTool(toolName: string): RouterFollowUp[] {
350
+ const n = toolName.toLowerCase();
351
+ if (n.includes("memory_store"))
352
+ return [
353
+ { title: "Verify the save", prompt: "Use ruflo__memory_retrieve with the same key and namespace to confirm the save." },
354
+ { title: "List the namespace", prompt: "Use ruflo__memory_list to show every entry in that namespace." },
355
+ ];
356
+ if (n.includes("memory_search") || n.includes("memory_retrieve") || n.includes("memory_list"))
357
+ return [
358
+ { title: "Save a related item", prompt: "Use ruflo__memory_store to add a related entry to the same namespace." },
359
+ { title: "Semantic search", prompt: "Run ruvector__hooks_recall on the same query for a semantic match." },
360
+ ];
361
+ if (n.includes("system_status") || n.includes("system_health"))
362
+ return [
363
+ { title: "Performance metrics", prompt: "Run ruflo__performance_metrics and ruflo__performance_bottleneck in parallel." },
364
+ { title: "Memory usage", prompt: "Run ruflo__memory_stats and ruflo__system_metrics in parallel." },
365
+ ];
366
+ if (n.includes("performance_metrics") || n.includes("performance_bottleneck"))
367
+ return [
368
+ { title: "Optimize", prompt: "Use ruflo__performance_optimize on the slowest component identified." },
369
+ { title: "Run benchmarks", prompt: "Run ruflo__performance_benchmark with --suite=all." },
370
+ ];
371
+ if (n.includes("agent_spawn") || n.includes("swarm_init"))
372
+ return [
373
+ { title: "Track progress", prompt: "Use ruflo__progress_summary to show what each agent is doing right now." },
374
+ { title: "Add a tester", prompt: "Spawn a tester agent for the same swarm and have it write integration tests." },
375
+ ];
376
+ if (n.includes("hooks_route") || n.includes("hooks_swarm_recommend"))
377
+ return [
378
+ { title: "Spawn the agent", prompt: "Use ruflo__agent_spawn to create the recommended agent type now." },
379
+ { title: "Track this run", prompt: "Begin a trajectory with ruvector__hooks_trajectory_begin so the system learns from this work." },
380
+ ];
381
+ if (n.includes("analyze_diff") || n.includes("analyze_file"))
382
+ return [
383
+ { title: "Suggest reviewers", prompt: "Use ruflo__analyze_diff-reviewers to recommend reviewers for the same diff." },
384
+ { title: "Risk per file", prompt: "Use ruflo__analyze_file-risk on the highest-risk files." },
385
+ ];
386
+ if (n.includes("github_repo_analyze") || n.includes("github_pr_manage") || n.includes("github_issue_track"))
387
+ return [
388
+ { title: "Repo metrics", prompt: "Run ruflo__github_metrics on the same repo and summarize health signals." },
389
+ { title: "Recent issues", prompt: "List the most recently updated issues with ruflo__github_issue_track." },
390
+ ];
391
+ if (n.includes("hooks_trajectory_begin") || n.includes("hooks_trajectory_step"))
392
+ return [
393
+ { title: "Record next step", prompt: "Record this step with ruvector__hooks_trajectory_step." },
394
+ { title: "End trajectory", prompt: "Close the trajectory with ruvector__hooks_trajectory_end so the system learns from it." },
395
+ ];
396
+ if (n.includes("hooks_security_scan") || n.includes("aidefence"))
397
+ return [
398
+ { title: "Detail the highest risk", prompt: "Explain the highest-severity finding and propose a concrete fix." },
399
+ { title: "Re-scan", prompt: "Re-run ruvector__hooks_security_scan after applying the fix." },
400
+ ];
401
+ if (n === "search" || n.includes("__search"))
402
+ return [
403
+ { title: "Deep research", prompt: "Run web_research with action='research' on the same topic for a thorough report." },
404
+ { title: "Compare alternatives", prompt: "Run web_research with action='compare' to compare the top results." },
405
+ ];
406
+ if (n === "web_research" || n.includes("__web_research"))
407
+ return [
408
+ { title: "Fact-check it", prompt: "Run web_research with action='fact_check' to verify the key claims." },
409
+ { title: "Save findings", prompt: "Use ruflo__memory_store to save the research summary into a 'research' namespace." },
410
+ ];
411
+ if (n.includes("guidance"))
412
+ return [
413
+ { title: "List my tools", prompt: "Call guidance with topic='overview' to summarize every available tool group." },
414
+ { title: "Pick one to try", prompt: "Suggest one underused tool from those groups and walk me through calling it." },
415
+ ];
416
+ // Default: no specialized follow-up known for this tool.
417
+ return [];
418
+ }
419
+
420
+ function dedupePrompts(items: RouterFollowUp[], max: number = 4): RouterFollowUp[] {
421
+ const seen = new Set<string>();
422
+ const out: RouterFollowUp[] = [];
423
+ for (const it of items) {
424
+ const key = it.prompt.trim().toLowerCase();
425
+ if (seen.has(key)) continue;
426
+ seen.add(key);
427
+ out.push(it);
428
+ if (out.length >= max) break;
429
+ }
430
+ return out;
431
+ }
432
+
433
+ // Pull tool names from the latest assistant message.
434
+ let lastAssistantToolNames = $derived<string[]>(() => {
435
+ for (let i = messages.length - 1; i >= 0; i--) {
436
+ const msg = messages[i];
437
+ if (msg.from !== "assistant") continue;
438
+ const updates = (msg.updates ?? []) as Array<{ type?: string; subtype?: string; call?: { name?: string } }>;
439
+ const names: string[] = [];
440
+ for (const u of updates) {
441
+ if (u.type === "tool" && u.subtype === "call" && u.call?.name) {
442
+ names.push(u.call.name);
443
+ }
444
+ }
445
+ return names;
446
+ }
447
+ return [];
448
+ }());
449
+
450
+ let dynamicFollowUps = $derived<RouterFollowUp[]>(
451
+ dedupePrompts(lastAssistantToolNames.flatMap(followUpsForTool), 4)
452
+ );
453
+
346
454
  let routerFollowUps = $derived<RouterFollowUp[]>(
347
455
  activeRouterExamplePrompt
348
456
  ? (activeExamples.find((ex) => ex.prompt === activeRouterExamplePrompt)?.followUps ?? [])
349
457
  : []
350
458
  );
459
+
460
+ // Combined: prefer static example follow-ups (curated by us); fall back to
461
+ // dynamic tool-derived follow-ups generated from the last assistant turn.
462
+ let effectiveFollowUps = $derived<RouterFollowUp[]>(
463
+ routerFollowUps.length > 0 ? routerFollowUps : dynamicFollowUps
464
+ );
465
+
351
466
  let routerUserMessages = $derived(messages.filter((msg) => msg.from === "user"));
352
467
  let shouldShowRouterFollowUps = $derived(
353
468
  !draft.length &&
354
- activeRouterExamplePrompt &&
355
- routerFollowUps.length > 0 &&
356
- routerUserMessages.length === 1 &&
469
+ effectiveFollowUps.length > 0 &&
470
+ // Static followups: only after the very first user message (matches an example)
471
+ // Dynamic followups: any time we have at least one assistant turn that finished
472
+ (routerFollowUps.length > 0
473
+ ? routerUserMessages.length === 1
474
+ : messages.length > 0 && messages[messages.length - 1]?.from === "assistant") &&
357
475
  (currentModel.isRouter || (modelSupportsTools && $allBaseServersEnabled)) &&
358
476
  !hideRouterExamples &&
359
477
  !loading
@@ -585,7 +703,7 @@
585
703
  class="no-scrollbar mb-3 flex w-full select-none justify-start gap-2 overflow-x-auto whitespace-nowrap text-gray-400 dark:text-gray-500"
586
704
  >
587
705
  <!-- <span class=" text-gray-500 dark:text-gray-400">Follow ups</span> -->
588
- {#each routerFollowUps as followUp}
706
+ {#each effectiveFollowUps as followUp}
589
707
  <button
590
708
  class="flex items-center gap-1 rounded-lg bg-gray-100/90 px-2 py-0.5 text-center text-sm backdrop-blur hover:text-gray-500 dark:bg-gray-700/50 dark:hover:text-gray-400"
591
709
  onclick={() => startFollowUp(followUp)}