Skip to content

Repository files navigation

Langclaw Backend

Node.js HTTP API (langclaw-backend) for Langclaw and Langclaw: agent workflows, 0G integrations, Supabase persistence, usage billing, and OpenAI-compatible 0G Compute proxy.

Organization: Langclaw-AI · Frontend: Langclaw-AI/frontend · Contracts: Langclaw-AI/contracts

Responsibilities

  • LangclawrunLangclawWorkflow(topic) via POST /api/discover and /api/discover/stream
  • ChatPOST /api/chat/stream, session sync to Supabase
  • Account — wallet auth, API keys (HMAC), memory, automation, usage ledger
  • 0G — Compute Router proxy (/v1/*), Storage uploads, Chain registry calls
  • On-chain tools — optional Alchemy, Dune, DeFiLlama, etc.

Local setup

cp .env.example .env
npm install
npm run dev

Default: http://localhost:3001

curl http://localhost:3001/health

Production:

npm run build && npm start

HTTP routes

Defined in src/server.ts:

Area Endpoints
Health GET /health
Research POST /api/discover, POST /api/discover/stream
Chat POST /api/chat/stream, POST /api/chat/sessions
Memory POST /api/memory, POST /api/memory/settings
API keys POST /api/api-keys
Usage POST /api/usage/balance, quote, deposit/verify, withdraw/request
Automation POST /api/automation/*, webhooks, Telegram
0G proxy GET/POST /v1/*, GET/POST /api/0g/*

Full request/response shapes: docs/API_REFERENCE.md.

Langclaw + OpenClaw

OpenClaw runs reasoning steps (openclaw agent --json); discovery and provider calls stay in TypeScript.

runLangclawWorkflow(topic)
  → Planner (OpenClaw)
  → Discovery (TS: X/Brave, GitHub, Tavily, HackQuest)
  → Source normalizer (TS)
  → Trend scorer (OpenClaw)
  → Evidence packager (OpenClaw)
  → Verifier (OpenClaw)
  → Final conclusion (0G Compute → OpenClaw → fallback)
  → 0G Storage upload → LangclawRegistry anchor

Skills: openclaw/skills/ — see openclaw/README.md.

X discovery defaults to Brave (X_DISCOVERY_PROVIDER=brave). Use x-api only with X_BEARER_TOKEN and credits.

OpenClaw install (optional, recommended for demos)

curl -fsSL https://openclaw.ai/install.sh | bash
openclaw onboard --install-daemon
openclaw doctor

Env (see .env.example):

OPENCLAW_ENABLED=true
OPENCLAW_WORKFLOW_ENABLED=true
OPENCLAW_AI_SYNTHESIS=true

Environment

Copy .env.example. Minimum for a useful dev server:

Variable Purpose
SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY Persistence
LANGCLAW_API_KEY_PEPPER API key hashing
OG_COMPUTE_API_KEY, OG_COMPUTE_ENABLED Model proxy
CORS_ORIGIN Frontend origin (default http://localhost:3000)

Langclaw providers: BRAVE_SEARCH_API_KEY, GITHUB_TOKEN, TAVILY_API_KEY, …

0G proof: OG_STORAGE_*, OG_CHAIN_*, LANGCLAW_REGISTRY_ADDRESS

Billing: LANGCLAW_USAGE_VAULT_ADDRESS — deploy from Langclaw-AI/contracts

Supabase

Apply migrations under supabase/migrations/. Clients never write directly; the server uses the service role key.

Smart contracts

Contract Deploy Env
LangclawUsageVault Langclaw-AI/contracts LANGCLAW_USAGE_VAULT_ADDRESS
LangclawRegistry npm run deploy:registry LANGCLAW_REGISTRY_ADDRESS

Registry source: contracts/LangclawRegistry.sol

Deposit verification: src/lib/usage.tsPOST /api/usage/deposit/verify

Vault spec: docs/SMART_CONTRACT_TEAM_NOTES.md

Scripts

npm run dev          # tsx watch src/server.ts
npm run build        # tsc → dist/
npm start            # node dist/server.js
npm test             # node --test
npm run deploy:registry

Related docs

File Description
docs/API_REFERENCE.md Full API
LANGCLAW_BLUEPRINT.md Hackathon blueprint
docs/DEMO_SCRIPT.md Demo video script
docs/SMART_CONTRACT_TEAM_NOTES.md Vault requirements

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages