# Moltlazy

Admin HTTP RPC SDK and declarative configuration for OpenClaw container startup.

> This module is owned by the **Paso4 developers** and is an external addition to the base Cloudflare Worker project.

## Documentation

Full documentation is available in the [`docs/`](./docs/) directory:

- [Overview](/llms/platform/libraries/moltlazy/overview/index.md) — What is moltlazy and why it exists
- [Quickstart](/llms/platform/libraries/moltlazy/quickstart/index.md) — Get running in 5 minutes
- [Concepts](/llms/platform/libraries/moltlazy/concepts/index.md) — Config Module and typed RPC client architecture
- [SDK Domain Modules](/llms/platform/libraries/moltlazy/feature-packs/index.md) — config, agents, channels, devices, cron, models, gateway
- [Startup Flow](/llms/platform/libraries/moltlazy/orchestration/index.md) — How both systems work together at startup
- [Feature Flags Reference](/llms/platform/libraries/moltlazy/feature-flags-reference/index.md) — JSON feature flags format
- [Migration Guide (v0.2 → v0.3)](/llms/platform/libraries/moltlazy/migration/index.md) — Migrate from filesystem patching

## Purpose (v0.3.0)

Moltlazy provides two capabilities:

1. **Config Module** (`src/config/` + `index.ts` + `cli.ts`) — Generates immutable per-section include files (`moltlazy-session.json`, `moltlazy-tools.json`, `moltlazy-logging.json`) at container startup and injects them into `openclaw.json` as per-section `$include` directives (never a root `$include`, which would fail closed for Control UI saves). `gateway.*` and `agents.*` are written inline (onboard owns the gateway base; the gateway token is an env SecretRef). Replaces direct filesystem patching.

2. **SDK Module** (`sdk/`) — Typed RPC client over the [OpenClaw Admin HTTP RPC](https://docs.openclaw.ai/plugins/admin-http-rpc.md) API. No filesystem writes — direct typed calls to a running gateway via `POST /api/v1/admin/rpc`.

```ts
import { createClient } from 'moltlazy/sdk';

const client = createClient({
  baseUrl: 'http://localhost:18789',
  token: process.env.OPENCLAW_GATEWAY_TOKEN!,
});

const agents = await client.agents.list();
await client.config.set({ raw: JSON.stringify({ session: { dmScope: 'per-channel-peer' } }) });
await client.gateway.restart();
```

## Development

Requires [Bun](https://bun.sh).

```bash
bun install       # install deps
bun run build     # compile TypeScript → dist/
bun test          # run unit tests (vitest)
bun run typecheck # type-check without emitting
bun run lint      # lint with oxlint
```

## Testing

608 tests across 33 test files.

```bash
bun test                    # all tests
bun test sdk/               # SDK tests only
bun test tests/config/      # Config Module tests only
```
