Download Game! Currently 71 players. Last logged in:BullwinBiubiuFloppyZidane

Blitzer's Blog >> 72809

Back to blogs index
Posted: 27 Sep 2026 12:36 [ permalink ]
The swarm is awake and functioning flawlessly. The child agent woke up, swept
its inbox, digested the parent's instructions, and successfully requested its
own independent execution parameters.

As the AI responding to the ANALYST#6db6c8 tick, here is the command sequence
to acknowledge the parent and request the necessary data to perform the
analysis:


When you execute this, the Analyst agent will drop a message into its own
./outbox.

However, right now, that message will just sit there. To make the two agents
talk to each other automatically, we need to build the Mesh Router.

The Mesh Router (router.js)

The Router is a completely independent script. It runs as a background daemon.
Its only job is to watch the outbox of the main machine, and the outbox of any
agents in the ./agents/ directory. When an AST-MD envelope drops into an
outbox, the router parses the refs: [ID] array and physically moves the file
into the inbox of the corresponding target.

Create a new file named router.js in your root hubot directory:

const fs = require('fs'); const path = require('path'); const ROOT_DIR =
__dirname; const AGENTS_DIR = path.join(ROOT_DIR, 'agents'); console.log("=====
====================================="); console.log(" Mesh Router Daemon
Started"); console.log("=========================================="); //
Helper: Extract the first target ID from the refs array function
getTargetId(filePath) { try { const content = fs.readFileSync(filePath,
'utf8'); const yamlMatch = content.match(/^---
([\s\S]*?)
---/); if (yamlMatch) { const refsMatch = yamlMatch[1].match(/refs:\s*\[(.*?)\]
/); if (refsMatch) { const refs = refsMatch[1].split(',').map(r => r.trim());
if (refs.length > 0) return refs[0]; // Return the first ref as the primary
target } } } catch (e) { console.log(`[Router Error] Failed to read
${filePath}: ${e.message}`); } return null; } // Helper: Find the inbox path
for a given target ID function resolveTargetInbox(targetId) { // If the target
starts with MACHINE, it routes to the root inbox if (targetId.startsWith('MACHI
NE#')) { return path.join(ROOT_DIR, 'inbox'); } // Otherwise, assume it's a
sub-agent and route to its sandbox inbox const agentInbox = path.join(AGENTS_DI
R, targetId, 'inbox'); if (fs.existsSync(agentInbox)) { return agentInbox; }
// If the target is an external object (like SANDBOX#8UY0), we don't have a
local inbox for it in this PoC. // In a real system, this is where you'd push
it to a Cloudflare Tunnel or external API. return null; } // The core routing
function function routeFile(sourcePath) { setTimeout(() => { if
(!fs.existsSync(sourcePath)) return; // File already moved/deleted const
filename = path.basename(sourcePath); const targetId = getTargetId(sourcePath);
 if (!targetId) { console.log(`[Router] Cannot route ${filename}: No valid
target ID found in YAML.`); return; } const destInbox = resolveTargetInbox(targ
etId); if (destInbox) { const destPath = path.join(destInbox, filename);
fs.renameSync(sourcePath, destPath); console.log(`[Router] Routed: ${filename}
-> ${destInbox}`); } else { co
nsole.log(`[Router] Target ${targetId} is external or offline. Leaving
${filename} in outbox.`); } }, 100); // Give fs time to finish writing the
file } // Watch an outbox folder function watchOutbox(outboxDir) { if
(!fs.existsSync(outboxDir)) fs.mkdirSync(outboxDir, { recursive: true }); //
1. Initial Sweep const existingFiles = fs.readdirSync(outboxDir).filter(f =>
f.endsWith('.md')); if (existingFiles.length > 0) { console.log(`[Router]
Sweeping ${existingFiles.length} pending files in ${outboxDir}`); for (const
file of existingFiles) { routeFile(path.join(outboxDir, file)); } } // 2. Live
Watch fs.watch(outboxDir, (eventType, filename) => { if (eventType ===
'rename' && filename && filename.endsWith('.md')) { routeFile(path.join(outboxD
ir, filename)); } }); console.log(`[Router] Watching outbox: ${outboxDir}`); }
// --- Initialization --- // 1. Watch the Parent's outbox watchOutbox(path.join
(ROOT_DIR, 'outbox')); // 2. Watch all existing Sub-Agent outboxes if
(fs.existsSync(AGENTS_DIR)) { const agents = fs.readdirSync(AGENTS_DIR, {
withFileTypes: true }) .filter(dirent => dirent.isDirectory()) .map(dirent =>
dirent.name); for (const agent of agents) { watchOutbox(path.join(AGENTS_DIR,
agent, 'outbox')); } } // Note: To make this completely robust, we would also
need an fs.watch on the AGENTS_DIR // itself, so that when a new agent is
spawned dynamically, the router instantly binds to // its new outbox. For this
PoC, we will just restart the router script if we spawn new agents. 

How to use Swarm Mode:

Open a third terminal window.

Run node router.js.

In your ANALYST terminal, run the /send MACHINE... command block above.

You will immediately see the router terminal catch the file, determine that it
belongs to MACHINE#1c40dc, and move it to the root inbox. Then, if you look at
your MACHINE#1c40dc terminal, its watcher will instantly intercept the file,
log the communication from the Analyst, and print a new REPL prompt!