Small B2B teams lose about an hour a day to the same loop: scan the inbox, scan Slack, work out what is urgent, update the CRM, repeat. Most "AI agent" demos solve this by letting a model act freely and printing "done". That is exactly the part that scares operators, and rightly so: a wrong refund or a wrong CRM stage change is a real cost.
OpsJarvis is my answer to that: a self-hosted operations desk where Claude does all the reading, classifying and drafting, and a human approves every write, with the real payload on screen. It is open-core under MIT; the live sandbox needs no login: https://caelaralabs.com. Source: https://github.com/kingefman1-cmyk/opsjarvis.
This post is the technical teardown: architecture, the approval gate, the circuit breaker, the injection hardening, and what I would do differently.
The one-sentence design rule
The model drafts. A human signs. The signature happens with the actual API payload and a before→after diff on screen, not a chat bubble.
Everything else falls out of that rule.
Stack
- Next.js 15 (App Router) + React 19 + Tailwind for the dashboard. The dashboard is a Client Component with zero secrets in it.
-
Claude via the Anthropic SDK as the drafting engine, behind a small adapter (
lib/llm.ts) with a Gemini → Groq fallback so a provider outage never blocks triage. Every call has a 30 s timeout; a provider that returns an auth error is disabled for the rest of the process. -
Route Handlers under `app/api/
** and background workers are the only places that read.env.local`. Nothing secret ever reaches the browser bundle. - grammY Telegram bot as the mobile approval surface: the same approve / regenerate / skip buttons a desktop user gets, delivered as cards.
- Vercel for the dashboard, PM2 on a Linux VPS for 24/7 workers when a team needs them.
Inbound: one queue for Gmail, WhatsApp Business, Slack and Telegram
Every channel normalises into the same InboxItem: channel, sender, body, a trace[] of timestamped reasoning steps, a classification (urgent | normal | low) and a suggested next step.
Two channel-specific lessons:
WhatsApp has no thread boundary. A customer sends the invoice number, the complaint and "pls call" as three pings, sometimes from two numbers. Classifying individual messages gives you garbage. The fix was a windowing step: group by sender within ~10 minutes, then classify the group. Also there is no quoting, so the reasoning trace has to carry the context the UI cannot.
Gmail has the opposite problem. Long quoted chains where the actionable line is buried at the top of reply #7. Thread + subject + stable message ID make dedup easy, but the extraction prompt has to be told explicitly to ignore quoted history.
The approval gate: ExecutionDiffModal
This is the component the whole product is built around. When a task is approved, it does not execute. It opens a review with three panes:
- Payload — the exact JSON that will be sent to Stripe / HubSpot / Xero. Derived from the task if the model did not supply one, so there is never an "unknown" payload.
- Before → After — a row-level diff of the state the write will change (deal stage, refund status, balance).
- Draft — the customer-facing text in an editable textarea. Edits flow into the payload.
The only button that runs anything is Confirm & Execute (⌘/Ctrl+Enter), and it calls a deterministic executor, not the model. The model has no tool that writes to the outside world. That single architectural decision removes an entire class of prompt-injection outcomes: an injected instruction can at most change a draft, which a human then reads.
// Simplified: the model proposes, the executor disposes.
async function executeTask(task: Task, editedDraft?: string) {
if (breakerActive(task.service)) return hold(task, "circuit breaker");
const payload = task.payload ?? derivePayload(task, editedDraft);
const result = await connectors[task.service].write(payload); // server-side, keys from .env
log({ actor: "human", time: new Date().toISOString(), target: task.target, result });
}
Low-risk items (acknowledgements, internal notes) can be bulk-approved with one key. Nothing is auto-sent unless the team flips that switch themselves in their own config.
Keyboard triage, because approvals are a volume problem
If a human has to approve everything, the approval UI must be faster than the thing it replaces. So: ⌘K command palette, J/K to move, A approve, R reject, U undo, and a 10-second undo toast on every destructive action. An operator can clear a 40-item morning queue in a couple of minutes without touching the mouse.
The circuit breaker
Downstream APIs degrade. The naive agent keeps firing writes into a HubSpot that is answering in 3 seconds and timing out half the time, and you end up with half-applied state.
The breaker is deliberately simple: a rolling latency sample per service; above a threshold (800 ms in the demo) the service is marked degraded, writes to it are held, drafts keep queueing, and a banner shows recovery status. When latency drops back, held items resume from the queue and ask for a fresh approval, because the world may have changed while they waited.
In the demo you can inject a crisis (HubSpot latency spike + a duplicate-charge complaint) with one click and watch the gate and the breaker interact.
Injection hardening
Beyond "the model cannot write", three concrete measures:
- Scrubbing. Every model output is scrubbed for secret-shaped strings, the admin chat id and a restricted-term list before it is displayed anywhere, including Telegram.
- Minimal context. The triage model sees only the system prompt and the visitor's text. No tool list, no environment, no history it could be tricked into leaking.
-
A self-test (
scripts/selftest.ts) that runs five canned injection attempts and five bad drafts through the guardrail on every deploy and fails the build if any pass.
Keys and ownership
Buyers of a build get the full source, a clean .env.example listing every variable with an empty value, and a HANDOVER doc for Vercel and for Ubuntu + PM2. Their Anthropic key, their Stripe key, their HubSpot token: all in their own .env.local, read only on the server. I never hold a client key. This matters more than any feature for the teams I work with, many of whom are in markets where "send us your API keys" is a non-starter.
Async by design
The same approval card renders in the dashboard and in Telegram. Someone in Lagos approves a refund from a phone at 09:30 WAT; the London accountant opens the log at 08:30 GMT and sees actor, time and target; nobody in Toronto had to be awake. Payment providers used across Africa (Paystack, Flutterwave) are first-class connectors next to Stripe, because that is what the teams asking for this actually run on.
What I would do differently
- Start with the execution diff on day one. I built triage first and the gate second; the gate is the product.
- Model the WhatsApp windowing explicitly in the data model instead of bolting it onto the classifier.
- Add the breaker before adding more connectors. Every connector is a new way for state to half-apply.
Try it
- Live sandbox, no login: https://caelaralabs.com (click "Inject crisis", then approve something)
- Source (MIT): https://github.com/kingefman1-cmyk/opsjarvis
- Telegram triage demo: https://t.me/OpsJarvisAI_bot
Happy to go deep in the comments on the approval-gate design, the breaker thresholds or the injection tests.
— OpsJarvis · Caelara Labs (@opsjarvisai)
Top comments (0)