httpcat-cli 0.0.16 ā 0.0.17
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 +165 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +48 -11
- package/dist/commands/chat.js.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/chat-state.d.ts.map +1 -0
- package/dist/mcp/chat-state.js +180 -0
- package/dist/mcp/chat-state.js.map +1 -0
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +147 -3
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/homebrew-httpcat/Formula/httpcat.rb +3 -3
- package/homebrew-httpcat/homebrew-httpcat/Formula/httpcat.rb +3 -3
- package/httpcat-mcp.json +11 -0
- package/monitor-foobar.js +118 -0
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Monitor FRIDA chat for mentions of "foobar"
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node monitor-foobar.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { dirname } from 'path';
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
|
|
17
|
+
const TOKEN = 'FRIDA';
|
|
18
|
+
const SEARCH_TERM = 'foobar';
|
|
19
|
+
|
|
20
|
+
console.error(`š Monitoring FRIDA chat for mentions of "${SEARCH_TERM}"...`);
|
|
21
|
+
console.error(`Press Ctrl+C to stop monitoring\n`);
|
|
22
|
+
|
|
23
|
+
// Spawn httpcat chat process
|
|
24
|
+
const chatProcess = spawn('httpcat', ['chat', '--json', TOKEN], {
|
|
25
|
+
stdio: ['pipe', 'pipe', 'inherit'],
|
|
26
|
+
shell: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
let outputBuffer = '';
|
|
30
|
+
let seenMessageIds = new Set();
|
|
31
|
+
|
|
32
|
+
chatProcess.stdout.on('data', (data) => {
|
|
33
|
+
outputBuffer += data.toString();
|
|
34
|
+
const lines = outputBuffer.split('\n');
|
|
35
|
+
outputBuffer = lines.pop() || '';
|
|
36
|
+
|
|
37
|
+
for (const line of lines) {
|
|
38
|
+
if (!line.trim()) continue;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const event = JSON.parse(line);
|
|
42
|
+
|
|
43
|
+
switch (event.type) {
|
|
44
|
+
case 'joined':
|
|
45
|
+
console.error(`ā
Joined FRIDA chat. Lease ID: ${event.leaseId}`);
|
|
46
|
+
console.error(`š” Monitoring for "${SEARCH_TERM}" mentions...\n`);
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
case 'message':
|
|
50
|
+
const msg = event.data;
|
|
51
|
+
|
|
52
|
+
// Skip if we've already seen this message
|
|
53
|
+
if (seenMessageIds.has(msg.messageId)) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
seenMessageIds.add(msg.messageId);
|
|
57
|
+
|
|
58
|
+
// Check if message contains search term (case-insensitive)
|
|
59
|
+
if (msg.message.toLowerCase().includes(SEARCH_TERM.toLowerCase())) {
|
|
60
|
+
const author = msg.authorShort || msg.author?.slice(0, 10);
|
|
61
|
+
const time = new Date(msg.timestamp).toLocaleString();
|
|
62
|
+
|
|
63
|
+
console.error('\n' + '='.repeat(60));
|
|
64
|
+
console.error(`šÆ FOUND "${SEARCH_TERM}" MENTION!`);
|
|
65
|
+
console.error('='.repeat(60));
|
|
66
|
+
console.error(`Time: ${time}`);
|
|
67
|
+
console.error(`Author: ${author}`);
|
|
68
|
+
console.error(`Message: ${msg.message}`);
|
|
69
|
+
console.error('='.repeat(60) + '\n');
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 'lease_expired':
|
|
74
|
+
console.error('ā±ļø Lease expired. Sending /renew...');
|
|
75
|
+
if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
|
|
76
|
+
chatProcess.stdin.write('/renew\n');
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case 'error':
|
|
81
|
+
console.error(`ā Error: ${event.error}`);
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
case 'exiting':
|
|
85
|
+
console.error('š Chat session ended');
|
|
86
|
+
process.exit(0);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// Not JSON, ignore
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
chatProcess.on('error', (error) => {
|
|
96
|
+
console.error(`ā Failed to start chat process: ${error.message}`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
chatProcess.on('exit', (code) => {
|
|
101
|
+
if (code !== 0 && code !== null) {
|
|
102
|
+
console.error(`Chat process exited with code ${code}`);
|
|
103
|
+
}
|
|
104
|
+
process.exit(code || 0);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Handle Ctrl+C
|
|
108
|
+
process.on('SIGINT', () => {
|
|
109
|
+
console.error('\nš Stopping monitor...');
|
|
110
|
+
if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
|
|
111
|
+
chatProcess.stdin.write('/exit\n');
|
|
112
|
+
}
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
chatProcess.kill();
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}, 1000);
|
|
117
|
+
});
|
|
118
|
+
|