Live demo: corpuslaw.us/autopilot — the Formation
Autopilot chat, backed by this repo's agent running on Alibaba Cloud Function Compute
(us-west-1, config in autopilot/deploy/alibaba/s.yaml).
API health: curl https://formatiutopilot-bfmjghskwt.us-west-1.fcapp.run/healthz → ok.
(The raw fcapp.run URL force-downloads HTML on FC's default domain — use the hosted page in a browser.)
Open-source connector kit for the Corpus legal platform:
- autopilot/ — Formation Autopilot: a Qwen Cloud agent that turns an ambiguous founder description into a cited launch checklist and a prefilled, human-approved formation handoff. (Qwen Hackathon Track 4 entry.)
- mcp-server/ — zero-dependency stdio MCP server exposing Corpus law search to Claude Desktop, Cursor, and any MCP client.
- widget/ — embeddable law-search widget (Preact, ~12 kB gzipped).
All three are thin clients of the hosted Corpus platform. The law corpus, hybrid search engine, human approval gate, and filing execution live in the hosted service — this repo never touches money or files anything.
See docs/architecture.md for the Mermaid source.
| Layer | This repo (Apache-2.0) | Hosted Corpus platform (closed) |
|---|---|---|
| Formation Autopilot agent | ✅ autopilot/ |
— |
| Two-lane Qwen routing | ✅ autopilot/src/ |
— |
MCP stdio bridge (corpus-mcp) |
✅ mcp-server/ |
— |
| Embeddable widget | ✅ widget/ |
— |
| Law database (~186 K nodes, Aurora) | — | ✅ |
Hybrid search engine + /api/mcp |
— | ✅ |
/formation checkout + GATE 2 |
— | ✅ |
| Stripe payment + state filing execution | — | ✅ |
The autopilot uses two Qwen models with different cost/quality profiles:
- Fast lane (
QWEN_MODEL_FAST, defaultqwen-flash): all standard turns — intent parsing, law search, checklist generation. Low latency, low spend. - Critical lane (
QWEN_MODEL_CRITICAL, defaultqwen3.7-max): the final pre-handoff draft review only. Higher quality for the one turn that shapes the prefilled filing URL.
The lane switch is automatic. Routing logic lives in autopilot/src/agent.ts.
The hourly spend cap (SPEND_CAP_TURNS_PER_HOUR) applies across both lanes.
The autopilot produces a prefilled draft URL — it never initiates a filing or charges a card. On the Corpus platform side, every order passes GATE 2: a human reviews and approves a snapshot of the exact filing payload, and that approval is cryptographically bound to a hash of the payload. If the payload changes by a single byte after approval, the gate rejects it. The agent is architecturally incapable of bypassing this.
node >=20
npm >=9
Clone and install all workspaces:
git clone https://github.com/teakesdev/corpus-agent-kit.git
cd corpus-agent-kit
npm installCopy and fill .env.example (required for autopilot; mcp-server and widget
read CORPUS_BASE_URL / CORPUS_API_KEY from env at runtime):
cp .env.example .env
# edit .env — at minimum set QWEN_API_KEY and CORPUS_API_KEY| Variable | Default | Purpose |
|---|---|---|
QWEN_API_KEY |
(required) | Qwen Cloud API key |
QWEN_BASE_URL |
(required) | Qwen OpenAI-compatible base URL (e.g. https://dashscope-intl.aliyuncs.com/compatible-mode/v1) |
QWEN_MODEL_FAST |
qwen-flash |
Fast-lane model — standard turns |
QWEN_MODEL_CRITICAL |
qwen3.7-max |
Critical-lane model — pre-handoff review |
CORPUS_BASE_URL |
https://corpuslaw.us |
Hosted Corpus platform base URL |
CORPUS_API_KEY |
(optional) | Corpus platform API key (optional — anonymous is rate-limited) |
SPEND_CAP_TURNS_PER_HOUR |
120 |
Abuse guard: max agent turns per hour |
PORT |
9000 |
HTTP server port (autopilot backend) |
cp .env.example .env # fill QWEN_API_KEY + CORPUS_API_KEY
npm install
npm run build # compiles all workspaces
cd autopilot && npm start # starts the autopilot HTTP server
# open http://localhost:9000The server exposes:
GET /healthz— liveness probePOST /api/chat— agent turn endpointGET /— chat UI
Deploy to Alibaba Cloud Function Compute: see autopilot/deploy/alibaba/README.md.
Build locally:
cd mcp-server && npm install && npm run buildAdd to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"corpus-law": {
"command": "node",
"args": ["/absolute/path/to/corpus-agent-kit/mcp-server/dist/index.js"]
}
}
}Replace /absolute/path/to/corpus-agent-kit with the actual path to your clone.
Note: The package name
@corpus-agent-kit/mcp-serveris reserved for a future npm publish; until then, build locally and point your MCP client atmcp-server/dist/index.js. HTTP MCP clients: the hosted endpointhttps://corpuslaw.us/api/mcpsupports the streamable-HTTP MCP transport directly — no local bridge needed.
This exposes three tools: search_law, get_law_node, list_coverage.
cd widget
npm run build # outputs dist/widget.js (loader) and dist/widget-app.js (app)Embed in any page using the hosted loader. Point src at the Corpus host (a relative
path would 404 on the host page's own origin) and pass your widget key (pk_…):
<script async src="https://corpuslaw.us/widget/widget.js"
data-corpus-key="pk_live_…"
data-corpus-origin="https://corpuslaw.us"></script>See autopilot/deploy/alibaba/README.md for
Function Compute deploy instructions (Serverless Devs s CLI).
Apache-2.0 — see LICENSE.
