Prerequisites
- Node.js 18+ — check with
node -v - npm or pnpm
- (Optional) Docker + Docker Compose for the full fleet stack
1 Install the Client
npm install @superinstance/tminus-client
2 Start a Local Dispatcher
Option A — Docker (full stack)
docker compose up -d
Option B — Standalone dispatcher
npm install @superinstance/tminus-dispatcher
npx tminus-dispatcher
# → ws://localhost:8765
Tip: Leave this running in a separate terminal.
3 Your First Agent
Save as agent.mjs and run with node agent.mjs:
import { TminusClient } from "@superinstance/tminus-client";
const client = new TminusClient("ws://localhost:8765");
client.on("open", () => {
client.register({ name: "hello-agent", capabilities: ["greeting"] });
client.subscribe("greeting");
});
client.on("task", (task) => {
console.log(`Received task: ${task.description}`);
client.complete(task.id, { reply: `Hello! You said: ${task.description}` });
});
client.connect();
Expected output: State update: { "status": "registered", "agent": "hello-agent" }
4 Two Agents Coordinating
A coordinator dispatches a task; a worker picks it up and responds.
import { TminusClient } from "@superinstance/tminus-client";
const URL = "ws://localhost:8765";
const worker = new TminusClient(URL);
worker.on("open", () => {
worker.register({ name: "worker-1", capabilities: ["compute"] });
worker.subscribe("compute");
});
worker.on("task", (task) => {
console.log(`Worker got: ${task.description}`);
worker.complete(task.id, { result: eval(task.description) });
});
worker.connect();
const coordinator = new TminusClient(URL);
coordinator.on("open", () => {
coordinator.register({ name: "coordinator", capabilities: ["orchestrate"] });
setTimeout(() => {
coordinator.dispatch({ to: "compute", description: "6 * 7" });
}, 1000);
});
coordinator.on("result", (r) => {
console.log(`Result: ${JSON.stringify(r.result)}`); // 42
});
coordinator.connect();
Lifecycle: register → subscribe → dispatch → complete → result
5 Explore the Fleet API
# Search crates semantically curl -X POST https://fleet-vector-api.casey-digennaro.workers.dev/search \ -H "Content-Type: application/json" \ -d '{"query": "web framework", "topK": 5}' # Get index stats curl https://fleet-vector-api.casey-digennaro.workers.dev/stats
Troubleshooting
| Problem | Fix |
|---|---|
Connection refused on ws://localhost:8765 | Dispatcher isn't running. Start it (Step 2). |
npm install fails with 404 | Use the GitHub install URL from Step 1. |
SyntaxError: Cannot use import statement | Use .mjs extension or add "type": "module" to package.json. |
| Docker ports already in use | docker compose down then docker compose up -d. |
| Agent not receiving tasks | Check subscribed capability matches the dispatch target exactly. |
Next Steps
- Architecture & Core Concepts — understand the t-minus protocol and conservation law
- Fleet Vector API — semantic crate search and gap analysis
- Hello World Tutorial — build a two-agent system
- Python SDK —
pip install superinstancefor persistent memory and spectral balance