Skip to main content
Clavion is organized as an npm workspaces monorepo. Each package maps to one of the three architectural trust domains. This page is a comprehensive map of the entire codebase.

Top-Level Layout

packages/              -- All packages (see below)
tests/                 -- Cross-package integration, security, and e2e tests
tools/                 -- Fixture generation, hash utilities
examples/              -- Example scripts and policy configs
docs/                  -- Architecture docs, API reference, guides
docker/                -- Dockerfile and Docker Compose configuration
scripts/               -- Demo scripts (demo-transfer.ts, demo-swap.ts)
openclaw-skills/       -- OpenClaw skill packages (SKILL.md + runner scripts)
Every component belongs to exactly one trust domain. The tabs below walk through every package, file, and its role.
Domain B is the trusted core. Private keys, policy evaluation, signing, audit logging, and RPC access all live here. No adapter or agent code runs in this domain. This is the only place where private keys exist and transactions are signed.

packages/types — @clavion/types

Shared TypeScript interfaces and JSON Schemas used across all packages.
packages/types/
  src/
    index.ts                             -- Shared TypeScript interfaces (TxIntent, BuildPlan, etc.)
    intent-utils.ts                      -- Intent helper utilities
    schemas/
      txintent-schema.ts                 -- TxIntent v1 JSON Schema (AJV strict mode)
      skill-manifest-schema.ts           -- SkillManifest v1 JSON Schema

packages/audit — @clavion/audit

Append-only audit trail backed by SQLite. Every fund-affecting operation is logged and correlated by intentId.
packages/audit/
  src/
    audit-trace-service.ts               -- Append-only SQLite event log, rate limit tracking

packages/policy — @clavion/policy

Policy engine that evaluates each TxIntent and returns allow, deny, or require_approval.
packages/policy/
  src/
    policy-engine.ts                     -- Intent evaluation: allow / deny / require_approval
    policy-config.ts                     -- Config schema and loader

packages/signer — @clavion/signer

Encrypted keystore and signing pipeline. Keys are encrypted at rest with scrypt + AES-256-GCM.
packages/signer/
  src/
    keystore.ts                          -- EncryptedKeystore (scrypt + AES-256-GCM)
    wallet-service.ts                    -- Signing pipeline
    mnemonic.ts                          -- BIP-39 mnemonic import with HD derivation

packages/preflight — @clavion/preflight

Simulates transactions via eth_call and scores risk before approval.
packages/preflight/
  src/
    preflight-service.ts                 -- eth_call simulation + risk scoring
    risk-scorer.ts                       -- 7 additive rules, capped at 100

packages/registry — @clavion/registry

Skill manifest validation, signing, and registry. Ensures only verified skills can interact with the system.
packages/registry/
  src/
    skill-registry-service.ts            -- Orchestrates skill registration pipeline
    manifest-signer.ts                   -- ECDSA sign/verify (viem)
    file-hasher.ts                       -- SHA-256 file integrity
    static-scanner.ts                    -- 5 rule categories for code analysis

packages/core — @clavion/core

The main API server, transaction builders, approval flow, multi-chain RPC routing, and the 1inch DEX aggregator integration.
packages/core/
  src/
    main.ts                              -- Production entry point
    demo-boot.ts                         -- Demo mode: auto-unlock + auto-approve
    index.ts                             -- Public re-exports
    api/
      app.ts                             -- Fastify app builder and service wiring
      routes/
        health.ts                        -- GET /v1/health
        tx.ts                            -- POST /v1/tx/* (build, preflight, approve-request, sign-and-send)
        balance.ts                       -- GET /v1/balance/:token/:account
        skills.ts                        -- Skill registry CRUD routes
        approval-ui.ts                   -- Web approval routes + inline HTML dashboard
    tx/builders/
      index.ts                           -- Action type -> builder dispatcher (async)
      transfer-builder.ts                -- ERC-20 transfer calldata
      transfer-native-builder.ts         -- Native ETH transfer
      approve-builder.ts                 -- ERC-20 approve calldata
      swap-builder.ts                    -- UniswapV3 SwapRouter02 calldata
      swap-oneinch-builder.ts            -- 1inch Swap API v6 calldata
      build-utils.ts                     -- Shared: txRequest hashing
    aggregator/
      oneinch-client.ts                  -- 1inch HTTP client (fetch + AbortController)
      oneinch-types.ts                   -- 1inch API request/response types
      oneinch-routers.ts                 -- Known 1inch router addresses per chain
    approval/
      approval-service.ts                -- User confirmation prompt (CLI or web)
      approval-token-manager.ts          -- Single-use TTL tokens
      pending-approval-store.ts          -- In-memory store bridging web UI to blocking promptFn
    rpc/
      rpc-router.ts                      -- Multi-chain RPC routing
      resolve-rpc.ts                     -- Chain-scoped RPC resolution
      parse-rpc-env.ts                   -- ISCL_RPC_URL_{chainId} env parser
      build-rpc-client.ts                -- RPC client factory
      viem-rpc-client.ts                 -- Viem-based RPC implementation
    canonicalize/
      intent-hash.ts                     -- JCS + keccak256
    schemas/
      validator.ts                       -- AJV strict-mode validator

CLI and SDK

The CLI provides key management commands. The SDK is a planned interface stub for v0.2.
packages/cli/                            @clavion/cli
  src/
    main.ts                              -- Entry point (clavion-cli)
    commands/
      key.ts                             -- Key management: import, import-mnemonic, generate, list
    io.ts                                -- Masked passphrase input, injectable I/O

packages/sdk/                            @clavion/sdk
  src/
    index.ts                             -- SDK interface (stub, v0.2)

Fixtures and Tools

Test fixtures live in tools/fixtures/. One valid fixture exists per action type, plus invalid and edge-case variants.
tools/fixtures/
  valid-intents.ts                       -- Valid TxIntent per action type (6 fixtures)
  invalid-intents.ts                     -- Edge cases and malformed intents
  skill-manifests.ts                     -- Skill manifest examples
  hash-fixtures.ts                       -- Expected keccak256 hashes
  generate-hashes.ts                     -- Regenerate hash fixtures
  index.ts                               -- Re-exports all fixtures
  mock-rpc.ts                            -- Mock RPC factory for tests
  test-keys.ts                           -- Test key material
  test-policy.ts                         -- Test policy configurations

Tests

tests/
  integration/                           -- HTTP API, adapter client, skill wrappers, rate limiting
  security/                              -- Trust domain isolation, sandbox escape, tampered packages
  e2e/                                   -- Anvil fork: full build -> sign -> broadcast flow
  helpers/                               -- Anvil fork management, Docker availability check
packages/*/test/                         -- Per-package unit tests

Docker

docker/
  Dockerfile.core                        -- Multi-stage build: Node 20 Alpine, non-root iscl user
  compose.yaml                           -- 3-service stack: Anvil, ISCL Core, OpenClaw (demo profile)