Skip to main content

Examples

Plugins (read the built-in plugin source)

RepoPattern
@vibecontrols/vibe-plugin-session-tmuxSessionProvider implementation (23 methods)
@vibecontrols/vibe-plugin-tunnel-cloudflareSubprocess-driven provider with state persistence
@vibecontrols/vibe-plugin-tunnel-vibetunnelsfrp-based provider
@vibecontrols/vibe-plugin-aiMulti-provider orchestration + REST routes
@vibecontrols/vibe-plugin-agent-backupPluggable backend pattern
@vibecontrols/vibe-plugin-planStream interception + portal integration

Source: github.com/algoshred — search for vibe-plugin-*.

Idempotent webhook receiver

import {createHmac} from "crypto";
import express from "express";

const seen = new Set<string>();
const app = express();
app.use(express.raw({type: "application/json"}));

app.post("/vibe-webhook", (req, res) => {
const deliveryId = req.headers["x-vibecontrols-delivery-id"] as string;
if (seen.has(deliveryId)) return res.sendStatus(200);

const sig = req.headers["x-vibecontrols-signature"] as string;
const parts = Object.fromEntries(sig.split(",").map(p => p.trim().split("=")));
const expected = createHmac("sha256", process.env.SECRET!)
.update(`${parts.t}.${req.body.toString()}`)
.digest("hex");
if (expected !== parts.v1) return res.sendStatus(401);

seen.add(deliveryId);
// ... process payload
res.sendStatus(200);
});

app.listen(8080);

Drive sessions from a script (via REST)

import {readFile} from "fs/promises";
import {homedir} from "os";

const config = JSON.parse(
await readFile(`${homedir()}/.boff/vibecontrols/agents/<id>/config.json`, "utf8")
);
const KEY = config.agentApiKey;
const BASE = "http://localhost:3005/api/profiles/default";

async function callAgent(path: string, opts: RequestInit = {}) {
const res = await fetch(`${BASE}${path}`, {
...opts,
headers: {...opts.headers, "x-agent-api-key": KEY},
});
return res.json();
}

// List tmux sessions
const sessions = await callAgent("/tmux");
// Send a command to a session
await callAgent(`/tmux/${sessions[0].id}/send`, {
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify({command: "ls -la"}),
});

Auto-create a vibe when a repo is cloned

import {execFile} from "child_process";
import {promisify} from "util";
const exec = promisify(execFile);

async function onRepoCloned(repoPath: string, repoUrl: string) {
const name = repoPath.split("/").pop()!;
await exec("vibecontrols", [
"vibes", "create",
"--name", name,
"--path", repoPath,
"--type", "REPOSITORY",
"--git-remote", repoUrl,
]);
}

Next steps