@dmsdc-ai/aigentry-telepty 0.1.2 → 0.1.3

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.
@@ -4,7 +4,7 @@
4
4
  Help the user interact with the `telepty` daemon, check their current session ID, list active sessions, and inject commands or JSON events into remote or local PTY sessions. All operations are performed using standard CLI commands or `curl`.
5
5
 
6
6
  **Trigger:**
7
- When the user asks about their current session ID, wants to check active sessions, wants to inject a prompt/command into a specific session, wants to send a JSON event via the bus, or wants to update telepty.
7
+ When the user asks about their current session ID, wants to check active sessions, wants to inject a prompt/command into a specific session, wants to send a JSON event via the bus, wants to subscribe/listen to the bus, or wants to update telepty.
8
8
 
9
9
  **Instructions:**
10
10
  1. **To check the current session ID:**
@@ -29,4 +29,11 @@ When the user asks about their current session ID, wants to check active session
29
29
  -H "x-telepty-token: $TOKEN" \
30
30
  -d '{"type": "my_event", "payload": "data"}'
31
31
  ```
32
- - (Modify the JSON payload structure according to the user's specific request.)
32
+ - (Modify the JSON payload structure according to the user's specific request.)
33
+ 6. **To subscribe to the Event Bus (Listen for JSON events):**
34
+ - If the user wants to wait for and listen to messages from other agents, simply run `telepty listen`.
35
+ - Run it in the background and redirect output to a log file so you can periodically check it:
36
+ ```bash
37
+ nohup telepty listen > .telepty_bus_events.log 2>&1 &
38
+ ```
39
+ - Inform the user that the agent is now listening, and any received JSON messages will be saved to `.telepty_bus_events.log` in the current directory. (You can read this file using `read_file` to see what messages arrived).
package/cli.js CHANGED
@@ -485,6 +485,32 @@ async function main() {
485
485
  return;
486
486
  }
487
487
 
488
+ if (cmd === 'listen') {
489
+ await ensureDaemonRunning();
490
+ console.log('\x1b[36m👂 Listening to the telepty event bus...\x1b[0m');
491
+ const wsUrl = `ws://${REMOTE_HOST}:${PORT}/api/bus?token=${encodeURIComponent(TOKEN)}`;
492
+ const ws = new WebSocket(wsUrl);
493
+
494
+ ws.on('open', () => {
495
+ // connected
496
+ });
497
+
498
+ ws.on('message', (message) => {
499
+ // Print raw JSON to stdout so agents can parse it
500
+ console.log(message.toString());
501
+ });
502
+
503
+ ws.on('close', () => {
504
+ console.error('\x1b[31m❌ Disconnected from event bus.\x1b[0m');
505
+ process.exit(1);
506
+ });
507
+
508
+ ws.on('error', (err) => {
509
+ console.error('\x1b[31m❌ WebSocket error:\x1b[0m', err.message);
510
+ });
511
+ return;
512
+ }
513
+
488
514
  console.log(`
489
515
  \x1b[1maigentry-telepty\x1b[0m - Remote PTY Control
490
516
 
@@ -496,6 +522,7 @@ Usage:
496
522
  telepty inject <id> "<prompt>" Inject text into a single session
497
523
  telepty multicast <id1,id2> "<prompt>" Inject text into multiple specific sessions
498
524
  telepty broadcast "<prompt>" Inject text into ALL active sessions
525
+ telepty listen Listen to the event bus and print JSON to stdout
499
526
  telepty update Update telepty to the latest version
500
527
  `);
501
528
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "telepty": "cli.js",