@dmsdc-ai/aigentry-telepty 0.1.85 → 0.1.87
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 +18 -3
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -446,6 +446,7 @@ async function writeDataToSession(id, session, data) {
|
|
|
446
446
|
if (session.delivery && session.delivery.transport === 'unix_socket' && session.delivery.address) {
|
|
447
447
|
return new Promise((resolve) => {
|
|
448
448
|
const payload = JSON.stringify({ action: "Inject", workspace: id, text: data }) + '\n';
|
|
449
|
+
let responseBuf = '';
|
|
449
450
|
const timeout = setTimeout(() => {
|
|
450
451
|
sock.destroy();
|
|
451
452
|
resolve(buildErrorBody('TIMEOUT', 'UDS delivery timed out.', { httpStatus: 504 }));
|
|
@@ -453,9 +454,23 @@ async function writeDataToSession(id, session, data) {
|
|
|
453
454
|
const sock = net.connect(session.delivery.address, () => {
|
|
454
455
|
sock.end(payload);
|
|
455
456
|
});
|
|
456
|
-
sock.on('data', () => {});
|
|
457
|
+
sock.on('data', (chunk) => { responseBuf += chunk.toString(); });
|
|
457
458
|
sock.on('end', () => {
|
|
458
459
|
clearTimeout(timeout);
|
|
460
|
+
if (responseBuf) {
|
|
461
|
+
try {
|
|
462
|
+
const resp = JSON.parse(responseBuf.trim());
|
|
463
|
+
if (resp.status === 'Error' || resp.success === false) {
|
|
464
|
+
resolve(buildErrorBody('DELIVERY_REJECTED', resp.error || resp.message || 'Target rejected the payload.', {
|
|
465
|
+
httpStatus: 502,
|
|
466
|
+
detail: resp
|
|
467
|
+
}));
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
} catch {
|
|
471
|
+
// Non-JSON response — treat as success (legacy endpoints)
|
|
472
|
+
}
|
|
473
|
+
}
|
|
459
474
|
resolve({ success: true });
|
|
460
475
|
});
|
|
461
476
|
sock.on('error', (err) => {
|
|
@@ -810,8 +825,8 @@ app.post('/api/sessions/spawn', (req, res) => {
|
|
|
810
825
|
app.post('/api/sessions/register', (req, res) => {
|
|
811
826
|
const { session_id, command, cwd = process.cwd(), backend, cmux_workspace_id, cmux_surface_id, term_program, term } = req.body;
|
|
812
827
|
if (!session_id) return res.status(400).json({ error: 'session_id is required' });
|
|
813
|
-
// Entitlement: check session limit for new registrations
|
|
814
|
-
if (!sessions[session_id]) {
|
|
828
|
+
// Entitlement: check session limit for new registrations (exempt aterm — embedded IPC, no PTY cost)
|
|
829
|
+
if (!sessions[session_id] && req.body.delivery_type !== 'aterm') {
|
|
815
830
|
const sessionCount = Object.keys(sessions).length;
|
|
816
831
|
const ent = checkEntitlement({ feature: 'telepty.multi_session', currentUsage: sessionCount });
|
|
817
832
|
if (!ent.allowed) {
|