Legal AI Project
An OpenClaw extension that enables AI-assisted legal document search, ingestion, and retrieval with mTLS-secured file-agent deployment and optional MinIO object storage.
Repository Layout
legal-ai-project/
├── extension/ # legal-docs OpenClaw plugin (TypeScript)
├── file-agent/ # Lightweight file-agent v1 — pre-built binaries + deploy scripts
├── file-agent-go/ # Full-featured file-agent v2 — build from source (Docker, YAML config)
├── config/
│ ├── openclaw.json.example # Full plugin configuration template
│ ├── schema.sql # PostgreSQL tables (documents + audit_log)
│ └── .env.example # Environment variable reference
├── scripts/
│ ├── setup-pki.sh # One-shot CA + client-cert generator
│ └── install-extension.sh # Copies extension into ~/.openclaw + npm install
└── certs/ # PKI output (gitignored — never commit *.key files)
---
Prerequisites
| Requirement | Notes | |---|---| | OpenClaw engine | Docker Compose or standalone | | Node.js ≥ 18 | For the extension | | Go 1.22+ | To rebuild file-agent-go from source (optional) | | OpenSSL | For PKI setup | | PostgreSQL | Tables in config/schema.sql | | Qdrant | Vector store — default collection legal_documents | | Apache Tika | Document text extraction | | rsync | Required by scripts/install-extension.sh |
---
Quick Start
1 Clone
git clone <your-fork-url> legal-ai-project
cd legal-ai-project
2 Generate PKI (CA + engine client certificate)
./scripts/setup-pki.sh
Outputs to certs/: ca.crt, ca.key, agent.crt, agent.key.
Copy the engine certs to your OpenClaw data directory:
mkdir -p ~/.openclaw/certs
cp certs/ca.crt certs/agent.crt certs/agent.key ~/.openclaw/certs/
3 Configure
cp config/openclaw.json.example ~/.openclaw/openclaw.json
Edit ~/.openclaw/openclaw.json — fill in real values for Qdrant, PostgreSQL, Tika, and the embedding API. Keep the fileAgent.caCert / clientCert / clientKey paths pointing to ~/.openclaw/certs/.
Apply database schema:
psql -h <host> -U openclaw_admin -d openclaw -f config/schema.sql
4 Install the extension
./scripts/install-extension.sh
Optional: --openclaw-dir /custom/path to override the default ~/.openclaw.
Restart OpenClaw:
docker compose restart openclaw-gateway # Docker
# or: systemctl restart openclaw
---
Deploying the File Agent
The file-agent runs on each machine that holds legal documents. It exposes a TLS-authenticated HTTP API that the OpenClaw plugin calls to scan folders and fetch file content.
Option A — Pre-built binary (file-agent v1)
Simplest option; uses command-line flags.
cd file-agent
# 1. Issue a server certificate for the target host
./issue-server-cert.sh <hostname-or-IP>
# reads CA from ../certs/ (project root)
# writes server-<host>.crt / .key to ../certs/
# 2. Deploy the binary + certs to the remote host
./deploy-linux.sh user@<host> /opt/file-agent
# copies binary and certs via scp, starts the agent
Windows: copy dist/file-agent-windows-amd64.exe manually and run with the appropriate flags (see output of --help).
Option B — Full-featured build (file-agent-go v2)
Supports YAML config, hot-watching folders, rate limiting, and Tika text extraction.
Build from source:
cd file-agent-go
go build -o dist/file-agent ./cmd/file-agent
Or via Docker:
docker build -t file-agent .
docker run -v /etc/file-agent:/etc/file-agent file-agent
Copy scripts/install-linux.sh to the target host and run as root — it creates a openclaw-agent system user, installs the binary to /opt/openclaw-file-agent/, and writes a default config.yaml.
> Note: The pre-built binaries in file-agent-go/dist/ were compiled from v1 source and do not include YAML-config features. Rebuild from file-agent-go/ source for full functionality.
---
Optional: MinIO Object Storage
No agent is required. Add a minio block to your openclaw.json plugin config (see config/openclaw.json.example). The plugin reads directly from the bucket using the legal_docs_list_minio + legal_docs_ingest (source: "minio") tools.
---
Extension Tool Reference
| Tool | Description | |---|---| | legal_docs_ingest | Ingest a document from file-agent or MinIO into Qdrant + Postgres | | legal_docs_search | Semantic search with classification filter | | legal_docs_get | Retrieve full document by ID | | legal_docs_audit | Query the audit log | | legal_docs_list_minio | List objects in the configured MinIO bucket |
See extension/README.md for full options and examples.
---
Security Notes
certs/*.keyand.envare gitignored — never commit private keys.- All file-agent communication is mutual TLS (both sides present a certificate).
- Classification labels (
PUBLIC,INTERNAL,CONFIDENTIAL,RESTRICTED) are enforced at the database level via CHECK constraints. - All AI-model interactions against classified documents are recorded in
audit_log.










