@dmsdc-ai/aigentry-telepty 0.1.74 → 0.1.75
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/daemon.js +35 -7
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -342,13 +342,17 @@ app.post('/api/sessions/register', (req, res) => {
|
|
|
342
342
|
if (backend) existing.backend = backend;
|
|
343
343
|
if (cmux_workspace_id) existing.cmuxWorkspaceId = cmux_workspace_id;
|
|
344
344
|
if (cmux_surface_id) existing.cmuxSurfaceId = cmux_surface_id;
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
if (req.body.delivery_type) existing.type = req.body.delivery_type;
|
|
346
|
+
if (req.body.delivery_endpoint) existing.deliveryEndpoint = req.body.delivery_endpoint;
|
|
347
|
+
if (req.body.delivery_type === 'aterm') existing.ready = true;
|
|
348
|
+
console.log(`[REGISTER] Re-registered session ${session_id} (type: ${existing.type}, updated metadata)`);
|
|
349
|
+
return res.status(200).json({ session_id, type: existing.type, command: existing.command, cwd: existing.cwd, reregistered: true });
|
|
347
350
|
}
|
|
348
351
|
|
|
352
|
+
const { delivery_type, delivery_endpoint } = req.body;
|
|
349
353
|
const sessionRecord = {
|
|
350
354
|
id: session_id,
|
|
351
|
-
type: 'wrapped',
|
|
355
|
+
type: delivery_type || 'wrapped',
|
|
352
356
|
ptyProcess: null,
|
|
353
357
|
ownerWs: null,
|
|
354
358
|
command: command || 'wrapped',
|
|
@@ -356,12 +360,13 @@ app.post('/api/sessions/register', (req, res) => {
|
|
|
356
360
|
backend: backend || 'kitty',
|
|
357
361
|
cmuxWorkspaceId: cmux_workspace_id || null,
|
|
358
362
|
cmuxSurfaceId: cmux_surface_id || null,
|
|
363
|
+
deliveryEndpoint: delivery_endpoint || null,
|
|
359
364
|
createdAt: new Date().toISOString(),
|
|
360
365
|
lastActivityAt: new Date().toISOString(),
|
|
361
366
|
clients: new Set(),
|
|
362
367
|
isClosing: false,
|
|
363
368
|
outputRing: [],
|
|
364
|
-
ready:
|
|
369
|
+
ready: delivery_type === 'aterm', // aterm sessions are always ready (aterm manages readiness)
|
|
365
370
|
};
|
|
366
371
|
// Check for existing session with same base alias and emit replaced event
|
|
367
372
|
const baseAlias = session_id.replace(/-\d+$/, '');
|
|
@@ -421,7 +426,8 @@ app.get('/api/sessions', (req, res) => {
|
|
|
421
426
|
lastActivityAt: session.lastActivityAt || null,
|
|
422
427
|
idleSeconds,
|
|
423
428
|
active_clients: session.clients.size,
|
|
424
|
-
ready: session.ready || false
|
|
429
|
+
ready: session.ready || false,
|
|
430
|
+
deliveryEndpoint: session.deliveryEndpoint || null
|
|
425
431
|
};
|
|
426
432
|
});
|
|
427
433
|
if (idleGt !== null) {
|
|
@@ -884,7 +890,19 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
884
890
|
// Always inject text WITHOUT \r first, then send \r separately after delay
|
|
885
891
|
// This two-step approach works for ALL CLIs (claude, codex, gemini)
|
|
886
892
|
function writeToSession(data) {
|
|
887
|
-
if (session.type === '
|
|
893
|
+
if (session.type === 'aterm' && session.deliveryEndpoint) {
|
|
894
|
+
// Route to aterm PtyManager — fire-and-forget, aterm handles delivery
|
|
895
|
+
try {
|
|
896
|
+
const url = session.deliveryEndpoint;
|
|
897
|
+
fetch(url, {
|
|
898
|
+
method: 'POST',
|
|
899
|
+
headers: { 'Content-Type': 'application/json' },
|
|
900
|
+
body: JSON.stringify({ text: data, session_id: id }),
|
|
901
|
+
signal: AbortSignal.timeout(5000)
|
|
902
|
+
}).catch(() => {});
|
|
903
|
+
return true;
|
|
904
|
+
} catch { return false; }
|
|
905
|
+
} else if (session.type === 'wrapped') {
|
|
888
906
|
if (session.ownerWs && session.ownerWs.readyState === 1) {
|
|
889
907
|
session.ownerWs.send(JSON.stringify({ type: 'inject', data }));
|
|
890
908
|
return true;
|
|
@@ -897,7 +915,17 @@ app.post('/api/sessions/:id/inject', (req, res) => {
|
|
|
897
915
|
}
|
|
898
916
|
|
|
899
917
|
let submitResult = null;
|
|
900
|
-
if (session.type === '
|
|
918
|
+
if (session.type === 'aterm' && session.deliveryEndpoint) {
|
|
919
|
+
// aterm sessions: deliver text + CR via aterm PtyManager endpoint
|
|
920
|
+
const wsOk = writeToSession(finalPrompt);
|
|
921
|
+
if (!wsOk) {
|
|
922
|
+
return res.status(503).json({ error: 'aterm endpoint not reachable' });
|
|
923
|
+
}
|
|
924
|
+
if (!no_enter) {
|
|
925
|
+
setTimeout(() => writeToSession('\r'), 300);
|
|
926
|
+
submitResult = { deferred: true, strategy: 'aterm_endpoint' };
|
|
927
|
+
}
|
|
928
|
+
} else if (session.type === 'wrapped') {
|
|
901
929
|
// For wrapped sessions: try cmux send (daemon-level auto-detect),
|
|
902
930
|
// then kitty send-text (bypasses allow bridge queue),
|
|
903
931
|
// then WS as fallback, then submit via consistent path for CR.
|