@dmsdc-ai/aigentry-telepty 0.0.19 → 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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"topic": "Critique and verify the Foreground-Only Session Lifecycle for telepty. The user proposes that all AI workers/sessions MUST run in visible, physical terminal windows. When the user closes the window, the session dies. No invisible background sessions exist. What are the edge cases, UX flaws, or technical limitations of this approach?", "speakers": ["claude", "gemini", "codex"], "role_preset": "critic"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"topic": "Re-evaluate the telepty architecture based on the user`s strict boundaries: 1. A session equals a physical, visible terminal window. If the window closes, the session MUST die. No zombies. 2. Background persistence is NOT telepty`s job (users can use tmux if they want, but telepty doesn`t manage it). 3. Unexpected disconnects (network drop, sleep) are treated as session death, and recovery is handled via a higher-level `Handoff` of context to a new session, NOT by keeping zombie processes alive. Double-check this philosophy for flaws, focusing on how AI agents will communicate (Pub/Sub) within this strict ephemeral foreground model.", "speakers": ["claude", "codex", "gemini"], "role_preset": "review"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"topic": "Final architectural verification of the Telepty Boundary Model. The user asserts a hard line on responsibility: 1. If a session/process dies, context is lost. That is the CLI/Terminal`s problem, not telepty`s. 2. If a Pub message is sent to a dead Sub, it is lost. Telepty just drops it or relies on Ack. If the sub reconnects in time, it gets it; if not, drop it. 3. If Wi-Fi drops, CLI dies, agent dies, scripts die. Telepty does not care about split-brain or script recovery. Is this stateless, hyper-minimalist `dumb pipe` philosophy technically viable for our goals?", "speakers": ["claude", "gemini", "codex"], "role_preset": "consensus"}
|
|
@@ -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 into remote or local PTY sessions.
|
|
5
5
|
|
|
6
6
|
**Trigger:**
|
|
7
|
-
When the user asks about their current session ID (e.g. "내 세션 ID가 뭐야?"), wants to check active sessions ("세션 목록 보여줘"),
|
|
7
|
+
When the user asks about their current session ID (e.g. "내 세션 ID가 뭐야?"), wants to check active sessions ("세션 목록 보여줘"), wants to inject a prompt/command into a specific session ("dustcraw한테 메시지 보내줘"), or wants to update telepty to the latest version ("업데이트 해줘").
|
|
8
8
|
|
|
9
9
|
**Instructions:**
|
|
10
10
|
1. **To check the current session ID:**
|
|
@@ -17,3 +17,5 @@ When the user asks about their current session ID (e.g. "내 세션 ID가 뭐야
|
|
|
17
17
|
- For a single session: Run `telepty inject <target_session_id> "<message or command>"`.
|
|
18
18
|
- For broadcasting to ALL active sessions: Run `telepty broadcast "<message or command>"`.
|
|
19
19
|
- For multicasting to multiple specific sessions: Run `telepty multicast <id1>,<id2> "<message or command>"`.
|
|
20
|
+
4. **To update telepty:**
|
|
21
|
+
- Run `telepty update`.
|
package/daemon.js
CHANGED
|
@@ -182,21 +182,11 @@ const server = app.listen(PORT, HOST, () => {
|
|
|
182
182
|
console.log(`🚀 aigentry-telepty daemon listening on http://${HOST}:${PORT}`);
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
const wss = new WebSocketServer({ server });
|
|
186
185
|
|
|
187
|
-
wss
|
|
188
|
-
const isLocalhost = req.socket.remoteAddress === '127.0.0.1' || req.socket.remoteAddress === '::1' || req.socket.remoteAddress === '::ffff:127.0.0.1';
|
|
189
|
-
const isTailscale = req.socket.remoteAddress && req.socket.remoteAddress.startsWith('100.');
|
|
190
|
-
|
|
191
|
-
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
192
|
-
const token = url.searchParams.get('token');
|
|
193
|
-
|
|
194
|
-
if (!isLocalhost && !isTailscale && token !== EXPECTED_TOKEN) {
|
|
195
|
-
console.warn(`[WS-AUTH] Rejected unauthorized WebSocket from ${req.socket.remoteAddress}`);
|
|
196
|
-
ws.close(1008, 'Unauthorized');
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
186
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
199
187
|
|
|
188
|
+
wss.on('connection', (ws, req) => {
|
|
189
|
+
const url = new URL(req.url, 'http://' + req.headers.host);
|
|
200
190
|
const sessionId = url.pathname.split('/').pop();
|
|
201
191
|
const session = sessions[sessionId];
|
|
202
192
|
|
|
@@ -206,7 +196,7 @@ wss.on('connection', (ws, req) => {
|
|
|
206
196
|
}
|
|
207
197
|
|
|
208
198
|
session.clients.add(ws);
|
|
209
|
-
console.log(`[WS] Client attached to session
|
|
199
|
+
console.log(`[WS] Client attached to session \${sessionId} (Total: \${session.clients.size})`);
|
|
210
200
|
|
|
211
201
|
ws.on('message', (message) => {
|
|
212
202
|
try {
|
|
@@ -223,6 +213,59 @@ wss.on('connection', (ws, req) => {
|
|
|
223
213
|
|
|
224
214
|
ws.on('close', () => {
|
|
225
215
|
session.clients.delete(ws);
|
|
226
|
-
console.log(`[WS] Client detached from session
|
|
216
|
+
console.log(`[WS] Client detached from session \${sessionId} (Total: \${session.clients.size})`);
|
|
227
217
|
});
|
|
228
218
|
});
|
|
219
|
+
|
|
220
|
+
const busWss = new WebSocketServer({ noServer: true });
|
|
221
|
+
const busClients = new Set();
|
|
222
|
+
|
|
223
|
+
busWss.on('connection', (ws, req) => {
|
|
224
|
+
busClients.add(ws);
|
|
225
|
+
console.log('[BUS] New agent connected to event bus');
|
|
226
|
+
|
|
227
|
+
ws.on('message', (message) => {
|
|
228
|
+
try {
|
|
229
|
+
const msg = JSON.parse(message);
|
|
230
|
+
// For MVP, simply broadcast any valid JSON message to all other bus clients
|
|
231
|
+
busClients.forEach(client => {
|
|
232
|
+
if (client !== ws && client.readyState === 1) {
|
|
233
|
+
client.send(JSON.stringify(msg));
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
} catch (e) {
|
|
237
|
+
console.error('[BUS] Invalid message format', e);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
ws.on('close', () => {
|
|
242
|
+
busClients.delete(ws);
|
|
243
|
+
console.log('[BUS] Agent disconnected from event bus');
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
server.on('upgrade', (req, socket, head) => {
|
|
248
|
+
const url = new URL(req.url, 'http://' + req.headers.host);
|
|
249
|
+
const token = url.searchParams.get('token');
|
|
250
|
+
|
|
251
|
+
const isLocalhost = req.socket.remoteAddress === '127.0.0.1' || req.socket.remoteAddress === '::1' || req.socket.remoteAddress === '::ffff:127.0.0.1';
|
|
252
|
+
const isTailscale = req.socket.remoteAddress && req.socket.remoteAddress.startsWith('100.');
|
|
253
|
+
|
|
254
|
+
if (!isLocalhost && !isTailscale && token !== EXPECTED_TOKEN) {
|
|
255
|
+
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
|
|
256
|
+
socket.destroy();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (url.pathname.startsWith('/api/sessions/')) {
|
|
261
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
262
|
+
wss.emit('connection', ws, req);
|
|
263
|
+
});
|
|
264
|
+
} else if (url.pathname === '/api/bus') {
|
|
265
|
+
busWss.handleUpgrade(req, socket, head, (ws) => {
|
|
266
|
+
busWss.emit('connection', ws, req);
|
|
267
|
+
});
|
|
268
|
+
} else {
|
|
269
|
+
socket.destroy();
|
|
270
|
+
}
|
|
271
|
+
});
|