@elizaos/server 1.5.12-alpha.1 → 1.5.12

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.
Files changed (36) hide show
  1. package/dist/api/agents/crud.d.ts +2 -2
  2. package/dist/api/agents/index.d.ts +2 -2
  3. package/dist/api/agents/lifecycle.d.ts +2 -2
  4. package/dist/api/agents/logs.d.ts +2 -2
  5. package/dist/api/agents/panels.d.ts +2 -2
  6. package/dist/api/agents/runs.d.ts +2 -2
  7. package/dist/api/agents/worlds.d.ts +2 -2
  8. package/dist/api/audio/conversation.d.ts +2 -2
  9. package/dist/api/audio/index.d.ts +2 -2
  10. package/dist/api/audio/processing.d.ts +2 -2
  11. package/dist/api/audio/synthesis.d.ts +2 -2
  12. package/dist/api/index.d.ts +5 -5
  13. package/dist/api/memory/agents.d.ts +2 -2
  14. package/dist/api/memory/groups.d.ts +2 -2
  15. package/dist/api/memory/index.d.ts +2 -2
  16. package/dist/api/memory/rooms.d.ts +2 -2
  17. package/dist/api/messaging/channels.d.ts +2 -2
  18. package/dist/api/messaging/index.d.ts +2 -2
  19. package/dist/api/messaging/sessions.d.ts +2 -2
  20. package/dist/api/runtime/health.d.ts +2 -2
  21. package/dist/api/runtime/index.d.ts +2 -2
  22. package/dist/api/shared/middleware.d.ts +2 -2
  23. package/dist/api/shared/validation.d.ts +2 -2
  24. package/dist/client/assets/{main-s5RJQPnO.js → main-Cxu5WF7C.js} +3 -3
  25. package/dist/client/assets/{main-s5RJQPnO.js.map → main-Cxu5WF7C.js.map} +1 -1
  26. package/dist/client/assets/main-Dbnvjs-Q.js +119 -0
  27. package/dist/client/assets/{main-Dv0pElLW.js.map → main-Dbnvjs-Q.js.map} +1 -1
  28. package/dist/client/index.html +1 -1
  29. package/dist/index.d.ts +5 -34
  30. package/dist/index.js +471 -1058
  31. package/dist/socketio/index.d.ts +4 -3
  32. package/package.json +5 -5
  33. package/dist/characters/default.d.ts +0 -14
  34. package/dist/client/assets/main-Dv0pElLW.js +0 -141
  35. package/dist/managers/ConfigManager.d.ts +0 -32
  36. package/dist/managers/PluginLoader.d.ts +0 -27
