agentgui 1.0.448 → 1.0.449
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/lib/gm-agent-configs.js +76 -0
- package/package.json +1 -1
- package/server.js +3 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
const isWindows = os.platform() === 'win32';
|
|
7
|
+
|
|
8
|
+
const GM_PACKAGES = [
|
|
9
|
+
{ id: 'opencode', pkg: 'gm-oc', marker: path.join(os.homedir(), '.config', 'opencode', 'agents') },
|
|
10
|
+
{ id: 'gemini', pkg: 'gm-gc', marker: path.join(os.homedir(), '.gemini', 'extensions', 'gm', 'agents') },
|
|
11
|
+
{ id: 'kilo', pkg: 'gm-kilo', marker: path.join(os.homedir(), '.config', 'kilo', 'agents') },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function log(msg) { console.log('[GM-CONFIG] ' + msg); }
|
|
15
|
+
|
|
16
|
+
function runInstaller(pkg) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const npxCmd = isWindows ? 'npx.cmd' : 'npx';
|
|
19
|
+
const proc = spawn(npxCmd, ['--yes', pkg], {
|
|
20
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
21
|
+
timeout: 60000,
|
|
22
|
+
shell: isWindows,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
let stdout = '';
|
|
26
|
+
let stderr = '';
|
|
27
|
+
proc.stdout.on('data', (d) => { stdout += d.toString(); });
|
|
28
|
+
proc.stderr.on('data', (d) => { stderr += d.toString(); });
|
|
29
|
+
proc.stdout.on('error', () => {});
|
|
30
|
+
proc.stderr.on('error', () => {});
|
|
31
|
+
|
|
32
|
+
proc.on('close', (code) => {
|
|
33
|
+
if (code === 0) {
|
|
34
|
+
log(pkg + ' installed successfully');
|
|
35
|
+
} else {
|
|
36
|
+
log(pkg + ' exited with code ' + code);
|
|
37
|
+
if (stderr.trim()) log(pkg + ' stderr: ' + stderr.trim().substring(0, 200));
|
|
38
|
+
}
|
|
39
|
+
resolve(code === 0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
proc.on('error', (err) => {
|
|
43
|
+
log(pkg + ' spawn error: ' + err.message);
|
|
44
|
+
resolve(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function installGMAgentConfigs() {
|
|
50
|
+
const needed = GM_PACKAGES.filter(p => !fs.existsSync(p.marker));
|
|
51
|
+
if (needed.length === 0) {
|
|
52
|
+
log('all agent configs already installed');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
log('installing agent configs for: ' + needed.map(p => p.pkg).join(', '));
|
|
57
|
+
const results = await Promise.allSettled(needed.map(p => runInstaller(p.pkg)));
|
|
58
|
+
|
|
59
|
+
const summary = needed.map((p, i) => {
|
|
60
|
+
const r = results[i];
|
|
61
|
+
const ok = r.status === 'fulfilled' && r.value;
|
|
62
|
+
return p.pkg + ': ' + (ok ? 'ok' : 'failed');
|
|
63
|
+
});
|
|
64
|
+
log('results: ' + summary.join(', '));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function forceReinstallGMAgentConfigs() {
|
|
68
|
+
log('force reinstalling all agent configs');
|
|
69
|
+
const results = await Promise.allSettled(GM_PACKAGES.map(p => runInstaller(p.pkg)));
|
|
70
|
+
const summary = GM_PACKAGES.map((p, i) => {
|
|
71
|
+
const r = results[i];
|
|
72
|
+
const ok = r.status === 'fulfilled' && r.value;
|
|
73
|
+
return p.pkg + ': ' + (ok ? 'ok' : 'failed');
|
|
74
|
+
});
|
|
75
|
+
log('results: ' + summary.join(', '));
|
|
76
|
+
}
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -23,6 +23,7 @@ import { register as registerSessionHandlers } from './lib/ws-handlers-session.j
|
|
|
23
23
|
import { register as registerRunHandlers } from './lib/ws-handlers-run.js';
|
|
24
24
|
import { register as registerUtilHandlers } from './lib/ws-handlers-util.js';
|
|
25
25
|
import { startAll as startACPTools, stopAll as stopACPTools, getStatus as getACPStatus, getPort as getACPPort, queryModels as queryACPModels, touch as touchACP } from './lib/acp-manager.js';
|
|
26
|
+
import { installGMAgentConfigs } from './lib/gm-agent-configs.js';
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
process.on('uncaughtException', (err, origin) => {
|
|
@@ -4173,6 +4174,8 @@ function onServerReady() {
|
|
|
4173
4174
|
|
|
4174
4175
|
resumeInterruptedStreams().catch(err => console.error('[RESUME] Startup error:', err.message));
|
|
4175
4176
|
|
|
4177
|
+
installGMAgentConfigs().catch(err => console.error('[GM-CONFIG] Startup error:', err.message));
|
|
4178
|
+
|
|
4176
4179
|
startACPTools().then(() => {
|
|
4177
4180
|
setTimeout(() => {
|
|
4178
4181
|
const acpStatus = getACPStatus();
|