@openagents-org/agent-launcher 0.2.159 → 0.2.161
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/daemon.js +43 -4
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -80,7 +80,19 @@ class Daemon {
|
|
|
80
80
|
try {
|
|
81
81
|
for (const a of this.config.getAgents()) {
|
|
82
82
|
const proc = this._processes[a.name];
|
|
83
|
-
|
|
83
|
+
// Model: per-agent env override, else the type-level saved model. Working
|
|
84
|
+
// dir: the agent's configured path. Both power the workspace agent cards.
|
|
85
|
+
let model = (a.env && a.env.LLM_MODEL) || null;
|
|
86
|
+
if (!model) {
|
|
87
|
+
try { model = (this.envManager.load(a.type) || {}).LLM_MODEL || null; } catch { model = null; }
|
|
88
|
+
}
|
|
89
|
+
roster.push({
|
|
90
|
+
name: a.name,
|
|
91
|
+
type: a.type || 'unknown',
|
|
92
|
+
status: (proc && proc.state) || 'stopped',
|
|
93
|
+
model: model || null,
|
|
94
|
+
workingDir: a.path || null,
|
|
95
|
+
});
|
|
84
96
|
}
|
|
85
97
|
} catch {
|
|
86
98
|
// best-effort
|
|
@@ -120,9 +132,13 @@ class Daemon {
|
|
|
120
132
|
try {
|
|
121
133
|
if (action === 'create_agent') {
|
|
122
134
|
const type = (args.type || '').trim();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
// Working directory: use the one the user picked, else a managed folder
|
|
136
|
+
// under the launcher home so every remote-created agent has a clean,
|
|
137
|
+
// predictable home without the user typing a path.
|
|
138
|
+
let workingDir = (args.workingDir || '').trim();
|
|
139
|
+
if (!workingDir) workingDir = path.join(os.homedir(), '.openagents', 'agents', name);
|
|
140
|
+
try { fs.mkdirSync(workingDir, { recursive: true }); } catch {}
|
|
141
|
+
const r1 = await this._runAgn(['create', name, '--type', type, '--install', '--path', workingDir]);
|
|
126
142
|
if (r1.code !== 0) throw new Error(r1.stderr || r1.stdout || 'create failed');
|
|
127
143
|
// Optional credentials for API-key agents (generic → provider mapping
|
|
128
144
|
// happens in env resolution).
|
|
@@ -146,6 +162,29 @@ class Daemon {
|
|
|
146
162
|
const r = await this._runAgn(['remove', name]);
|
|
147
163
|
ok = r.code === 0;
|
|
148
164
|
message = ok ? `Agent '${name}' removed` : (r.stderr || r.stdout || 'remove failed');
|
|
165
|
+
} else if (action === 'configure_agent') {
|
|
166
|
+
// Reconfigure an existing agent: update model/key (type-level env), then
|
|
167
|
+
// restart it so the change takes effect. Working-dir changes require a
|
|
168
|
+
// recreate (agn has no in-place path change) at the new path.
|
|
169
|
+
const type = (args.type || '').trim();
|
|
170
|
+
if (args.apiKey) await this._runAgn(['env', type, '--set', `LLM_API_KEY=${args.apiKey}`]);
|
|
171
|
+
if (args.model !== undefined) {
|
|
172
|
+
await this._runAgn(['env', type, '--set', `LLM_MODEL=${String(args.model || '')}`]);
|
|
173
|
+
}
|
|
174
|
+
const newDir = (args.workingDir || '').trim();
|
|
175
|
+
if (newDir && newDir !== (args.currentWorkingDir || '')) {
|
|
176
|
+
try { fs.mkdirSync(newDir, { recursive: true }); } catch {}
|
|
177
|
+
await this._runAgn(['remove', name]);
|
|
178
|
+
const rc = await this._runAgn(['create', name, '--type', type, '--install', '--path', newDir]);
|
|
179
|
+
if (rc.code !== 0) throw new Error(rc.stderr || rc.stdout || 'recreate failed');
|
|
180
|
+
const rc2 = await this._runAgn(['connect', name, n.token, '--endpoint', n.endpoint]);
|
|
181
|
+
if (rc2.code !== 0) throw new Error(rc2.stderr || rc2.stdout || 'connect failed');
|
|
182
|
+
} else {
|
|
183
|
+
await this._runAgn(['stop', name]);
|
|
184
|
+
await this._runAgn(['start', name]);
|
|
185
|
+
}
|
|
186
|
+
ok = true;
|
|
187
|
+
message = `Agent '${name}' reconfigured`;
|
|
149
188
|
} else if (action === 'detect_runtimes') {
|
|
150
189
|
await this._refreshRuntimes();
|
|
151
190
|
// Push the fresh detection right away rather than waiting for the next
|