@myvillage/cli 1.88.0 → 1.88.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myvillage/cli",
3
- "version": "1.88.0",
3
+ "version": "1.88.2",
4
4
  "description": "MyVillageOS CLI for community developers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -171,9 +171,12 @@ async function resolveMachineIdentity(opts) {
171
171
  }
172
172
 
173
173
  if (saved?.machineKey) {
174
- // Re-register with the stored credential so name/metadata/version refresh.
175
- const { machineId } = await register(makeClient(saved.machineKey, null), opts);
176
- persistRunnerState({ ...saved, machineId, name: opts.name || saved.name, registeredAt: new Date().toISOString() });
174
+ // Re-register with the stored credential so metadata/version refresh. Keep
175
+ // the name this machine already goes by unless a new one was asked for —
176
+ // restarting the runner must not rename the machine out from under the user.
177
+ const name = opts.name || saved.name || os.hostname();
178
+ const { machineId } = await register(makeClient(saved.machineKey, null), { ...opts, name });
179
+ persistRunnerState({ ...saved, machineId, name, registeredAt: new Date().toISOString() });
177
180
  return { machineId, machineKey: saved.machineKey };
178
181
  }
179
182
 
@@ -251,6 +254,21 @@ async function reconcileOnce(ctx) {
251
254
  continue;
252
255
  }
253
256
  const epoch = lease.json.data.leaseEpoch;
257
+
258
+ // Never fork a second daemon on top of a live one. An agent started outside
259
+ // the fleet (Studio's local Start, or a previous CLI `agent start`) has no
260
+ // lease, so it reaches here with a fresh lease and an already-running
261
+ // process; forking again would double-run it and orphan the first daemon
262
+ // (the pid file is last-writer-wins). Adopt it instead.
263
+ if (isDaemonRunning(entry.name)) {
264
+ ctx.leases.set(a.agentProfileId, { name: entry.name, epoch });
265
+ log(
266
+ `adopted already-running ${entry.name} under lease (epoch ${epoch}) — started outside the fleet, so it ` +
267
+ `reports no fence; stop/start it from Studio to relaunch it fenced`,
268
+ );
269
+ continue;
270
+ }
271
+
254
272
  const pid = startAgent(entry.name, entry.config, ctx.machineId, epoch);
255
273
  ctx.leases.set(a.agentProfileId, { name: entry.name, epoch });
256
274
  log(`started ${entry.name} (pid ${pid}, epoch ${epoch})`);