{"_id":"@aipuna/openclaw-plugin","_rev":"2-b26cae4ef631a155db4d9c910010a495","name":"@aipuna/openclaw-plugin","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@aipuna/openclaw-plugin","version":"0.1.0","keywords":["openclaw","webrtc","datachannel","flutter","plugin"],"license":"MIT","_id":"@aipuna/openclaw-plugin@0.1.0","maintainers":[{"name":"aipuna.com","email":"npm@aipuna.com"}],"dist":{"shasum":"78d02dc967b2ca2dacbede52b6e559e023bd8321","tarball":"https://registry.npmjs.org/@aipuna/openclaw-plugin/-/openclaw-plugin-0.1.0.tgz","fileCount":17,"integrity":"sha512-q5fZ/3sRPE7L+qWNwaXhVgN55tDOb65Vv293u1xL8O3mstB93JMsPn7wFSktMSZm2mlXMkKkaETBWhkcnHRQBg==","signatures":[{"sig":"MEYCIQDZg2EpE/2xlgQuW787GqJrVOt9jpgjIZFUW3Yf9v/fywIhAMxhrFWCcgHBz0yIhxgkqDXdfMHLpW4FbsTXnu8VDZkn","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":737738},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.20.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./register":{"import":{"types":"./dist/register.d.ts","default":"./dist/register.js"},"require":{"types":"./dist/register.d.cts","default":"./dist/register.cjs"}}},"scripts":{"dev":"tsx watch src/index.ts","lint":"eslint .","test":"vitest run","build":"tsup","format":"prettier --write .","lint:fix":"eslint . --fix","typecheck":"tsc --noEmit","test:watch":"vitest","format:check":"prettier --check ."},"_npmUser":{"name":"aipuna.com","email":"npm@aipuna.com"},"openclaw":{"channel":{"id":"aipuna","blurb":"WebRTC DataChannel bridge for Flutter apps with subagent session support.","label":"AIPuna WebRTC","aliases":["aipuna","octochat"],"selectionLabel":"AIPuna (WebRTC DataChannel)"},"install":{"npmSpec":"@aipuna/openclaw-plugin","defaultChoice":"npm"},"channels":["aipuna"],"extensions":["./dist/register.js"],"installDependencies":true},"_npmVersion":"11.5.1","description":"WebRTC bridge plugin connecting Flutter apps to a local OpenClaw instance","directories":{},"_nodeVersion":"24.5.0","dependencies":{"ws":"^8.19.0","zod":"^4.3.6","pino":"^10.3.1","nanoid":"^5.1.6","node-datachannel":"^0.32.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","tsup":"^8.5.1","eslint":"^10.0.2","vitest":"^4.0.18","prettier":"^3.8.1","@types/ws":"^8.18.1","@eslint/js":"^10.0.1","typescript":"~5.9.3","pino-pretty":"^13.1.3","typescript-eslint":"^8.56.1","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.5"},"peerDependencies":{"openclaw":">=2026.2.0"},"peerDependenciesMeta":{"openclaw":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/openclaw-plugin_0.1.0_1772540839383_0.7598192023348818","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @aipuna/aipuna"}},"time":{"created":"2026-03-03T12:27:19.324Z","modified":"2026-03-04T08:22:38.229Z","0.1.0":"2026-03-03T12:27:19.547Z"},"license":"MIT","keywords":["openclaw","webrtc","datachannel","flutter","plugin"],"description":"WebRTC bridge plugin connecting Flutter apps to a local OpenClaw instance","maintainers":[{"name":"aipuna.com","email":"npm@aipuna.com"}],"readme":"# openclaw-plugin\n\nWebRTC bridge plugin that connects Flutter apps (AIPuna, Octochat) to a local OpenClaw instance via peer-to-peer DataChannel connections.\n\n## Installation\n\n```bash\nnpm install openclaw-plugin\n```\n\n**Requirements:** Node.js >= 18.20.0\n\n## Quick Start\n\n```typescript\nimport { OpenClawPlugin } from 'openclaw-plugin';\n\nconst plugin = new OpenClawPlugin({\n  gatewayUrl: 'ws://127.0.0.1:18789',\n  gatewayToken: process.env.OPENCLAW_PLUGIN_GATEWAY_TOKEN,\n  signalingUrl: 'wss://signal.example.com',\n  tokenStoragePath: './data/token.json',\n  iceServers: [{ urls: 'stun:stun.l.google.com:19302' }],\n});\n\nplugin.on('pairing:code', (code, displayText) => {\n  console.log(displayText); // formatted pairing code for terminal\n});\n\nplugin.on('pairing:complete', () => {\n  console.log('Pairing complete — token stored for future sessions');\n});\n\nplugin.on('ready', () => {\n  console.log('Plugin ready for connections');\n});\n\nplugin.on('session:connected', (peerId) => {\n  console.log(`Flutter app connected: ${peerId}`);\n});\n\nplugin.on('session:disconnected', (peerId) => {\n  console.log(`Flutter app disconnected: ${peerId}`);\n});\n\nplugin.on('error', (error) => {\n  console.error('Plugin error:', error);\n});\n\nawait plugin.start();\n```\n\n## Configuration\n\nAll settings can be provided via constructor options or environment variables. Constructor options take precedence.\n\n| Option | Env Variable | Required | Description |\n|---|---|---|---|\n| `gatewayUrl` | `OPENCLAW_PLUGIN_GATEWAY_URL` | Yes | OpenClaw gateway WebSocket URL |\n| `gatewayToken` | `OPENCLAW_PLUGIN_GATEWAY_TOKEN` | Yes | Authentication token for the gateway |\n| `signalingUrl` | `OPENCLAW_PLUGIN_SIGNALING_URL` | Yes | FastAPI signaling server URL |\n| `tokenStoragePath` | `OPENCLAW_PLUGIN_TOKEN_STORAGE_PATH` | Yes | File path for persistent token storage |\n| `iceServers` | `OPENCLAW_PLUGIN_ICE_SERVERS` | Yes | ICE server config (JSON array for env) |\n| `pluginToken` | `OPENCLAW_PLUGIN_TOKEN` | No | Pre-existing plugin token (`oc_` prefix) |\n| `logLevel` | `OPENCLAW_PLUGIN_LOG_LEVEL` | No | Log level: `fatal\\|error\\|warn\\|info\\|debug\\|trace` |\n\n### ICE Servers\n\n```typescript\n// Constructor\n{ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] }\n\n// Environment (JSON array)\nOPENCLAW_PLUGIN_ICE_SERVERS='[{\"urls\":\"stun:stun.l.google.com:19302\"}]'\n\n// TURN server with credentials\n{ iceServers: [{ urls: 'turn:turn.example.com:3478', username: 'user', credential: 'pass' }] }\n```\n\n## API Reference\n\n### `OpenClawPlugin`\n\n#### Methods\n\n| Method | Returns | Description |\n|---|---|---|\n| `start()` | `Promise<void>` | Connects to gateway and signaling. Uses stored token or enters pairing flow |\n| `stop()` | `Promise<void>` | Graceful shutdown in reverse order, emits `stopped` |\n| `getPairingCode()` | `string \\| null` | Returns the current 6-character pairing code during pairing |\n| `getActiveSessions()` | `SessionInfo[]` | Returns info about all active peer sessions |\n\n#### Events\n\n| Event | Payload | Description |\n|---|---|---|\n| `ready` | — | Plugin is connected and ready for Flutter apps |\n| `stopped` | — | Plugin has shut down |\n| `pairing:code` | `code: string, displayText: string` | A pairing code was received (display to user) |\n| `pairing:complete` | — | Pairing succeeded, token stored |\n| `session:connected` | `peerId: string` | A Flutter app established a DataChannel |\n| `session:disconnected` | `peerId: string` | A Flutter app disconnected |\n| `error` | `error: Error` | An error occurred |\n\n### Error Classes\n\nAll errors extend `OpenClawPluginError`:\n\n- `ConfigurationError` — Invalid or missing configuration\n- `SignalingConnectionError` — Signaling server connection failure\n- `OpenClawConnectionError` — Gateway connection failure\n- `WebRTCError` — WebRTC/DataChannel failure\n- `AuthenticationError` — Authentication failure\n- `TimeoutError` — Operation timed out\n- `ProtocolError` — Invalid message format\n\n## Development\n\n```bash\nnpm run build        # Build ESM + CJS + types\nnpm test             # Run tests\nnpm run test:watch   # Run tests in watch mode\nnpm run typecheck    # TypeScript type checking\nnpm run lint         # ESLint\nnpm run format       # Prettier\n```\n\n## Architecture\n\nSee [docs/architecture.md](docs/architecture.md) for module interactions and data flow.\n\n## Protocol\n\nSee [docs/protocol.md](docs/protocol.md) for the DataChannel message specification.\n","readmeFilename":"README.md"}