@elizaos/server 1.6.2-alpha.7 → 1.6.2-alpha.9

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/dist/index.js CHANGED
@@ -23764,6 +23764,8 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
23764
23764
  }
23765
23765
  const updates = req.body;
23766
23766
  try {
23767
+ const currentAgent = await db.getAgent(agentId);
23768
+ const activeRuntime = elizaOS.getAgent(agentId);
23767
23769
  if (updates.settings?.secrets) {
23768
23770
  const salt = getSalt();
23769
23771
  const encryptedSecrets = {};
@@ -23782,11 +23784,46 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
23782
23784
  await db.updateAgent(agentId, updates);
23783
23785
  }
23784
23786
  const updatedAgent = await db.getAgent(agentId);
23785
- const activeRuntime = elizaOS.getAgent(agentId);
23787
+ let needsRestart = false;
23788
+ if (currentAgent && activeRuntime && updatedAgent) {
23789
+ if (updatedAgent.plugins && !Array.isArray(updatedAgent.plugins)) {
23790
+ throw new Error("plugins must be an array");
23791
+ }
23792
+ const currentPlugins = (currentAgent.plugins || []).filter((p) => p != null).map((p) => typeof p === "string" ? p : p.name).filter((name) => typeof name === "string").sort();
23793
+ const updatedPlugins = (updatedAgent.plugins || []).filter((p) => p != null).map((p) => typeof p === "string" ? p : p.name).filter((name) => typeof name === "string").sort();
23794
+ const pluginsChanged = currentPlugins.length !== updatedPlugins.length || currentPlugins.some((plugin, idx) => plugin !== updatedPlugins[idx]);
23795
+ needsRestart = pluginsChanged;
23796
+ if (needsRestart) {
23797
+ logger.debug(`[AGENT UPDATE] Agent ${agentId} requires restart due to plugins changes`);
23798
+ }
23799
+ }
23786
23800
  if (activeRuntime && updatedAgent) {
23787
- const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
23788
- await elizaOS.updateAgent(agentId, characterData);
23789
- logger.debug(`[AGENT UPDATE] Updated active agent ${agentId} without restart`);
23801
+ if (needsRestart) {
23802
+ logger.debug(`[AGENT UPDATE] Restarting agent ${agentId} due to configuration changes`);
23803
+ try {
23804
+ await serverInstance?.unregisterAgent(agentId);
23805
+ const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
23806
+ const runtimes = await serverInstance?.startAgents([characterData]);
23807
+ if (!runtimes || runtimes.length === 0) {
23808
+ throw new Error("Failed to restart agent after configuration change");
23809
+ }
23810
+ logger.success(`[AGENT UPDATE] Agent ${agentId} restarted successfully`);
23811
+ } catch (restartError) {
23812
+ logger.error({ error: restartError, agentId }, `[AGENT UPDATE] Failed to restart agent ${agentId}, attempting to restore previous state`);
23813
+ try {
23814
+ const { enabled, status: status2, createdAt, updatedAt, ...previousCharacterData } = currentAgent;
23815
+ await serverInstance?.startAgents([previousCharacterData]);
23816
+ logger.warn(`[AGENT UPDATE] Restored agent ${agentId} to previous state`);
23817
+ } catch (restoreError) {
23818
+ logger.error({ error: restoreError, agentId }, `[AGENT UPDATE] Failed to restore agent ${agentId} - agent may be in broken state`);
23819
+ }
23820
+ throw restartError;
23821
+ }
23822
+ } else {
23823
+ const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
23824
+ await elizaOS.updateAgent(agentId, characterData);
23825
+ logger.debug(`[AGENT UPDATE] Updated active agent ${agentId} without restart`);
23826
+ }
23790
23827
  }
23791
23828
  const runtime = elizaOS.getAgent(agentId);
23792
23829
  const status = runtime ? "active" : "inactive";
@@ -28796,7 +28833,7 @@ import express30 from "express";
28796
28833
  // package.json
28797
28834
  var package_default = {
28798
28835
  name: "@elizaos/server",
28799
- version: "1.6.2-alpha.7",
28836
+ version: "1.6.2-alpha.9",
28800
28837
  description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
28801
28838
  publishConfig: {
28802
28839
  access: "public",
@@ -46515,12 +46552,11 @@ class AgentServer {
46515
46552
  const agent = this.elizaOS?.getAgent(agentId);
46516
46553
  if (agent) {
46517
46554
  try {
46518
- agent.stop().catch((stopError) => {
46519
- logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
46520
- });
46521
46555
  logger32.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
46556
+ await agent.stop();
46557
+ logger32.debug(`[AGENT UNREGISTER] All services stopped for agent ${agentId}`);
46522
46558
  } catch (stopError) {
46523
- logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
46559
+ logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
46524
46560
  }
46525
46561
  }
46526
46562
  if (this.elizaOS) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/server",
3
- "version": "1.6.2-alpha.7",
3
+ "version": "1.6.2-alpha.9",
4
4
  "description": "ElizaOS Server - Core server infrastructure for ElizaOS agents",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -44,7 +44,7 @@
44
44
  "dev": "bun run build.ts --watch"
45
45
  },
46
46
  "devDependencies": {
47
- "@elizaos/client": "1.6.2-alpha.7",
47
+ "@elizaos/client": "1.6.2-alpha.9",
48
48
  "@types/node": "^24.0.1",
49
49
  "prettier": "3.6.2",
50
50
  "tsx": "4.20.6",
@@ -52,10 +52,10 @@
52
52
  "which": "^5.0.0",
53
53
  "ws": "^8.18.0"
54
54
  },
55
- "gitHead": "12c302bd51ede310467cc4d21c73ea9e440a570b",
55
+ "gitHead": "7b886b28e506f8e02c8519cea7efc64758c169b6",
56
56
  "dependencies": {
57
- "@elizaos/core": "1.6.2-alpha.7",
58
- "@elizaos/plugin-sql": "1.6.2-alpha.7",
57
+ "@elizaos/core": "1.6.2-alpha.9",
58
+ "@elizaos/plugin-sql": "1.6.2-alpha.9",
59
59
  "@sentry/node": "^10.16.0",
60
60
  "@types/express": "^5.0.2",
61
61
  "@types/helmet": "^4.0.0",