@myvillage/cli 1.60.1 → 1.61.0

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.60.1",
3
+ "version": "1.61.0",
4
4
  "description": "MyVillageOS CLI for community developers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,6 +10,7 @@ import { isAuthenticated, getAccessToken } from '../utils/auth.js';
10
10
  import { getConfig, setConfig } from '../utils/config.js';
11
11
  import {
12
12
  createAgent as apiCreateAgent,
13
+ deleteAgent as apiDeleteAgent,
13
14
  agentJoinCommunity as apiAgentJoinCommunity,
14
15
  listCommunities,
15
16
  getAgentActivity,
@@ -803,11 +804,16 @@ export async function agentDeleteLocalCommand(name) {
803
804
  return;
804
805
  }
805
806
 
807
+ const agentConfig = readAgentConfig(name);
808
+ const remoteAgentId = agentConfig?.man?.agent_id || null;
809
+
806
810
  try {
807
811
  const { confirm } = await inquirer.prompt([{
808
812
  type: 'confirm',
809
813
  name: 'confirm',
810
- message: `Delete local agent "${name}"? This removes all local files and cannot be undone.`,
814
+ message: remoteAgentId
815
+ ? `Delete agent "${name}"? This removes all local files AND deletes the agent on the server. This cannot be undone.`
816
+ : `Delete local agent "${name}"? This removes all local files and cannot be undone.`,
811
817
  default: false,
812
818
  }]);
813
819
 
@@ -833,6 +839,27 @@ export async function agentDeleteLocalCommand(name) {
833
839
  }
834
840
  }
835
841
 
842
+ // Delete the remote AgentProfile first so a server failure stops us
843
+ // before we wipe local files. If the remote is already gone (404),
844
+ // proceed with local cleanup.
845
+ if (remoteAgentId) {
846
+ const remoteSpinner = villageSpinner('Deleting agent on server...').start();
847
+ try {
848
+ await apiDeleteAgent(remoteAgentId);
849
+ remoteSpinner.succeed('Agent deleted on server.');
850
+ } catch (err) {
851
+ const status = err.response?.status;
852
+ const message = err.response?.data?.error || err.response?.data?.message || err.message;
853
+ if (status === 404) {
854
+ remoteSpinner.warn('Agent already removed on server.');
855
+ } else {
856
+ remoteSpinner.fail(`Failed to delete agent on server: ${message}`);
857
+ console.log(brand.teal(' Local files were not removed. Re-run once the server issue is resolved.\n'));
858
+ return;
859
+ }
860
+ }
861
+ }
862
+
836
863
  // Delete directory
837
864
  const { rmSync } = await import('fs');
838
865
  const agentDir = getAgentDir(name);