@openagents-org/agent-launcher 0.1.3 → 0.1.4
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/package.json +1 -1
- package/src/tui.js +27 -57
package/package.json
CHANGED
package/src/tui.js
CHANGED
|
@@ -19,7 +19,7 @@ function getConnector() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function loadAgentRows(connector) {
|
|
22
|
-
const config = connector.
|
|
22
|
+
const config = connector.config.load();
|
|
23
23
|
const agents = config.agents || [];
|
|
24
24
|
const status = connector.getDaemonStatus() || {};
|
|
25
25
|
const agentStatuses = status.agents || {};
|
|
@@ -38,13 +38,13 @@ function loadAgentRows(connector) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function loadCatalog(connector) {
|
|
41
|
-
const
|
|
42
|
-
return
|
|
41
|
+
const entries = connector.registry.getCatalogSync();
|
|
42
|
+
return entries.map(e => {
|
|
43
43
|
let installed = false;
|
|
44
44
|
try { const { whichBinary } = require('./paths'); installed = !!whichBinary(e.install?.binary || e.name); } catch {}
|
|
45
45
|
if (!installed) {
|
|
46
46
|
try {
|
|
47
|
-
const f = path.join(connector.
|
|
47
|
+
const f = path.join(connector._configDir, 'installed_agents.json');
|
|
48
48
|
if (fs.existsSync(f)) installed = !!JSON.parse(fs.readFileSync(f, 'utf-8'))[e.name];
|
|
49
49
|
} catch {}
|
|
50
50
|
}
|
|
@@ -244,60 +244,30 @@ function createTUI() {
|
|
|
244
244
|
function doInstall(entry, statusBar, list, catalog, renderList) {
|
|
245
245
|
statusBar.setContent(` Installing ${entry.name}...`);
|
|
246
246
|
screen.render();
|
|
247
|
+
log('Installing ' + entry.name + '...');
|
|
247
248
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
statusBar.setContent(` Error: No install command for ${entry.name}`);
|
|
252
|
-
screen.render();
|
|
253
|
-
list.focus();
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
log('$ ' + cmd);
|
|
258
|
-
statusBar.setContent(' Running: ' + cmd.substring(0, 70));
|
|
259
|
-
screen.render();
|
|
260
|
-
|
|
261
|
-
const env = { ...process.env, npm_config_yes: 'true', CI: '1' };
|
|
262
|
-
const extra = getExtraBinDirs();
|
|
263
|
-
if (extra.length) {
|
|
264
|
-
env.PATH = extra.join(IS_WINDOWS ? ';' : ':') + (IS_WINDOWS ? ';' : ':') + (env.PATH || '');
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const proc = spawn(cmd, [], { shell: true, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
268
|
-
let lines = 0;
|
|
269
|
-
|
|
270
|
-
const onData = (data) => {
|
|
271
|
-
data.toString().split('\n').filter(l => l.trim()).forEach(line => {
|
|
272
|
-
lines++;
|
|
249
|
+
connector.installer.installStreaming(entry.name, (chunk) => {
|
|
250
|
+
const lines = chunk.split('\n').filter(l => l.trim());
|
|
251
|
+
for (const line of lines) {
|
|
273
252
|
const clean = line.trim().substring(0, 90);
|
|
274
253
|
log(' ' + clean);
|
|
275
|
-
statusBar.setContent(
|
|
254
|
+
statusBar.setContent(' ' + clean.substring(0, 70));
|
|
276
255
|
screen.render();
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
proc.stdout.on('data', onData);
|
|
280
|
-
proc.stderr.on('data', onData);
|
|
281
|
-
|
|
282
|
-
proc.on('close', (code) => {
|
|
283
|
-
if (code === 0) {
|
|
284
|
-
statusBar.setContent(` Done! ${entry.name} installed successfully.`);
|
|
285
|
-
statusBar.style.fg = 'green';
|
|
286
|
-
log(entry.name + ' installed successfully');
|
|
287
|
-
try {
|
|
288
|
-
const f = path.join(connector.config?.configDir || '', 'installed_agents.json');
|
|
289
|
-
let m = {}; try { m = JSON.parse(fs.readFileSync(f, 'utf-8')); } catch {}
|
|
290
|
-
m[entry.name] = { installed_at: new Date().toISOString() };
|
|
291
|
-
fs.writeFileSync(f, JSON.stringify(m, null, 2));
|
|
292
|
-
} catch {}
|
|
293
|
-
const idx = catalog.findIndex(c => c.name === entry.name);
|
|
294
|
-
if (idx >= 0) catalog[idx].installed = true;
|
|
295
|
-
renderList();
|
|
296
|
-
} else {
|
|
297
|
-
statusBar.setContent(` Failed (exit ${code})`);
|
|
298
|
-
statusBar.style.fg = 'red';
|
|
299
|
-
log(entry.name + ' install failed (exit ' + code + ')');
|
|
300
256
|
}
|
|
257
|
+
}).then(() => {
|
|
258
|
+
statusBar.setContent(` Done! ${entry.name} installed successfully.`);
|
|
259
|
+
statusBar.style.fg = 'green';
|
|
260
|
+
log(entry.name + ' installed successfully');
|
|
261
|
+
const idx = catalog.findIndex(c => c.name === entry.name);
|
|
262
|
+
if (idx >= 0) catalog[idx].installed = true;
|
|
263
|
+
renderList();
|
|
264
|
+
setTimeout(() => { statusBar.style.fg = 'white'; }, 5000);
|
|
265
|
+
list.focus();
|
|
266
|
+
screen.render();
|
|
267
|
+
}).catch((e) => {
|
|
268
|
+
statusBar.setContent(` Failed: ${e.message.substring(0, 60)}`);
|
|
269
|
+
statusBar.style.fg = 'red';
|
|
270
|
+
log('Install failed: ' + e.message);
|
|
301
271
|
setTimeout(() => { statusBar.style.fg = 'white'; }, 5000);
|
|
302
272
|
list.focus();
|
|
303
273
|
screen.render();
|
|
@@ -336,7 +306,7 @@ function createTUI() {
|
|
|
336
306
|
if (!name) { msg.setContent('Name is required'); screen.render(); return; }
|
|
337
307
|
if (!type) { msg.setContent('Type is required'); screen.render(); return; }
|
|
338
308
|
try {
|
|
339
|
-
connector.
|
|
309
|
+
connector.addAgent({ name, type });
|
|
340
310
|
log('Agent ' + name + ' (' + type + ') created');
|
|
341
311
|
} catch (e) { msg.setContent(e.message); screen.render(); return; }
|
|
342
312
|
screen.remove(dialog); dialog.destroy();
|
|
@@ -367,14 +337,14 @@ function createTUI() {
|
|
|
367
337
|
screen.key('s', () => {
|
|
368
338
|
if (currentView !== 'main' || !agentRows[agentList.selected]) return;
|
|
369
339
|
const a = agentRows[agentList.selected];
|
|
370
|
-
try { connector.
|
|
340
|
+
try { connector.sendDaemonCommand('start:' + a.name); log('Starting ' + a.name + '...'); } catch (e) { log('Error: ' + e.message); }
|
|
371
341
|
setTimeout(refreshAgentTable, 2000);
|
|
372
342
|
});
|
|
373
343
|
|
|
374
344
|
screen.key('x', () => {
|
|
375
345
|
if (currentView !== 'main' || !agentRows[agentList.selected]) return;
|
|
376
346
|
const a = agentRows[agentList.selected];
|
|
377
|
-
try { connector.
|
|
347
|
+
try { connector.sendDaemonCommand('stop:' + a.name); log('Stopped ' + a.name); } catch (e) { log('Error: ' + e.message); }
|
|
378
348
|
setTimeout(refreshAgentTable, 1000);
|
|
379
349
|
});
|
|
380
350
|
|
|
@@ -393,7 +363,7 @@ function createTUI() {
|
|
|
393
363
|
screen.key('d', () => {
|
|
394
364
|
if (currentView !== 'main' || !agentRows[agentList.selected]) return;
|
|
395
365
|
const a = agentRows[agentList.selected];
|
|
396
|
-
try { connector.
|
|
366
|
+
try { connector.disconnectWorkspace(a.name); log('Disconnected ' + a.name); } catch (e) { log('Error: ' + e.message); }
|
|
397
367
|
refreshAgentTable();
|
|
398
368
|
});
|
|
399
369
|
|