livetap 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/bin/livetap.js +3 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -26,6 +26,67 @@ Then ask your agent:
|
|
|
26
26
|
|
|
27
27
|
> "Connect to the IoT demo at mqtt://broker.emqx.io on topic justinx/demo/# and watch for temperature above 23 degrees"
|
|
28
28
|
|
|
29
|
+
## Setup with Claude Code (for AI agents)
|
|
30
|
+
|
|
31
|
+
If you are Claude Code or another AI agent and a user asks you to install and use livetap, follow these steps exactly:
|
|
32
|
+
|
|
33
|
+
### Step 1: Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun add livetap
|
|
37
|
+
bun pm trust livetap
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The postinstall script creates `.mcp.json` in the project root. Verify it exists:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
cat .mcp.json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
It should contain a `livetap` MCP server entry.
|
|
47
|
+
|
|
48
|
+
### Step 2: Tell the user to restart
|
|
49
|
+
|
|
50
|
+
You CANNOT restart yourself. Tell the user:
|
|
51
|
+
|
|
52
|
+
> "livetap is installed. To enable live data streaming, please restart me with:
|
|
53
|
+
> `claude --dangerously-load-development-channels server:livetap`
|
|
54
|
+
> Then ask me to connect to your data source."
|
|
55
|
+
|
|
56
|
+
### Step 3: After restart — use MCP tools
|
|
57
|
+
|
|
58
|
+
Once restarted with the channel flag, you have 12 MCP tools available. Follow this workflow:
|
|
59
|
+
|
|
60
|
+
1. **CONNECT** — `create_connection({ type: "mqtt", broker: "broker.emqx.io", port: 1883, tls: false, topics: ["justinx/demo/#"] })`
|
|
61
|
+
2. **SAMPLE** — `read_stream({ connectionId: "conn_xxx", backfillSeconds: 60, maxEntries: 10 })` — ALWAYS sample first to see field paths
|
|
62
|
+
3. **WATCH** — `create_watcher({ connectionId: "conn_xxx", conditions: [{ field: "sensors.temperature.value", op: ">", value: 50 }], match: "all", cooldown: 60 })`
|
|
63
|
+
|
|
64
|
+
### Supported source types
|
|
65
|
+
|
|
66
|
+
| Type | create_connection params | CLI |
|
|
67
|
+
|------|------------------------|-----|
|
|
68
|
+
| MQTT | `{ type: "mqtt", broker: "host", port: 1883, tls: false, topics: ["topic/#"] }` | `livetap tap mqtt://host:1883/topic/#` |
|
|
69
|
+
| WebSocket | `{ type: "websocket", url: "wss://..." }` | `livetap tap wss://...` |
|
|
70
|
+
| File | `{ type: "file", path: "/var/log/app.log" }` | `livetap tap file:///var/log/app.log` |
|
|
71
|
+
|
|
72
|
+
### Data shape by source
|
|
73
|
+
|
|
74
|
+
- **MQTT/WebSocket (JSON):** payload is parsed. Use dot-paths: `sensors.temperature.value`
|
|
75
|
+
- **File (plain text):** field is `payload`. Use: `{ field: "payload", op: "contains", value: "ERROR" }` or `{ field: "payload", op: "matches", value: "5[0-9]{2}" }`
|
|
76
|
+
- **File (JSON lines):** parsed. Use dot-paths: `level`, `msg`
|
|
77
|
+
- **IMPORTANT:** always `read_stream` first. The field is `payload`, NOT `line` or `message`.
|
|
78
|
+
|
|
79
|
+
### Watcher operators
|
|
80
|
+
|
|
81
|
+
`>`, `<`, `>=`, `<=`, `==`, `!=`, `contains`, `matches` (regex)
|
|
82
|
+
|
|
83
|
+
### If the daemon is not running
|
|
84
|
+
|
|
85
|
+
The MCP proxy auto-starts the daemon. If it fails, run:
|
|
86
|
+
```bash
|
|
87
|
+
livetap start
|
|
88
|
+
```
|
|
89
|
+
|
|
29
90
|
## What it does
|
|
30
91
|
|
|
31
92
|
livetap runs a background daemon that connects to live data sources, buffers messages in embedded Redis, and pushes alerts into your Claude Code session via the [Channels API](https://code.claude.com/docs/en/channels). Your agent sees the data in real-time and can create expression-based watchers that fire when conditions match.
|
package/bin/livetap.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livetap",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Push live data streams into your AI coding agent. Connect MQTT, WebSocket, or
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Push live data streams into your AI coding agent. Connect MQTT brokers, WebSocket feeds, or tail log files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"livetap": "./bin/livetap.
|
|
7
|
+
"livetap": "./bin/livetap.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postinstall": "bun ./scripts/postinstall.ts",
|