Developers

One object model. Pluggable engines.

Everything in SafeTool — the home page, every tool, the workbench and the space — runs on the same pipeline: objects go through engines, engines produce findings anchored to evidence, moves turn findings into new verified versions.

Architecture

From an object to an action

  1. ObjectA link, email, file, text or value, with versions and children (attachments, extracted links).
  2. EnginesPhase 1 parses, phase 2 inspects locally, phase 3 enriches over the network with consent.
  3. FindingsSeverity, lens, confidence and anchors to the exact evidence (text range, field, region, node, byte offset).
  4. MovesTransforms, extractions and lookups. Transforms create a new version that is analyzed again.

Entities (domains, IPs, people, wallets…) and relations connect objects across a case; the space visualizes them. Every event lands on the case’s trust timeline.

Engines

Write an engine

Engines are plain modules registered at startup. They receive a context with the object, its bytes or text, your rules, and functions to report findings, entities, relations, facts and child objects. Network engines declare a service and are skipped until the user consents.

import { registerEngine } from '@/core/engine';

registerEngine({
  id: 'sec.my-check',
  name: 'My check',
  description: 'Flags invoices that ask for gift cards.',
  lenses: ['security'],
  phase: 2,                       // 1 parse · 2 inspect (local) · 3 enrich (network)
  accepts: (o) => o.kind === 'text' || o.kind === 'email',
  rules: [{ id: 'my.giftcard', title: 'Gift-card payment', lens: 'security', severity: 'high', description: '…' }],
  async run(ctx) {
    const text = ctx.text();                       // body text for emails, text for documents
    const m = /gift ?cards?/i.exec(text ?? '');
    if (!m) return;
    ctx.finding({
      rule: 'my.giftcard',
      lens: 'security',
      severity: 'high',
      title: 'Asks for payment in gift cards',
      detail: 'Legitimate businesses do not invoice in gift cards.',
      confidence: 0.9,
      anchors: [{ type: 'text', start: m.index, end: m.index + m[0].length, quote: m[0] }],
    });
  },
});

Server-side engines (YARA-X, Presidio, Gitleaks, a malware sandbox) plug in the same way: an engine with requiresEdge: true posts the object to an edge route and maps the response to findings.

Moves

Add a move

import { registerMove } from '@/core/moves';

registerMove({
  id: 'text.defang-links',
  title: 'Defang links',
  verb: 'Defang',
  description: 'Make links unclickable before pasting them into a report.',
  kind: 'transform',
  icon: 'link',
  intents: ['share', 'investigate'],
  appliesTo: (o) => o.kind === 'text',
  async run(o) {
    const text = (o.text ?? '').replace(/https?:\/\//g, 'hxxps://').replace(/\./g, '[.]');
    // A transform returns a new version; SafeTool re-analyzes it and keeps the original.
    return { type: 'version', text, summary: 'Links defanged', changes: ['links'] };
  },
});
Edge API

The Cloudflare Worker

The app works without it. When deployed, the worker adds services that need a secret or must not run in the browser. Every response is JSON; every call from the app is consent-gated and logged in the privacy ledger.

EndpointPurposeResponse
GET /api/healthWhich edge services are configured{ ok, version, services: { ipinfo, webrisk, ct, fetch, claude }, model? }
GET /api/ip/:ipIP owner, ASN and country (IPinfo Lite){ ip, asn, as_name, as_domain, country, country_code, continent }
GET /api/webrisk?uri=Google Web Risk lookup for a URL{ threat?: { threatTypes[], expireTime } }
GET /api/ct?domain=Certificate Transparency summary (crt.sh){ count, first?, last?, names[], issuers[] }
GET /api/fetch?url=Isolated page fetch with SSRF guard{ status, finalUrl, redirects[], headers, html?, tls, error? }
POST /api/aiClaude answer over finding summaries{ answer, evidence[], moves[], uncertainty?, model, refused? }

AI contract

The worker calls Claude with a JSON schema for the answer. The app checks every cited finding id and every proposed move against local state before showing anything.

POST /api/ai
{
  "question": "Is this email legit?",
  "intent": "check",
  "context": [{
    "ref": "O1", "name": "Invoice #88213 …", "kind": "email", "posture": "Serious concerns",
    "facts": ["Authentication / SPF: fail", …],
    "findings": [{ "id": "f_…", "severity": "high", "lens": "authenticity", "title": "…", "detail": "…" }],
    "moves": ["email.extract-links: Inspect links individually", …],
    "excerpt": "… only when the user allows excerpts …"
  }],
  "selection": "optional selected text"
}

200 OK
{
  "answer": "Treat it as phishing: …",
  "evidence": ["f_…", "f_…"],            // must be finding ids from the context
  "moves": [{ "move": "email.extract-links", "object": "O1", "label": "Inspect the links" }],
  "uncertainty": "DNS was not checked.",
  "model": "claude-opus-5-5"
}
Configuration

Secrets stay on the server

VariableEnablesSet with
IPINFO_TOKENIP lookups via IPinfo Litewrangler secret put IPINFO_TOKEN
GOOGLE_WEB_RISK_API_KEYURL reputation via Google Web Riskwrangler secret put GOOGLE_WEB_RISK_API_KEY
ANTHROPIC_API_KEYClaude answers (POST /api/ai)wrangler secret put ANTHROPIC_API_KEY
ANTHROPIC_MODELOptional model override (default claude-opus-5-5)vars in wrangler.jsonc

For local development put them in .dev.vars (git-ignored). Without them the corresponding checks report “not configured” and everything else keeps working.

Licences

Open source underneath

Runtime dependencies use permissive licences compatible with commercial, ad-supported use. Network data sources have their own terms — see the Trust center.

ProjectLicenceUsed for
React, React Router, zustand, immerMITUI and state
pdf.js (pdfjs-dist)Apache-2.0PDF parsing and rendering
pdf-libMITPDF sanitize and flatten
exifrMITEXIF, XMP, IPTC, GPS
postal-mimeMIT-0Email (RFC 822) parsing
DOMPurifyMPL-2.0 or Apache-2.0Safe email/HTML previews
fflateMITZIP / OOXML / gzip
jsQRApache-2.0QR decoding
hash-wasmMITMD5, SHA-3, BLAKE3, CRC32
d3-forceISCGraph layout
diffBSD-3-ClauseVersion comparison
lucide-reactISCIcons
Geist, Instrument SerifOFL-1.1Fonts
@anthropic-ai/sdk (edge)MITClaude API client

Ideas from CyberChef (Apache-2.0), Presidio, Gitleaks, YARA/YARA-X, C2PA and Web-Check informed the engines; their code is not bundled.