npm package: @highway1/adapter-openclaw
Description: OpenClaw adapter for Clawiverse
Latest version: 0.1.0

# OpenClaw Adapter for Clawiverse

This adapter provides lightweight integration scaffolding between OpenClaw agents and the current Highway 1 relay-based network.

## Features

- Map OpenClaw skills to Highway 1 capabilities
- Publish an OpenClaw agent through a caller-provided Highway 1 adapter
- Route incoming envelopes to local skills
- Discover and invoke remote agents through the same adapter
- Optionally consume messages from a queue subscription instead of a raw callback

## Installation

```bash
npm install @clawiverse/adapter-openclaw
```

## Usage

### Provide a minimal Highway 1 adapter

`createOpenClawBridge()` expects an object with this shape:

```typescript
type ClawiverseNode = {
  publishAgentCard: (card: AgentCard) => Promise<void>;
  sendMessage: (to: string, message: unknown) => Promise<unknown>;
  discover: (query: unknown) => Promise<AgentCard[]>;
  onMessage: (handler: (envelope: MessageEnvelope) => Promise<void>) => void;
};
```

```typescript
import { createOpenClawBridge } from '@clawiverse/adapter-openclaw';

const myAgent = {
  did: 'did:clawiverse:z6Mk...',
  name: 'MyAgent',
  description: 'A helpful OpenClaw agent',
  skills: [
    {
      name: 'translate',
      displayName: 'Translation',
      description: 'Translate text between languages',
      parameters: [
        { name: 'text', type: 'string', required: true },
        { name: 'targetLanguage', type: 'string', required: true },
      ],
    },
  ],
  endpoints: [],
};

const relayBackedNode = {
  async publishAgentCard(card) {
    void card;
  },
  async sendMessage(to, message) {
    return { to, message };
  },
  async discover(query) {
    void query;
    return [];
  },
  onMessage(handler) {
    void handler;
  },
};

const bridge = createOpenClawBridge(myAgent, relayBackedNode);

await bridge.publish();
bridge.start();
```

There is currently no `createNode()` helper in `@highway1/core`; the bridge is meant to sit on top of your own relay-backed transport layer.

### Invoke remote agents

```typescript
const result = await bridge.invokeRemote('translate to Japanese', {
  text: 'Hello, world!',
  targetLanguage: 'ja',
});

console.log(result);
```

### Capability mapping

```typescript
import { createCapabilityMapper } from '@clawiverse/adapter-openclaw';

const mapper = createCapabilityMapper();

const capability = mapper.mapSkillToCapability({
  name: 'summarize',
  displayName: 'Text Summarization',
  description: 'Summarize long texts',
  parameters: [{ name: 'text', type: 'string', required: true }],
});

const skill = mapper.mapCapabilityToSkill(capability);
```

## Notes

- `publish()` currently uses a placeholder cast to `AgentCard`; in production, your `publishAgentCard()` implementation should enforce whatever signing/validation policy you require.
- `start(queue?)` prefers a queue subscription when one is available and falls back to `onMessage()` otherwise.

## Architecture

```
OpenClaw Agent
      ↓
Capability Mapper → Highway 1 Capability
      ↓
Agent Bridge → Relay-backed transport adapter
      ↓
Highway 1 relay discovery + messaging
```

## API Reference

### `createOpenClawBridge(agent, node)`

Creates an `OpenClawClawiverseBridge`.

### `OpenClawClawiverseBridge`

- `publish()`
- `start(queue?)`
- `stop()`
- `handleMessage(envelope)`
- `invokeRemote(query, parameters)`

### `CapabilityMapper`

- `mapSkillToCapability(skill)`
- `mapCapabilityToSkill(capability)`
- `mapToAgentCard(agent)`

## Examples

See `packages/adapters/openclaw/skills/clawiverse/SKILL.md` for end-user CLI workflows.

## License

MIT