livetap 0.1.0
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/LICENSE +21 -0
- package/README.md +223 -0
- package/bin/livetap.ts +33 -0
- package/package.json +43 -0
- package/scripts/postinstall.ts +75 -0
- package/src/cli/daemon-client.ts +43 -0
- package/src/cli/help.ts +9 -0
- package/src/cli/sip.ts +63 -0
- package/src/cli/start.ts +75 -0
- package/src/cli/status.ts +45 -0
- package/src/cli/stop.ts +64 -0
- package/src/cli/tap.ts +94 -0
- package/src/cli/taps.ts +32 -0
- package/src/cli/untap.ts +23 -0
- package/src/cli/unwatch.ts +23 -0
- package/src/cli/watch.ts +91 -0
- package/src/cli/watchers.ts +116 -0
- package/src/mcp/channel.ts +121 -0
- package/src/mcp/tools.ts +314 -0
- package/src/server/connection-manager.ts +171 -0
- package/src/server/connections/file.ts +123 -0
- package/src/server/connections/mqtt.ts +104 -0
- package/src/server/connections/webhook.ts +54 -0
- package/src/server/connections/websocket.ts +154 -0
- package/src/server/index.ts +255 -0
- package/src/server/redis.ts +62 -0
- package/src/server/types.ts +94 -0
- package/src/server/watchers/engine.ts +70 -0
- package/src/server/watchers/manager.ts +354 -0
- package/src/server/watchers/types.ts +44 -0
- package/src/shared/catalog-generators.ts +125 -0
- package/src/shared/command-catalog.ts +143 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Catalog — single source of truth for all CLI commands and MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Consumed by:
|
|
5
|
+
* 1. src/mcp/tools.ts → MCP tool registration (imports TOOLS directly)
|
|
6
|
+
* 2. src/mcp/channel.ts → LLM instructions (imports generateInstructions)
|
|
7
|
+
* 3. bin/livetap.ts --help → human-readable help (imports generateHelpText)
|
|
8
|
+
* 4. bin/livetap.ts --llm-help → machine-readable JSON (imports generateLlmHelp)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface CatalogCommand {
|
|
12
|
+
name: string
|
|
13
|
+
usage: string
|
|
14
|
+
description: string
|
|
15
|
+
args?: { position: number; name: string; required: boolean; description?: string }[]
|
|
16
|
+
flags?: { name: string; type: string; default?: unknown; description: string }[]
|
|
17
|
+
examples?: string[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* All CLI commands. This is the single source — help text and --llm-help
|
|
22
|
+
* are generated from this array.
|
|
23
|
+
*/
|
|
24
|
+
export const CLI_COMMANDS: CatalogCommand[] = [
|
|
25
|
+
// --- Daemon ---
|
|
26
|
+
{
|
|
27
|
+
name: 'start',
|
|
28
|
+
usage: 'livetap start',
|
|
29
|
+
description: 'Start the livetap daemon (embedded Redis + HTTP API)',
|
|
30
|
+
flags: [
|
|
31
|
+
{ name: '--port', type: 'number', default: 8788, description: 'Daemon port (env: LIVETAP_PORT)' },
|
|
32
|
+
{ name: '--foreground', type: 'boolean', description: 'Run in foreground (don\'t detach)' },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'stop',
|
|
37
|
+
usage: 'livetap stop',
|
|
38
|
+
description: 'Stop the daemon',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'status',
|
|
42
|
+
usage: 'livetap status',
|
|
43
|
+
description: 'Show daemon, taps, and watchers',
|
|
44
|
+
flags: [
|
|
45
|
+
{ name: '--json', type: 'boolean', description: 'Output as JSON' },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
// --- Connections ---
|
|
49
|
+
{
|
|
50
|
+
name: 'tap',
|
|
51
|
+
usage: 'livetap tap <uri|file.json>',
|
|
52
|
+
description: 'Tap into a data source (MQTT, WebSocket, file, or webhook)',
|
|
53
|
+
args: [
|
|
54
|
+
{ position: 0, name: 'source', required: true, description: 'URI (mqtt://..., wss://..., file:///path), "webhook", or a .json config file' },
|
|
55
|
+
],
|
|
56
|
+
flags: [
|
|
57
|
+
{ name: '--name', type: 'string', description: 'Display name for the connection' },
|
|
58
|
+
],
|
|
59
|
+
examples: [
|
|
60
|
+
'livetap tap mqtt://broker.emqx.io:1883/sensors/#',
|
|
61
|
+
'livetap tap wss://stream.example.com/prices',
|
|
62
|
+
'livetap tap file:///var/log/nginx/error.log',
|
|
63
|
+
'livetap tap webhook',
|
|
64
|
+
'livetap tap connection.json',
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'untap',
|
|
69
|
+
usage: 'livetap untap <connectionId>',
|
|
70
|
+
description: 'Remove a tap',
|
|
71
|
+
args: [
|
|
72
|
+
{ position: 0, name: 'connectionId', required: true },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'taps',
|
|
77
|
+
usage: 'livetap taps',
|
|
78
|
+
description: 'List active taps',
|
|
79
|
+
flags: [
|
|
80
|
+
{ name: '--json', type: 'boolean', description: 'Output as JSON' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
// --- Sampling ---
|
|
84
|
+
{
|
|
85
|
+
name: 'sip',
|
|
86
|
+
usage: 'livetap sip <connectionId>',
|
|
87
|
+
description: 'Sip from a stream (sample recent entries as pretty JSON)',
|
|
88
|
+
args: [
|
|
89
|
+
{ position: 0, name: 'connectionId', required: true },
|
|
90
|
+
],
|
|
91
|
+
flags: [
|
|
92
|
+
{ name: '--max', type: 'number', default: 10, description: 'Max entries to return' },
|
|
93
|
+
{ name: '--back', type: 'number', default: 60, description: 'Backfill seconds' },
|
|
94
|
+
{ name: '--raw', type: 'boolean', description: 'Output raw JSON' },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
// --- Watchers ---
|
|
98
|
+
{
|
|
99
|
+
name: 'watch',
|
|
100
|
+
usage: 'livetap watch <connectionId> "expression"',
|
|
101
|
+
description: 'Create an expression-based watcher',
|
|
102
|
+
args: [
|
|
103
|
+
{ position: 0, name: 'connectionId', required: true },
|
|
104
|
+
{ position: 1, name: 'expression', required: true, description: '"field > value", supports AND/OR' },
|
|
105
|
+
],
|
|
106
|
+
flags: [
|
|
107
|
+
{ name: '--cooldown', type: 'number', default: 60, description: 'Seconds between repeated alerts (0 = every match)' },
|
|
108
|
+
{ name: '--action', type: 'string', description: '"channel_alert" (default), "webhook:URL", or "shell:command"' },
|
|
109
|
+
],
|
|
110
|
+
examples: [
|
|
111
|
+
'livetap watch conn_abc "temperature > 50"',
|
|
112
|
+
'livetap watch conn_abc "temp > 50 AND humidity > 90"',
|
|
113
|
+
'livetap watch conn_abc "temp > 50 OR smoke > 0.05"',
|
|
114
|
+
'livetap watch conn_abc "price > 70000" --cooldown 300',
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'unwatch',
|
|
119
|
+
usage: 'livetap unwatch <watcherId>',
|
|
120
|
+
description: 'Remove a watcher',
|
|
121
|
+
args: [
|
|
122
|
+
{ position: 0, name: 'watcherId', required: true },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'watchers',
|
|
127
|
+
usage: 'livetap watchers [connectionId|watcherId]',
|
|
128
|
+
description: 'List watchers, show watcher details, or view watcher logs',
|
|
129
|
+
args: [
|
|
130
|
+
{ position: 0, name: 'connectionId or watcherId', required: false, description: 'Filter by connection (conn_xxx) or show details for a watcher (w_xxx)' },
|
|
131
|
+
],
|
|
132
|
+
flags: [
|
|
133
|
+
{ name: '--json', type: 'boolean', description: 'Output as JSON' },
|
|
134
|
+
{ name: '--logs', type: 'string', description: 'Show evaluation logs for a watcher ID' },
|
|
135
|
+
],
|
|
136
|
+
examples: [
|
|
137
|
+
'livetap watchers',
|
|
138
|
+
'livetap watchers conn_abc',
|
|
139
|
+
'livetap watchers w_abc',
|
|
140
|
+
'livetap watchers --logs w_abc',
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
]
|