package/dist/index.js CHANGED
@@ -21934,12 +21934,11 @@ var require_src32 = __commonJS((exports) => {
21934
21934
 
21935
21935
  // src/index.ts
21936
21936
  import {
21937
- logger as logger31,
21937
+ logger as logger30,
21938
21938
  parseBooleanFromText,
21939
21939
  getDatabaseDir,
21940
21940
  getGeneratedDir as getGeneratedDir2,
21941
- getUploadsAgentsDir as getUploadsAgentsDir4,
21942
- ElizaOS as ElizaOS2
21941
+ getUploadsAgentsDir as getUploadsAgentsDir4
21943
21942
  } from "@elizaos/core";
21944
21943
  import cors2 from "cors";
21945
21944
  import express33 from "express";
@@ -22484,10 +22483,10 @@ var helmet = Object.assign(function helmet2(options = {}) {
22484
22483
  });
22485
22484
 
22486
22485
  // src/index.ts
22487
- import * as fs7 from "node:fs";
22486
+ import * as fs6 from "node:fs";
22488
22487
  import http4 from "node:http";
22489
22488
  import os3 from "node:os";
22490
- import path9, { basename as basename2, dirname as dirname3, extname, join as join5 } from "node:path";
22489
+ import path8, { basename as basename2, dirname as dirname3, extname, join as join4 } from "node:path";
22491
22490
  import { fileURLToPath as fileURLToPath2 } from "node:url";
22492
22491
 
22493
22492
  // src/api/index.ts
@@ -22530,7 +22529,7 @@ var sendSuccess = (res, data, status = 200) => {
22530
22529
  };
22531
22530
 
22532
22531
  // src/api/agents/crud.ts
22533
- function createAgentCrudRouter(elizaOS, serverInstance) {
22532
+ function createAgentCrudRouter(agents, serverInstance) {
22534
22533
  const router = express.Router();
22535
22534
  const db = serverInstance?.database;
22536
22535
  router.get("/", async (_, res) => {
@@ -22539,7 +22538,7 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
22539
22538
  return sendError(res, 500, "DB_ERROR", "Database not available");
22540
22539
  }
22541
22540
  const allAgents = await db.getAgents();
22542
- const runtimes = elizaOS.getAgents().map((a) => a.agentId);
22541
+ const runtimes = Array.from(agents.keys());
22543
22542
  const response = allAgents.map((agent) => ({
22544
22543
  id: agent.id,
22545
22544
  name: agent.name || "",
@@ -22571,7 +22570,7 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
22571
22570
  if (!agent) {
22572
22571
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22573
22572
  }
22574
- const runtime = elizaOS.getAgent(agentId);
22573
+ const runtime = agents.get(agentId);
22575
22574
  const response = {
22576
22575
  ...agent,
22577
22576
  status: runtime ? "active" : "inactive"
@@ -22671,13 +22670,12 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
22671
22670
  await db.updateAgent(agentId, updates);
22672
22671
  }
22673
22672
  const updatedAgent = await db.getAgent(agentId);
22674
- const activeRuntime = elizaOS.getAgent(agentId);
22675
- if (activeRuntime && updatedAgent) {
22676
- const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
22677
- await elizaOS.updateAgent(agentId, characterData);
22678
- logger.debug(`[AGENT UPDATE] Updated active agent ${agentId} without restart`);
22673
+ const isActive = !!agents.get(agentId);
22674
+ if (isActive && updatedAgent) {
22675
+ serverInstance?.unregisterAgent(agentId);
22676
+ await serverInstance?.startAgent(updatedAgent);
22679
22677
  }
22680
- const runtime = elizaOS.getAgent(agentId);
22678
+ const runtime = agents.get(agentId);
22681
22679
  const status = runtime ? "active" : "inactive";
22682
22680
  sendSuccess(res, { ...updatedAgent, status });
22683
22681
  } catch (error) {
@@ -22721,11 +22719,11 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
22721
22719
  let lastError = null;
22722
22720
  while (retryCount <= MAX_RETRIES) {
22723
22721
  try {
22724
- const runtime = elizaOS.getAgent(agentId);
22722
+ const runtime = agents.get(agentId);
22725
22723
  if (runtime) {
22726
22724
  logger.debug(`[AGENT DELETE] Agent ${agentId} is running, unregistering from server`);
22727
22725
  try {
22728
- await serverInstance?.unregisterAgent(agentId);
22726
+ serverInstance?.unregisterAgent(agentId);
22729
22727
  logger.debug(`[AGENT DELETE] Agent ${agentId} unregistered successfully`);
22730
22728
  } catch (stopError) {
22731
22729
  logger.error(`[AGENT DELETE] Error stopping agent ${agentId}:`, stopError instanceof Error ? stopError.message : String(stopError));
@@ -22784,7 +22782,7 @@ function createAgentCrudRouter(elizaOS, serverInstance) {
22784
22782
  // src/api/agents/lifecycle.ts
22785
22783
  import { validateUuid as validateUuid2, logger as logger2 } from "@elizaos/core";
22786
22784
  import express2 from "express";
22787
- function createAgentLifecycleRouter(elizaOS, serverInstance) {
22785
+ function createAgentLifecycleRouter(agents, serverInstance) {
22788
22786
  const router = express2.Router();
22789
22787
  const db = serverInstance?.database;
22790
22788
  router.post("/:agentId/start", async (req, res) => {
@@ -22801,7 +22799,7 @@ function createAgentLifecycleRouter(elizaOS, serverInstance) {
22801
22799
  logger2.debug("[AGENT START] Agent not found");
22802
22800
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22803
22801
  }
22804
- const isActive = !!elizaOS.getAgent(agentId);
22802
+ const isActive = !!agents.get(agentId);
22805
22803
  if (isActive) {
22806
22804
  logger2.debug(`[AGENT START] Agent ${agentId} is already running`);
22807
22805
  return sendSuccess(res, {
@@ -22810,8 +22808,8 @@ function createAgentLifecycleRouter(elizaOS, serverInstance) {
22810
22808
  status: "active"
22811
22809
  });
22812
22810
  }
22813
- await serverInstance?.startAgents([agent]);
22814
- const runtime = elizaOS.getAgent(agentId);
22811
+ await serverInstance?.startAgent(agent);
22812
+ const runtime = agents.get(agentId);
22815
22813
  if (!runtime) {
22816
22814
  throw new Error("Failed to start agent");
22817
22815
  }
@@ -22832,11 +22830,11 @@ function createAgentLifecycleRouter(elizaOS, serverInstance) {
22832
22830
  logger2.debug("[AGENT STOP] Invalid agent ID format");
22833
22831
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
22834
22832
  }
22835
- const runtime = elizaOS.getAgent(agentId);
22833
+ const runtime = agents.get(agentId);
22836
22834
  if (!runtime) {
22837
22835
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22838
22836
  }
22839
- await serverInstance?.unregisterAgent(agentId);
22837
+ serverInstance?.unregisterAgent(agentId);
22840
22838
  logger2.debug(`[AGENT STOP] Successfully stopped agent: ${runtime.character.name} (${agentId})`);
22841
22839
  sendSuccess(res, {
22842
22840
  message: "Agent stopped"
@@ -22848,11 +22846,11 @@ function createAgentLifecycleRouter(elizaOS, serverInstance) {
22848
22846
  // src/api/agents/worlds.ts
22849
22847
  import { validateUuid as validateUuid3, logger as logger3, createUniqueUuid } from "@elizaos/core";
22850
22848
  import express3 from "express";
22851
- function createAgentWorldsRouter(elizaOS) {
22849
+ function createAgentWorldsRouter(agents) {
22852
22850
  const router = express3.Router();
22853
22851
  router.get("/worlds", async (_req, res) => {
22854
22852
  try {
22855
- const runtime = elizaOS.getAgents()[0];
22853
+ const runtime = Array.from(agents.values())[0];
22856
22854
  if (!runtime) {
22857
22855
  return sendError(res, 404, "NOT_FOUND", "No active agents found to get worlds");
22858
22856
  }
@@ -22889,7 +22887,7 @@ function createAgentWorldsRouter(elizaOS) {
22889
22887
  if (!agentId) {
22890
22888
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
22891
22889
  }
22892
- const runtime = elizaOS.getAgent(agentId);
22890
+ const runtime = agents.get(agentId);
22893
22891
  if (!runtime) {
22894
22892
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22895
22893
  }
@@ -22901,7 +22899,7 @@ function createAgentWorldsRouter(elizaOS) {
22901
22899
  if (!agentId || !worldId) {
22902
22900
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID or world ID format");
22903
22901
  }
22904
- const runtime = elizaOS.getAgent(agentId);
22902
+ const runtime = agents.get(agentId);
22905
22903
  if (!runtime) {
22906
22904
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22907
22905
  }
@@ -22930,14 +22928,14 @@ function createAgentWorldsRouter(elizaOS) {
22930
22928
  // src/api/agents/panels.ts
22931
22929
  import { validateUuid as validateUuid4, logger as logger4 } from "@elizaos/core";
22932
22930
  import express4 from "express";
22933
- function createAgentPanelsRouter(elizaOS) {
22931
+ function createAgentPanelsRouter(agents) {
22934
22932
  const router = express4.Router();
22935
22933
  router.get("/:agentId/panels", async (req, res) => {
22936
22934
  const agentId = validateUuid4(req.params.agentId);
22937
22935
  if (!agentId) {
22938
22936
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
22939
22937
  }
22940
- const runtime = elizaOS.getAgent(agentId);
22938
+ const runtime = agents.get(agentId);
22941
22939
  if (!runtime) {
22942
22940
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22943
22941
  }
@@ -22958,7 +22956,7 @@ function createAgentPanelsRouter(elizaOS) {
22958
22956
  // src/api/agents/logs.ts
22959
22957
  import { validateUuid as validateUuid5, logger as logger5 } from "@elizaos/core";
22960
22958
  import express5 from "express";
22961
- function createAgentLogsRouter(elizaOS) {
22959
+ function createAgentLogsRouter(agents) {
22962
22960
  const router = express5.Router();
22963
22961
  router.get("/:agentId/logs", async (req, res) => {
22964
22962
  const agentId = validateUuid5(req.params.agentId);
@@ -22966,7 +22964,7 @@ function createAgentLogsRouter(elizaOS) {
22966
22964
  if (!agentId) {
22967
22965
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
22968
22966
  }
22969
- const runtime = elizaOS.getAgent(agentId);
22967
+ const runtime = agents.get(agentId);
22970
22968
  if (!runtime) {
22971
22969
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
22972
22970
  }
@@ -23012,7 +23010,7 @@ function createAgentLogsRouter(elizaOS) {
23012
23010
  if (!agentId || !logId) {
23013
23011
  return sendError(res, 400, "INVALID_ID", "Invalid agent or log ID format");
23014
23012
  }
23015
- const runtime = elizaOS.getAgent(agentId);
23013
+ const runtime = agents.get(agentId);
23016
23014
  if (!runtime) {
23017
23015
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23018
23016
  }
@@ -23030,14 +23028,14 @@ function createAgentLogsRouter(elizaOS) {
23030
23028
  // src/api/agents/runs.ts
23031
23029
  import { validateUuid as validateUuid6 } from "@elizaos/core";
23032
23030
  import express6 from "express";
23033
- function createAgentRunsRouter(elizaOS) {
23031
+ function createAgentRunsRouter(agents) {
23034
23032
  const router = express6.Router();
23035
23033
  router.get("/:agentId/runs", async (req, res) => {
23036
23034
  const agentId = validateUuid6(req.params.agentId);
23037
23035
  if (!agentId) {
23038
23036
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
23039
23037
  }
23040
- const runtime = elizaOS.getAgent(agentId);
23038
+ const runtime = agents.get(agentId);
23041
23039
  if (!runtime) {
23042
23040
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23043
23041
  }
@@ -23186,7 +23184,7 @@ function createAgentRunsRouter(elizaOS) {
23186
23184
  if (roomId && !validateUuid6(roomId)) {
23187
23185
  return sendError(res, 400, "INVALID_ID", "Invalid room ID format");
23188
23186
  }
23189
- const runtime = elizaOS.getAgent(agentId);
23187
+ const runtime = agents.get(agentId);
23190
23188
  if (!runtime) {
23191
23189
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23192
23190
  }
@@ -23322,7 +23320,7 @@ function createAgentRunsRouter(elizaOS) {
23322
23320
  import { MemoryType, createUniqueUuid as createUniqueUuid2 } from "@elizaos/core";
23323
23321
  import { validateUuid as validateUuid7, logger as logger6 } from "@elizaos/core";
23324
23322
  import express7 from "express";
23325
- function createAgentMemoryRouter(elizaOS) {
23323
+ function createAgentMemoryRouter(agents) {
23326
23324
  const router = express7.Router();
23327
23325
  router.get("/:agentId/rooms/:roomId/memories", async (req, res) => {
23328
23326
  const agentId = validateUuid7(req.params.agentId);
@@ -23330,7 +23328,7 @@ function createAgentMemoryRouter(elizaOS) {
23330
23328
  if (!agentId || !roomId) {
23331
23329
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID or room ID format");
23332
23330
  }
23333
- const runtime = elizaOS.getAgent(agentId);
23331
+ const runtime = agents.get(agentId);
23334
23332
  if (!runtime) {
23335
23333
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23336
23334
  }
@@ -23360,7 +23358,7 @@ function createAgentMemoryRouter(elizaOS) {
23360
23358
  if (!agentId) {
23361
23359
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID");
23362
23360
  }
23363
- const runtime = elizaOS.getAgent(agentId);
23361
+ const runtime = agents.get(agentId);
23364
23362
  if (!runtime) {
23365
23363
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23366
23364
  }
@@ -23404,7 +23402,7 @@ function createAgentMemoryRouter(elizaOS) {
23404
23402
  if (!agentId || !memoryId) {
23405
23403
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID or memory ID format");
23406
23404
  }
23407
- const runtime = elizaOS.getAgent(agentId);
23405
+ const runtime = agents.get(agentId);
23408
23406
  if (!runtime) {
23409
23407
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23410
23408
  }
@@ -23437,7 +23435,7 @@ function createAgentMemoryRouter(elizaOS) {
23437
23435
  if (!agentId) {
23438
23436
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID");
23439
23437
  }
23440
- const runtime = elizaOS.getAgent(agentId);
23438
+ const runtime = agents.get(agentId);
23441
23439
  if (!runtime) {
23442
23440
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23443
23441
  }
@@ -23459,7 +23457,7 @@ function createAgentMemoryRouter(elizaOS) {
23459
23457
  if (!roomId) {
23460
23458
  return sendError(res, 400, "INVALID_ID", "Invalid room ID");
23461
23459
  }
23462
- const runtime = elizaOS.getAgent(agentId);
23460
+ const runtime = agents.get(agentId);
23463
23461
  if (!runtime) {
23464
23462
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23465
23463
  }
@@ -23478,7 +23476,7 @@ function createAgentMemoryRouter(elizaOS) {
23478
23476
  if (!agentId || !memoryId) {
23479
23477
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID or memory ID format");
23480
23478
  }
23481
- const runtime = elizaOS.getAgent(agentId);
23479
+ const runtime = agents.get(agentId);
23482
23480
  if (!runtime) {
23483
23481
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23484
23482
  }
@@ -23495,14 +23493,14 @@ function createAgentMemoryRouter(elizaOS) {
23495
23493
  // src/api/memory/rooms.ts
23496
23494
  import { validateUuid as validateUuid8, logger as logger7, createUniqueUuid as createUniqueUuid3, ChannelType } from "@elizaos/core";
23497
23495
  import express8 from "express";
23498
- function createRoomManagementRouter(elizaOS) {
23496
+ function createRoomManagementRouter(agents) {
23499
23497
  const router = express8.Router();
23500
23498
  router.post("/:agentId/rooms", async (req, res) => {
23501
23499
  const agentId = validateUuid8(req.params.agentId);
23502
23500
  if (!agentId) {
23503
23501
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
23504
23502
  }
23505
- const runtime = elizaOS.getAgent(agentId);
23503
+ const runtime = agents.get(agentId);
23506
23504
  if (!runtime) {
23507
23505
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23508
23506
  }
@@ -23559,7 +23557,7 @@ function createRoomManagementRouter(elizaOS) {
23559
23557
  if (!agentId) {
23560
23558
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
23561
23559
  }
23562
- const runtime = elizaOS.getAgent(agentId);
23560
+ const runtime = agents.get(agentId);
23563
23561
  if (!runtime) {
23564
23562
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23565
23563
  }
@@ -23589,7 +23587,7 @@ function createRoomManagementRouter(elizaOS) {
23589
23587
  if (!agentId || !roomId) {
23590
23588
  return sendError(res, 400, "INVALID_ID", "Invalid agent ID or room ID format");
23591
23589
  }
23592
- const runtime = elizaOS.getAgent(agentId);
23590
+ const runtime = agents.get(agentId);
23593
23591
  if (!runtime) {
23594
23592
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
23595
23593
  }
@@ -23616,16 +23614,16 @@ function createRoomManagementRouter(elizaOS) {
23616
23614
  }
23617
23615
 
23618
23616
  // src/api/agents/index.ts
23619
- function agentsRouter(elizaOS, serverInstance) {
23617
+ function agentsRouter(agents, serverInstance) {
23620
23618
  const router = express9.Router();
23621
- router.use("/", createAgentCrudRouter(elizaOS, serverInstance));
23622
- router.use("/", createAgentLifecycleRouter(elizaOS, serverInstance));
23623
- router.use("/", createAgentWorldsRouter(elizaOS));
23624
- router.use("/", createAgentPanelsRouter(elizaOS));
23625
- router.use("/", createAgentLogsRouter(elizaOS));
23626
- router.use("/", createAgentRunsRouter(elizaOS));
23627
- router.use("/", createAgentMemoryRouter(elizaOS));
23628
- router.use("/", createRoomManagementRouter(elizaOS));
23619
+ router.use("/", createAgentCrudRouter(agents, serverInstance));
23620
+ router.use("/", createAgentLifecycleRouter(agents, serverInstance));
23621
+ router.use("/", createAgentWorldsRouter(agents));
23622
+ router.use("/", createAgentPanelsRouter(agents));
23623
+ router.use("/", createAgentLogsRouter(agents));
23624
+ router.use("/", createAgentRunsRouter(agents));
23625
+ router.use("/", createAgentMemoryRouter(agents));
23626
+ router.use("/", createRoomManagementRouter(agents));
23629
23627
  return router;
23630
23628
  }
23631
23629
 
@@ -24180,8 +24178,8 @@ import { validateUuid as validateUuid12, logger as logger11 } from "@elizaos/cor
24180
24178
 
24181
24179
  // src/api/shared/validation.ts
24182
24180
  import { validateUuid as validateUuid11, logger as logger10 } from "@elizaos/core";
24183
- var getRuntime = (elizaOS, agentId) => {
24184
- const runtime = elizaOS.getAgent(agentId);
24181
+ var getRuntime = (agents, agentId) => {
24182
+ const runtime = agents.get(agentId);
24185
24183
  if (!runtime) {
24186
24184
  throw new Error(`Agent not found: ${agentId}`);
24187
24185
  }
@@ -24923,7 +24921,7 @@ async function saveChannelUploadedFile(file, channelId) {
24923
24921
  const url = `/media/uploads/channels/${channelId}/${filename}`;
24924
24922
  return { filename, url };
24925
24923
  }
24926
- function createChannelsRouter(elizaOS, serverInstance) {
24924
+ function createChannelsRouter(agents, serverInstance) {
24927
24925
  const router = express12.Router();
24928
24926
  router.post("/central-channels/:channelId/messages", async (req, res) => {
24929
24927
  const channelIdParam = validateUuid13(req.params.channelId);
@@ -25496,7 +25494,7 @@ function createChannelsRouter(elizaOS, serverInstance) {
25496
25494
  });
25497
25495
  }
25498
25496
  try {
25499
- const runtime = elizaOS.getAgent(agentId);
25497
+ const runtime = agents.get(agentId);
25500
25498
  if (!runtime) {
25501
25499
  return res.status(404).json({
25502
25500
  success: false,
@@ -26002,7 +26000,7 @@ function asyncHandler(fn) {
26002
26000
  Promise.resolve(fn(req, res, next)).catch(next);
26003
26001
  };
26004
26002
  }
26005
- function createSessionsRouter(elizaOS, serverInstance) {
26003
+ function createSessionsRouter(agents, serverInstance) {
26006
26004
  const router = express13.Router();
26007
26005
  router.get("/sessions/health", (_req, res) => {
26008
26006
  const now = Date.now();
@@ -26042,7 +26040,7 @@ function createSessionsRouter(elizaOS, serverInstance) {
26042
26040
  if (!validateUuid14(body.userId)) {
26043
26041
  throw new InvalidUuidError("userId", body.userId);
26044
26042
  }
26045
- const agent = elizaOS.getAgent(body.agentId);
26043
+ const agent = agents.get(body.agentId);
26046
26044
  if (!agent) {
26047
26045
  throw new AgentNotFoundError(body.agentId);
26048
26046
  }
@@ -26350,7 +26348,7 @@ function createSessionsRouter(elizaOS, serverInstance) {
26350
26348
  }
26351
26349
  }
26352
26350
  }
26353
- const agent = elizaOS.getAgent(session.agentId);
26351
+ const agent = agents.get(session.agentId);
26354
26352
  const agentConfig = agent ? getAgentTimeoutConfig(agent) : undefined;
26355
26353
  session.timeoutConfig = mergeTimeoutConfigs(newConfig, agentConfig);
26356
26354
  session.expiresAt = calculateExpirationDate(session.createdAt, session.lastActivity, session.timeoutConfig, session.renewalCount);
@@ -26467,15 +26465,15 @@ function createSessionsRouter(elizaOS, serverInstance) {
26467
26465
  }
26468
26466
 
26469
26467
  // src/api/messaging/index.ts
26470
- function messagingRouter(elizaOS, serverInstance) {
26468
+ function messagingRouter(agents, serverInstance) {
26471
26469
  const router = express14.Router();
26472
26470
  if (!serverInstance) {
26473
26471
  throw new Error("ServerInstance is required for messaging router");
26474
26472
  }
26475
26473
  router.use("/", createMessagingCoreRouter(serverInstance));
26476
26474
  router.use("/", createServersRouter(serverInstance));
26477
- router.use("/", createChannelsRouter(elizaOS, serverInstance));
26478
- router.use("/", createSessionsRouter(elizaOS, serverInstance));
26475
+ router.use("/", createChannelsRouter(agents, serverInstance));
26476
+ router.use("/", createSessionsRouter(agents, serverInstance));
26479
26477
  return router;
26480
26478
  }
26481
26479
 
@@ -26671,7 +26669,7 @@ function validateAudioFile(file) {
26671
26669
  return ALLOWED_AUDIO_MIME_TYPES.some((allowed) => allowed === file.mimetype);
26672
26670
  }
26673
26671
  // src/api/memory/groups.ts
26674
- function createGroupMemoryRouter(elizaOS, serverInstance) {
26672
+ function createGroupMemoryRouter(agents, serverInstance) {
26675
26673
  const router = express18.Router();
26676
26674
  const db = serverInstance?.database;
26677
26675
  router.post("/groups/:serverId", async (req, res) => {
@@ -26684,7 +26682,7 @@ function createGroupMemoryRouter(elizaOS, serverInstance) {
26684
26682
  let errors = [];
26685
26683
  for (const agentId of agentIds) {
26686
26684
  try {
26687
- const runtime = getRuntime(elizaOS, agentId);
26685
+ const runtime = getRuntime(agents, agentId);
26688
26686
  const roomId = createUniqueUuid4(runtime, serverId);
26689
26687
  const roomName = name || `Chat ${new Date().toLocaleString()}`;
26690
26688
  await runtime.ensureWorldExists({
@@ -26776,11 +26774,11 @@ function createGroupMemoryRouter(elizaOS, serverInstance) {
26776
26774
  }
26777
26775
 
26778
26776
  // src/api/memory/index.ts
26779
- function memoryRouter(elizaOS, serverInstance) {
26777
+ function memoryRouter(agents, serverInstance) {
26780
26778
  const router = express19.Router();
26781
- router.use("/", createAgentMemoryRouter(elizaOS));
26782
- router.use("/", createGroupMemoryRouter(elizaOS, serverInstance));
26783
- router.use("/", createRoomManagementRouter(elizaOS));
26779
+ router.use("/", createAgentMemoryRouter(agents));
26780
+ router.use("/", createGroupMemoryRouter(agents, serverInstance));
26781
+ router.use("/", createRoomManagementRouter(agents));
26784
26782
  return router;
26785
26783
  }
26786
26784
 
@@ -26790,7 +26788,7 @@ import express23 from "express";
26790
26788
  // src/api/audio/processing.ts
26791
26789
  import { logger as logger19, ModelType as ModelType2, validateUuid as validateUuid19 } from "@elizaos/core";
26792
26790
  import express20 from "express";
26793
- function createAudioProcessingRouter(elizaOS) {
26791
+ function createAudioProcessingRouter(agents) {
26794
26792
  const router = express20.Router();
26795
26793
  router.use(createUploadRateLimit());
26796
26794
  router.use(createFileSystemRateLimit());
@@ -26805,7 +26803,7 @@ function createAudioProcessingRouter(elizaOS) {
26805
26803
  if (!audioFile) {
26806
26804
  return sendError(res, 400, "INVALID_REQUEST", "No audio file provided");
26807
26805
  }
26808
- const runtime = elizaOS.getAgent(agentId);
26806
+ const runtime = agents.get(agentId);
26809
26807
  if (!runtime) {
26810
26808
  cleanupUploadedFile(audioFile);
26811
26809
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
@@ -26840,7 +26838,7 @@ function createAudioProcessingRouter(elizaOS) {
26840
26838
  if (!audioFile) {
26841
26839
  return sendError(res, 400, "INVALID_REQUEST", "No audio file provided");
26842
26840
  }
26843
- const runtime = elizaOS.getAgent(agentId);
26841
+ const runtime = agents.get(agentId);
26844
26842
  if (!runtime) {
26845
26843
  cleanupUploadedFile(audioFile);
26846
26844
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
@@ -26929,7 +26927,7 @@ async function convertToAudioBuffer(speechResponse, detectMimeType) {
26929
26927
  }
26930
26928
 
26931
26929
  // src/api/audio/synthesis.ts
26932
- function createSynthesisRouter(elizaOS) {
26930
+ function createSynthesisRouter(agents) {
26933
26931
  const router = express21.Router();
26934
26932
  router.post("/:agentId/audio-messages/synthesize", async (req, res) => {
26935
26933
  const agentId = validateUuid20(req.params.agentId);
@@ -26940,7 +26938,7 @@ function createSynthesisRouter(elizaOS) {
26940
26938
  if (!text) {
26941
26939
  return sendError(res, 400, "INVALID_REQUEST", "Text is required for speech synthesis");
26942
26940
  }
26943
- const runtime = elizaOS.getAgent(agentId);
26941
+ const runtime = agents.get(agentId);
26944
26942
  if (!runtime) {
26945
26943
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
26946
26944
  }
@@ -26968,7 +26966,7 @@ function createSynthesisRouter(elizaOS) {
26968
26966
  if (!text) {
26969
26967
  return sendError(res, 400, "INVALID_REQUEST", "Text is required for speech synthesis");
26970
26968
  }
26971
- const runtime = elizaOS.getAgent(agentId);
26969
+ const runtime = agents.get(agentId);
26972
26970
  if (!runtime) {
26973
26971
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
26974
26972
  }
@@ -27003,7 +27001,7 @@ import {
27003
27001
  messageHandlerTemplate
27004
27002
  } from "@elizaos/core";
27005
27003
  import express22 from "express";
27006
- function createConversationRouter(elizaOS) {
27004
+ function createConversationRouter(agents) {
27007
27005
  const router = express22.Router();
27008
27006
  router.post("/:agentId/speech/conversation", async (req, res) => {
27009
27007
  const agentId = validateUuid21(req.params.agentId);
@@ -27014,7 +27012,7 @@ function createConversationRouter(elizaOS) {
27014
27012
  if (!text) {
27015
27013
  return sendError(res, 400, "INVALID_REQUEST", "Text is required for conversation");
27016
27014
  }
27017
- const runtime = elizaOS.getAgent(agentId);
27015
+ const runtime = agents.get(agentId);
27018
27016
  if (!runtime) {
27019
27017
  return sendError(res, 404, "NOT_FOUND", "Agent not found");
27020
27018
  }
@@ -27107,11 +27105,11 @@ function createConversationRouter(elizaOS) {
27107
27105
  }
27108
27106
 
27109
27107
  // src/api/audio/index.ts
27110
- function audioRouter(elizaOS) {
27108
+ function audioRouter(agents) {
27111
27109
  const router = express23.Router();
27112
- router.use("/", createAudioProcessingRouter(elizaOS));
27113
- router.use("/", createSynthesisRouter(elizaOS));
27114
- router.use("/", createConversationRouter(elizaOS));
27110
+ router.use("/", createAudioProcessingRouter(agents));
27111
+ router.use("/", createSynthesisRouter(agents));
27112
+ router.use("/", createConversationRouter(agents));
27115
27113
  return router;
27116
27114
  }
27117
27115
 
@@ -27121,7 +27119,7 @@ import express27 from "express";
27121
27119
  // src/api/runtime/health.ts
27122
27120
  import { logger as logger22 } from "@elizaos/core";
27123
27121
  import express24 from "express";
27124
- function createHealthRouter(elizaOS, serverInstance) {
27122
+ function createHealthRouter(agents, serverInstance) {
27125
27123
  const router = express24.Router();
27126
27124
  router.get("/ping", (_req, res) => {
27127
27125
  res.json({ pong: true, timestamp: Date.now() });
@@ -27136,7 +27134,7 @@ function createHealthRouter(elizaOS, serverInstance) {
27136
27134
  res.setHeader("Content-Type", "application/json");
27137
27135
  res.send(JSON.stringify({
27138
27136
  status: "ok",
27139
- agentCount: elizaOS.getAgents().length,
27137
+ agentCount: agents.size,
27140
27138
  timestamp: new Date().toISOString()
27141
27139
  }));
27142
27140
  });
@@ -27147,7 +27145,7 @@ function createHealthRouter(elizaOS, serverInstance) {
27147
27145
  version: process.env.APP_VERSION || "unknown",
27148
27146
  timestamp: new Date().toISOString(),
27149
27147
  dependencies: {
27150
- agents: elizaOS.getAgents().length > 0 ? "healthy" : "no_agents"
27148
+ agents: agents.size > 0 ? "healthy" : "no_agents"
27151
27149
  }
27152
27150
  };
27153
27151
  const statusCode = healthcheck.dependencies.agents === "healthy" ? 200 : 503;
@@ -27318,9 +27316,9 @@ function createDebugRouter(serverInstance) {
27318
27316
  }
27319
27317
 
27320
27318
  // src/api/runtime/index.ts
27321
- function runtimeRouter(elizaOS, serverInstance) {
27319
+ function runtimeRouter(agents, serverInstance) {
27322
27320
  const router = express27.Router();
27323
- router.use("/", createHealthRouter(elizaOS, serverInstance));
27321
+ router.use("/", createHealthRouter(agents, serverInstance));
27324
27322
  router.use("/", createLoggingRouter());
27325
27323
  router.use("/debug", createDebugRouter(serverInstance));
27326
27324
  return router;
@@ -27454,7 +27452,7 @@ import express30 from "express";
27454
27452
  // package.json
27455
27453
  var package_default = {
27456
27454
  name: "@elizaos/server",
27457
- version: "1.5.12-alpha.1",
27455
+ version: "1.5.12",
27458
27456
  description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
27459
27457
  publishConfig: {
27460
27458
  access: "public",
@@ -27577,16 +27575,16 @@ import {
27577
27575
  var DEFAULT_SERVER_ID5 = "00000000-0000-0000-0000-000000000000";
27578
27576
 
27579
27577
  class SocketIORouter {
27580
- elizaOS;
27578
+ agents;
27581
27579
  connections;
27582
27580
  logStreamConnections;
27583
27581
  serverInstance;
27584
- constructor(elizaOS, serverInstance) {
27585
- this.elizaOS = elizaOS;
27582
+ constructor(agents, serverInstance) {
27583
+ this.agents = agents;
27586
27584
  this.connections = new Map;
27587
27585
  this.logStreamConnections = new Map;
27588
27586
  this.serverInstance = serverInstance;
27589
- logger25.info(`[SocketIO] Router initialized with ${this.elizaOS.getAgents().length} agents`);
27587
+ logger25.info(`[SocketIO] Router initialized with ${this.agents.size} agents`);
27590
27588
  }
27591
27589
  setupListeners(io) {
27592
27590
  logger25.info(`[SocketIO] Setting up Socket.IO event listeners`);
@@ -27678,7 +27676,7 @@ class SocketIORouter {
27678
27676
  const finalServerId = serverId || DEFAULT_SERVER_ID5;
27679
27677
  const isDm = metadata?.isDm || metadata?.channelType === ChannelType6.DM;
27680
27678
  logger25.info(`[SocketIO] Emitting ENTITY_JOINED event for entityId: ${entityId}, serverId: ${finalServerId}, isDm: ${isDm}`);
27681
- const runtime = this.elizaOS.getAgents()[0];
27679
+ const runtime = Array.from(this.agents.values())[0];
27682
27680
  if (runtime) {
27683
27681
  runtime.emitEvent(EventType.ENTITY_JOINED, {
27684
27682
  entityId,
@@ -27724,7 +27722,7 @@ class SocketIORouter {
27724
27722
  const isDmForWorldSetup = metadata?.isDm || metadata?.channelType === ChannelType6.DM;
27725
27723
  if (isDmForWorldSetup && senderId) {
27726
27724
  logger25.info(`[SocketIO] Detected DM channel during message submission, emitting ENTITY_JOINED for proper world setup`);
27727
- const runtime = this.elizaOS.getAgents()[0];
27725
+ const runtime = Array.from(this.agents.values())[0];
27728
27726
  if (runtime) {
27729
27727
  runtime.emitEvent(EventType.ENTITY_JOINED, {
27730
27728
  entityId: senderId,
@@ -27916,14 +27914,14 @@ class SocketIORouter {
27916
27914
  }
27917
27915
 
27918
27916
  // src/api/index.ts
27919
- function setupSocketIO(server, elizaOS, serverInstance) {
27917
+ function setupSocketIO(server, agents, serverInstance) {
27920
27918
  const io = new SocketIOServer(server, {
27921
27919
  cors: {
27922
27920
  origin: "*",
27923
27921
  methods: ["GET", "POST"]
27924
27922
  }
27925
27923
  });
27926
- const centralSocketRouter = new SocketIORouter(elizaOS, serverInstance);
27924
+ const centralSocketRouter = new SocketIORouter(agents, serverInstance);
27927
27925
  centralSocketRouter.setupListeners(io);
27928
27926
  setupLogStreaming(io, centralSocketRouter);
27929
27927
  return io;
@@ -27954,7 +27952,7 @@ function setupLogStreaming(io, router) {
27954
27952
  };
27955
27953
  }
27956
27954
  }
27957
- function createPluginRouteHandler(elizaOS) {
27955
+ function createPluginRouteHandler(agents) {
27958
27956
  return (req, res, next) => {
27959
27957
  logger26.debug("Handling plugin request in the plugin route handler", `path: ${req.path}, method: ${req.method}`, {
27960
27958
  path: req.path,
@@ -27978,7 +27976,7 @@ function createPluginRouteHandler(elizaOS) {
27978
27976
  logger26.debug(`JavaScript request in plugin handler: ${req.method} ${req.path}`);
27979
27977
  res.setHeader("Content-Type", "application/javascript");
27980
27978
  }
27981
- if (elizaOS.getAgents().length === 0) {
27979
+ if (agents.size === 0) {
27982
27980
  logger26.debug("No agents available, skipping plugin route handling.");
27983
27981
  return next();
27984
27982
  }
@@ -28056,7 +28054,7 @@ function createPluginRouteHandler(elizaOS) {
28056
28054
  return handled;
28057
28055
  }
28058
28056
  if (agentIdFromQuery && validateUuid23(agentIdFromQuery)) {
28059
- const runtime = elizaOS.getAgent(agentIdFromQuery);
28057
+ const runtime = agents.get(agentIdFromQuery);
28060
28058
  if (runtime) {
28061
28059
  logger26.debug(`Agent-scoped request for Agent ID: ${agentIdFromQuery} from query. Path: ${reqPath}`);
28062
28060
  handled = findRouteInRuntime(runtime);
@@ -28091,7 +28089,7 @@ function createPluginRouteHandler(elizaOS) {
28091
28089
  }
28092
28090
  } else {
28093
28091
  logger26.debug(`No valid agentId in query. Trying global match for path: ${reqPath}`);
28094
- for (const runtime of elizaOS.getAgents()) {
28092
+ for (const [_, runtime] of agents) {
28095
28093
  if (handled)
28096
28094
  break;
28097
28095
  handled = findRouteInRuntime(runtime);
@@ -28104,7 +28102,7 @@ function createPluginRouteHandler(elizaOS) {
28104
28102
  next();
28105
28103
  };
28106
28104
  }
28107
- function createApiRouter(elizaOS, serverInstance) {
28105
+ function createApiRouter(agents, serverInstance) {
28108
28106
  const router = express32.Router();
28109
28107
  router.use(helmet({
28110
28108
  contentSecurityPolicy: false,
@@ -28123,14 +28121,14 @@ function createApiRouter(elizaOS, serverInstance) {
28123
28121
  router.use(securityMiddleware());
28124
28122
  router.use("/media", mediaRouter());
28125
28123
  router.use(validateContentTypeMiddleware());
28126
- router.use("/agents", agentsRouter(elizaOS, serverInstance));
28127
- router.use("/messaging", messagingRouter(elizaOS, serverInstance));
28128
- router.use("/memory", memoryRouter(elizaOS, serverInstance));
28129
- router.use("/audio", audioRouter(elizaOS));
28130
- router.use("/server", runtimeRouter(elizaOS, serverInstance));
28124
+ router.use("/agents", agentsRouter(agents, serverInstance));
28125
+ router.use("/messaging", messagingRouter(agents, serverInstance));
28126
+ router.use("/memory", memoryRouter(agents, serverInstance));
28127
+ router.use("/audio", audioRouter(agents));
28128
+ router.use("/server", runtimeRouter(agents, serverInstance));
28131
28129
  router.use("/tee", teeRouter());
28132
28130
  router.use("/system", systemRouter());
28133
- router.use(createPluginRouteHandler(elizaOS));
28131
+ router.use(createPluginRouteHandler(agents));
28134
28132
  return router;
28135
28133
  }
28136
28134
 
@@ -29011,7 +29009,7 @@ var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
29011
29009
  var GLOBAL_OBJ = globalThis;
29012
29010
 
29013
29011
  // ../../node_modules/@sentry/core/build/esm/utils/version.js
29014
- var SDK_VERSION = "10.13.0";
29012
+ var SDK_VERSION = "10.12.0";
29015
29013
 
29016
29014
  // ../../node_modules/@sentry/core/build/esm/carrier.js
29017
29015
  function getMainCarrier() {
@@ -30797,7 +30795,7 @@ function getActiveSpan() {
30797
30795
  function showSpanDropWarning() {
30798
30796
  if (!hasShownSpanDropWarning) {
30799
30797
  consoleSandbox(() => {
30800
- console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.");
30798
+ console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly.");
30801
30799
  });
30802
30800
  hasShownSpanDropWarning = true;
30803
30801
  }
@@ -30832,50 +30830,6 @@ function hasSpansEnabled(maybeOptions) {
30832
30830
  return !!options && (options.tracesSampleRate != null || !!options.tracesSampler);
30833
30831
  }
30834
30832
 
30835
- // ../../node_modules/@sentry/core/build/esm/utils/should-ignore-span.js
30836
- function logIgnoredSpan(droppedSpan) {
30837
- debug.log(`Ignoring span ${droppedSpan.op} - ${droppedSpan.description} because it matches \`ignoreSpans\`.`);
30838
- }
30839
- function shouldIgnoreSpan(span, ignoreSpans) {
30840
- if (!ignoreSpans?.length || !span.description) {
30841
- return false;
30842
- }
30843
- for (const pattern of ignoreSpans) {
30844
- if (isStringOrRegExp(pattern)) {
30845
- if (isMatchingPattern(span.description, pattern)) {
30846
- DEBUG_BUILD && logIgnoredSpan(span);
30847
- return true;
30848
- }
30849
- continue;
30850
- }
30851
- if (!pattern.name && !pattern.op) {
30852
- continue;
30853
- }
30854
- const nameMatches = pattern.name ? isMatchingPattern(span.description, pattern.name) : true;
30855
- const opMatches = pattern.op ? span.op && isMatchingPattern(span.op, pattern.op) : true;
30856
- if (nameMatches && opMatches) {
30857
- DEBUG_BUILD && logIgnoredSpan(span);
30858
- return true;
30859
- }
30860
- }
30861
- return false;
30862
- }
30863
- function reparentChildSpans(spans, dropSpan) {
30864
- const droppedSpanParentId = dropSpan.parent_span_id;
30865
- const droppedSpanId = dropSpan.span_id;
30866
- if (!droppedSpanParentId) {
30867
- return;
30868
- }
30869
- for (const span of spans) {
30870
- if (span.parent_span_id === droppedSpanId) {
30871
- span.parent_span_id = droppedSpanParentId;
30872
- }
30873
- }
30874
- }
30875
- function isStringOrRegExp(value) {
30876
- return typeof value === "string" || value instanceof RegExp;
30877
- }
30878
-
30879
30833
  // ../../node_modules/@sentry/core/build/esm/constants.js
30880
30834
  var DEFAULT_ENVIRONMENT = "production";
30881
30835
 
@@ -31233,6 +31187,45 @@ function createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn) {
31233
31187
  };
31234
31188
  }
31235
31189
 
31190
+ // ../../node_modules/@sentry/core/build/esm/utils/should-ignore-span.js
31191
+ function shouldIgnoreSpan(span, ignoreSpans) {
31192
+ if (!ignoreSpans?.length || !span.description) {
31193
+ return false;
31194
+ }
31195
+ for (const pattern of ignoreSpans) {
31196
+ if (isStringOrRegExp(pattern)) {
31197
+ if (isMatchingPattern(span.description, pattern)) {
31198
+ return true;
31199
+ }
31200
+ continue;
31201
+ }
31202
+ if (!pattern.name && !pattern.op) {
31203
+ continue;
31204
+ }
31205
+ const nameMatches = pattern.name ? isMatchingPattern(span.description, pattern.name) : true;
31206
+ const opMatches = pattern.op ? span.op && isMatchingPattern(span.op, pattern.op) : true;
31207
+ if (nameMatches && opMatches) {
31208
+ return true;
31209
+ }
31210
+ }
31211
+ return false;
31212
+ }
31213
+ function reparentChildSpans(spans, dropSpan) {
31214
+ const droppedSpanParentId = dropSpan.parent_span_id;
31215
+ const droppedSpanId = dropSpan.span_id;
31216
+ if (!droppedSpanParentId) {
31217
+ return;
31218
+ }
31219
+ for (const span of spans) {
31220
+ if (span.parent_span_id === droppedSpanId) {
31221
+ span.parent_span_id = droppedSpanParentId;
31222
+ }
31223
+ }
31224
+ }
31225
+ function isStringOrRegExp(value) {
31226
+ return typeof value === "string" || value instanceof RegExp;
31227
+ }
31228
+
31236
31229
  // ../../node_modules/@sentry/core/build/esm/envelope.js
31237
31230
  function _enhanceEventWithSdkInfo(event, newSdkInfo) {
31238
31231
  if (!newSdkInfo) {
@@ -31589,7 +31582,7 @@ function sendSpanEnvelope(envelope) {
31589
31582
  }
31590
31583
 
31591
31584
  // ../../node_modules/@sentry/core/build/esm/utils/handleCallbackErrors.js
31592
- function handleCallbackErrors(fn, onError, onFinally = () => {}, onSuccess = () => {}) {
31585
+ function handleCallbackErrors(fn, onError, onFinally = () => {}) {
31593
31586
  let maybePromiseResult;
31594
31587
  try {
31595
31588
  maybePromiseResult = fn();
@@ -31598,13 +31591,12 @@ function handleCallbackErrors(fn, onError, onFinally = () => {}, onSuccess = ()
31598
31591
  onFinally();
31599
31592
  throw e;
31600
31593
  }
31601
- return maybeHandlePromiseRejection(maybePromiseResult, onError, onFinally, onSuccess);
31594
+ return maybeHandlePromiseRejection(maybePromiseResult, onError, onFinally);
31602
31595
  }
31603
- function maybeHandlePromiseRejection(value, onError, onFinally, onSuccess) {
31596
+ function maybeHandlePromiseRejection(value, onError, onFinally) {
31604
31597
  if (isThenable(value)) {
31605
31598
  return value.then((res) => {
31606
31599
  onFinally();
31607
- onSuccess(res);
31608
31600
  return res;
31609
31601
  }, (e) => {
31610
31602
  onError(e);
@@ -31613,7 +31605,6 @@ function maybeHandlePromiseRejection(value, onError, onFinally, onSuccess) {
31613
31605
  });
31614
31606
  }
31615
31607
  onFinally();
31616
- onSuccess(value);
31617
31608
  return value;
31618
31609
  }
31619
31610
 
@@ -32714,21 +32705,23 @@ class Client {
32714
32705
  getTransport() {
32715
32706
  return this._transport;
32716
32707
  }
32717
- async flush(timeout) {
32708
+ flush(timeout) {
32718
32709
  const transport = this._transport;
32719
- if (!transport) {
32720
- return true;
32710
+ if (transport) {
32711
+ this.emit("flush");
32712
+ return this._isClientDoneProcessing(timeout).then((clientFinished) => {
32713
+ return transport.flush(timeout).then((transportFlushed) => clientFinished && transportFlushed);
32714
+ });
32715
+ } else {
32716
+ return resolvedSyncPromise(true);
32721
32717
  }
32722
- this.emit("flush");
32723
- const clientFinished = await this._isClientDoneProcessing(timeout);
32724
- const transportFlushed = await transport.flush(timeout);
32725
- return clientFinished && transportFlushed;
32726
32718
  }
32727
- async close(timeout) {
32728
- const result = await this.flush(timeout);
32729
- this.getOptions().enabled = false;
32730
- this.emit("close");
32731
- return result;
32719
+ close(timeout) {
32720
+ return this.flush(timeout).then((result) => {
32721
+ this.getOptions().enabled = false;
32722
+ this.emit("close");
32723
+ return result;
32724
+ });
32732
32725
  }
32733
32726
  getEventProcessors() {
32734
32727
  return this._eventProcessors;
@@ -32790,11 +32783,13 @@ class Client {
32790
32783
  }
32791
32784
  }
32792
32785
  on(hook, callback) {
32793
- const hookCallbacks = this._hooks[hook] = this._hooks[hook] || new Set;
32794
- const uniqueCallback = (...args) => callback(...args);
32795
- hookCallbacks.add(uniqueCallback);
32786
+ const hooks = this._hooks[hook] = this._hooks[hook] || [];
32787
+ hooks.push(callback);
32796
32788
  return () => {
32797
- hookCallbacks.delete(uniqueCallback);
32789
+ const cbIndex = hooks.indexOf(callback);
32790
+ if (cbIndex > -1) {
32791
+ hooks.splice(cbIndex, 1);
32792
+ }
32798
32793
  };
32799
32794
  }
32800
32795
  emit(hook, ...rest) {
@@ -32803,18 +32798,16 @@ class Client {
32803
32798
  callbacks.forEach((callback) => callback(...rest));
32804
32799
  }
32805
32800
  }
32806
- async sendEnvelope(envelope) {
32801
+ sendEnvelope(envelope) {
32807
32802
  this.emit("beforeEnvelope", envelope);
32808
32803
  if (this._isEnabled() && this._transport) {
32809
- try {
32810
- return await this._transport.send(envelope);
32811
- } catch (reason) {
32804
+ return this._transport.send(envelope).then(null, (reason) => {
32812
32805
  DEBUG_BUILD && debug.error("Error while sending envelope:", reason);
32813
32806
  return {};
32814
- }
32807
+ });
32815
32808
  }
32816
32809
  DEBUG_BUILD && debug.error("Transport disabled");
32817
- return {};
32810
+ return resolvedSyncPromise({});
32818
32811
  }
32819
32812
  _setupIntegrations() {
32820
32813
  const { integrations } = this._options;
@@ -32845,16 +32838,23 @@ class Client {
32845
32838
  this.captureSession(session);
32846
32839
  }
32847
32840
  }
32848
- async _isClientDoneProcessing(timeout) {
32849
- let ticked = 0;
32850
- while (!timeout || ticked < timeout) {
32851
- await new Promise((resolve) => setTimeout(resolve, 1));
32852
- if (!this._numProcessing) {
32853
- return true;
32854
- }
32855
- ticked++;
32856
- }
32857
- return false;
32841
+ _isClientDoneProcessing(timeout) {
32842
+ return new SyncPromise((resolve) => {
32843
+ let ticked = 0;
32844
+ const tick = 1;
32845
+ const interval = setInterval(() => {
32846
+ if (this._numProcessing == 0) {
32847
+ clearInterval(interval);
32848
+ resolve(true);
32849
+ } else {
32850
+ ticked += tick;
32851
+ if (timeout && ticked >= timeout) {
32852
+ clearInterval(interval);
32853
+ resolve(false);
32854
+ }
32855
+ }
32856
+ }, tick);
32857
+ });
32858
32858
  }
32859
32859
  _isEnabled() {
32860
32860
  return this.getOptions().enabled !== false && this._transport !== undefined;
@@ -33165,7 +33165,7 @@ function createLogEnvelope(logs, metadata, tunnel, dsn) {
33165
33165
  return createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
33166
33166
  }
33167
33167
 
33168
- // ../../node_modules/@sentry/core/build/esm/logs/internal.js
33168
+ // ../../node_modules/@sentry/core/build/esm/logs/exports.js
33169
33169
  function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
33170
33170
  const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
33171
33171
  if (logBuffer.length === 0) {
@@ -33566,7 +33566,7 @@ function createTransport(options, makeRequest, buffer = makePromiseBuffer(option
33566
33566
  }
33567
33567
  });
33568
33568
  if (filteredEnvelopeItems.length === 0) {
33569
- return Promise.resolve({});
33569
+ return resolvedSyncPromise({});
33570
33570
  }
33571
33571
  const filteredEnvelope = createEnvelope(envelope[0], filteredEnvelopeItems);
33572
33572
  const recordEnvelopeLoss = (reason) => {
@@ -33589,7 +33589,7 @@ function createTransport(options, makeRequest, buffer = makePromiseBuffer(option
33589
33589
  if (error2 === SENTRY_BUFFER_FULL_ERROR) {
33590
33590
  DEBUG_BUILD && debug.error("Skipped sending event because buffer is full.");
33591
33591
  recordEnvelopeLoss("queue_overflow");
33592
- return Promise.resolve({});
33592
+ return resolvedSyncPromise({});
33593
33593
  } else {
33594
33594
  throw error2;
33595
33595
  }
@@ -35059,9 +35059,6 @@ function getFinalOperationName(methodPath) {
35059
35059
  if (methodPath.includes("models")) {
35060
35060
  return "models";
35061
35061
  }
35062
- if (methodPath.includes("chat")) {
35063
- return "chat";
35064
- }
35065
35062
  return methodPath.split(".").pop() || "unknown";
35066
35063
  }
35067
35064
  function getSpanOperation2(methodPath) {
@@ -35089,6 +35086,18 @@ function setTokenUsageAttributes2(span, promptTokens, completionTokens, cachedIn
35089
35086
  }
35090
35087
  }
35091
35088
 
35089
+ // ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/constants.js
35090
+ var ANTHROPIC_AI_INTEGRATION_NAME = "Anthropic_AI";
35091
+ var ANTHROPIC_AI_INSTRUMENTED_METHODS = [
35092
+ "messages.create",
35093
+ "messages.stream",
35094
+ "messages.countTokens",
35095
+ "models.get",
35096
+ "completions.create",
35097
+ "models.retrieve",
35098
+ "beta.messages.create"
35099
+ ];
35100
+
35092
35101
  // ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/streaming.js
35093
35102
  function isErrorEvent3(event, span) {
35094
35103
  if ("type" in event && typeof event.type === "string") {
@@ -35238,18 +35247,6 @@ async function* instrumentStream2(stream, span, recordOutputs) {
35238
35247
  }
35239
35248
  }
35240
35249
 
35241
- // ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/constants.js
35242
- var ANTHROPIC_AI_INTEGRATION_NAME = "Anthropic_AI";
35243
- var ANTHROPIC_AI_INSTRUMENTED_METHODS = [
35244
- "messages.create",
35245
- "messages.stream",
35246
- "messages.countTokens",
35247
- "models.get",
35248
- "completions.create",
35249
- "models.retrieve",
35250
- "beta.messages.create"
35251
- ];
35252
-
35253
35250
  // ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/utils.js
35254
35251
  function shouldInstrument2(methodPath) {
35255
35252
  return ANTHROPIC_AI_INSTRUMENTED_METHODS.includes(methodPath);
@@ -35368,8 +35365,19 @@ function addResponseAttributes2(span, response, recordOutputs) {
35368
35365
  }
35369
35366
  addMetadataAttributes(span, response);
35370
35367
  }
35368
+ function getRecordingOptionsFromIntegration() {
35369
+ const scope = getCurrentScope();
35370
+ const client = scope.getClient();
35371
+ const integration = client?.getIntegrationByName(ANTHROPIC_AI_INTEGRATION_NAME);
35372
+ const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;
35373
+ return {
35374
+ recordInputs: integration?.options?.recordInputs ?? shouldRecordInputsAndOutputs,
35375
+ recordOutputs: integration?.options?.recordOutputs ?? shouldRecordInputsAndOutputs
35376
+ };
35377
+ }
35371
35378
  function instrumentMethod2(originalMethod, methodPath, context, options) {
35372
35379
  return async function instrumentedMethod(...args) {
35380
+ const finalOptions = options || getRecordingOptionsFromIntegration();
35373
35381
  const requestAttributes = extractRequestAttributes2(args, methodPath);
35374
35382
  const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
35375
35383
  const operationName = getFinalOperationName(methodPath);
@@ -35383,11 +35391,11 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
35383
35391
  attributes: requestAttributes
35384
35392
  }, async (span) => {
35385
35393
  try {
35386
- if (options.recordInputs && params) {
35394
+ if (finalOptions.recordInputs && params) {
35387
35395
  addPrivateRequestAttributes(span, params);
35388
35396
  }
35389
35397
  const result = await originalMethod.apply(context, args);
35390
- return instrumentStream2(result, span, options.recordOutputs ?? false);
35398
+ return instrumentStream2(result, span, finalOptions.recordOutputs ?? false);
35391
35399
  } catch (error2) {
35392
35400
  span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
35393
35401
  captureException(error2, {
@@ -35408,11 +35416,15 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
35408
35416
  name: `${operationName} ${model}`,
35409
35417
  op: getSpanOperation2(methodPath),
35410
35418
  attributes: requestAttributes
35411
- }, (span) => {
35412
- if (options.recordInputs && params) {
35413
- addPrivateRequestAttributes(span, params);
35414
- }
35415
- return handleCallbackErrors(() => originalMethod.apply(context, args), (error2) => {
35419
+ }, async (span) => {
35420
+ try {
35421
+ if (finalOptions.recordInputs && args[0] && typeof args[0] === "object") {
35422
+ addPrivateRequestAttributes(span, args[0]);
35423
+ }
35424
+ const result = await originalMethod.apply(context, args);
35425
+ addResponseAttributes2(span, result, finalOptions.recordOutputs);
35426
+ return result;
35427
+ } catch (error2) {
35416
35428
  captureException(error2, {
35417
35429
  mechanism: {
35418
35430
  handled: false,
@@ -35422,7 +35434,8 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
35422
35434
  }
35423
35435
  }
35424
35436
  });
35425
- }, () => {}, (result) => addResponseAttributes2(span, result, options.recordOutputs));
35437
+ throw error2;
35438
+ }
35426
35439
  });
35427
35440
  };
35428
35441
  }
@@ -35444,195 +35457,8 @@ function createDeepProxy2(target, currentPath = "", options) {
35444
35457
  }
35445
35458
  });
35446
35459
  }
35447
- function instrumentAnthropicAiClient(anthropicAiClient, options) {
35448
- const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);
35449
- const _options = {
35450
- recordInputs: sendDefaultPii,
35451
- recordOutputs: sendDefaultPii,
35452
- ...options
35453
- };
35454
- return createDeepProxy2(anthropicAiClient, "", _options);
35455
- }
35456
- // ../../node_modules/@sentry/core/build/esm/utils/google-genai/constants.js
35457
- var GOOGLE_GENAI_INTEGRATION_NAME = "Google_GenAI";
35458
- var GOOGLE_GENAI_INSTRUMENTED_METHODS = ["models.generateContent", "chats.create", "sendMessage"];
35459
- var GOOGLE_GENAI_SYSTEM_NAME = "google_genai";
35460
- var CHATS_CREATE_METHOD = "chats.create";
35461
- var CHAT_PATH = "chat";
35462
-
35463
- // ../../node_modules/@sentry/core/build/esm/utils/google-genai/utils.js
35464
- function shouldInstrument3(methodPath) {
35465
- if (GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(methodPath)) {
35466
- return true;
35467
- }
35468
- const methodName = methodPath.split(".").pop();
35469
- return GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(methodName);
35470
- }
35471
-
35472
- // ../../node_modules/@sentry/core/build/esm/utils/google-genai/index.js
35473
- function extractModel(params, context) {
35474
- if ("model" in params && typeof params.model === "string") {
35475
- return params.model;
35476
- }
35477
- if (context && typeof context === "object") {
35478
- const contextObj = context;
35479
- if ("model" in contextObj && typeof contextObj.model === "string") {
35480
- return contextObj.model;
35481
- }
35482
- if ("modelVersion" in contextObj && typeof contextObj.modelVersion === "string") {
35483
- return contextObj.modelVersion;
35484
- }
35485
- }
35486
- return "unknown";
35487
- }
35488
- function extractConfigAttributes(config) {
35489
- const attributes = {};
35490
- if ("temperature" in config && typeof config.temperature === "number") {
35491
- attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = config.temperature;
35492
- }
35493
- if ("topP" in config && typeof config.topP === "number") {
35494
- attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = config.topP;
35495
- }
35496
- if ("topK" in config && typeof config.topK === "number") {
35497
- attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = config.topK;
35498
- }
35499
- if ("maxOutputTokens" in config && typeof config.maxOutputTokens === "number") {
35500
- attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = config.maxOutputTokens;
35501
- }
35502
- if ("frequencyPenalty" in config && typeof config.frequencyPenalty === "number") {
35503
- attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = config.frequencyPenalty;
35504
- }
35505
- if ("presencePenalty" in config && typeof config.presencePenalty === "number") {
35506
- attributes[GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE] = config.presencePenalty;
35507
- }
35508
- return attributes;
35509
- }
35510
- function extractRequestAttributes3(args, methodPath, context) {
35511
- const attributes = {
35512
- [GEN_AI_SYSTEM_ATTRIBUTE]: GOOGLE_GENAI_SYSTEM_NAME,
35513
- [GEN_AI_OPERATION_NAME_ATTRIBUTE]: getFinalOperationName(methodPath),
35514
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ai.google_genai"
35515
- };
35516
- if (args.length > 0 && typeof args[0] === "object" && args[0] !== null) {
35517
- const params = args[0];
35518
- attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel(params, context);
35519
- if ("config" in params && typeof params.config === "object" && params.config) {
35520
- Object.assign(attributes, extractConfigAttributes(params.config));
35521
- }
35522
- } else {
35523
- attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel({}, context);
35524
- }
35525
- return attributes;
35526
- }
35527
- function addPrivateRequestAttributes2(span, params) {
35528
- if ("contents" in params) {
35529
- span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.contents) });
35530
- }
35531
- if ("message" in params) {
35532
- span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.message) });
35533
- }
35534
- if ("history" in params) {
35535
- span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.history) });
35536
- }
35537
- }
35538
- function addResponseAttributes3(span, response, recordOutputs) {
35539
- if (!response || typeof response !== "object")
35540
- return;
35541
- if (response.usageMetadata && typeof response.usageMetadata === "object") {
35542
- const usage = response.usageMetadata;
35543
- if (typeof usage.promptTokenCount === "number") {
35544
- span.setAttributes({
35545
- [GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: usage.promptTokenCount
35546
- });
35547
- }
35548
- if (typeof usage.candidatesTokenCount === "number") {
35549
- span.setAttributes({
35550
- [GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: usage.candidatesTokenCount
35551
- });
35552
- }
35553
- if (typeof usage.totalTokenCount === "number") {
35554
- span.setAttributes({
35555
- [GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: usage.totalTokenCount
35556
- });
35557
- }
35558
- }
35559
- if (recordOutputs && Array.isArray(response.candidates) && response.candidates.length > 0) {
35560
- const responseTexts = response.candidates.map((candidate) => {
35561
- if (candidate.content?.parts && Array.isArray(candidate.content.parts)) {
35562
- return candidate.content.parts.map((part) => typeof part.text === "string" ? part.text : "").filter((text) => text.length > 0).join("");
35563
- }
35564
- return "";
35565
- }).filter((text) => text.length > 0);
35566
- if (responseTexts.length > 0) {
35567
- span.setAttributes({
35568
- [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: responseTexts.join("")
35569
- });
35570
- }
35571
- }
35572
- }
35573
- function instrumentMethod3(originalMethod, methodPath, context, options) {
35574
- const isSyncCreate = methodPath === CHATS_CREATE_METHOD;
35575
- const run = (...args) => {
35576
- const requestAttributes = extractRequestAttributes3(args, methodPath, context);
35577
- const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
35578
- const operationName = getFinalOperationName(methodPath);
35579
- return startSpan({
35580
- name: isSyncCreate ? `${operationName} ${model} create` : `${operationName} ${model}`,
35581
- op: getSpanOperation2(methodPath),
35582
- attributes: requestAttributes
35583
- }, (span) => {
35584
- if (options.recordInputs && args[0] && typeof args[0] === "object") {
35585
- addPrivateRequestAttributes2(span, args[0]);
35586
- }
35587
- return handleCallbackErrors(() => originalMethod.apply(context, args), (error2) => {
35588
- captureException(error2, {
35589
- mechanism: { handled: false, type: "auto.ai.google_genai", data: { function: methodPath } }
35590
- });
35591
- }, () => {}, (result) => {
35592
- if (!isSyncCreate) {
35593
- addResponseAttributes3(span, result, options.recordOutputs);
35594
- }
35595
- });
35596
- });
35597
- };
35598
- return run;
35599
- }
35600
- function createDeepProxy3(target, currentPath = "", options) {
35601
- return new Proxy(target, {
35602
- get: (t, prop, receiver) => {
35603
- const value = Reflect.get(t, prop, receiver);
35604
- const methodPath = buildMethodPath2(currentPath, String(prop));
35605
- if (typeof value === "function" && shouldInstrument3(methodPath)) {
35606
- if (methodPath === CHATS_CREATE_METHOD) {
35607
- const instrumentedMethod = instrumentMethod3(value, methodPath, t, options);
35608
- return function instrumentedAndProxiedCreate(...args) {
35609
- const result = instrumentedMethod(...args);
35610
- if (result && typeof result === "object") {
35611
- return createDeepProxy3(result, CHAT_PATH, options);
35612
- }
35613
- return result;
35614
- };
35615
- }
35616
- return instrumentMethod3(value, methodPath, t, options);
35617
- }
35618
- if (typeof value === "function") {
35619
- return value.bind(t);
35620
- }
35621
- if (value && typeof value === "object") {
35622
- return createDeepProxy3(value, methodPath, options);
35623
- }
35624
- return value;
35625
- }
35626
- });
35627
- }
35628
- function instrumentGoogleGenAIClient(client, options) {
35629
- const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);
35630
- const _options = {
35631
- recordInputs: sendDefaultPii,
35632
- recordOutputs: sendDefaultPii,
35633
- ...options
35634
- };
35635
- return createDeepProxy3(client, "", _options);
35460
+ function instrumentAnthropicAiClient(client, options) {
35461
+ return createDeepProxy2(client, "", options);
35636
35462
  }
35637
35463
  // ../../node_modules/@sentry/core/build/esm/utils/breadcrumb-log-level.js
35638
35464
  function getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {
@@ -35646,35 +35472,6 @@ function getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {
35646
35472
  return;
35647
35473
  }
35648
35474
  }
35649
- // ../../node_modules/@sentry/core/build/esm/utils/exports.js
35650
- function replaceExports(exports, exportName, wrappedConstructor) {
35651
- const original = exports[exportName];
35652
- if (typeof original !== "function") {
35653
- return;
35654
- }
35655
- try {
35656
- exports[exportName] = wrappedConstructor;
35657
- } catch (error2) {
35658
- Object.defineProperty(exports, exportName, {
35659
- value: wrappedConstructor,
35660
- writable: true,
35661
- configurable: true,
35662
- enumerable: true
35663
- });
35664
- }
35665
- if (exports.default === original) {
35666
- try {
35667
- exports.default = wrappedConstructor;
35668
- } catch (error2) {
35669
- Object.defineProperty(exports, "default", {
35670
- value: wrappedConstructor,
35671
- writable: true,
35672
- configurable: true,
35673
- enumerable: true
35674
- });
35675
- }
35676
- }
35677
- }
35678
35475
  // ../../node_modules/@sentry/core/build/esm/utils/node-stack-trace.js
35679
35476
  function filenameIsInApp(filename, isNative = false) {
35680
35477
  const isInternal = isNative || filename && !filename.startsWith("/") && !filename.match(/^[A-Z]:/) && !filename.startsWith(".") && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//);
@@ -35802,9 +35599,6 @@ class LRUMap {
35802
35599
  return values;
35803
35600
  }
35804
35601
  }
35805
- // ../../node_modules/@sentry/node-core/build/esm/debug-build.js
35806
- var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
35807
-
35808
35602
  // ../../node_modules/@sentry/node-core/build/esm/otel/instrument.js
35809
35603
  var import_instrumentation = __toESM(require_src6(), 1);
35810
35604
  var INSTRUMENTED = {};
@@ -35880,6 +35674,9 @@ var import_core40 = __toESM(require_src3(), 1);
35880
35674
  var import_instrumentation2 = __toESM(require_src6(), 1);
35881
35675
  import { subscribe, unsubscribe } from "node:diagnostics_channel";
35882
35676
 
35677
+ // ../../node_modules/@sentry/node-core/build/esm/debug-build.js
35678
+ var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
35679
+
35883
35680
  // ../../node_modules/@sentry/node-core/build/esm/utils/getRequestUrl.js
35884
35681
  function getRequestUrl(requestOptions) {
35885
35682
  const protocol = requestOptions.protocol || "";
@@ -37693,8 +37490,7 @@ var instrumentSentryHttp = generateInstrumentOnce(`${INTEGRATION_NAME6}.sentry`,
37693
37490
  var httpIntegration = defineIntegration((options = {}) => {
37694
37491
  const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
37695
37492
  [401, 404],
37696
- [301, 303],
37697
- [305, 399]
37493
+ [300, 399]
37698
37494
  ];
37699
37495
  return {
37700
37496
  name: INTEGRATION_NAME6,
@@ -37709,27 +37505,20 @@ var httpIntegration = defineIntegration((options = {}) => {
37709
37505
  processEvent(event) {
37710
37506
  if (event.type === "transaction") {
37711
37507
  const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
37712
- if (typeof statusCode === "number") {
37713
- const shouldDrop = shouldFilterStatusCode(statusCode, dropSpansForIncomingRequestStatusCodes);
37714
- if (shouldDrop) {
37715
- DEBUG_BUILD2 && debug.log("Dropping transaction due to status code", statusCode);
37716
- return null;
37508
+ if (typeof statusCode === "number" && dropSpansForIncomingRequestStatusCodes.some((code) => {
37509
+ if (typeof code === "number") {
37510
+ return code === statusCode;
37717
37511
  }
37512
+ const [min, max] = code;
37513
+ return statusCode >= min && statusCode <= max;
37514
+ })) {
37515
+ return null;
37718
37516
  }
37719
37517
  }
37720
37518
  return event;
37721
37519
  }
37722
37520
  };
37723
37521
  });
37724
- function shouldFilterStatusCode(statusCode, dropForStatusCodes) {
37725
- return dropForStatusCodes.some((code) => {
37726
- if (typeof code === "number") {
37727
- return code === statusCode;
37728
- }
37729
- const [min, max] = code;
37730
- return statusCode >= min && statusCode <= max;
37731
- });
37732
- }
37733
37522
  // ../../node_modules/@sentry/node-core/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js
37734
37523
  var import_api5 = __toESM(require_src(), 1);
37735
37524
  var import_core44 = __toESM(require_src3(), 1);
@@ -38082,9 +37871,7 @@ var PLATFORM_NAMES = {
38082
37871
  freebsd: "FreeBSD",
38083
37872
  openbsd: "OpenBSD",
38084
37873
  sunos: "SunOS",
38085
- win32: "Windows",
38086
- ohos: "OpenHarmony",
38087
- android: "Android"
37874
+ win32: "Windows"
38088
37875
  };
38089
37876
  var LINUX_DISTROS = [
38090
37877
  { name: "fedora-release", distros: ["Fedora"] },
@@ -38519,7 +38306,7 @@ function functionNamesMatch(a, b) {
38519
38306
  }
38520
38307
 
38521
38308
  // ../../node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js
38522
- var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjEzLjAgKGQxOGE5NWUpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
38309
+ var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjEyLjAgKGEzYTA3MGIpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
38523
38310
  function log2(...args) {
38524
38311
  debug.log("[LocalVariables]", ...args);
38525
38312
  }
@@ -39791,7 +39578,7 @@ class NodeClient extends ServerRuntimeClient {
39791
39578
  }
39792
39579
  return super.flush(timeout);
39793
39580
  }
39794
- async close(timeout) {
39581
+ close(timeout) {
39795
39582
  if (this._clientReportInterval) {
39796
39583
  clearInterval(this._clientReportInterval);
39797
39584
  }
@@ -39801,11 +39588,7 @@ class NodeClient extends ServerRuntimeClient {
39801
39588
  if (this._logOnExitFlushListener) {
39802
39589
  process.off("beforeExit", this._logOnExitFlushListener);
39803
39590
  }
39804
- const allEventsSent = await super.close(timeout);
39805
- if (this.traceProvider) {
39806
- await this.traceProvider.shutdown();
39807
- }
39808
- return allEventsSent;
39591
+ return super.close(timeout).then((allEventsSent) => this.traceProvider ? this.traceProvider.shutdown().then(() => allEventsSent) : allEventsSent);
39809
39592
  }
39810
39593
  startClientReportTracking() {
39811
39594
  const clientOptions = this.getOptions();
@@ -39983,9 +39766,6 @@ function updateScopeFromEnvVariables() {
39983
39766
  function addOriginToSpan2(span, origin) {
39984
39767
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
39985
39768
  }
39986
- // ../../node_modules/@sentry/node/build/esm/debug-build.js
39987
- var DEBUG_BUILD4 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
39988
-
39989
39769
  // ../../node_modules/@sentry/node/build/esm/integrations/http.js
39990
39770
  var INTEGRATION_NAME18 = "Http";
39991
39771
  var INSTRUMENTATION_NAME2 = "@opentelemetry_sentry-patched/instrumentation-http";
@@ -40020,8 +39800,7 @@ function _shouldUseOtelHttpInstrumentation(options, clientOptions = {}) {
40020
39800
  var httpIntegration2 = defineIntegration((options = {}) => {
40021
39801
  const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
40022
39802
  [401, 404],
40023
- [301, 303],
40024
- [305, 399]
39803
+ [300, 399]
40025
39804
  ];
40026
39805
  return {
40027
39806
  name: INTEGRATION_NAME18,
@@ -40043,12 +39822,14 @@ var httpIntegration2 = defineIntegration((options = {}) => {
40043
39822
  processEvent(event) {
40044
39823
  if (event.type === "transaction") {
40045
39824
  const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
40046
- if (typeof statusCode === "number") {
40047
- const shouldDrop = shouldFilterStatusCode2(statusCode, dropSpansForIncomingRequestStatusCodes);
40048
- if (shouldDrop) {
40049
- DEBUG_BUILD4 && debug.log("Dropping transaction due to status code", statusCode);
40050
- return null;
39825
+ if (typeof statusCode === "number" && dropSpansForIncomingRequestStatusCodes.some((code) => {
39826
+ if (typeof code === "number") {
39827
+ return code === statusCode;
40051
39828
  }
39829
+ const [min, max] = code;
39830
+ return statusCode >= min && statusCode <= max;
39831
+ })) {
39832
+ return null;
40052
39833
  }
40053
39834
  }
40054
39835
  return event;
@@ -40082,15 +39863,6 @@ function getConfigWithDefaults(options = {}) {
40082
39863
  };
40083
39864
  return instrumentationConfig;
40084
39865
  }
40085
- function shouldFilterStatusCode2(statusCode, dropForStatusCodes) {
40086
- return dropForStatusCodes.some((code) => {
40087
- if (typeof code === "number") {
40088
- return code === statusCode;
40089
- }
40090
- const [min, max] = code;
40091
- return statusCode >= min && statusCode <= max;
40092
- });
40093
- }
40094
39866
 
40095
39867
  // ../../node_modules/@sentry/node/build/esm/integrations/node-fetch.js
40096
39868
  var import_instrumentation_undici = __toESM(require_src11(), 1);
@@ -40147,6 +39919,11 @@ function getConfigWithDefaults2(options = {}) {
40147
39919
 
40148
39920
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/express.js
40149
39921
  var import_instrumentation_express = __toESM(require_src12(), 1);
39922
+
39923
+ // ../../node_modules/@sentry/node/build/esm/debug-build.js
39924
+ var DEBUG_BUILD4 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
39925
+
39926
+ // ../../node_modules/@sentry/node/build/esm/integrations/tracing/express.js
40150
39927
  var INTEGRATION_NAME20 = "Express";
40151
39928
  function requestHook(span) {
40152
39929
  addOriginToSpan2(span, "auto.http.otel.express");
@@ -43222,32 +42999,36 @@ class SentryVercelAiInstrumentation extends import_instrumentation11.Instrumenta
43222
42999
  this._isPatched = true;
43223
43000
  this._callbacks.forEach((callback) => callback());
43224
43001
  this._callbacks = [];
43225
- const generatePatch = (originalMethod) => {
43226
- return new Proxy(originalMethod, {
43227
- apply: (target, thisArg, args) => {
43228
- const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
43229
- const isEnabled3 = existingExperimentalTelemetry.isEnabled;
43230
- const client = getClient();
43231
- const integration = client?.getIntegrationByName(INTEGRATION_NAME39);
43232
- const integrationOptions = integration?.options;
43233
- const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;
43234
- const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOptions, existingExperimentalTelemetry, isEnabled3, shouldRecordInputsAndOutputs);
43235
- args[0].experimental_telemetry = {
43236
- ...existingExperimentalTelemetry,
43237
- isEnabled: isEnabled3 !== undefined ? isEnabled3 : true,
43238
- recordInputs,
43239
- recordOutputs
43240
- };
43241
- return handleCallbackErrors(() => Reflect.apply(target, thisArg, args), (error2) => {
43242
- if (error2 && typeof error2 === "object") {
43243
- addNonEnumerableProperty(error2, "_sentry_active_span", getActiveSpan());
43244
- }
43245
- }, () => {}, (result) => {
43246
- checkResultForToolErrors(result);
43247
- });
43248
- }
43249
- });
43250
- };
43002
+ function generatePatch(originalMethod) {
43003
+ return (...args) => {
43004
+ const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
43005
+ const isEnabled3 = existingExperimentalTelemetry.isEnabled;
43006
+ const client = getCurrentScope().getClient();
43007
+ const integration = client?.getIntegrationByName(INTEGRATION_NAME39);
43008
+ const integrationOptions = integration?.options;
43009
+ const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;
43010
+ const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOptions, existingExperimentalTelemetry, isEnabled3, shouldRecordInputsAndOutputs);
43011
+ args[0].experimental_telemetry = {
43012
+ ...existingExperimentalTelemetry,
43013
+ isEnabled: isEnabled3 !== undefined ? isEnabled3 : true,
43014
+ recordInputs,
43015
+ recordOutputs
43016
+ };
43017
+ return handleCallbackErrors(() => {
43018
+ const result = originalMethod.apply(this, args);
43019
+ if (isThenable(result)) {
43020
+ result.then(checkResultForToolErrors, () => {});
43021
+ return result;
43022
+ }
43023
+ checkResultForToolErrors(result);
43024
+ return result;
43025
+ }, (error2) => {
43026
+ if (error2 && typeof error2 === "object") {
43027
+ addNonEnumerableProperty(error2, "_sentry_active_span", getActiveSpan());
43028
+ }
43029
+ });
43030
+ };
43031
+ }
43251
43032
  if (Object.prototype.toString.call(moduleExports) === "[object Module]") {
43252
43033
  for (const method of INSTRUMENTED_METHODS2) {
43253
43034
  moduleExports[method] = generatePatch(moduleExports[method]);
@@ -43309,10 +43090,10 @@ class SentryOpenAiInstrumentation extends import_instrumentation13.Instrumentati
43309
43090
  const Original = exports.OpenAI;
43310
43091
  const WrappedOpenAI = function(...args) {
43311
43092
  const instance = Reflect.construct(Original, args);
43312
- const client = getClient();
43313
- const integration = client?.getIntegrationByName(OPENAI_INTEGRATION_NAME);
43093
+ const scopeClient = getCurrentScope().getClient();
43094
+ const integration = scopeClient?.getIntegrationByName(OPENAI_INTEGRATION_NAME);
43314
43095
  const integrationOpts = integration?.options;
43315
- const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
43096
+ const defaultPii = Boolean(scopeClient?.getOptions().sendDefaultPii);
43316
43097
  const { recordInputs, recordOutputs } = determineRecordingSettings2(integrationOpts, defaultPii);
43317
43098
  return instrumentOpenAiClient(instance, {
43318
43099
  recordInputs,
@@ -43371,6 +43152,11 @@ var openAIIntegration = defineIntegration(_openAiIntegration);
43371
43152
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/anthropic-ai/instrumentation.js
43372
43153
  var import_instrumentation15 = __toESM(require_src6(), 1);
43373
43154
  var supportedVersions2 = [">=0.19.2 <1.0.0"];
43155
+ function determineRecordingSettings3(integrationOptions, defaultEnabled) {
43156
+ const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;
43157
+ const recordOutputs = integrationOptions?.recordOutputs ?? defaultEnabled;
43158
+ return { recordInputs, recordOutputs };
43159
+ }
43374
43160
 
43375
43161
  class SentryAnthropicAiInstrumentation extends import_instrumentation15.InstrumentationBase {
43376
43162
  constructor(config2 = {}) {
@@ -43382,13 +43168,13 @@ class SentryAnthropicAiInstrumentation extends import_instrumentation15.Instrume
43382
43168
  }
43383
43169
  _patch(exports) {
43384
43170
  const Original = exports.Anthropic;
43385
- const config2 = this.getConfig();
43386
43171
  const WrappedAnthropic = function(...args) {
43387
43172
  const instance = Reflect.construct(Original, args);
43388
- const client = getClient();
43389
- const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
43390
- const recordInputs = config2.recordInputs ?? defaultPii;
43391
- const recordOutputs = config2.recordOutputs ?? defaultPii;
43173
+ const scopeClient = getCurrentScope().getClient();
43174
+ const integration = scopeClient?.getIntegrationByName(ANTHROPIC_AI_INTEGRATION_NAME);
43175
+ const integrationOpts = integration?.options;
43176
+ const defaultPii = Boolean(scopeClient?.getOptions().sendDefaultPii);
43177
+ const { recordInputs, recordOutputs } = determineRecordingSettings3(integrationOpts, defaultPii);
43392
43178
  return instrumentAnthropicAiClient(instance, {
43393
43179
  recordInputs,
43394
43180
  recordOutputs
@@ -43431,83 +43217,24 @@ class SentryAnthropicAiInstrumentation extends import_instrumentation15.Instrume
43431
43217
  }
43432
43218
 
43433
43219
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/anthropic-ai/index.js
43434
- var instrumentAnthropicAi = generateInstrumentOnce(ANTHROPIC_AI_INTEGRATION_NAME, (options) => new SentryAnthropicAiInstrumentation(options));
43220
+ var instrumentAnthropicAi = generateInstrumentOnce(ANTHROPIC_AI_INTEGRATION_NAME, () => new SentryAnthropicAiInstrumentation({}));
43435
43221
  var _anthropicAIIntegration = (options = {}) => {
43436
43222
  return {
43437
43223
  name: ANTHROPIC_AI_INTEGRATION_NAME,
43438
43224
  options,
43439
43225
  setupOnce() {
43440
- instrumentAnthropicAi(options);
43226
+ instrumentAnthropicAi();
43441
43227
  }
43442
43228
  };
43443
43229
  };
43444
43230
  var anthropicAIIntegration = defineIntegration(_anthropicAIIntegration);
43445
43231
 
43446
- // ../../node_modules/@sentry/node/build/esm/integrations/tracing/google-genai/instrumentation.js
43447
- var import_instrumentation17 = __toESM(require_src6(), 1);
43448
- var supportedVersions3 = [">=0.10.0 <2"];
43449
-
43450
- class SentryGoogleGenAiInstrumentation extends import_instrumentation17.InstrumentationBase {
43451
- constructor(config2 = {}) {
43452
- super("@sentry/instrumentation-google-genai", SDK_VERSION, config2);
43453
- }
43454
- init() {
43455
- const module = new import_instrumentation17.InstrumentationNodeModuleDefinition("@google/genai", supportedVersions3, (exports) => this._patch(exports), (exports) => exports, [
43456
- new import_instrumentation17.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs", supportedVersions3, (exports) => this._patch(exports), (exports) => exports)
43457
- ]);
43458
- return module;
43459
- }
43460
- _patch(exports) {
43461
- const Original = exports.GoogleGenAI;
43462
- const config2 = this.getConfig();
43463
- if (typeof Original !== "function") {
43464
- return exports;
43465
- }
43466
- const WrappedGoogleGenAI = function(...args) {
43467
- const instance = Reflect.construct(Original, args);
43468
- const client = getClient();
43469
- const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
43470
- const typedConfig = config2;
43471
- const recordInputs = typedConfig?.recordInputs ?? defaultPii;
43472
- const recordOutputs = typedConfig?.recordOutputs ?? defaultPii;
43473
- return instrumentGoogleGenAIClient(instance, {
43474
- recordInputs,
43475
- recordOutputs
43476
- });
43477
- };
43478
- Object.setPrototypeOf(WrappedGoogleGenAI, Original);
43479
- Object.setPrototypeOf(WrappedGoogleGenAI.prototype, Original.prototype);
43480
- for (const key of Object.getOwnPropertyNames(Original)) {
43481
- if (!["length", "name", "prototype"].includes(key)) {
43482
- const descriptor = Object.getOwnPropertyDescriptor(Original, key);
43483
- if (descriptor) {
43484
- Object.defineProperty(WrappedGoogleGenAI, key, descriptor);
43485
- }
43486
- }
43487
- }
43488
- replaceExports(exports, "GoogleGenAI", WrappedGoogleGenAI);
43489
- return exports;
43490
- }
43491
- }
43492
-
43493
- // ../../node_modules/@sentry/node/build/esm/integrations/tracing/google-genai/index.js
43494
- var instrumentGoogleGenAI = generateInstrumentOnce(GOOGLE_GENAI_INTEGRATION_NAME, (options) => new SentryGoogleGenAiInstrumentation(options));
43495
- var _googleGenAIIntegration = (options = {}) => {
43496
- return {
43497
- name: GOOGLE_GENAI_INTEGRATION_NAME,
43498
- setupOnce() {
43499
- instrumentGoogleGenAI(options);
43500
- }
43501
- };
43502
- };
43503
- var googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);
43504
-
43505
43232
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js
43506
- var import_instrumentation20 = __toESM(require_src6(), 1);
43233
+ var import_instrumentation18 = __toESM(require_src6(), 1);
43507
43234
 
43508
43235
  // ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/patches/firestore.js
43509
43236
  var import_api18 = __toESM(require_src(), 1);
43510
- var import_instrumentation19 = __toESM(require_src6(), 1);
43237
+ var import_instrumentation17 = __toESM(require_src6(), 1);
43511
43238
  var import_semantic_conventions7 = __toESM(require_src2(), 1);
43512
43239
  import * as net2 from "node:net";
43513
43240
  function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config2) {
@@ -43516,7 +43243,7 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
43516
43243
  const configFirestoreSpanCreationHook = config2.firestoreSpanCreationHook;
43517
43244
  if (typeof configFirestoreSpanCreationHook === "function") {
43518
43245
  firestoreSpanCreationHook = (span) => {
43519
- import_instrumentation19.safeExecuteInTheMiddle(() => configFirestoreSpanCreationHook(span), (error2) => {
43246
+ import_instrumentation17.safeExecuteInTheMiddle(() => configFirestoreSpanCreationHook(span), (error2) => {
43520
43247
  if (!error2) {
43521
43248
  return;
43522
43249
  }
@@ -43524,7 +43251,7 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
43524
43251
  }, true);
43525
43252
  };
43526
43253
  }
43527
- const moduleFirestoreCJS = new import_instrumentation19.InstrumentationNodeModuleDefinition("@firebase/firestore", firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook));
43254
+ const moduleFirestoreCJS = new import_instrumentation17.InstrumentationNodeModuleDefinition("@firebase/firestore", firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook));
43528
43255
  const files = [
43529
43256
  "@firebase/firestore/dist/lite/index.node.cjs.js",
43530
43257
  "@firebase/firestore/dist/lite/index.node.mjs.js",
@@ -43532,7 +43259,7 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
43532
43259
  "@firebase/firestore/dist/lite/index.cjs.js"
43533
43260
  ];
43534
43261
  for (const file of files) {
43535
- moduleFirestoreCJS.files.push(new import_instrumentation19.InstrumentationNodeModuleFile(file, firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook), (moduleExports) => unwrapMethods(moduleExports, unwrap)));
43262
+ moduleFirestoreCJS.files.push(new import_instrumentation17.InstrumentationNodeModuleFile(file, firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook), (moduleExports) => unwrapMethods(moduleExports, unwrap)));
43536
43263
  }
43537
43264
  return moduleFirestoreCJS;
43538
43265
  }
@@ -43546,7 +43273,7 @@ function wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationH
43546
43273
  }
43547
43274
  function unwrapMethods(moduleExports, unwrap) {
43548
43275
  for (const method of ["addDoc", "getDocs", "setDoc", "deleteDoc"]) {
43549
- if (import_instrumentation19.isWrapped(moduleExports[method])) {
43276
+ if (import_instrumentation17.isWrapped(moduleExports[method])) {
43550
43277
  unwrap(moduleExports, method);
43551
43278
  }
43552
43279
  }
@@ -43598,7 +43325,7 @@ function patchSetDoc(tracer, firestoreSpanCreationHook) {
43598
43325
  }
43599
43326
  function executeContextWithSpan(span, callback) {
43600
43327
  return import_api18.context.with(import_api18.trace.setSpan(import_api18.context.active(), span), () => {
43601
- return import_instrumentation19.safeExecuteInTheMiddle(() => {
43328
+ return import_instrumentation17.safeExecuteInTheMiddle(() => {
43602
43329
  return callback();
43603
43330
  }, (err) => {
43604
43331
  if (err) {
@@ -43676,7 +43403,7 @@ function addAttributes(span, reference) {
43676
43403
  var DefaultFirebaseInstrumentationConfig = {};
43677
43404
  var firestoreSupportedVersions = [">=3.0.0 <5"];
43678
43405
 
43679
- class FirebaseInstrumentation extends import_instrumentation20.InstrumentationBase {
43406
+ class FirebaseInstrumentation extends import_instrumentation18.InstrumentationBase {
43680
43407
  constructor(config2 = DefaultFirebaseInstrumentationConfig) {
43681
43408
  super("@sentry/instrumentation-firebase", SDK_VERSION, config2);
43682
43409
  }
@@ -43734,8 +43461,7 @@ function getAutoPerformanceIntegrations() {
43734
43461
  openAIIntegration(),
43735
43462
  postgresJsIntegration(),
43736
43463
  firebaseIntegration(),
43737
- anthropicAIIntegration(),
43738
- googleGenAIIntegration()
43464
+ anthropicAIIntegration()
43739
43465
  ];
43740
43466
  }
43741
43467
 
@@ -43817,205 +43543,8 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
43817
43543
  }
43818
43544
  // src/index.ts
43819
43545
  import sqlPlugin, { createDatabaseAdapter, DatabaseMigrationService } from "@elizaos/plugin-sql";
43820
-
43821
- // src/managers/PluginLoader.ts
43822
- import { logger as logger30 } from "@elizaos/core";
43823
-
43824
- class PluginLoader {
43825
- isValidPluginShape(obj) {
43826
- if (!obj || typeof obj !== "object" || !obj.name) {
43827
- return false;
43828
- }
43829
- return !!(obj.init || obj.services || obj.providers || obj.actions || obj.evaluators || obj.description);
43830
- }
43831
- validatePlugin(plugin) {
43832
- const errors = [];
43833
- if (!plugin) {
43834
- errors.push("Plugin is null or undefined");
43835
- return { isValid: false, errors };
43836
- }
43837
- if (!plugin.name) {
43838
- errors.push("Plugin must have a name");
43839
- }
43840
- if (plugin.actions) {
43841
- if (!Array.isArray(plugin.actions)) {
43842
- errors.push("Plugin actions must be an array");
43843
- } else {
43844
- const invalidActions = plugin.actions.filter((a) => typeof a !== "object" || !a);
43845
- if (invalidActions.length > 0) {
43846
- errors.push("Plugin actions must be an array of action objects");
43847
- }
43848
- }
43849
- }
43850
- if (plugin.services) {
43851
- if (!Array.isArray(plugin.services)) {
43852
- errors.push("Plugin services must be an array");
43853
- } else {
43854
- const invalidServices = plugin.services.filter((s) => typeof s !== "function" && (typeof s !== "object" || !s));
43855
- if (invalidServices.length > 0) {
43856
- errors.push("Plugin services must be an array of service classes or objects");
43857
- }
43858
- }
43859
- }
43860
- if (plugin.providers && !Array.isArray(plugin.providers)) {
43861
- errors.push("Plugin providers must be an array");
43862
- }
43863
- if (plugin.evaluators && !Array.isArray(plugin.evaluators)) {
43864
- errors.push("Plugin evaluators must be an array");
43865
- }
43866
- return {
43867
- isValid: errors.length === 0,
43868
- errors
43869
- };
43870
- }
43871
- async loadAndPreparePlugin(pluginName) {
43872
- try {
43873
- let pluginModule;
43874
- try {
43875
- pluginModule = await import(pluginName);
43876
- } catch (error2) {
43877
- logger30.error(`Failed to load plugin ${pluginName}: ${error2}`);
43878
- return null;
43879
- }
43880
- if (!pluginModule) {
43881
- logger30.error(`Failed to load module for plugin ${pluginName}.`);
43882
- return null;
43883
- }
43884
- const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match3) => match3[1].toUpperCase())}Plugin`;
43885
- const exportsToCheck = [
43886
- pluginModule[expectedFunctionName],
43887
- pluginModule.default,
43888
- ...Object.values(pluginModule)
43889
- ];
43890
- for (const potentialPlugin of exportsToCheck) {
43891
- if (this.isValidPluginShape(potentialPlugin)) {
43892
- return potentialPlugin;
43893
- }
43894
- if (typeof potentialPlugin === "function" && potentialPlugin.length === 0) {
43895
- try {
43896
- const produced = potentialPlugin();
43897
- if (this.isValidPluginShape(produced)) {
43898
- return produced;
43899
- }
43900
- } catch (err) {
43901
- logger30.debug(`Factory export threw for ${pluginName}: ${err}`);
43902
- }
43903
- }
43904
- }
43905
- logger30.warn(`Could not find a valid plugin export in ${pluginName}.`);
43906
- return null;
43907
- } catch (error2) {
43908
- logger30.error(`Error loading plugin ${pluginName}: ${error2}`);
43909
- return null;
43910
- }
43911
- }
43912
- resolvePluginDependencies(availablePlugins, isTestMode = false) {
43913
- const resolutionOrder = [];
43914
- const visited = new Set;
43915
- const visiting = new Set;
43916
- function visit2(pluginName) {
43917
- if (!availablePlugins.has(pluginName)) {
43918
- logger30.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
43919
- return;
43920
- }
43921
- if (visited.has(pluginName))
43922
- return;
43923
- if (visiting.has(pluginName)) {
43924
- logger30.error(`Circular dependency detected involving plugin: ${pluginName}`);
43925
- return;
43926
- }
43927
- visiting.add(pluginName);
43928
- const plugin = availablePlugins.get(pluginName);
43929
- if (plugin) {
43930
- const deps = [...plugin.dependencies || []];
43931
- if (isTestMode) {
43932
- deps.push(...plugin.testDependencies || []);
43933
- }
43934
- for (const dep of deps) {
43935
- visit2(dep);
43936
- }
43937
- }
43938
- visiting.delete(pluginName);
43939
- visited.add(pluginName);
43940
- resolutionOrder.push(pluginName);
43941
- }
43942
- for (const name of availablePlugins.keys()) {
43943
- if (!visited.has(name)) {
43944
- visit2(name);
43945
- }
43946
- }
43947
- const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
43948
- logger30.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
43949
- return finalPlugins;
43950
- }
43951
- }
43952
-
43953
- // src/managers/ConfigManager.ts
43546
+ import { existsSync as existsSync4 } from "node:fs";
43954
43547
  var import_dotenv2 = __toESM(require_main(), 1);
43955
- import * as fs6 from "node:fs";
43956
- import * as path8 from "node:path";
43957
-
43958
- class ConfigManager {
43959
- async loadEnvConfig() {
43960
- const envPath = this.findEnvFile();
43961
- if (envPath) {
43962
- import_dotenv2.default.config({ path: envPath });
43963
- }
43964
- return process.env;
43965
- }
43966
- findEnvFile() {
43967
- const possiblePaths = [
43968
- path8.join(process.cwd(), ".env"),
43969
- path8.join(process.cwd(), ".env.local")
43970
- ];
43971
- for (const envPath of possiblePaths) {
43972
- if (fs6.existsSync(envPath)) {
43973
- return envPath;
43974
- }
43975
- }
43976
- return null;
43977
- }
43978
- hasCharacterSecrets(character) {
43979
- return Boolean(character?.settings?.secrets && Object.keys(character.settings.secrets).length > 0);
43980
- }
43981
- ensureCharacterSettings(character) {
43982
- if (!character.settings) {
43983
- character.settings = {};
43984
- }
43985
- }
43986
- async loadLocalEnvSecrets() {
43987
- const envPath = this.findEnvFile();
43988
- if (!envPath)
43989
- return null;
43990
- try {
43991
- const buf = fs6.readFileSync(envPath);
43992
- return import_dotenv2.default.parse(buf);
43993
- } catch {
43994
- return null;
43995
- }
43996
- }
43997
- async setDefaultSecretsFromEnv(character) {
43998
- this.ensureCharacterSettings(character);
43999
- if (this.hasCharacterSecrets(character)) {
44000
- return false;
44001
- }
44002
- const envSecrets = await this.loadLocalEnvSecrets();
44003
- if (!envSecrets) {
44004
- return false;
44005
- }
44006
- if (!character.settings) {
44007
- character.settings = {};
44008
- }
44009
- character.settings.secrets = envSecrets;
44010
- return true;
44011
- }
44012
- }
44013
-
44014
- // src/index.ts
44015
- import { encryptedCharacter, stringToUuid as stringToUuid2 } from "@elizaos/core";
44016
- import { existsSync as existsSync5 } from "node:fs";
44017
- var import_dotenv3 = __toESM(require_main(), 1);
44018
- import { ElizaOS as ElizaOS3 } from "@elizaos/core";
44019
43548
  function expandTildePath(filepath) {
44020
43549
  if (!filepath) {
44021
43550
  return filepath;
@@ -44024,19 +43553,19 @@ function expandTildePath(filepath) {
44024
43553
  if (filepath === "~") {
44025
43554
  return process.cwd();
44026
43555
  } else if (filepath.startsWith("~/")) {
44027
- return path9.join(process.cwd(), filepath.slice(2));
43556
+ return path8.join(process.cwd(), filepath.slice(2));
44028
43557
  } else if (filepath.startsWith("~~")) {
44029
43558
  return filepath;
44030
43559
  } else {
44031
- return path9.join(process.cwd(), filepath.slice(1));
43560
+ return path8.join(process.cwd(), filepath.slice(1));
44032
43561
  }
44033
43562
  }
44034
43563
  return filepath;
44035
43564
  }
44036
43565
  function resolvePgliteDir(dir, fallbackDir) {
44037
43566
  const envPath = resolveEnvFile();
44038
- if (existsSync5(envPath)) {
44039
- import_dotenv3.default.config({ path: envPath });
43567
+ if (existsSync4(envPath)) {
43568
+ import_dotenv2.default.config({ path: envPath });
44040
43569
  }
44041
43570
  if (dir) {
44042
43571
  const resolved2 = expandTildePath(dir);
@@ -44065,229 +43594,119 @@ function isWebUIEnabled() {
44065
43594
 
44066
43595
  class AgentServer {
44067
43596
  app;
43597
+ agents;
44068
43598
  server;
44069
43599
  socketIO;
44070
43600
  isInitialized = false;
44071
43601
  isWebUIEnabled = true;
44072
43602
  clientPath;
44073
- elizaOS;
44074
- pluginLoader;
44075
- configManager;
44076
43603
  database;
43604
+ startAgent;
43605
+ stopAgent;
44077
43606
  loadCharacterTryPath;
44078
43607
  jsonToCharacter;
44079
- async startAgents(characters, plugins = []) {
44080
- if (!this.elizaOS || !this.pluginLoader || !this.configManager) {
44081
- throw new Error("Server not properly initialized");
44082
- }
44083
- const preparations = await Promise.all(characters.map(async (character) => {
44084
- character.id ??= stringToUuid2(character.name);
44085
- if (!this.configManager?.hasCharacterSecrets(character)) {
44086
- await this.configManager?.setDefaultSecretsFromEnv(character);
44087
- }
44088
- const loadedPlugins = new Map;
44089
- const pluginsToLoad = new Set(character.plugins || []);
44090
- for (const p of plugins) {
44091
- if (typeof p === "string") {
44092
- pluginsToLoad.add(p);
44093
- } else if (this.pluginLoader?.isValidPluginShape(p) && !loadedPlugins.has(p.name)) {
44094
- loadedPlugins.set(p.name, p);
44095
- (p.dependencies || []).forEach((dep) => {
44096
- pluginsToLoad.add(dep);
44097
- });
44098
- }
44099
- }
44100
- const allAvailablePlugins = new Map;
44101
- for (const p of loadedPlugins.values()) {
44102
- allAvailablePlugins.set(p.name, p);
44103
- }
44104
- for (const name of pluginsToLoad) {
44105
- if (!allAvailablePlugins.has(name)) {
44106
- const loaded = await this.pluginLoader?.loadAndPreparePlugin(name);
44107
- if (loaded) {
44108
- allAvailablePlugins.set(loaded.name, loaded);
44109
- }
44110
- }
44111
- }
44112
- let haveSql = false;
44113
- for (const [name] of allAvailablePlugins.entries()) {
44114
- if (name === sqlPlugin.name || name === "mysql") {
44115
- haveSql = true;
44116
- break;
44117
- }
44118
- }
44119
- if (!haveSql) {
44120
- allAvailablePlugins.set(sqlPlugin.name, sqlPlugin);
44121
- }
44122
- allAvailablePlugins.set(messageBusConnectorPlugin.name, messageBusConnectorPlugin);
44123
- const finalPlugins = this.pluginLoader?.resolvePluginDependencies(allAvailablePlugins, false);
44124
- const preparedCharacter = encryptedCharacter(character);
44125
- return { character: preparedCharacter, plugins: finalPlugins };
44126
- }));
44127
- const agentIds = await this.elizaOS.addAgents(preparations.map((p) => ({
44128
- character: p.character,
44129
- plugins: p.plugins
44130
- })));
44131
- await this.elizaOS.startAgents(agentIds);
44132
- const runtimes = [];
44133
- const settings = await this.configManager?.loadEnvConfig();
44134
- for (const id of agentIds) {
44135
- const runtime = this.elizaOS.getAgent(id);
44136
- if (runtime) {
44137
- Object.assign(runtime, { settings });
44138
- await this.registerAgent(runtime);
44139
- if (this.database) {
44140
- try {
44141
- const existingAgent = await this.database.getAgent(runtime.agentId);
44142
- if (!existingAgent) {
44143
- await this.database.createAgent({
44144
- ...runtime.character,
44145
- id: runtime.agentId
44146
- });
44147
- logger31.info(`Persisted agent ${runtime.character.name} (${runtime.agentId}) to database`);
44148
- }
44149
- } catch (error2) {
44150
- logger31.error({ error: error2 }, `Failed to persist agent ${runtime.agentId} to database`);
44151
- }
44152
- }
44153
- runtimes.push(runtime);
44154
- }
44155
- }
44156
- return runtimes;
44157
- }
44158
- async stopAgents(agentIds) {
44159
- if (!this.elizaOS) {
44160
- throw new Error("ElizaOS not initialized");
44161
- }
44162
- await this.elizaOS.stopAgents(agentIds);
44163
- }
44164
- getAllAgents() {
44165
- if (!this.elizaOS) {
44166
- return [];
44167
- }
44168
- return this.elizaOS.getAgents();
44169
- }
44170
- getAgent(agentId) {
44171
- if (!this.elizaOS) {
44172
- return;
44173
- }
44174
- return this.elizaOS.getAgent(agentId);
44175
- }
44176
43608
  constructor() {
44177
43609
  try {
44178
- logger31.debug("Initializing AgentServer (constructor)...");
43610
+ logger30.debug("Initializing AgentServer (constructor)...");
43611
+ this.agents = new Map;
44179
43612
  this.loadCharacterTryPath = loadCharacterTryPath;
44180
43613
  this.jsonToCharacter = jsonToCharacter;
44181
43614
  this.registerSignalHandlers();
44182
43615
  } catch (error2) {
44183
- logger31.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
43616
+ logger30.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
44184
43617
  throw error2;
44185
43618
  }
44186
43619
  }
44187
43620
  async initialize(options) {
44188
43621
  if (this.isInitialized) {
44189
- logger31.warn("AgentServer is already initialized, skipping initialization");
43622
+ logger30.warn("AgentServer is already initialized, skipping initialization");
44190
43623
  return;
44191
43624
  }
44192
43625
  try {
44193
- logger31.debug("Initializing AgentServer (async operations)...");
43626
+ logger30.debug("Initializing AgentServer (async operations)...");
44194
43627
  const agentDataDir = resolvePgliteDir(options?.dataDir);
44195
- logger31.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
44196
- const dbDir = path9.dirname(agentDataDir);
44197
- if (!fs7.existsSync(dbDir)) {
44198
- fs7.mkdirSync(dbDir, { recursive: true });
44199
- logger31.info(`[INIT] Created database directory: ${dbDir}`);
44200
- }
44201
- const tempServerAgentId = "00000000-0000-0000-0000-000000000000";
43628
+ logger30.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
44202
43629
  this.database = createDatabaseAdapter({
44203
43630
  dataDir: agentDataDir,
44204
43631
  postgresUrl: options?.postgresUrl
44205
- }, tempServerAgentId);
43632
+ }, "00000000-0000-0000-0000-000000000002");
44206
43633
  await this.database.init();
44207
- logger31.success("Database initialized for server operations");
44208
- logger31.info("[INIT] Running database migrations for messaging tables...");
43634
+ logger30.success("Consolidated database initialized successfully");
43635
+ logger30.info("[INIT] Running database migrations for messaging tables...");
44209
43636
  try {
44210
43637
  const migrationService = new DatabaseMigrationService;
44211
43638
  const db = this.database.getDatabase();
44212
43639
  await migrationService.initializeWithDatabase(db);
44213
43640
  migrationService.discoverAndRegisterPluginSchemas([sqlPlugin]);
44214
43641
  await migrationService.runAllPluginMigrations();
44215
- logger31.success("[INIT] Database migrations completed successfully");
43642
+ logger30.success("[INIT] Database migrations completed successfully");
44216
43643
  } catch (migrationError) {
44217
- logger31.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
43644
+ logger30.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
44218
43645
  throw new Error(`Database migration failed: ${migrationError instanceof Error ? migrationError.message : String(migrationError)}`);
44219
43646
  }
44220
43647
  await new Promise((resolve2) => setTimeout(resolve2, 500));
44221
- logger31.info("[INIT] Ensuring default server exists...");
43648
+ logger30.info("[INIT] Ensuring default server exists...");
44222
43649
  await this.ensureDefaultServer();
44223
- logger31.success("[INIT] Default server setup complete");
44224
- logger31.info("[INIT] Server uses temporary adapter for migrations only");
44225
- logger31.info("[INIT] Initializing ElizaOS...");
44226
- logger31.debug("[INIT] ElizaOS will use agent-specific database adapters from SQL plugin");
44227
- this.elizaOS = new ElizaOS2;
44228
- this.elizaOS.enableEditableMode();
44229
- this.pluginLoader = new PluginLoader;
44230
- this.configManager = new ConfigManager;
44231
- logger31.success("[INIT] ElizaOS initialized");
43650
+ logger30.success("[INIT] Default server setup complete");
44232
43651
  await this.initializeServer(options);
44233
43652
  await new Promise((resolve2) => setTimeout(resolve2, 250));
44234
43653
  this.isInitialized = true;
44235
43654
  } catch (error2) {
44236
- logger31.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
43655
+ logger30.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
44237
43656
  console.trace(error2);
44238
43657
  throw error2;
44239
43658
  }
44240
43659
  }
44241
43660
  async ensureDefaultServer() {
44242
43661
  try {
44243
- logger31.info("[AgentServer] Checking for default server...");
43662
+ logger30.info("[AgentServer] Checking for default server...");
44244
43663
  const servers = await this.database.getMessageServers();
44245
- logger31.debug(`[AgentServer] Found ${servers.length} existing servers`);
43664
+ logger30.debug(`[AgentServer] Found ${servers.length} existing servers`);
44246
43665
  servers.forEach((s) => {
44247
- logger31.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
43666
+ logger30.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
44248
43667
  });
44249
43668
  const defaultServer = servers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
44250
43669
  if (!defaultServer) {
44251
- logger31.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
43670
+ logger30.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
44252
43671
  try {
44253
43672
  await this.database.db.execute(`
44254
43673
  INSERT INTO message_servers (id, name, source_type, created_at, updated_at)
44255
43674
  VALUES ('00000000-0000-0000-0000-000000000000', 'Default Server', 'eliza_default', NOW(), NOW())
44256
43675
  ON CONFLICT (id) DO NOTHING
44257
43676
  `);
44258
- logger31.success("[AgentServer] Default server created via raw SQL");
43677
+ logger30.success("[AgentServer] Default server created via raw SQL");
44259
43678
  const checkResult = await this.database.db.execute("SELECT id, name FROM message_servers WHERE id = '00000000-0000-0000-0000-000000000000'");
44260
- logger31.debug("[AgentServer] Raw SQL check result:", checkResult);
43679
+ logger30.debug("[AgentServer] Raw SQL check result:", checkResult);
44261
43680
  } catch (sqlError) {
44262
- logger31.error("[AgentServer] Raw SQL insert failed:", sqlError);
43681
+ logger30.error("[AgentServer] Raw SQL insert failed:", sqlError);
44263
43682
  try {
44264
43683
  const server = await this.database.createMessageServer({
44265
43684
  id: "00000000-0000-0000-0000-000000000000",
44266
43685
  name: "Default Server",
44267
43686
  sourceType: "eliza_default"
44268
43687
  });
44269
- logger31.success("[AgentServer] Default server created via ORM with ID:", server.id);
43688
+ logger30.success("[AgentServer] Default server created via ORM with ID:", server.id);
44270
43689
  } catch (ormError) {
44271
- logger31.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
43690
+ logger30.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
44272
43691
  throw new Error(`Failed to create default server: ${ormError.message}`);
44273
43692
  }
44274
43693
  }
44275
43694
  const verifyServers = await this.database.getMessageServers();
44276
- logger31.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
43695
+ logger30.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
44277
43696
  verifyServers.forEach((s) => {
44278
- logger31.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
43697
+ logger30.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
44279
43698
  });
44280
43699
  const verifyDefault = verifyServers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
44281
43700
  if (!verifyDefault) {
44282
43701
  throw new Error(`Failed to create or verify default server with ID ${DEFAULT_SERVER_ID6}`);
44283
43702
  } else {
44284
- logger31.success("[AgentServer] Default server creation verified successfully");
43703
+ logger30.success("[AgentServer] Default server creation verified successfully");
44285
43704
  }
44286
43705
  } else {
44287
- logger31.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
43706
+ logger30.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
44288
43707
  }
44289
43708
  } catch (error2) {
44290
- logger31.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
43709
+ logger30.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
44291
43710
  throw error2;
44292
43711
  }
44293
43712
  }
@@ -44298,7 +43717,7 @@ class AgentServer {
44298
43717
  }
44299
43718
  this.app = express33();
44300
43719
  const DEFAULT_SENTRY_DSN = "https://c20e2d51b66c14a783b0689d536f7e5c@o4509349865259008.ingest.us.sentry.io/4509352524120064";
44301
- const sentryDsn = process.env.SENTRY_DSN?.trim() || DEFAULT_SENTRY_DSN;
43720
+ const sentryDsn = process.env.SENTRY_DSN && process.env.SENTRY_DSN.trim() || DEFAULT_SENTRY_DSN;
44302
43721
  const sentryEnabled = Boolean(sentryDsn);
44303
43722
  if (sentryEnabled) {
44304
43723
  try {
@@ -44308,16 +43727,16 @@ class AgentServer {
44308
43727
  integrations: [vercelAIIntegration({ force: sentryEnabled })],
44309
43728
  tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE || 0)
44310
43729
  });
44311
- logger31.info("[Sentry] Initialized Sentry for @elizaos/server");
43730
+ logger30.info("[Sentry] Initialized Sentry for @elizaos/server");
44312
43731
  } catch (sentryInitError) {
44313
- logger31.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
43732
+ logger30.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
44314
43733
  }
44315
43734
  }
44316
43735
  const isProd = false;
44317
- logger31.debug("Setting up security headers...");
43736
+ logger30.debug("Setting up security headers...");
44318
43737
  if (!isProd) {
44319
- logger31.debug(`NODE_ENV: ${"development"}`);
44320
- logger31.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
43738
+ logger30.debug(`NODE_ENV: ${"development"}`);
43739
+ logger30.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
44321
43740
  }
44322
43741
  this.app.use(helmet({
44323
43742
  contentSecurityPolicy: isProd ? {
@@ -44365,12 +43784,12 @@ class AgentServer {
44365
43784
  xssFilter: true
44366
43785
  }));
44367
43786
  if (options?.middlewares) {
44368
- logger31.debug("Applying custom middlewares...");
43787
+ logger30.debug("Applying custom middlewares...");
44369
43788
  for (const middleware2 of options.middlewares) {
44370
43789
  this.app.use(middleware2);
44371
43790
  }
44372
43791
  }
44373
- logger31.debug("Setting up standard middlewares...");
43792
+ logger30.debug("Setting up standard middlewares...");
44374
43793
  this.app.use(cors2({
44375
43794
  origin: process.env.CORS_ORIGIN || true,
44376
43795
  credentials: true,
@@ -44382,28 +43801,28 @@ class AgentServer {
44382
43801
  }));
44383
43802
  const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
44384
43803
  if (serverAuthToken) {
44385
- logger31.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
43804
+ logger30.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
44386
43805
  this.app.use("/api", (req, res, next) => {
44387
43806
  apiKeyAuthMiddleware(req, res, next);
44388
43807
  });
44389
43808
  } else {
44390
- logger31.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
43809
+ logger30.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
44391
43810
  }
44392
43811
  this.isWebUIEnabled = isWebUIEnabled();
44393
43812
  if (this.isWebUIEnabled) {
44394
- logger31.info("Web UI enabled");
43813
+ logger30.info("Web UI enabled");
44395
43814
  } else {
44396
43815
  const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
44397
43816
  if (uiEnabledEnv !== undefined && uiEnabledEnv.trim() !== "") {
44398
- logger31.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
43817
+ logger30.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
44399
43818
  } else {
44400
- logger31.info("Web UI disabled for security (production mode)");
43819
+ logger30.info("Web UI disabled for security (production mode)");
44401
43820
  }
44402
43821
  }
44403
43822
  const uploadsBasePath = getUploadsAgentsDir4();
44404
43823
  const generatedBasePath = getGeneratedDir2();
44405
- fs7.mkdirSync(uploadsBasePath, { recursive: true });
44406
- fs7.mkdirSync(generatedBasePath, { recursive: true });
43824
+ fs6.mkdirSync(uploadsBasePath, { recursive: true });
43825
+ fs6.mkdirSync(generatedBasePath, { recursive: true });
44407
43826
  this.app.get("/media/uploads/agents/:agentId/:filename", (req, res) => {
44408
43827
  const agentId = req.params.agentId;
44409
43828
  const filename = req.params.filename;
@@ -44413,26 +43832,26 @@ class AgentServer {
44413
43832
  return;
44414
43833
  }
44415
43834
  const sanitizedFilename = basename2(filename);
44416
- const agentUploadsPath = join5(uploadsBasePath, agentId);
44417
- const filePath = join5(agentUploadsPath, sanitizedFilename);
43835
+ const agentUploadsPath = join4(uploadsBasePath, agentId);
43836
+ const filePath = join4(agentUploadsPath, sanitizedFilename);
44418
43837
  if (!filePath.startsWith(agentUploadsPath)) {
44419
43838
  res.status(403).json({ error: "Access denied" });
44420
43839
  return;
44421
43840
  }
44422
- if (!fs7.existsSync(filePath)) {
43841
+ if (!fs6.existsSync(filePath)) {
44423
43842
  res.status(404).json({ error: "File does not exist!!!!!!!" });
44424
43843
  return;
44425
43844
  }
44426
43845
  res.sendFile(sanitizedFilename, { root: agentUploadsPath }, (err) => {
44427
43846
  if (err) {
44428
43847
  if (err.message === "Request aborted") {
44429
- logger31.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
43848
+ logger30.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
44430
43849
  } else if (!res.headersSent) {
44431
- logger31.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
43850
+ logger30.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
44432
43851
  res.status(404).json({ error: "File not found" });
44433
43852
  }
44434
43853
  } else {
44435
- logger31.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
43854
+ logger30.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
44436
43855
  }
44437
43856
  });
44438
43857
  });
@@ -44445,17 +43864,17 @@ class AgentServer {
44445
43864
  return;
44446
43865
  }
44447
43866
  const sanitizedFilename = basename2(filename);
44448
- const agentGeneratedPath = join5(generatedBasePath, agentId);
44449
- const filePath = join5(agentGeneratedPath, sanitizedFilename);
43867
+ const agentGeneratedPath = join4(generatedBasePath, agentId);
43868
+ const filePath = join4(agentGeneratedPath, sanitizedFilename);
44450
43869
  if (!filePath.startsWith(agentGeneratedPath)) {
44451
43870
  res.status(403).json({ error: "Access denied" });
44452
43871
  return;
44453
43872
  }
44454
- if (!existsSync5(filePath)) {
43873
+ if (!existsSync4(filePath)) {
44455
43874
  res.status(404).json({ error: "File not found" });
44456
43875
  return;
44457
43876
  }
44458
- const absolutePath = path9.resolve(filePath);
43877
+ const absolutePath = path8.resolve(filePath);
44459
43878
  const options2 = {
44460
43879
  dotfiles: "deny"
44461
43880
  };
@@ -44464,7 +43883,7 @@ class AgentServer {
44464
43883
  const ext2 = extname(filename).toLowerCase();
44465
43884
  const mimeType = ext2 === ".png" ? "image/png" : ext2 === ".jpg" || ext2 === ".jpeg" ? "image/jpeg" : "application/octet-stream";
44466
43885
  res.setHeader("Content-Type", mimeType);
44467
- const stream = fs7.createReadStream(absolutePath);
43886
+ const stream = fs6.createReadStream(absolutePath);
44468
43887
  stream.on("error", () => res.status(404).json({ error: "File not found" }));
44469
43888
  stream.pipe(res);
44470
43889
  }
@@ -44479,20 +43898,20 @@ class AgentServer {
44479
43898
  return;
44480
43899
  }
44481
43900
  const sanitizedFilename = basename2(filename);
44482
- const channelUploadsPath = join5(uploadsBasePath, "channels", channelId);
44483
- const filePath = join5(channelUploadsPath, sanitizedFilename);
43901
+ const channelUploadsPath = join4(uploadsBasePath, "channels", channelId);
43902
+ const filePath = join4(channelUploadsPath, sanitizedFilename);
44484
43903
  if (!filePath.startsWith(channelUploadsPath)) {
44485
43904
  res.status(403).json({ error: "Access denied" });
44486
43905
  return;
44487
43906
  }
44488
43907
  res.sendFile(filePath, (err) => {
44489
43908
  if (err) {
44490
- logger31.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
43909
+ logger30.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
44491
43910
  if (!res.headersSent) {
44492
43911
  res.status(404).json({ error: "File not found" });
44493
43912
  }
44494
43913
  } else {
44495
- logger31.debug(`[STATIC] Served channel media file: ${filePath}`);
43914
+ logger30.debug(`[STATIC] Served channel media file: ${filePath}`);
44496
43915
  }
44497
43916
  });
44498
43917
  });
@@ -44536,11 +43955,11 @@ class AgentServer {
44536
43955
  if (this.isWebUIEnabled) {
44537
43956
  const possiblePaths = [
44538
43957
  this.clientPath,
44539
- path9.resolve(__dirname3, "client"),
44540
- path9.resolve(__dirname3, "../../client/dist"),
43958
+ path8.resolve(__dirname3, "client"),
43959
+ path8.resolve(__dirname3, "../../client/dist"),
44541
43960
  (() => {
44542
43961
  try {
44543
- return path9.resolve(path9.dirname(__require.resolve("@elizaos/client/package.json")), "dist");
43962
+ return path8.resolve(path8.dirname(__require.resolve("@elizaos/client/package.json")), "dist");
44544
43963
  } catch {
44545
43964
  return null;
44546
43965
  }
@@ -44548,12 +43967,12 @@ class AgentServer {
44548
43967
  (() => {
44549
43968
  try {
44550
43969
  if (process.argv[1]) {
44551
- const serverPath = path9.dirname(process.argv[1]);
44552
- const possibleClientPath = path9.join(serverPath, "client");
44553
- if (existsSync5(path9.join(possibleClientPath, "index.html"))) {
43970
+ const serverPath = path8.dirname(process.argv[1]);
43971
+ const possibleClientPath = path8.join(serverPath, "client");
43972
+ if (existsSync4(path8.join(possibleClientPath, "index.html"))) {
44554
43973
  return possibleClientPath;
44555
43974
  }
44556
- if (existsSync5(path9.join(serverPath, "index.html"))) {
43975
+ if (existsSync4(path8.join(serverPath, "index.html"))) {
44557
43976
  return serverPath;
44558
43977
  }
44559
43978
  }
@@ -44562,8 +43981,8 @@ class AgentServer {
44562
43981
  })(),
44563
43982
  (() => {
44564
43983
  try {
44565
- const bunGlobalPath = path9.join(os3.homedir(), ".bun/install/global/node_modules/@elizaos/server/dist/client");
44566
- if (existsSync5(path9.join(bunGlobalPath, "index.html"))) {
43984
+ const bunGlobalPath = path8.join(os3.homedir(), ".bun/install/global/node_modules/@elizaos/server/dist/client");
43985
+ if (existsSync4(path8.join(bunGlobalPath, "index.html"))) {
44567
43986
  return bunGlobalPath;
44568
43987
  }
44569
43988
  try {
@@ -44573,8 +43992,8 @@ class AgentServer {
44573
43992
  });
44574
43993
  if (proc.exitCode === 0 && proc.stdout) {
44575
43994
  const npmRoot = new TextDecoder().decode(proc.stdout).trim();
44576
- const globalServerPath = path9.join(npmRoot, "@elizaos/server/dist/client");
44577
- if (existsSync5(path9.join(globalServerPath, "index.html"))) {
43995
+ const globalServerPath = path8.join(npmRoot, "@elizaos/server/dist/client");
43996
+ if (existsSync4(path8.join(globalServerPath, "index.html"))) {
44578
43997
  return globalServerPath;
44579
43998
  }
44580
43999
  }
@@ -44585,15 +44004,15 @@ class AgentServer {
44585
44004
  ...[
44586
44005
  "/usr/local/lib/node_modules/@elizaos/server/dist/client",
44587
44006
  "/usr/lib/node_modules/@elizaos/server/dist/client",
44588
- path9.join(os3.homedir(), ".npm-global/lib/node_modules/@elizaos/server/dist/client"),
44007
+ path8.join(os3.homedir(), ".npm-global/lib/node_modules/@elizaos/server/dist/client"),
44589
44008
  (() => {
44590
44009
  try {
44591
- const nvmPath = path9.join(os3.homedir(), ".nvm/versions/node");
44592
- if (existsSync5(nvmPath)) {
44593
- const versions = fs7.readdirSync(nvmPath);
44010
+ const nvmPath = path8.join(os3.homedir(), ".nvm/versions/node");
44011
+ if (existsSync4(nvmPath)) {
44012
+ const versions = fs6.readdirSync(nvmPath);
44594
44013
  for (const version of versions) {
44595
- const cliPath = path9.join(nvmPath, version, "lib/node_modules/@elizaos/server/dist/client");
44596
- if (existsSync5(path9.join(cliPath, "index.html"))) {
44014
+ const cliPath = path8.join(nvmPath, version, "lib/node_modules/@elizaos/server/dist/client");
44015
+ if (existsSync4(path8.join(cliPath, "index.html"))) {
44597
44016
  return cliPath;
44598
44017
  }
44599
44018
  }
@@ -44603,37 +44022,37 @@ class AgentServer {
44603
44022
  })()
44604
44023
  ].filter(Boolean)
44605
44024
  ].filter(Boolean);
44606
- logger31.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
44607
- logger31.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
44608
- logger31.debug(`[STATIC] __dirname: ${__dirname3}`);
44025
+ logger30.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
44026
+ logger30.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
44027
+ logger30.debug(`[STATIC] __dirname: ${__dirname3}`);
44609
44028
  for (const possiblePath of possiblePaths) {
44610
- if (possiblePath && existsSync5(path9.join(possiblePath, "index.html"))) {
44029
+ if (possiblePath && existsSync4(path8.join(possiblePath, "index.html"))) {
44611
44030
  clientPath = possiblePath;
44612
- logger31.info(`[STATIC] Found client files at: ${clientPath}`);
44031
+ logger30.info(`[STATIC] Found client files at: ${clientPath}`);
44613
44032
  break;
44614
44033
  }
44615
44034
  }
44616
44035
  if (clientPath) {
44617
44036
  this.clientPath = clientPath;
44618
44037
  this.app.use(express33.static(clientPath, staticOptions));
44619
- logger31.info(`[STATIC] Serving static files from: ${clientPath}`);
44038
+ logger30.info(`[STATIC] Serving static files from: ${clientPath}`);
44620
44039
  } else {
44621
- logger31.warn("[STATIC] Client dist path not found. Searched locations:");
44040
+ logger30.warn("[STATIC] Client dist path not found. Searched locations:");
44622
44041
  possiblePaths.forEach((p) => {
44623
44042
  if (p)
44624
- logger31.warn(`[STATIC] - ${p}`);
44043
+ logger30.warn(`[STATIC] - ${p}`);
44625
44044
  });
44626
- logger31.warn("[STATIC] The web UI will not be available.");
44627
- logger31.warn("[STATIC] To fix this, ensure the client is built: cd packages/client && bun run build");
44628
- logger31.warn("[STATIC] Then rebuild the server: cd packages/server && bun run build");
44045
+ logger30.warn("[STATIC] The web UI will not be available.");
44046
+ logger30.warn("[STATIC] To fix this, ensure the client is built: cd packages/client && bun run build");
44047
+ logger30.warn("[STATIC] Then rebuild the server: cd packages/server && bun run build");
44629
44048
  }
44630
44049
  }
44631
- const pluginRouteHandler = createPluginRouteHandler(this.elizaOS);
44050
+ const pluginRouteHandler = createPluginRouteHandler(this.agents);
44632
44051
  this.app.use(pluginRouteHandler);
44633
- const apiRouter = createApiRouter(this.elizaOS, this);
44052
+ const apiRouter = createApiRouter(this.agents, this);
44634
44053
  this.app.use("/api", (req, _res, next) => {
44635
44054
  if (req.path !== "/ping") {
44636
- logger31.debug(`API request: ${req.method} ${req.path}`);
44055
+ logger30.debug(`API request: ${req.method} ${req.path}`);
44637
44056
  }
44638
44057
  next();
44639
44058
  }, apiRouter, (err, req, res, _next) => {
@@ -44648,7 +44067,7 @@ class AgentServer {
44648
44067
  return scope;
44649
44068
  });
44650
44069
  }
44651
- logger31.error({ err }, `API error: ${req.method} ${req.path}`);
44070
+ logger30.error({ err }, `API error: ${req.method} ${req.path}`);
44652
44071
  res.status(500).json({
44653
44072
  success: false,
44654
44073
  error: {
@@ -44696,29 +44115,29 @@ class AgentServer {
44696
44115
  }
44697
44116
  const resolvedClientPath = clientPath || this.clientPath;
44698
44117
  if (resolvedClientPath) {
44699
- const indexFilePath = path9.join(resolvedClientPath, "index.html");
44700
- if (!existsSync5(indexFilePath)) {
44701
- logger31.error(`[STATIC] index.html not found at expected path: ${indexFilePath}`);
44702
- logger31.error(`[STATIC] Client path was: ${resolvedClientPath}`);
44118
+ const indexFilePath = path8.join(resolvedClientPath, "index.html");
44119
+ if (!existsSync4(indexFilePath)) {
44120
+ logger30.error(`[STATIC] index.html not found at expected path: ${indexFilePath}`);
44121
+ logger30.error(`[STATIC] Client path was: ${resolvedClientPath}`);
44703
44122
  res.status(404).send("Client application not found");
44704
44123
  return;
44705
44124
  }
44706
44125
  res.sendFile("index.html", { root: resolvedClientPath }, (err) => {
44707
44126
  if (err) {
44708
- logger31.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
44709
- logger31.warn(`[STATIC] Attempted root: ${resolvedClientPath}`);
44710
- logger31.warn(`[STATIC] Full path was: ${indexFilePath}`);
44711
- logger31.warn(`[STATIC] Error code: ${err.code || "unknown"}`);
44127
+ logger30.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
44128
+ logger30.warn(`[STATIC] Attempted root: ${resolvedClientPath}`);
44129
+ logger30.warn(`[STATIC] Full path was: ${indexFilePath}`);
44130
+ logger30.warn(`[STATIC] Error code: ${err.code || "unknown"}`);
44712
44131
  if (!res.headersSent) {
44713
44132
  res.status(404).send("Client application not found");
44714
44133
  }
44715
44134
  } else {
44716
- logger31.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
44135
+ logger30.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
44717
44136
  }
44718
44137
  });
44719
44138
  } else {
44720
- logger31.warn("[STATIC] Client dist path not found in SPA fallback");
44721
- logger31.warn("[STATIC] Neither local nor instance clientPath variables are set");
44139
+ logger30.warn("[STATIC] Client dist path not found in SPA fallback");
44140
+ logger30.warn("[STATIC] Neither local nor instance clientPath variables are set");
44722
44141
  res.status(404).send("Client application not found");
44723
44142
  }
44724
44143
  });
@@ -44728,10 +44147,10 @@ class AgentServer {
44728
44147
  });
44729
44148
  }
44730
44149
  this.server = http4.createServer(this.app);
44731
- this.socketIO = setupSocketIO(this.server, this.elizaOS, this);
44732
- logger31.success("AgentServer HTTP server and Socket.IO initialized");
44150
+ this.socketIO = setupSocketIO(this.server, this.agents, this);
44151
+ logger30.success("AgentServer HTTP server and Socket.IO initialized");
44733
44152
  } catch (error2) {
44734
- logger31.error({ error: error2 }, "Failed to complete server initialization:");
44153
+ logger30.error({ error: error2 }, "Failed to complete server initialization:");
44735
44154
  throw error2;
44736
44155
  }
44737
44156
  }
@@ -44746,64 +44165,63 @@ class AgentServer {
44746
44165
  if (!runtime.character) {
44747
44166
  throw new Error("Runtime missing character configuration");
44748
44167
  }
44749
- logger31.debug(`Agent ${runtime.character.name} (${runtime.agentId}) registered`);
44168
+ this.agents.set(runtime.agentId, runtime);
44169
+ logger30.debug(`Agent ${runtime.character.name} (${runtime.agentId}) added to agents map`);
44750
44170
  try {
44751
44171
  if (messageBusConnectorPlugin) {
44752
44172
  await runtime.registerPlugin(messageBusConnectorPlugin);
44753
- logger31.info(`[AgentServer] Automatically registered MessageBusConnector for agent ${runtime.character.name}`);
44173
+ logger30.info(`[AgentServer] Automatically registered MessageBusConnector for agent ${runtime.character.name}`);
44754
44174
  } else {
44755
- logger31.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
44175
+ logger30.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
44756
44176
  }
44757
44177
  } catch (e) {
44758
- logger31.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
44178
+ logger30.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
44759
44179
  }
44760
44180
  const teePlugin = runtime.plugins.find((p) => p.name === "phala-tee-plugin");
44761
44181
  if (teePlugin) {
44762
- logger31.debug(`Found TEE plugin for agent ${runtime.agentId}`);
44182
+ logger30.debug(`Found TEE plugin for agent ${runtime.agentId}`);
44763
44183
  if (teePlugin.providers) {
44764
44184
  for (const provider of teePlugin.providers) {
44765
44185
  runtime.registerProvider(provider);
44766
- logger31.debug(`Registered TEE provider: ${provider.name}`);
44186
+ logger30.debug(`Registered TEE provider: ${provider.name}`);
44767
44187
  }
44768
44188
  }
44769
44189
  if (teePlugin.actions) {
44770
44190
  for (const action of teePlugin.actions) {
44771
44191
  runtime.registerAction(action);
44772
- logger31.debug(`Registered TEE action: ${action.name}`);
44192
+ logger30.debug(`Registered TEE action: ${action.name}`);
44773
44193
  }
44774
44194
  }
44775
44195
  }
44776
- logger31.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
44196
+ logger30.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
44777
44197
  await this.addAgentToServer(DEFAULT_SERVER_ID6, runtime.agentId);
44778
- logger31.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
44198
+ logger30.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
44779
44199
  } catch (error2) {
44780
- logger31.error({ error: error2 }, "Failed to register agent:");
44200
+ logger30.error({ error: error2 }, "Failed to register agent:");
44781
44201
  throw error2;
44782
44202
  }
44783
44203
  }
44784
- async unregisterAgent(agentId) {
44204
+ unregisterAgent(agentId) {
44785
44205
  if (!agentId) {
44786
- logger31.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
44206
+ logger30.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
44787
44207
  return;
44788
44208
  }
44789
44209
  try {
44790
- const agent = this.elizaOS?.getAgent(agentId);
44210
+ const agent = this.agents.get(agentId);
44791
44211
  if (agent) {
44792
44212
  try {
44793
44213
  agent.stop().catch((stopError) => {
44794
- logger31.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
44214
+ logger30.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
44795
44215
  });
44796
- logger31.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
44216
+ logger30.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
44797
44217
  } catch (stopError) {
44798
- logger31.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
44218
+ logger30.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
44799
44219
  }
44800
44220
  }
44801
- if (this.elizaOS) {
44802
- await this.elizaOS.deleteAgents([agentId]);
44803
- }
44804
- logger31.debug(`Agent ${agentId} unregistered`);
44221
+ this.agents.delete(agentId);
44222
+ logger30.debug(`Agent ${agentId} removed from agents map`);
44805
44223
  } catch (error2) {
44806
- logger31.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
44224
+ logger30.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
44807
44225
  }
44808
44226
  }
44809
44227
  registerMiddleware(middleware2) {
@@ -44815,9 +44233,9 @@ class AgentServer {
44815
44233
  if (!port || typeof port !== "number") {
44816
44234
  throw new Error(`Invalid port number: ${port}`);
44817
44235
  }
44818
- logger31.debug(`Starting server on port ${port}...`);
44819
- logger31.debug(`Current agents count: ${this.elizaOS?.getAgents().length || 0}`);
44820
- logger31.debug(`Environment: ${"development"}`);
44236
+ logger30.debug(`Starting server on port ${port}...`);
44237
+ logger30.debug(`Current agents count: ${this.agents.size}`);
44238
+ logger30.debug(`Environment: ${"development"}`);
44821
44239
  const host = process.env.SERVER_HOST || "0.0.0.0";
44822
44240
  this.server.listen(port, host, () => {
44823
44241
  if (this.isWebUIEnabled && false) {} else if (!this.isWebUIEnabled) {
@@ -44830,26 +44248,25 @@ class AgentServer {
44830
44248
  ` + ` \x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`);
44831
44249
  }
44832
44250
  console.log(`AgentServer is listening on port ${port}`);
44833
- logger31.success(`REST API bound to ${host}:${port}. If running locally, access it at http://localhost:${port}.`);
44834
- const agents = this.elizaOS?.getAgents() || [];
44835
- logger31.debug(`Active agents: ${agents.length}`);
44836
- agents.forEach((agent) => {
44837
- logger31.debug(`- Agent ${agent.agentId}: ${agent.character.name}`);
44251
+ logger30.success(`REST API bound to ${host}:${port}. If running locally, access it at http://localhost:${port}.`);
44252
+ logger30.debug(`Active agents: ${this.agents.size}`);
44253
+ this.agents.forEach((agent, id) => {
44254
+ logger30.debug(`- Agent ${id}: ${agent.character.name}`);
44838
44255
  });
44839
44256
  resolve2();
44840
44257
  }).on("error", (error2) => {
44841
- logger31.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
44258
+ logger30.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
44842
44259
  if (error2.code === "EADDRINUSE") {
44843
- logger31.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
44260
+ logger30.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
44844
44261
  } else if (error2.code === "EACCES") {
44845
- logger31.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
44262
+ logger30.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
44846
44263
  } else if (error2.code === "EADDRNOTAVAIL") {
44847
- logger31.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
44264
+ logger30.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
44848
44265
  }
44849
44266
  reject(error2);
44850
44267
  });
44851
44268
  } catch (error2) {
44852
- logger31.error({ error: error2 }, "Failed to start server:");
44269
+ logger30.error({ error: error2 }, "Failed to start server:");
44853
44270
  reject(error2);
44854
44271
  }
44855
44272
  });
@@ -44857,7 +44274,7 @@ class AgentServer {
44857
44274
  async stop() {
44858
44275
  if (this.server) {
44859
44276
  this.server.close(() => {
44860
- logger31.success("Server stopped");
44277
+ logger30.success("Server stopped");
44861
44278
  });
44862
44279
  }
44863
44280
  }
@@ -44904,7 +44321,7 @@ class AgentServer {
44904
44321
  for (const message of messages) {
44905
44322
  await this.database.deleteMessage(message.id);
44906
44323
  }
44907
- logger31.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
44324
+ logger30.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
44908
44325
  }
44909
44326
  async findOrCreateCentralDmChannel(user1Id, user2Id, messageServerId) {
44910
44327
  return this.database.findOrCreateDmChannel(user1Id, user2Id, messageServerId);
@@ -44927,7 +44344,7 @@ class AgentServer {
44927
44344
  metadata: createdMessage.metadata
44928
44345
  };
44929
44346
  bus_default.emit("new_message", messageForBus);
44930
- logger31.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
44347
+ logger30.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
44931
44348
  }
44932
44349
  return createdMessage;
44933
44350
  }
@@ -44938,7 +44355,7 @@ class AgentServer {
44938
44355
  return this.database.updateMessage(messageId, patch);
44939
44356
  }
44940
44357
  async removeParticipantFromChannel() {
44941
- logger31.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
44358
+ logger30.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
44942
44359
  }
44943
44360
  async addAgentToServer(serverId, agentId) {
44944
44361
  const server = await this.getServerById(serverId);
@@ -44966,32 +44383,31 @@ class AgentServer {
44966
44383
  }
44967
44384
  registerSignalHandlers() {
44968
44385
  const gracefulShutdown = async () => {
44969
- logger31.info("Received shutdown signal, initiating graceful shutdown...");
44970
- logger31.debug("Stopping all agents...");
44971
- const agents = this.elizaOS?.getAgents() || [];
44972
- for (const agent of agents) {
44386
+ logger30.info("Received shutdown signal, initiating graceful shutdown...");
44387
+ logger30.debug("Stopping all agents...");
44388
+ for (const [id, agent] of this.agents.entries()) {
44973
44389
  try {
44974
44390
  await agent.stop();
44975
- logger31.debug(`Stopped agent ${agent.agentId}`);
44391
+ logger30.debug(`Stopped agent ${id}`);
44976
44392
  } catch (error2) {
44977
- logger31.error({ error: error2, agentId: agent.agentId }, `Error stopping agent ${agent.agentId}:`);
44393
+ logger30.error({ error: error2, agentId: id }, `Error stopping agent ${id}:`);
44978
44394
  }
44979
44395
  }
44980
44396
  if (this.database) {
44981
44397
  try {
44982
44398
  await this.database.close();
44983
- logger31.info("Database closed.");
44399
+ logger30.info("Database closed.");
44984
44400
  } catch (error2) {
44985
- logger31.error({ error: error2 }, "Error closing database:");
44401
+ logger30.error({ error: error2 }, "Error closing database:");
44986
44402
  }
44987
44403
  }
44988
44404
  if (this.server) {
44989
44405
  this.server.close(() => {
44990
- logger31.success("Server closed successfully");
44406
+ logger30.success("Server closed successfully");
44991
44407
  process.exit(0);
44992
44408
  });
44993
44409
  setTimeout(() => {
44994
- logger31.error("Could not close connections in time, forcing shutdown");
44410
+ logger30.error("Could not close connections in time, forcing shutdown");
44995
44411
  process.exit(1);
44996
44412
  }, 5000);
44997
44413
  } else {
@@ -45000,7 +44416,7 @@ class AgentServer {
45000
44416
  };
45001
44417
  process.on("SIGTERM", gracefulShutdown);
45002
44418
  process.on("SIGINT", gracefulShutdown);
45003
- logger31.debug("Shutdown handlers registered");
44419
+ logger30.debug("Shutdown handlers registered");
45004
44420
  }
45005
44421
  }
45006
44422
  export {
@@ -45014,8 +44430,5 @@ export {
45014
44430
  isWebUIEnabled,
45015
44431
  hasValidRemoteUrls,
45016
44432
  expandTildePath,
45017
- PluginLoader,
45018
- ElizaOS3 as ElizaOS,
45019
- ConfigManager,
45020
44433
  AgentServer
45021
44434
  };