@elizaos/server 1.5.12-alpha.2 → 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.
- package/dist/api/agents/crud.d.ts +2 -2
- package/dist/api/agents/index.d.ts +2 -2
- package/dist/api/agents/lifecycle.d.ts +2 -2
- package/dist/api/agents/logs.d.ts +2 -2
- package/dist/api/agents/panels.d.ts +2 -2
- package/dist/api/agents/runs.d.ts +2 -2
- package/dist/api/agents/worlds.d.ts +2 -2
- package/dist/api/audio/conversation.d.ts +2 -2
- package/dist/api/audio/index.d.ts +2 -2
- package/dist/api/audio/processing.d.ts +2 -2
- package/dist/api/audio/synthesis.d.ts +2 -2
- package/dist/api/index.d.ts +5 -5
- package/dist/api/memory/agents.d.ts +2 -2
- package/dist/api/memory/groups.d.ts +2 -2
- package/dist/api/memory/index.d.ts +2 -2
- package/dist/api/memory/rooms.d.ts +2 -2
- package/dist/api/messaging/channels.d.ts +2 -2
- package/dist/api/messaging/index.d.ts +2 -2
- package/dist/api/messaging/sessions.d.ts +2 -2
- package/dist/api/runtime/health.d.ts +2 -2
- package/dist/api/runtime/index.d.ts +2 -2
- package/dist/api/shared/middleware.d.ts +2 -2
- package/dist/api/shared/validation.d.ts +2 -2
- package/dist/client/assets/{main-FtAaPweT.js → main-Cxu5WF7C.js} +3 -3
- package/dist/client/assets/{main-FtAaPweT.js.map → main-Cxu5WF7C.js.map} +1 -1
- package/dist/client/assets/main-Dbnvjs-Q.js +119 -0
- package/dist/client/assets/main-Dbnvjs-Q.js.map +1 -0
- package/dist/client/assets/{react-vendor-2Sp1NOb7.js → react-vendor-BZhB15Ka.js} +31 -31
- package/dist/client/assets/react-vendor-BZhB15Ka.js.map +1 -0
- package/dist/client/index.html +1 -1
- package/dist/index.d.ts +5 -34
- package/dist/index.js +550 -1369
- package/dist/socketio/index.d.ts +4 -3
- package/package.json +5 -5
- package/dist/characters/default.d.ts +0 -14
- package/dist/client/assets/main-CoxLIDww.js +0 -141
- package/dist/client/assets/main-CoxLIDww.js.map +0 -1
- package/dist/client/assets/react-vendor-2Sp1NOb7.js.map +0 -1
- package/dist/managers/ConfigManager.d.ts +0 -32
- package/dist/managers/PluginLoader.d.ts +0 -27
package/dist/index.js
CHANGED
|
@@ -20653,11 +20653,11 @@ var require_version17 = __commonJS((exports) => {
|
|
|
20653
20653
|
var require_AttributeNames7 = __commonJS((exports) => {
|
|
20654
20654
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20655
20655
|
exports.AttributeNames = undefined;
|
|
20656
|
-
var
|
|
20657
|
-
(function(
|
|
20658
|
-
|
|
20659
|
-
|
|
20660
|
-
})(
|
|
20656
|
+
var AttributeNames2;
|
|
20657
|
+
(function(AttributeNames3) {
|
|
20658
|
+
AttributeNames3["KOA_TYPE"] = "koa.type";
|
|
20659
|
+
AttributeNames3["KOA_NAME"] = "koa.name";
|
|
20660
|
+
})(AttributeNames2 = exports.AttributeNames || (exports.AttributeNames = {}));
|
|
20661
20661
|
});
|
|
20662
20662
|
|
|
20663
20663
|
// ../../node_modules/@opentelemetry/instrumentation-koa/build/src/utils.js
|
|
@@ -20667,7 +20667,7 @@ var require_utils20 = __commonJS((exports) => {
|
|
|
20667
20667
|
var types_1 = require_types3();
|
|
20668
20668
|
var AttributeNames_1 = require_AttributeNames7();
|
|
20669
20669
|
var semantic_conventions_1 = require_src2();
|
|
20670
|
-
var getMiddlewareMetadata = (
|
|
20670
|
+
var getMiddlewareMetadata = (context10, layer, isRouter, layerPath) => {
|
|
20671
20671
|
if (isRouter) {
|
|
20672
20672
|
return {
|
|
20673
20673
|
attributes: {
|
|
@@ -20675,7 +20675,7 @@ var require_utils20 = __commonJS((exports) => {
|
|
|
20675
20675
|
[AttributeNames_1.AttributeNames.KOA_TYPE]: types_1.KoaLayerType.ROUTER,
|
|
20676
20676
|
[semantic_conventions_1.SEMATTRS_HTTP_ROUTE]: layerPath?.toString()
|
|
20677
20677
|
},
|
|
20678
|
-
name:
|
|
20678
|
+
name: context10._matchedRouteName || `router - ${layerPath}`
|
|
20679
20679
|
};
|
|
20680
20680
|
} else {
|
|
20681
20681
|
return {
|
|
@@ -20771,23 +20771,23 @@ var require_instrumentation17 = __commonJS((exports) => {
|
|
|
20771
20771
|
}
|
|
20772
20772
|
middlewareLayer[internal_types_1.kLayerPatched] = true;
|
|
20773
20773
|
api2.diag.debug("patching Koa middleware layer");
|
|
20774
|
-
return async (
|
|
20774
|
+
return async (context10, next) => {
|
|
20775
20775
|
const parent = api2.trace.getSpan(api2.context.active());
|
|
20776
20776
|
if (parent === undefined) {
|
|
20777
|
-
return middlewareLayer(
|
|
20777
|
+
return middlewareLayer(context10, next);
|
|
20778
20778
|
}
|
|
20779
|
-
const metadata = (0, utils_1.getMiddlewareMetadata)(
|
|
20779
|
+
const metadata = (0, utils_1.getMiddlewareMetadata)(context10, middlewareLayer, isRouter, layerPath);
|
|
20780
20780
|
const span = this.tracer.startSpan(metadata.name, {
|
|
20781
20781
|
attributes: metadata.attributes
|
|
20782
20782
|
});
|
|
20783
20783
|
const rpcMetadata = (0, core_1.getRPCMetadata)(api2.context.active());
|
|
20784
|
-
if (rpcMetadata?.type === core_1.RPCType.HTTP &&
|
|
20785
|
-
rpcMetadata.route =
|
|
20784
|
+
if (rpcMetadata?.type === core_1.RPCType.HTTP && context10._matchedRoute) {
|
|
20785
|
+
rpcMetadata.route = context10._matchedRoute.toString();
|
|
20786
20786
|
}
|
|
20787
20787
|
const { requestHook: requestHook2 } = this.getConfig();
|
|
20788
20788
|
if (requestHook2) {
|
|
20789
20789
|
(0, instrumentation_1.safeExecuteInTheMiddle)(() => requestHook2(span, {
|
|
20790
|
-
context:
|
|
20790
|
+
context: context10,
|
|
20791
20791
|
middlewareLayer,
|
|
20792
20792
|
layerType
|
|
20793
20793
|
}), (e) => {
|
|
@@ -20799,7 +20799,7 @@ var require_instrumentation17 = __commonJS((exports) => {
|
|
|
20799
20799
|
const newContext = api2.trace.setSpan(api2.context.active(), span);
|
|
20800
20800
|
return api2.context.with(newContext, async () => {
|
|
20801
20801
|
try {
|
|
20802
|
-
return await middlewareLayer(
|
|
20802
|
+
return await middlewareLayer(context10, next);
|
|
20803
20803
|
} catch (err) {
|
|
20804
20804
|
span.recordException(err);
|
|
20805
20805
|
throw err;
|
|
@@ -20835,11 +20835,11 @@ var require_src28 = __commonJS((exports) => {
|
|
|
20835
20835
|
var require_AttributeNames8 = __commonJS((exports) => {
|
|
20836
20836
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20837
20837
|
exports.ConnectNames = exports.ConnectTypes = exports.AttributeNames = undefined;
|
|
20838
|
-
var
|
|
20839
|
-
(function(
|
|
20840
|
-
|
|
20841
|
-
|
|
20842
|
-
})(
|
|
20838
|
+
var AttributeNames2;
|
|
20839
|
+
(function(AttributeNames3) {
|
|
20840
|
+
AttributeNames3["CONNECT_TYPE"] = "connect.type";
|
|
20841
|
+
AttributeNames3["CONNECT_NAME"] = "connect.name";
|
|
20842
|
+
})(AttributeNames2 = exports.AttributeNames || (exports.AttributeNames = {}));
|
|
20843
20843
|
var ConnectTypes;
|
|
20844
20844
|
(function(ConnectTypes2) {
|
|
20845
20845
|
ConnectTypes2["MIDDLEWARE"] = "middleware";
|
|
@@ -21504,16 +21504,16 @@ var require_utils23 = __commonJS((exports) => {
|
|
|
21504
21504
|
return attributes;
|
|
21505
21505
|
};
|
|
21506
21506
|
exports.getConnectionAttributesFromUrl = getConnectionAttributesFromUrl;
|
|
21507
|
-
var markConfirmChannelTracing = (
|
|
21508
|
-
return
|
|
21507
|
+
var markConfirmChannelTracing = (context10) => {
|
|
21508
|
+
return context10.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);
|
|
21509
21509
|
};
|
|
21510
21510
|
exports.markConfirmChannelTracing = markConfirmChannelTracing;
|
|
21511
|
-
var unmarkConfirmChannelTracing = (
|
|
21512
|
-
return
|
|
21511
|
+
var unmarkConfirmChannelTracing = (context10) => {
|
|
21512
|
+
return context10.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);
|
|
21513
21513
|
};
|
|
21514
21514
|
exports.unmarkConfirmChannelTracing = unmarkConfirmChannelTracing;
|
|
21515
|
-
var isConfirmChannelTracing = (
|
|
21516
|
-
return
|
|
21515
|
+
var isConfirmChannelTracing = (context10) => {
|
|
21516
|
+
return context10.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) === true;
|
|
21517
21517
|
};
|
|
21518
21518
|
exports.isConfirmChannelTracing = isConfirmChannelTracing;
|
|
21519
21519
|
});
|
|
@@ -21934,12 +21934,11 @@ var require_src32 = __commonJS((exports) => {
|
|
|
21934
21934
|
|
|
21935
21935
|
// src/index.ts
|
|
21936
21936
|
import {
|
|
21937
|
-
logger as
|
|
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
|
|
22486
|
+
import * as fs6 from "node:fs";
|
|
22488
22487
|
import http4 from "node:http";
|
|
22489
22488
|
import os3 from "node:os";
|
|
22490
|
-
import
|
|
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(
|
|
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 =
|
|
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 =
|
|
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
|
|
22675
|
-
if (
|
|
22676
|
-
|
|
22677
|
-
await
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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(
|
|
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 = !!
|
|
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?.
|
|
22814
|
-
const runtime =
|
|
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 =
|
|
22833
|
+
const runtime = agents.get(agentId);
|
|
22836
22834
|
if (!runtime) {
|
|
22837
22835
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22838
22836
|
}
|
|
22839
|
-
|
|
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(
|
|
22849
|
+
function createAgentWorldsRouter(agents) {
|
|
22852
22850
|
const router = express3.Router();
|
|
22853
22851
|
router.get("/worlds", async (_req, res) => {
|
|
22854
22852
|
try {
|
|
22855
|
-
const runtime =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
23617
|
+
function agentsRouter(agents, serverInstance) {
|
|
23620
23618
|
const router = express9.Router();
|
|
23621
|
-
router.use("/", createAgentCrudRouter(
|
|
23622
|
-
router.use("/", createAgentLifecycleRouter(
|
|
23623
|
-
router.use("/", createAgentWorldsRouter(
|
|
23624
|
-
router.use("/", createAgentPanelsRouter(
|
|
23625
|
-
router.use("/", createAgentLogsRouter(
|
|
23626
|
-
router.use("/", createAgentRunsRouter(
|
|
23627
|
-
router.use("/", createAgentMemoryRouter(
|
|
23628
|
-
router.use("/", createRoomManagementRouter(
|
|
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 = (
|
|
24184
|
-
const runtime =
|
|
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(
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
26478
|
-
router.use("/", createSessionsRouter(
|
|
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(
|
|
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(
|
|
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(
|
|
26777
|
+
function memoryRouter(agents, serverInstance) {
|
|
26780
26778
|
const router = express19.Router();
|
|
26781
|
-
router.use("/", createAgentMemoryRouter(
|
|
26782
|
-
router.use("/", createGroupMemoryRouter(
|
|
26783
|
-
router.use("/", createRoomManagementRouter(
|
|
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(
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
27108
|
+
function audioRouter(agents) {
|
|
27111
27109
|
const router = express23.Router();
|
|
27112
|
-
router.use("/", createAudioProcessingRouter(
|
|
27113
|
-
router.use("/", createSynthesisRouter(
|
|
27114
|
-
router.use("/", createConversationRouter(
|
|
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(
|
|
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:
|
|
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:
|
|
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(
|
|
27319
|
+
function runtimeRouter(agents, serverInstance) {
|
|
27322
27320
|
const router = express27.Router();
|
|
27323
|
-
router.use("/", createHealthRouter(
|
|
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
|
|
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
|
-
|
|
27578
|
+
agents;
|
|
27581
27579
|
connections;
|
|
27582
27580
|
logStreamConnections;
|
|
27583
27581
|
serverInstance;
|
|
27584
|
-
constructor(
|
|
27585
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
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(
|
|
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(
|
|
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 (
|
|
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 =
|
|
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
|
|
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(
|
|
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(
|
|
28127
|
-
router.use("/messaging", messagingRouter(
|
|
28128
|
-
router.use("/memory", memoryRouter(
|
|
28129
|
-
router.use("/audio", audioRouter(
|
|
28130
|
-
router.use("/server", runtimeRouter(
|
|
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(
|
|
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.
|
|
29012
|
+
var SDK_VERSION = "10.12.0";
|
|
29015
29013
|
|
|
29016
29014
|
// ../../node_modules/@sentry/core/build/esm/carrier.js
|
|
29017
29015
|
function getMainCarrier() {
|
|
@@ -30355,39 +30353,16 @@ function getSpanStatusFromHttpCode(httpStatus) {
|
|
|
30355
30353
|
// ../../node_modules/@sentry/core/build/esm/tracing/utils.js
|
|
30356
30354
|
var SCOPE_ON_START_SPAN_FIELD = "_sentryScope";
|
|
30357
30355
|
var ISOLATION_SCOPE_ON_START_SPAN_FIELD = "_sentryIsolationScope";
|
|
30358
|
-
function wrapScopeWithWeakRef(scope) {
|
|
30359
|
-
try {
|
|
30360
|
-
const WeakRefClass = GLOBAL_OBJ.WeakRef;
|
|
30361
|
-
if (typeof WeakRefClass === "function") {
|
|
30362
|
-
return new WeakRefClass(scope);
|
|
30363
|
-
}
|
|
30364
|
-
} catch {}
|
|
30365
|
-
return scope;
|
|
30366
|
-
}
|
|
30367
|
-
function unwrapScopeFromWeakRef(scopeRef) {
|
|
30368
|
-
if (!scopeRef) {
|
|
30369
|
-
return;
|
|
30370
|
-
}
|
|
30371
|
-
if (typeof scopeRef === "object" && "deref" in scopeRef && typeof scopeRef.deref === "function") {
|
|
30372
|
-
try {
|
|
30373
|
-
return scopeRef.deref();
|
|
30374
|
-
} catch {
|
|
30375
|
-
return;
|
|
30376
|
-
}
|
|
30377
|
-
}
|
|
30378
|
-
return scopeRef;
|
|
30379
|
-
}
|
|
30380
30356
|
function setCapturedScopesOnSpan(span, scope, isolationScope) {
|
|
30381
30357
|
if (span) {
|
|
30382
|
-
addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD,
|
|
30358
|
+
addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
|
|
30383
30359
|
addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
|
|
30384
30360
|
}
|
|
30385
30361
|
}
|
|
30386
30362
|
function getCapturedScopesOnSpan(span) {
|
|
30387
|
-
const spanWithScopes = span;
|
|
30388
30363
|
return {
|
|
30389
|
-
scope:
|
|
30390
|
-
isolationScope:
|
|
30364
|
+
scope: span[SCOPE_ON_START_SPAN_FIELD],
|
|
30365
|
+
isolationScope: span[ISOLATION_SCOPE_ON_START_SPAN_FIELD]
|
|
30391
30366
|
};
|
|
30392
30367
|
}
|
|
30393
30368
|
|
|
@@ -30820,7 +30795,7 @@ function getActiveSpan() {
|
|
|
30820
30795
|
function showSpanDropWarning() {
|
|
30821
30796
|
if (!hasShownSpanDropWarning) {
|
|
30822
30797
|
consoleSandbox(() => {
|
|
30823
|
-
console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly
|
|
30798
|
+
console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly.");
|
|
30824
30799
|
});
|
|
30825
30800
|
hasShownSpanDropWarning = true;
|
|
30826
30801
|
}
|
|
@@ -30855,50 +30830,6 @@ function hasSpansEnabled(maybeOptions) {
|
|
|
30855
30830
|
return !!options && (options.tracesSampleRate != null || !!options.tracesSampler);
|
|
30856
30831
|
}
|
|
30857
30832
|
|
|
30858
|
-
// ../../node_modules/@sentry/core/build/esm/utils/should-ignore-span.js
|
|
30859
|
-
function logIgnoredSpan(droppedSpan) {
|
|
30860
|
-
debug.log(`Ignoring span ${droppedSpan.op} - ${droppedSpan.description} because it matches \`ignoreSpans\`.`);
|
|
30861
|
-
}
|
|
30862
|
-
function shouldIgnoreSpan(span, ignoreSpans) {
|
|
30863
|
-
if (!ignoreSpans?.length || !span.description) {
|
|
30864
|
-
return false;
|
|
30865
|
-
}
|
|
30866
|
-
for (const pattern of ignoreSpans) {
|
|
30867
|
-
if (isStringOrRegExp(pattern)) {
|
|
30868
|
-
if (isMatchingPattern(span.description, pattern)) {
|
|
30869
|
-
DEBUG_BUILD && logIgnoredSpan(span);
|
|
30870
|
-
return true;
|
|
30871
|
-
}
|
|
30872
|
-
continue;
|
|
30873
|
-
}
|
|
30874
|
-
if (!pattern.name && !pattern.op) {
|
|
30875
|
-
continue;
|
|
30876
|
-
}
|
|
30877
|
-
const nameMatches = pattern.name ? isMatchingPattern(span.description, pattern.name) : true;
|
|
30878
|
-
const opMatches = pattern.op ? span.op && isMatchingPattern(span.op, pattern.op) : true;
|
|
30879
|
-
if (nameMatches && opMatches) {
|
|
30880
|
-
DEBUG_BUILD && logIgnoredSpan(span);
|
|
30881
|
-
return true;
|
|
30882
|
-
}
|
|
30883
|
-
}
|
|
30884
|
-
return false;
|
|
30885
|
-
}
|
|
30886
|
-
function reparentChildSpans(spans, dropSpan) {
|
|
30887
|
-
const droppedSpanParentId = dropSpan.parent_span_id;
|
|
30888
|
-
const droppedSpanId = dropSpan.span_id;
|
|
30889
|
-
if (!droppedSpanParentId) {
|
|
30890
|
-
return;
|
|
30891
|
-
}
|
|
30892
|
-
for (const span of spans) {
|
|
30893
|
-
if (span.parent_span_id === droppedSpanId) {
|
|
30894
|
-
span.parent_span_id = droppedSpanParentId;
|
|
30895
|
-
}
|
|
30896
|
-
}
|
|
30897
|
-
}
|
|
30898
|
-
function isStringOrRegExp(value) {
|
|
30899
|
-
return typeof value === "string" || value instanceof RegExp;
|
|
30900
|
-
}
|
|
30901
|
-
|
|
30902
30833
|
// ../../node_modules/@sentry/core/build/esm/constants.js
|
|
30903
30834
|
var DEFAULT_ENVIRONMENT = "production";
|
|
30904
30835
|
|
|
@@ -31256,6 +31187,45 @@ function createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn) {
|
|
|
31256
31187
|
};
|
|
31257
31188
|
}
|
|
31258
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
|
+
|
|
31259
31229
|
// ../../node_modules/@sentry/core/build/esm/envelope.js
|
|
31260
31230
|
function _enhanceEventWithSdkInfo(event, newSdkInfo) {
|
|
31261
31231
|
if (!newSdkInfo) {
|
|
@@ -31612,7 +31582,7 @@ function sendSpanEnvelope(envelope) {
|
|
|
31612
31582
|
}
|
|
31613
31583
|
|
|
31614
31584
|
// ../../node_modules/@sentry/core/build/esm/utils/handleCallbackErrors.js
|
|
31615
|
-
function handleCallbackErrors(fn, onError, onFinally = () => {}
|
|
31585
|
+
function handleCallbackErrors(fn, onError, onFinally = () => {}) {
|
|
31616
31586
|
let maybePromiseResult;
|
|
31617
31587
|
try {
|
|
31618
31588
|
maybePromiseResult = fn();
|
|
@@ -31621,13 +31591,12 @@ function handleCallbackErrors(fn, onError, onFinally = () => {}, onSuccess = ()
|
|
|
31621
31591
|
onFinally();
|
|
31622
31592
|
throw e;
|
|
31623
31593
|
}
|
|
31624
|
-
return maybeHandlePromiseRejection(maybePromiseResult, onError, onFinally
|
|
31594
|
+
return maybeHandlePromiseRejection(maybePromiseResult, onError, onFinally);
|
|
31625
31595
|
}
|
|
31626
|
-
function maybeHandlePromiseRejection(value, onError, onFinally
|
|
31596
|
+
function maybeHandlePromiseRejection(value, onError, onFinally) {
|
|
31627
31597
|
if (isThenable(value)) {
|
|
31628
31598
|
return value.then((res) => {
|
|
31629
31599
|
onFinally();
|
|
31630
|
-
onSuccess(res);
|
|
31631
31600
|
return res;
|
|
31632
31601
|
}, (e) => {
|
|
31633
31602
|
onError(e);
|
|
@@ -31636,7 +31605,6 @@ function maybeHandlePromiseRejection(value, onError, onFinally, onSuccess) {
|
|
|
31636
31605
|
});
|
|
31637
31606
|
}
|
|
31638
31607
|
onFinally();
|
|
31639
|
-
onSuccess(value);
|
|
31640
31608
|
return value;
|
|
31641
31609
|
}
|
|
31642
31610
|
|
|
@@ -32737,21 +32705,23 @@ class Client {
|
|
|
32737
32705
|
getTransport() {
|
|
32738
32706
|
return this._transport;
|
|
32739
32707
|
}
|
|
32740
|
-
|
|
32708
|
+
flush(timeout) {
|
|
32741
32709
|
const transport = this._transport;
|
|
32742
|
-
if (
|
|
32743
|
-
|
|
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);
|
|
32744
32717
|
}
|
|
32745
|
-
this.emit("flush");
|
|
32746
|
-
const clientFinished = await this._isClientDoneProcessing(timeout);
|
|
32747
|
-
const transportFlushed = await transport.flush(timeout);
|
|
32748
|
-
return clientFinished && transportFlushed;
|
|
32749
32718
|
}
|
|
32750
|
-
|
|
32751
|
-
|
|
32752
|
-
|
|
32753
|
-
|
|
32754
|
-
|
|
32719
|
+
close(timeout) {
|
|
32720
|
+
return this.flush(timeout).then((result) => {
|
|
32721
|
+
this.getOptions().enabled = false;
|
|
32722
|
+
this.emit("close");
|
|
32723
|
+
return result;
|
|
32724
|
+
});
|
|
32755
32725
|
}
|
|
32756
32726
|
getEventProcessors() {
|
|
32757
32727
|
return this._eventProcessors;
|
|
@@ -32813,11 +32783,13 @@ class Client {
|
|
|
32813
32783
|
}
|
|
32814
32784
|
}
|
|
32815
32785
|
on(hook, callback) {
|
|
32816
|
-
const
|
|
32817
|
-
|
|
32818
|
-
hookCallbacks.add(uniqueCallback);
|
|
32786
|
+
const hooks = this._hooks[hook] = this._hooks[hook] || [];
|
|
32787
|
+
hooks.push(callback);
|
|
32819
32788
|
return () => {
|
|
32820
|
-
|
|
32789
|
+
const cbIndex = hooks.indexOf(callback);
|
|
32790
|
+
if (cbIndex > -1) {
|
|
32791
|
+
hooks.splice(cbIndex, 1);
|
|
32792
|
+
}
|
|
32821
32793
|
};
|
|
32822
32794
|
}
|
|
32823
32795
|
emit(hook, ...rest) {
|
|
@@ -32826,18 +32798,16 @@ class Client {
|
|
|
32826
32798
|
callbacks.forEach((callback) => callback(...rest));
|
|
32827
32799
|
}
|
|
32828
32800
|
}
|
|
32829
|
-
|
|
32801
|
+
sendEnvelope(envelope) {
|
|
32830
32802
|
this.emit("beforeEnvelope", envelope);
|
|
32831
32803
|
if (this._isEnabled() && this._transport) {
|
|
32832
|
-
|
|
32833
|
-
return await this._transport.send(envelope);
|
|
32834
|
-
} catch (reason) {
|
|
32804
|
+
return this._transport.send(envelope).then(null, (reason) => {
|
|
32835
32805
|
DEBUG_BUILD && debug.error("Error while sending envelope:", reason);
|
|
32836
32806
|
return {};
|
|
32837
|
-
}
|
|
32807
|
+
});
|
|
32838
32808
|
}
|
|
32839
32809
|
DEBUG_BUILD && debug.error("Transport disabled");
|
|
32840
|
-
return {};
|
|
32810
|
+
return resolvedSyncPromise({});
|
|
32841
32811
|
}
|
|
32842
32812
|
_setupIntegrations() {
|
|
32843
32813
|
const { integrations } = this._options;
|
|
@@ -32868,16 +32838,23 @@ class Client {
|
|
|
32868
32838
|
this.captureSession(session);
|
|
32869
32839
|
}
|
|
32870
32840
|
}
|
|
32871
|
-
|
|
32872
|
-
|
|
32873
|
-
|
|
32874
|
-
|
|
32875
|
-
|
|
32876
|
-
|
|
32877
|
-
|
|
32878
|
-
|
|
32879
|
-
|
|
32880
|
-
|
|
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
|
+
});
|
|
32881
32858
|
}
|
|
32882
32859
|
_isEnabled() {
|
|
32883
32860
|
return this.getOptions().enabled !== false && this._transport !== undefined;
|
|
@@ -33188,7 +33165,7 @@ function createLogEnvelope(logs, metadata, tunnel, dsn) {
|
|
|
33188
33165
|
return createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
|
|
33189
33166
|
}
|
|
33190
33167
|
|
|
33191
|
-
// ../../node_modules/@sentry/core/build/esm/logs/
|
|
33168
|
+
// ../../node_modules/@sentry/core/build/esm/logs/exports.js
|
|
33192
33169
|
function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
|
|
33193
33170
|
const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
|
|
33194
33171
|
if (logBuffer.length === 0) {
|
|
@@ -33589,7 +33566,7 @@ function createTransport(options, makeRequest, buffer = makePromiseBuffer(option
|
|
|
33589
33566
|
}
|
|
33590
33567
|
});
|
|
33591
33568
|
if (filteredEnvelopeItems.length === 0) {
|
|
33592
|
-
return
|
|
33569
|
+
return resolvedSyncPromise({});
|
|
33593
33570
|
}
|
|
33594
33571
|
const filteredEnvelope = createEnvelope(envelope[0], filteredEnvelopeItems);
|
|
33595
33572
|
const recordEnvelopeLoss = (reason) => {
|
|
@@ -33612,7 +33589,7 @@ function createTransport(options, makeRequest, buffer = makePromiseBuffer(option
|
|
|
33612
33589
|
if (error2 === SENTRY_BUFFER_FULL_ERROR) {
|
|
33613
33590
|
DEBUG_BUILD && debug.error("Skipped sending event because buffer is full.");
|
|
33614
33591
|
recordEnvelopeLoss("queue_overflow");
|
|
33615
|
-
return
|
|
33592
|
+
return resolvedSyncPromise({});
|
|
33616
33593
|
} else {
|
|
33617
33594
|
throw error2;
|
|
33618
33595
|
}
|
|
@@ -35082,9 +35059,6 @@ function getFinalOperationName(methodPath) {
|
|
|
35082
35059
|
if (methodPath.includes("models")) {
|
|
35083
35060
|
return "models";
|
|
35084
35061
|
}
|
|
35085
|
-
if (methodPath.includes("chat")) {
|
|
35086
|
-
return "chat";
|
|
35087
|
-
}
|
|
35088
35062
|
return methodPath.split(".").pop() || "unknown";
|
|
35089
35063
|
}
|
|
35090
35064
|
function getSpanOperation2(methodPath) {
|
|
@@ -35112,6 +35086,18 @@ function setTokenUsageAttributes2(span, promptTokens, completionTokens, cachedIn
|
|
|
35112
35086
|
}
|
|
35113
35087
|
}
|
|
35114
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
|
+
|
|
35115
35101
|
// ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/streaming.js
|
|
35116
35102
|
function isErrorEvent3(event, span) {
|
|
35117
35103
|
if ("type" in event && typeof event.type === "string") {
|
|
@@ -35261,18 +35247,6 @@ async function* instrumentStream2(stream, span, recordOutputs) {
|
|
|
35261
35247
|
}
|
|
35262
35248
|
}
|
|
35263
35249
|
|
|
35264
|
-
// ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/constants.js
|
|
35265
|
-
var ANTHROPIC_AI_INTEGRATION_NAME = "Anthropic_AI";
|
|
35266
|
-
var ANTHROPIC_AI_INSTRUMENTED_METHODS = [
|
|
35267
|
-
"messages.create",
|
|
35268
|
-
"messages.stream",
|
|
35269
|
-
"messages.countTokens",
|
|
35270
|
-
"models.get",
|
|
35271
|
-
"completions.create",
|
|
35272
|
-
"models.retrieve",
|
|
35273
|
-
"beta.messages.create"
|
|
35274
|
-
];
|
|
35275
|
-
|
|
35276
35250
|
// ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/utils.js
|
|
35277
35251
|
function shouldInstrument2(methodPath) {
|
|
35278
35252
|
return ANTHROPIC_AI_INSTRUMENTED_METHODS.includes(methodPath);
|
|
@@ -35391,8 +35365,19 @@ function addResponseAttributes2(span, response, recordOutputs) {
|
|
|
35391
35365
|
}
|
|
35392
35366
|
addMetadataAttributes(span, response);
|
|
35393
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
|
+
}
|
|
35394
35378
|
function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
35395
35379
|
return async function instrumentedMethod(...args) {
|
|
35380
|
+
const finalOptions = options || getRecordingOptionsFromIntegration();
|
|
35396
35381
|
const requestAttributes = extractRequestAttributes2(args, methodPath);
|
|
35397
35382
|
const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
|
|
35398
35383
|
const operationName = getFinalOperationName(methodPath);
|
|
@@ -35406,11 +35391,11 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35406
35391
|
attributes: requestAttributes
|
|
35407
35392
|
}, async (span) => {
|
|
35408
35393
|
try {
|
|
35409
|
-
if (
|
|
35394
|
+
if (finalOptions.recordInputs && params) {
|
|
35410
35395
|
addPrivateRequestAttributes(span, params);
|
|
35411
35396
|
}
|
|
35412
35397
|
const result = await originalMethod.apply(context, args);
|
|
35413
|
-
return instrumentStream2(result, span,
|
|
35398
|
+
return instrumentStream2(result, span, finalOptions.recordOutputs ?? false);
|
|
35414
35399
|
} catch (error2) {
|
|
35415
35400
|
span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
|
|
35416
35401
|
captureException(error2, {
|
|
@@ -35431,11 +35416,15 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35431
35416
|
name: `${operationName} ${model}`,
|
|
35432
35417
|
op: getSpanOperation2(methodPath),
|
|
35433
35418
|
attributes: requestAttributes
|
|
35434
|
-
}, (span) => {
|
|
35435
|
-
|
|
35436
|
-
|
|
35437
|
-
|
|
35438
|
-
|
|
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) {
|
|
35439
35428
|
captureException(error2, {
|
|
35440
35429
|
mechanism: {
|
|
35441
35430
|
handled: false,
|
|
@@ -35445,7 +35434,8 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35445
35434
|
}
|
|
35446
35435
|
}
|
|
35447
35436
|
});
|
|
35448
|
-
|
|
35437
|
+
throw error2;
|
|
35438
|
+
}
|
|
35449
35439
|
});
|
|
35450
35440
|
};
|
|
35451
35441
|
}
|
|
@@ -35467,195 +35457,8 @@ function createDeepProxy2(target, currentPath = "", options) {
|
|
|
35467
35457
|
}
|
|
35468
35458
|
});
|
|
35469
35459
|
}
|
|
35470
|
-
function instrumentAnthropicAiClient(
|
|
35471
|
-
|
|
35472
|
-
const _options = {
|
|
35473
|
-
recordInputs: sendDefaultPii,
|
|
35474
|
-
recordOutputs: sendDefaultPii,
|
|
35475
|
-
...options
|
|
35476
|
-
};
|
|
35477
|
-
return createDeepProxy2(anthropicAiClient, "", _options);
|
|
35478
|
-
}
|
|
35479
|
-
// ../../node_modules/@sentry/core/build/esm/utils/google-genai/constants.js
|
|
35480
|
-
var GOOGLE_GENAI_INTEGRATION_NAME = "Google_GenAI";
|
|
35481
|
-
var GOOGLE_GENAI_INSTRUMENTED_METHODS = ["models.generateContent", "chats.create", "sendMessage"];
|
|
35482
|
-
var GOOGLE_GENAI_SYSTEM_NAME = "google_genai";
|
|
35483
|
-
var CHATS_CREATE_METHOD = "chats.create";
|
|
35484
|
-
var CHAT_PATH = "chat";
|
|
35485
|
-
|
|
35486
|
-
// ../../node_modules/@sentry/core/build/esm/utils/google-genai/utils.js
|
|
35487
|
-
function shouldInstrument3(methodPath) {
|
|
35488
|
-
if (GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(methodPath)) {
|
|
35489
|
-
return true;
|
|
35490
|
-
}
|
|
35491
|
-
const methodName = methodPath.split(".").pop();
|
|
35492
|
-
return GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(methodName);
|
|
35493
|
-
}
|
|
35494
|
-
|
|
35495
|
-
// ../../node_modules/@sentry/core/build/esm/utils/google-genai/index.js
|
|
35496
|
-
function extractModel(params, context) {
|
|
35497
|
-
if ("model" in params && typeof params.model === "string") {
|
|
35498
|
-
return params.model;
|
|
35499
|
-
}
|
|
35500
|
-
if (context && typeof context === "object") {
|
|
35501
|
-
const contextObj = context;
|
|
35502
|
-
if ("model" in contextObj && typeof contextObj.model === "string") {
|
|
35503
|
-
return contextObj.model;
|
|
35504
|
-
}
|
|
35505
|
-
if ("modelVersion" in contextObj && typeof contextObj.modelVersion === "string") {
|
|
35506
|
-
return contextObj.modelVersion;
|
|
35507
|
-
}
|
|
35508
|
-
}
|
|
35509
|
-
return "unknown";
|
|
35510
|
-
}
|
|
35511
|
-
function extractConfigAttributes(config) {
|
|
35512
|
-
const attributes = {};
|
|
35513
|
-
if ("temperature" in config && typeof config.temperature === "number") {
|
|
35514
|
-
attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = config.temperature;
|
|
35515
|
-
}
|
|
35516
|
-
if ("topP" in config && typeof config.topP === "number") {
|
|
35517
|
-
attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = config.topP;
|
|
35518
|
-
}
|
|
35519
|
-
if ("topK" in config && typeof config.topK === "number") {
|
|
35520
|
-
attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = config.topK;
|
|
35521
|
-
}
|
|
35522
|
-
if ("maxOutputTokens" in config && typeof config.maxOutputTokens === "number") {
|
|
35523
|
-
attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = config.maxOutputTokens;
|
|
35524
|
-
}
|
|
35525
|
-
if ("frequencyPenalty" in config && typeof config.frequencyPenalty === "number") {
|
|
35526
|
-
attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = config.frequencyPenalty;
|
|
35527
|
-
}
|
|
35528
|
-
if ("presencePenalty" in config && typeof config.presencePenalty === "number") {
|
|
35529
|
-
attributes[GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE] = config.presencePenalty;
|
|
35530
|
-
}
|
|
35531
|
-
return attributes;
|
|
35532
|
-
}
|
|
35533
|
-
function extractRequestAttributes3(args, methodPath, context) {
|
|
35534
|
-
const attributes = {
|
|
35535
|
-
[GEN_AI_SYSTEM_ATTRIBUTE]: GOOGLE_GENAI_SYSTEM_NAME,
|
|
35536
|
-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: getFinalOperationName(methodPath),
|
|
35537
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ai.google_genai"
|
|
35538
|
-
};
|
|
35539
|
-
if (args.length > 0 && typeof args[0] === "object" && args[0] !== null) {
|
|
35540
|
-
const params = args[0];
|
|
35541
|
-
attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel(params, context);
|
|
35542
|
-
if ("config" in params && typeof params.config === "object" && params.config) {
|
|
35543
|
-
Object.assign(attributes, extractConfigAttributes(params.config));
|
|
35544
|
-
}
|
|
35545
|
-
} else {
|
|
35546
|
-
attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel({}, context);
|
|
35547
|
-
}
|
|
35548
|
-
return attributes;
|
|
35549
|
-
}
|
|
35550
|
-
function addPrivateRequestAttributes2(span, params) {
|
|
35551
|
-
if ("contents" in params) {
|
|
35552
|
-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.contents) });
|
|
35553
|
-
}
|
|
35554
|
-
if ("message" in params) {
|
|
35555
|
-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.message) });
|
|
35556
|
-
}
|
|
35557
|
-
if ("history" in params) {
|
|
35558
|
-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.history) });
|
|
35559
|
-
}
|
|
35560
|
-
}
|
|
35561
|
-
function addResponseAttributes3(span, response, recordOutputs) {
|
|
35562
|
-
if (!response || typeof response !== "object")
|
|
35563
|
-
return;
|
|
35564
|
-
if (response.usageMetadata && typeof response.usageMetadata === "object") {
|
|
35565
|
-
const usage = response.usageMetadata;
|
|
35566
|
-
if (typeof usage.promptTokenCount === "number") {
|
|
35567
|
-
span.setAttributes({
|
|
35568
|
-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: usage.promptTokenCount
|
|
35569
|
-
});
|
|
35570
|
-
}
|
|
35571
|
-
if (typeof usage.candidatesTokenCount === "number") {
|
|
35572
|
-
span.setAttributes({
|
|
35573
|
-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: usage.candidatesTokenCount
|
|
35574
|
-
});
|
|
35575
|
-
}
|
|
35576
|
-
if (typeof usage.totalTokenCount === "number") {
|
|
35577
|
-
span.setAttributes({
|
|
35578
|
-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: usage.totalTokenCount
|
|
35579
|
-
});
|
|
35580
|
-
}
|
|
35581
|
-
}
|
|
35582
|
-
if (recordOutputs && Array.isArray(response.candidates) && response.candidates.length > 0) {
|
|
35583
|
-
const responseTexts = response.candidates.map((candidate) => {
|
|
35584
|
-
if (candidate.content?.parts && Array.isArray(candidate.content.parts)) {
|
|
35585
|
-
return candidate.content.parts.map((part) => typeof part.text === "string" ? part.text : "").filter((text) => text.length > 0).join("");
|
|
35586
|
-
}
|
|
35587
|
-
return "";
|
|
35588
|
-
}).filter((text) => text.length > 0);
|
|
35589
|
-
if (responseTexts.length > 0) {
|
|
35590
|
-
span.setAttributes({
|
|
35591
|
-
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: responseTexts.join("")
|
|
35592
|
-
});
|
|
35593
|
-
}
|
|
35594
|
-
}
|
|
35595
|
-
}
|
|
35596
|
-
function instrumentMethod3(originalMethod, methodPath, context, options) {
|
|
35597
|
-
const isSyncCreate = methodPath === CHATS_CREATE_METHOD;
|
|
35598
|
-
const run = (...args) => {
|
|
35599
|
-
const requestAttributes = extractRequestAttributes3(args, methodPath, context);
|
|
35600
|
-
const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
|
|
35601
|
-
const operationName = getFinalOperationName(methodPath);
|
|
35602
|
-
return startSpan({
|
|
35603
|
-
name: isSyncCreate ? `${operationName} ${model} create` : `${operationName} ${model}`,
|
|
35604
|
-
op: getSpanOperation2(methodPath),
|
|
35605
|
-
attributes: requestAttributes
|
|
35606
|
-
}, (span) => {
|
|
35607
|
-
if (options.recordInputs && args[0] && typeof args[0] === "object") {
|
|
35608
|
-
addPrivateRequestAttributes2(span, args[0]);
|
|
35609
|
-
}
|
|
35610
|
-
return handleCallbackErrors(() => originalMethod.apply(context, args), (error2) => {
|
|
35611
|
-
captureException(error2, {
|
|
35612
|
-
mechanism: { handled: false, type: "auto.ai.google_genai", data: { function: methodPath } }
|
|
35613
|
-
});
|
|
35614
|
-
}, () => {}, (result) => {
|
|
35615
|
-
if (!isSyncCreate) {
|
|
35616
|
-
addResponseAttributes3(span, result, options.recordOutputs);
|
|
35617
|
-
}
|
|
35618
|
-
});
|
|
35619
|
-
});
|
|
35620
|
-
};
|
|
35621
|
-
return run;
|
|
35622
|
-
}
|
|
35623
|
-
function createDeepProxy3(target, currentPath = "", options) {
|
|
35624
|
-
return new Proxy(target, {
|
|
35625
|
-
get: (t, prop, receiver) => {
|
|
35626
|
-
const value = Reflect.get(t, prop, receiver);
|
|
35627
|
-
const methodPath = buildMethodPath2(currentPath, String(prop));
|
|
35628
|
-
if (typeof value === "function" && shouldInstrument3(methodPath)) {
|
|
35629
|
-
if (methodPath === CHATS_CREATE_METHOD) {
|
|
35630
|
-
const instrumentedMethod = instrumentMethod3(value, methodPath, t, options);
|
|
35631
|
-
return function instrumentedAndProxiedCreate(...args) {
|
|
35632
|
-
const result = instrumentedMethod(...args);
|
|
35633
|
-
if (result && typeof result === "object") {
|
|
35634
|
-
return createDeepProxy3(result, CHAT_PATH, options);
|
|
35635
|
-
}
|
|
35636
|
-
return result;
|
|
35637
|
-
};
|
|
35638
|
-
}
|
|
35639
|
-
return instrumentMethod3(value, methodPath, t, options);
|
|
35640
|
-
}
|
|
35641
|
-
if (typeof value === "function") {
|
|
35642
|
-
return value.bind(t);
|
|
35643
|
-
}
|
|
35644
|
-
if (value && typeof value === "object") {
|
|
35645
|
-
return createDeepProxy3(value, methodPath, options);
|
|
35646
|
-
}
|
|
35647
|
-
return value;
|
|
35648
|
-
}
|
|
35649
|
-
});
|
|
35650
|
-
}
|
|
35651
|
-
function instrumentGoogleGenAIClient(client, options) {
|
|
35652
|
-
const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);
|
|
35653
|
-
const _options = {
|
|
35654
|
-
recordInputs: sendDefaultPii,
|
|
35655
|
-
recordOutputs: sendDefaultPii,
|
|
35656
|
-
...options
|
|
35657
|
-
};
|
|
35658
|
-
return createDeepProxy3(client, "", _options);
|
|
35460
|
+
function instrumentAnthropicAiClient(client, options) {
|
|
35461
|
+
return createDeepProxy2(client, "", options);
|
|
35659
35462
|
}
|
|
35660
35463
|
// ../../node_modules/@sentry/core/build/esm/utils/breadcrumb-log-level.js
|
|
35661
35464
|
function getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {
|
|
@@ -35669,35 +35472,6 @@ function getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {
|
|
|
35669
35472
|
return;
|
|
35670
35473
|
}
|
|
35671
35474
|
}
|
|
35672
|
-
// ../../node_modules/@sentry/core/build/esm/utils/exports.js
|
|
35673
|
-
function replaceExports(exports, exportName, wrappedConstructor) {
|
|
35674
|
-
const original = exports[exportName];
|
|
35675
|
-
if (typeof original !== "function") {
|
|
35676
|
-
return;
|
|
35677
|
-
}
|
|
35678
|
-
try {
|
|
35679
|
-
exports[exportName] = wrappedConstructor;
|
|
35680
|
-
} catch (error2) {
|
|
35681
|
-
Object.defineProperty(exports, exportName, {
|
|
35682
|
-
value: wrappedConstructor,
|
|
35683
|
-
writable: true,
|
|
35684
|
-
configurable: true,
|
|
35685
|
-
enumerable: true
|
|
35686
|
-
});
|
|
35687
|
-
}
|
|
35688
|
-
if (exports.default === original) {
|
|
35689
|
-
try {
|
|
35690
|
-
exports.default = wrappedConstructor;
|
|
35691
|
-
} catch (error2) {
|
|
35692
|
-
Object.defineProperty(exports, "default", {
|
|
35693
|
-
value: wrappedConstructor,
|
|
35694
|
-
writable: true,
|
|
35695
|
-
configurable: true,
|
|
35696
|
-
enumerable: true
|
|
35697
|
-
});
|
|
35698
|
-
}
|
|
35699
|
-
}
|
|
35700
|
-
}
|
|
35701
35475
|
// ../../node_modules/@sentry/core/build/esm/utils/node-stack-trace.js
|
|
35702
35476
|
function filenameIsInApp(filename, isNative = false) {
|
|
35703
35477
|
const isInternal = isNative || filename && !filename.startsWith("/") && !filename.match(/^[A-Z]:/) && !filename.startsWith(".") && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//);
|
|
@@ -35825,9 +35599,6 @@ class LRUMap {
|
|
|
35825
35599
|
return values;
|
|
35826
35600
|
}
|
|
35827
35601
|
}
|
|
35828
|
-
// ../../node_modules/@sentry/node-core/build/esm/debug-build.js
|
|
35829
|
-
var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
35830
|
-
|
|
35831
35602
|
// ../../node_modules/@sentry/node-core/build/esm/otel/instrument.js
|
|
35832
35603
|
var import_instrumentation = __toESM(require_src6(), 1);
|
|
35833
35604
|
var INSTRUMENTED = {};
|
|
@@ -35903,6 +35674,9 @@ var import_core40 = __toESM(require_src3(), 1);
|
|
|
35903
35674
|
var import_instrumentation2 = __toESM(require_src6(), 1);
|
|
35904
35675
|
import { subscribe, unsubscribe } from "node:diagnostics_channel";
|
|
35905
35676
|
|
|
35677
|
+
// ../../node_modules/@sentry/node-core/build/esm/debug-build.js
|
|
35678
|
+
var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
35679
|
+
|
|
35906
35680
|
// ../../node_modules/@sentry/node-core/build/esm/utils/getRequestUrl.js
|
|
35907
35681
|
function getRequestUrl(requestOptions) {
|
|
35908
35682
|
const protocol = requestOptions.protocol || "";
|
|
@@ -37716,8 +37490,7 @@ var instrumentSentryHttp = generateInstrumentOnce(`${INTEGRATION_NAME6}.sentry`,
|
|
|
37716
37490
|
var httpIntegration = defineIntegration((options = {}) => {
|
|
37717
37491
|
const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
|
|
37718
37492
|
[401, 404],
|
|
37719
|
-
[
|
|
37720
|
-
[305, 399]
|
|
37493
|
+
[300, 399]
|
|
37721
37494
|
];
|
|
37722
37495
|
return {
|
|
37723
37496
|
name: INTEGRATION_NAME6,
|
|
@@ -37732,27 +37505,20 @@ var httpIntegration = defineIntegration((options = {}) => {
|
|
|
37732
37505
|
processEvent(event) {
|
|
37733
37506
|
if (event.type === "transaction") {
|
|
37734
37507
|
const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
|
|
37735
|
-
if (typeof statusCode === "number") {
|
|
37736
|
-
|
|
37737
|
-
|
|
37738
|
-
DEBUG_BUILD2 && debug.log("Dropping transaction due to status code", statusCode);
|
|
37739
|
-
return null;
|
|
37508
|
+
if (typeof statusCode === "number" && dropSpansForIncomingRequestStatusCodes.some((code) => {
|
|
37509
|
+
if (typeof code === "number") {
|
|
37510
|
+
return code === statusCode;
|
|
37740
37511
|
}
|
|
37512
|
+
const [min, max] = code;
|
|
37513
|
+
return statusCode >= min && statusCode <= max;
|
|
37514
|
+
})) {
|
|
37515
|
+
return null;
|
|
37741
37516
|
}
|
|
37742
37517
|
}
|
|
37743
37518
|
return event;
|
|
37744
37519
|
}
|
|
37745
37520
|
};
|
|
37746
37521
|
});
|
|
37747
|
-
function shouldFilterStatusCode(statusCode, dropForStatusCodes) {
|
|
37748
|
-
return dropForStatusCodes.some((code) => {
|
|
37749
|
-
if (typeof code === "number") {
|
|
37750
|
-
return code === statusCode;
|
|
37751
|
-
}
|
|
37752
|
-
const [min, max] = code;
|
|
37753
|
-
return statusCode >= min && statusCode <= max;
|
|
37754
|
-
});
|
|
37755
|
-
}
|
|
37756
37522
|
// ../../node_modules/@sentry/node-core/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js
|
|
37757
37523
|
var import_api5 = __toESM(require_src(), 1);
|
|
37758
37524
|
var import_core44 = __toESM(require_src3(), 1);
|
|
@@ -38105,9 +37871,7 @@ var PLATFORM_NAMES = {
|
|
|
38105
37871
|
freebsd: "FreeBSD",
|
|
38106
37872
|
openbsd: "OpenBSD",
|
|
38107
37873
|
sunos: "SunOS",
|
|
38108
|
-
win32: "Windows"
|
|
38109
|
-
ohos: "OpenHarmony",
|
|
38110
|
-
android: "Android"
|
|
37874
|
+
win32: "Windows"
|
|
38111
37875
|
};
|
|
38112
37876
|
var LINUX_DISTROS = [
|
|
38113
37877
|
{ name: "fedora-release", distros: ["Fedora"] },
|
|
@@ -38542,7 +38306,7 @@ function functionNamesMatch(a, b) {
|
|
|
38542
38306
|
}
|
|
38543
38307
|
|
|
38544
38308
|
// ../../node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js
|
|
38545
|
-
var base64WorkerScript = "
|
|
38309
|
+
var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjEyLjAgKGEzYTA3MGIpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
|
|
38546
38310
|
function log2(...args) {
|
|
38547
38311
|
debug.log("[LocalVariables]", ...args);
|
|
38548
38312
|
}
|
|
@@ -39814,7 +39578,7 @@ class NodeClient extends ServerRuntimeClient {
|
|
|
39814
39578
|
}
|
|
39815
39579
|
return super.flush(timeout);
|
|
39816
39580
|
}
|
|
39817
|
-
|
|
39581
|
+
close(timeout) {
|
|
39818
39582
|
if (this._clientReportInterval) {
|
|
39819
39583
|
clearInterval(this._clientReportInterval);
|
|
39820
39584
|
}
|
|
@@ -39824,11 +39588,7 @@ class NodeClient extends ServerRuntimeClient {
|
|
|
39824
39588
|
if (this._logOnExitFlushListener) {
|
|
39825
39589
|
process.off("beforeExit", this._logOnExitFlushListener);
|
|
39826
39590
|
}
|
|
39827
|
-
|
|
39828
|
-
if (this.traceProvider) {
|
|
39829
|
-
await this.traceProvider.shutdown();
|
|
39830
|
-
}
|
|
39831
|
-
return allEventsSent;
|
|
39591
|
+
return super.close(timeout).then((allEventsSent) => this.traceProvider ? this.traceProvider.shutdown().then(() => allEventsSent) : allEventsSent);
|
|
39832
39592
|
}
|
|
39833
39593
|
startClientReportTracking() {
|
|
39834
39594
|
const clientOptions = this.getOptions();
|
|
@@ -40006,9 +39766,6 @@ function updateScopeFromEnvVariables() {
|
|
|
40006
39766
|
function addOriginToSpan2(span, origin) {
|
|
40007
39767
|
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
|
|
40008
39768
|
}
|
|
40009
|
-
// ../../node_modules/@sentry/node/build/esm/debug-build.js
|
|
40010
|
-
var DEBUG_BUILD4 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
40011
|
-
|
|
40012
39769
|
// ../../node_modules/@sentry/node/build/esm/integrations/http.js
|
|
40013
39770
|
var INTEGRATION_NAME18 = "Http";
|
|
40014
39771
|
var INSTRUMENTATION_NAME2 = "@opentelemetry_sentry-patched/instrumentation-http";
|
|
@@ -40043,8 +39800,7 @@ function _shouldUseOtelHttpInstrumentation(options, clientOptions = {}) {
|
|
|
40043
39800
|
var httpIntegration2 = defineIntegration((options = {}) => {
|
|
40044
39801
|
const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
|
|
40045
39802
|
[401, 404],
|
|
40046
|
-
[
|
|
40047
|
-
[305, 399]
|
|
39803
|
+
[300, 399]
|
|
40048
39804
|
];
|
|
40049
39805
|
return {
|
|
40050
39806
|
name: INTEGRATION_NAME18,
|
|
@@ -40066,12 +39822,14 @@ var httpIntegration2 = defineIntegration((options = {}) => {
|
|
|
40066
39822
|
processEvent(event) {
|
|
40067
39823
|
if (event.type === "transaction") {
|
|
40068
39824
|
const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
|
|
40069
|
-
if (typeof statusCode === "number") {
|
|
40070
|
-
|
|
40071
|
-
|
|
40072
|
-
DEBUG_BUILD4 && debug.log("Dropping transaction due to status code", statusCode);
|
|
40073
|
-
return null;
|
|
39825
|
+
if (typeof statusCode === "number" && dropSpansForIncomingRequestStatusCodes.some((code) => {
|
|
39826
|
+
if (typeof code === "number") {
|
|
39827
|
+
return code === statusCode;
|
|
40074
39828
|
}
|
|
39829
|
+
const [min, max] = code;
|
|
39830
|
+
return statusCode >= min && statusCode <= max;
|
|
39831
|
+
})) {
|
|
39832
|
+
return null;
|
|
40075
39833
|
}
|
|
40076
39834
|
}
|
|
40077
39835
|
return event;
|
|
@@ -40105,15 +39863,6 @@ function getConfigWithDefaults(options = {}) {
|
|
|
40105
39863
|
};
|
|
40106
39864
|
return instrumentationConfig;
|
|
40107
39865
|
}
|
|
40108
|
-
function shouldFilterStatusCode2(statusCode, dropForStatusCodes) {
|
|
40109
|
-
return dropForStatusCodes.some((code) => {
|
|
40110
|
-
if (typeof code === "number") {
|
|
40111
|
-
return code === statusCode;
|
|
40112
|
-
}
|
|
40113
|
-
const [min, max] = code;
|
|
40114
|
-
return statusCode >= min && statusCode <= max;
|
|
40115
|
-
});
|
|
40116
|
-
}
|
|
40117
39866
|
|
|
40118
39867
|
// ../../node_modules/@sentry/node/build/esm/integrations/node-fetch.js
|
|
40119
39868
|
var import_instrumentation_undici = __toESM(require_src11(), 1);
|
|
@@ -40170,6 +39919,11 @@ function getConfigWithDefaults2(options = {}) {
|
|
|
40170
39919
|
|
|
40171
39920
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/express.js
|
|
40172
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
|
|
40173
39927
|
var INTEGRATION_NAME20 = "Express";
|
|
40174
39928
|
function requestHook(span) {
|
|
40175
39929
|
addOriginToSpan2(span, "auto.http.otel.express");
|
|
@@ -43009,219 +42763,11 @@ var _hapiIntegration = () => {
|
|
|
43009
42763
|
};
|
|
43010
42764
|
var hapiIntegration = defineIntegration(_hapiIntegration);
|
|
43011
42765
|
|
|
43012
|
-
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/hono/index.js
|
|
43013
|
-
var import_semantic_conventions6 = __toESM(require_src2(), 1);
|
|
43014
|
-
|
|
43015
|
-
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/hono/constants.js
|
|
43016
|
-
var AttributeNames2 = {
|
|
43017
|
-
HONO_TYPE: "hono.type",
|
|
43018
|
-
HONO_NAME: "hono.name"
|
|
43019
|
-
};
|
|
43020
|
-
var HonoTypes = {
|
|
43021
|
-
MIDDLEWARE: "middleware",
|
|
43022
|
-
REQUEST_HANDLER: "request_handler"
|
|
43023
|
-
};
|
|
43024
|
-
|
|
43025
|
-
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/hono/instrumentation.js
|
|
43026
|
-
var import_api18 = __toESM(require_src(), 1);
|
|
43027
|
-
var import_instrumentation11 = __toESM(require_src6(), 1);
|
|
43028
|
-
var PACKAGE_NAME3 = "@sentry/instrumentation-hono";
|
|
43029
|
-
var PACKAGE_VERSION3 = "0.0.1";
|
|
43030
|
-
|
|
43031
|
-
class HonoInstrumentation extends import_instrumentation11.InstrumentationBase {
|
|
43032
|
-
constructor(config = {}) {
|
|
43033
|
-
super(PACKAGE_NAME3, PACKAGE_VERSION3, config);
|
|
43034
|
-
}
|
|
43035
|
-
init() {
|
|
43036
|
-
return [
|
|
43037
|
-
new import_instrumentation11.InstrumentationNodeModuleDefinition("hono", [">=4.0.0 <5"], (moduleExports) => this._patch(moduleExports))
|
|
43038
|
-
];
|
|
43039
|
-
}
|
|
43040
|
-
_patch(moduleExports) {
|
|
43041
|
-
const instrumentation = this;
|
|
43042
|
-
|
|
43043
|
-
class WrappedHono extends moduleExports.Hono {
|
|
43044
|
-
constructor(...args) {
|
|
43045
|
-
super(...args);
|
|
43046
|
-
instrumentation._wrap(this, "get", instrumentation._patchHandler());
|
|
43047
|
-
instrumentation._wrap(this, "post", instrumentation._patchHandler());
|
|
43048
|
-
instrumentation._wrap(this, "put", instrumentation._patchHandler());
|
|
43049
|
-
instrumentation._wrap(this, "delete", instrumentation._patchHandler());
|
|
43050
|
-
instrumentation._wrap(this, "options", instrumentation._patchHandler());
|
|
43051
|
-
instrumentation._wrap(this, "patch", instrumentation._patchHandler());
|
|
43052
|
-
instrumentation._wrap(this, "all", instrumentation._patchHandler());
|
|
43053
|
-
instrumentation._wrap(this, "on", instrumentation._patchOnHandler());
|
|
43054
|
-
instrumentation._wrap(this, "use", instrumentation._patchMiddlewareHandler());
|
|
43055
|
-
}
|
|
43056
|
-
}
|
|
43057
|
-
try {
|
|
43058
|
-
moduleExports.Hono = WrappedHono;
|
|
43059
|
-
} catch {
|
|
43060
|
-
return { ...moduleExports, Hono: WrappedHono };
|
|
43061
|
-
}
|
|
43062
|
-
return moduleExports;
|
|
43063
|
-
}
|
|
43064
|
-
_patchHandler() {
|
|
43065
|
-
const instrumentation = this;
|
|
43066
|
-
return function(original) {
|
|
43067
|
-
return function wrappedHandler(...args) {
|
|
43068
|
-
if (typeof args[0] === "string") {
|
|
43069
|
-
const path8 = args[0];
|
|
43070
|
-
if (args.length === 1) {
|
|
43071
|
-
return original.apply(this, [path8]);
|
|
43072
|
-
}
|
|
43073
|
-
const handlers2 = args.slice(1);
|
|
43074
|
-
return original.apply(this, [
|
|
43075
|
-
path8,
|
|
43076
|
-
...handlers2.map((handler) => instrumentation._wrapHandler(handler))
|
|
43077
|
-
]);
|
|
43078
|
-
}
|
|
43079
|
-
return original.apply(this, args.map((handler) => instrumentation._wrapHandler(handler)));
|
|
43080
|
-
};
|
|
43081
|
-
};
|
|
43082
|
-
}
|
|
43083
|
-
_patchOnHandler() {
|
|
43084
|
-
const instrumentation = this;
|
|
43085
|
-
return function(original) {
|
|
43086
|
-
return function wrappedHandler(...args) {
|
|
43087
|
-
const handlers2 = args.slice(2);
|
|
43088
|
-
return original.apply(this, [
|
|
43089
|
-
...args.slice(0, 2),
|
|
43090
|
-
...handlers2.map((handler) => instrumentation._wrapHandler(handler))
|
|
43091
|
-
]);
|
|
43092
|
-
};
|
|
43093
|
-
};
|
|
43094
|
-
}
|
|
43095
|
-
_patchMiddlewareHandler() {
|
|
43096
|
-
const instrumentation = this;
|
|
43097
|
-
return function(original) {
|
|
43098
|
-
return function wrappedHandler(...args) {
|
|
43099
|
-
if (typeof args[0] === "string") {
|
|
43100
|
-
const path8 = args[0];
|
|
43101
|
-
if (args.length === 1) {
|
|
43102
|
-
return original.apply(this, [path8]);
|
|
43103
|
-
}
|
|
43104
|
-
const handlers2 = args.slice(1);
|
|
43105
|
-
return original.apply(this, [
|
|
43106
|
-
path8,
|
|
43107
|
-
...handlers2.map((handler) => instrumentation._wrapHandler(handler))
|
|
43108
|
-
]);
|
|
43109
|
-
}
|
|
43110
|
-
return original.apply(this, args.map((handler) => instrumentation._wrapHandler(handler)));
|
|
43111
|
-
};
|
|
43112
|
-
};
|
|
43113
|
-
}
|
|
43114
|
-
_wrapHandler(handler) {
|
|
43115
|
-
const instrumentation = this;
|
|
43116
|
-
return function(c, next) {
|
|
43117
|
-
if (!instrumentation.isEnabled()) {
|
|
43118
|
-
return handler.apply(this, [c, next]);
|
|
43119
|
-
}
|
|
43120
|
-
const path8 = c.req.path;
|
|
43121
|
-
const span = instrumentation.tracer.startSpan(path8);
|
|
43122
|
-
return import_api18.context.with(import_api18.trace.setSpan(import_api18.context.active(), span), () => {
|
|
43123
|
-
return instrumentation._safeExecute(() => {
|
|
43124
|
-
const result = handler.apply(this, [c, next]);
|
|
43125
|
-
if (isThenable(result)) {
|
|
43126
|
-
return result.then((result2) => {
|
|
43127
|
-
const type = instrumentation._determineHandlerType(result2);
|
|
43128
|
-
span.setAttributes({
|
|
43129
|
-
[AttributeNames2.HONO_TYPE]: type,
|
|
43130
|
-
[AttributeNames2.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path8 : handler.name || "anonymous"
|
|
43131
|
-
});
|
|
43132
|
-
instrumentation.getConfig().responseHook?.(span);
|
|
43133
|
-
return result2;
|
|
43134
|
-
});
|
|
43135
|
-
} else {
|
|
43136
|
-
const type = instrumentation._determineHandlerType(result);
|
|
43137
|
-
span.setAttributes({
|
|
43138
|
-
[AttributeNames2.HONO_TYPE]: type,
|
|
43139
|
-
[AttributeNames2.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path8 : handler.name || "anonymous"
|
|
43140
|
-
});
|
|
43141
|
-
instrumentation.getConfig().responseHook?.(span);
|
|
43142
|
-
return result;
|
|
43143
|
-
}
|
|
43144
|
-
}, () => span.end(), (error2) => {
|
|
43145
|
-
instrumentation._handleError(span, error2);
|
|
43146
|
-
span.end();
|
|
43147
|
-
});
|
|
43148
|
-
});
|
|
43149
|
-
};
|
|
43150
|
-
}
|
|
43151
|
-
_safeExecute(execute, onSuccess, onFailure) {
|
|
43152
|
-
try {
|
|
43153
|
-
const result = execute();
|
|
43154
|
-
if (isThenable(result)) {
|
|
43155
|
-
result.then(() => onSuccess(), (error2) => onFailure(error2));
|
|
43156
|
-
} else {
|
|
43157
|
-
onSuccess();
|
|
43158
|
-
}
|
|
43159
|
-
return result;
|
|
43160
|
-
} catch (error2) {
|
|
43161
|
-
onFailure(error2);
|
|
43162
|
-
throw error2;
|
|
43163
|
-
}
|
|
43164
|
-
}
|
|
43165
|
-
_determineHandlerType(result) {
|
|
43166
|
-
return result === undefined ? HonoTypes.MIDDLEWARE : HonoTypes.REQUEST_HANDLER;
|
|
43167
|
-
}
|
|
43168
|
-
_handleError(span, error2) {
|
|
43169
|
-
if (error2 instanceof Error) {
|
|
43170
|
-
span.setStatus({
|
|
43171
|
-
code: import_api18.SpanStatusCode.ERROR,
|
|
43172
|
-
message: error2.message
|
|
43173
|
-
});
|
|
43174
|
-
span.recordException(error2);
|
|
43175
|
-
}
|
|
43176
|
-
}
|
|
43177
|
-
}
|
|
43178
|
-
|
|
43179
|
-
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/hono/index.js
|
|
43180
|
-
var INTEGRATION_NAME34 = "Hono";
|
|
43181
|
-
function addHonoSpanAttributes(span) {
|
|
43182
|
-
const attributes = spanToJSON(span).data;
|
|
43183
|
-
const type = attributes[AttributeNames2.HONO_TYPE];
|
|
43184
|
-
if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {
|
|
43185
|
-
return;
|
|
43186
|
-
}
|
|
43187
|
-
span.setAttributes({
|
|
43188
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.http.otel.hono",
|
|
43189
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.hono`
|
|
43190
|
-
});
|
|
43191
|
-
const name = attributes[AttributeNames2.HONO_NAME];
|
|
43192
|
-
if (typeof name === "string") {
|
|
43193
|
-
span.updateName(name);
|
|
43194
|
-
}
|
|
43195
|
-
if (getIsolationScope() === getDefaultIsolationScope()) {
|
|
43196
|
-
DEBUG_BUILD4 && debug.warn("Isolation scope is default isolation scope - skipping setting transactionName");
|
|
43197
|
-
return;
|
|
43198
|
-
}
|
|
43199
|
-
const route = attributes[import_semantic_conventions6.ATTR_HTTP_ROUTE];
|
|
43200
|
-
const method = attributes[import_semantic_conventions6.ATTR_HTTP_REQUEST_METHOD];
|
|
43201
|
-
if (typeof route === "string" && typeof method === "string") {
|
|
43202
|
-
getIsolationScope().setTransactionName(`${method} ${route}`);
|
|
43203
|
-
}
|
|
43204
|
-
}
|
|
43205
|
-
var instrumentHono = generateInstrumentOnce(INTEGRATION_NAME34, () => new HonoInstrumentation({
|
|
43206
|
-
responseHook: (span) => {
|
|
43207
|
-
addHonoSpanAttributes(span);
|
|
43208
|
-
}
|
|
43209
|
-
}));
|
|
43210
|
-
var _honoIntegration = () => {
|
|
43211
|
-
return {
|
|
43212
|
-
name: INTEGRATION_NAME34,
|
|
43213
|
-
setupOnce() {
|
|
43214
|
-
instrumentHono();
|
|
43215
|
-
}
|
|
43216
|
-
};
|
|
43217
|
-
};
|
|
43218
|
-
var honoIntegration = defineIntegration(_honoIntegration);
|
|
43219
|
-
|
|
43220
42766
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/koa.js
|
|
43221
42767
|
var import_instrumentation_koa = __toESM(require_src28(), 1);
|
|
43222
|
-
var
|
|
43223
|
-
var
|
|
43224
|
-
var instrumentKoa = generateInstrumentOnce(
|
|
42768
|
+
var import_semantic_conventions6 = __toESM(require_src2(), 1);
|
|
42769
|
+
var INTEGRATION_NAME34 = "Koa";
|
|
42770
|
+
var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME34, import_instrumentation_koa.KoaInstrumentation, (options = {}) => {
|
|
43225
42771
|
return {
|
|
43226
42772
|
ignoreLayersType: options.ignoreLayersType,
|
|
43227
42773
|
requestHook(span, info) {
|
|
@@ -43239,7 +42785,7 @@ var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME35, import_instrument
|
|
|
43239
42785
|
DEBUG_BUILD4 && debug.warn("Isolation scope is default isolation scope - skipping setting transactionName");
|
|
43240
42786
|
return;
|
|
43241
42787
|
}
|
|
43242
|
-
const route = attributes[
|
|
42788
|
+
const route = attributes[import_semantic_conventions6.ATTR_HTTP_ROUTE];
|
|
43243
42789
|
const method = info.context?.request?.method?.toUpperCase() || "GET";
|
|
43244
42790
|
if (route) {
|
|
43245
42791
|
getIsolationScope().setTransactionName(`${method} ${route}`);
|
|
@@ -43249,7 +42795,7 @@ var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME35, import_instrument
|
|
|
43249
42795
|
});
|
|
43250
42796
|
var _koaIntegration = (options = {}) => {
|
|
43251
42797
|
return {
|
|
43252
|
-
name:
|
|
42798
|
+
name: INTEGRATION_NAME34,
|
|
43253
42799
|
setupOnce() {
|
|
43254
42800
|
instrumentKoa(options);
|
|
43255
42801
|
}
|
|
@@ -43259,11 +42805,11 @@ var koaIntegration = defineIntegration(_koaIntegration);
|
|
|
43259
42805
|
|
|
43260
42806
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/connect.js
|
|
43261
42807
|
var import_instrumentation_connect = __toESM(require_src29(), 1);
|
|
43262
|
-
var
|
|
43263
|
-
var instrumentConnect = generateInstrumentOnce(
|
|
42808
|
+
var INTEGRATION_NAME35 = "Connect";
|
|
42809
|
+
var instrumentConnect = generateInstrumentOnce(INTEGRATION_NAME35, () => new import_instrumentation_connect.ConnectInstrumentation);
|
|
43264
42810
|
var _connectIntegration = () => {
|
|
43265
42811
|
return {
|
|
43266
|
-
name:
|
|
42812
|
+
name: INTEGRATION_NAME35,
|
|
43267
42813
|
setupOnce() {
|
|
43268
42814
|
instrumentConnect();
|
|
43269
42815
|
}
|
|
@@ -43281,12 +42827,12 @@ var TEDIUS_INSTRUMENTED_METHODS = new Set([
|
|
|
43281
42827
|
"prepare",
|
|
43282
42828
|
"execute"
|
|
43283
42829
|
]);
|
|
43284
|
-
var
|
|
43285
|
-
var instrumentTedious = generateInstrumentOnce(
|
|
42830
|
+
var INTEGRATION_NAME36 = "Tedious";
|
|
42831
|
+
var instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME36, () => new import_instrumentation_tedious.TediousInstrumentation({}));
|
|
43286
42832
|
var _tediousIntegration = () => {
|
|
43287
42833
|
let instrumentationWrappedCallback;
|
|
43288
42834
|
return {
|
|
43289
|
-
name:
|
|
42835
|
+
name: INTEGRATION_NAME36,
|
|
43290
42836
|
setupOnce() {
|
|
43291
42837
|
const instrumentation = instrumentTedious();
|
|
43292
42838
|
instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
|
|
@@ -43309,12 +42855,12 @@ var tediousIntegration = defineIntegration(_tediousIntegration);
|
|
|
43309
42855
|
|
|
43310
42856
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/genericPool.js
|
|
43311
42857
|
var import_instrumentation_generic_pool = __toESM(require_src31(), 1);
|
|
43312
|
-
var
|
|
43313
|
-
var instrumentGenericPool = generateInstrumentOnce(
|
|
42858
|
+
var INTEGRATION_NAME37 = "GenericPool";
|
|
42859
|
+
var instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME37, () => new import_instrumentation_generic_pool.GenericPoolInstrumentation({}));
|
|
43314
42860
|
var _genericPoolIntegration = () => {
|
|
43315
42861
|
let instrumentationWrappedCallback;
|
|
43316
42862
|
return {
|
|
43317
|
-
name:
|
|
42863
|
+
name: INTEGRATION_NAME37,
|
|
43318
42864
|
setupOnce() {
|
|
43319
42865
|
const instrumentation = instrumentGenericPool();
|
|
43320
42866
|
instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
|
|
@@ -43335,7 +42881,7 @@ var genericPoolIntegration = defineIntegration(_genericPoolIntegration);
|
|
|
43335
42881
|
|
|
43336
42882
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/amqplib.js
|
|
43337
42883
|
var import_instrumentation_amqplib = __toESM(require_src32(), 1);
|
|
43338
|
-
var
|
|
42884
|
+
var INTEGRATION_NAME38 = "Amqplib";
|
|
43339
42885
|
var config = {
|
|
43340
42886
|
consumeEndHook: (span) => {
|
|
43341
42887
|
addOriginToSpan2(span, "auto.amqplib.otel.consumer");
|
|
@@ -43344,10 +42890,10 @@ var config = {
|
|
|
43344
42890
|
addOriginToSpan2(span, "auto.amqplib.otel.publisher");
|
|
43345
42891
|
}
|
|
43346
42892
|
};
|
|
43347
|
-
var instrumentAmqplib = generateInstrumentOnce(
|
|
42893
|
+
var instrumentAmqplib = generateInstrumentOnce(INTEGRATION_NAME38, () => new import_instrumentation_amqplib.AmqplibInstrumentation(config));
|
|
43348
42894
|
var _amqplibIntegration = () => {
|
|
43349
42895
|
return {
|
|
43350
|
-
name:
|
|
42896
|
+
name: INTEGRATION_NAME38,
|
|
43351
42897
|
setupOnce() {
|
|
43352
42898
|
instrumentAmqplib();
|
|
43353
42899
|
}
|
|
@@ -43356,10 +42902,10 @@ var _amqplibIntegration = () => {
|
|
|
43356
42902
|
var amqplibIntegration = defineIntegration(_amqplibIntegration);
|
|
43357
42903
|
|
|
43358
42904
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/constants.js
|
|
43359
|
-
var
|
|
42905
|
+
var INTEGRATION_NAME39 = "VercelAI";
|
|
43360
42906
|
|
|
43361
42907
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/instrumentation.js
|
|
43362
|
-
var
|
|
42908
|
+
var import_instrumentation11 = __toESM(require_src6(), 1);
|
|
43363
42909
|
var INSTRUMENTED_METHODS2 = [
|
|
43364
42910
|
"generateText",
|
|
43365
42911
|
"streamText",
|
|
@@ -43426,7 +42972,7 @@ function determineRecordingSettings(integrationRecordingOptions, methodTelemetry
|
|
|
43426
42972
|
return { recordInputs, recordOutputs };
|
|
43427
42973
|
}
|
|
43428
42974
|
|
|
43429
|
-
class SentryVercelAiInstrumentation extends
|
|
42975
|
+
class SentryVercelAiInstrumentation extends import_instrumentation11.InstrumentationBase {
|
|
43430
42976
|
__init() {
|
|
43431
42977
|
this._isPatched = false;
|
|
43432
42978
|
}
|
|
@@ -43439,7 +42985,7 @@ class SentryVercelAiInstrumentation extends import_instrumentation13.Instrumenta
|
|
|
43439
42985
|
SentryVercelAiInstrumentation.prototype.__init2.call(this);
|
|
43440
42986
|
}
|
|
43441
42987
|
init() {
|
|
43442
|
-
const module = new
|
|
42988
|
+
const module = new import_instrumentation11.InstrumentationNodeModuleDefinition("ai", [">=3.0.0 <6"], this._patch.bind(this));
|
|
43443
42989
|
return module;
|
|
43444
42990
|
}
|
|
43445
42991
|
callWhenPatched(callback) {
|
|
@@ -43453,32 +42999,36 @@ class SentryVercelAiInstrumentation extends import_instrumentation13.Instrumenta
|
|
|
43453
42999
|
this._isPatched = true;
|
|
43454
43000
|
this._callbacks.forEach((callback) => callback());
|
|
43455
43001
|
this._callbacks = [];
|
|
43456
|
-
|
|
43457
|
-
return
|
|
43458
|
-
|
|
43459
|
-
|
|
43460
|
-
|
|
43461
|
-
|
|
43462
|
-
|
|
43463
|
-
|
|
43464
|
-
|
|
43465
|
-
|
|
43466
|
-
|
|
43467
|
-
|
|
43468
|
-
|
|
43469
|
-
|
|
43470
|
-
|
|
43471
|
-
|
|
43472
|
-
|
|
43473
|
-
|
|
43474
|
-
|
|
43475
|
-
|
|
43476
|
-
}
|
|
43477
|
-
|
|
43478
|
-
|
|
43479
|
-
}
|
|
43480
|
-
|
|
43481
|
-
|
|
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
|
+
}
|
|
43482
43032
|
if (Object.prototype.toString.call(moduleExports) === "[object Module]") {
|
|
43483
43033
|
for (const method of INSTRUMENTED_METHODS2) {
|
|
43484
43034
|
moduleExports[method] = generatePatch(moduleExports[method]);
|
|
@@ -43495,7 +43045,7 @@ class SentryVercelAiInstrumentation extends import_instrumentation13.Instrumenta
|
|
|
43495
43045
|
}
|
|
43496
43046
|
|
|
43497
43047
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/index.js
|
|
43498
|
-
var instrumentVercelAi = generateInstrumentOnce(
|
|
43048
|
+
var instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME39, () => new SentryVercelAiInstrumentation({}));
|
|
43499
43049
|
function shouldForceIntegration(client) {
|
|
43500
43050
|
const modules = client.getIntegrationByName("Modules");
|
|
43501
43051
|
return !!modules?.getModules?.()?.ai;
|
|
@@ -43503,7 +43053,7 @@ function shouldForceIntegration(client) {
|
|
|
43503
43053
|
var _vercelAIIntegration = (options = {}) => {
|
|
43504
43054
|
let instrumentation;
|
|
43505
43055
|
return {
|
|
43506
|
-
name:
|
|
43056
|
+
name: INTEGRATION_NAME39,
|
|
43507
43057
|
options,
|
|
43508
43058
|
setupOnce() {
|
|
43509
43059
|
instrumentation = instrumentVercelAi();
|
|
@@ -43520,7 +43070,7 @@ var _vercelAIIntegration = (options = {}) => {
|
|
|
43520
43070
|
};
|
|
43521
43071
|
var vercelAIIntegration = defineIntegration(_vercelAIIntegration);
|
|
43522
43072
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/openai/instrumentation.js
|
|
43523
|
-
var
|
|
43073
|
+
var import_instrumentation13 = __toESM(require_src6(), 1);
|
|
43524
43074
|
var supportedVersions = [">=4.0.0 <6"];
|
|
43525
43075
|
function determineRecordingSettings2(integrationOptions, defaultEnabled) {
|
|
43526
43076
|
const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;
|
|
@@ -43528,22 +43078,22 @@ function determineRecordingSettings2(integrationOptions, defaultEnabled) {
|
|
|
43528
43078
|
return { recordInputs, recordOutputs };
|
|
43529
43079
|
}
|
|
43530
43080
|
|
|
43531
|
-
class SentryOpenAiInstrumentation extends
|
|
43081
|
+
class SentryOpenAiInstrumentation extends import_instrumentation13.InstrumentationBase {
|
|
43532
43082
|
constructor(config2 = {}) {
|
|
43533
43083
|
super("@sentry/instrumentation-openai", SDK_VERSION, config2);
|
|
43534
43084
|
}
|
|
43535
43085
|
init() {
|
|
43536
|
-
const module = new
|
|
43086
|
+
const module = new import_instrumentation13.InstrumentationNodeModuleDefinition("openai", supportedVersions, this._patch.bind(this));
|
|
43537
43087
|
return module;
|
|
43538
43088
|
}
|
|
43539
43089
|
_patch(exports) {
|
|
43540
43090
|
const Original = exports.OpenAI;
|
|
43541
43091
|
const WrappedOpenAI = function(...args) {
|
|
43542
43092
|
const instance = Reflect.construct(Original, args);
|
|
43543
|
-
const
|
|
43544
|
-
const integration =
|
|
43093
|
+
const scopeClient = getCurrentScope().getClient();
|
|
43094
|
+
const integration = scopeClient?.getIntegrationByName(OPENAI_INTEGRATION_NAME);
|
|
43545
43095
|
const integrationOpts = integration?.options;
|
|
43546
|
-
const defaultPii = Boolean(
|
|
43096
|
+
const defaultPii = Boolean(scopeClient?.getOptions().sendDefaultPii);
|
|
43547
43097
|
const { recordInputs, recordOutputs } = determineRecordingSettings2(integrationOpts, defaultPii);
|
|
43548
43098
|
return instrumentOpenAiClient(instance, {
|
|
43549
43099
|
recordInputs,
|
|
@@ -43600,26 +43150,31 @@ var _openAiIntegration = (options = {}) => {
|
|
|
43600
43150
|
var openAIIntegration = defineIntegration(_openAiIntegration);
|
|
43601
43151
|
|
|
43602
43152
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/anthropic-ai/instrumentation.js
|
|
43603
|
-
var
|
|
43153
|
+
var import_instrumentation15 = __toESM(require_src6(), 1);
|
|
43604
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
|
+
}
|
|
43605
43160
|
|
|
43606
|
-
class SentryAnthropicAiInstrumentation extends
|
|
43161
|
+
class SentryAnthropicAiInstrumentation extends import_instrumentation15.InstrumentationBase {
|
|
43607
43162
|
constructor(config2 = {}) {
|
|
43608
43163
|
super("@sentry/instrumentation-anthropic-ai", SDK_VERSION, config2);
|
|
43609
43164
|
}
|
|
43610
43165
|
init() {
|
|
43611
|
-
const module = new
|
|
43166
|
+
const module = new import_instrumentation15.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk", supportedVersions2, this._patch.bind(this));
|
|
43612
43167
|
return module;
|
|
43613
43168
|
}
|
|
43614
43169
|
_patch(exports) {
|
|
43615
43170
|
const Original = exports.Anthropic;
|
|
43616
|
-
const config2 = this.getConfig();
|
|
43617
43171
|
const WrappedAnthropic = function(...args) {
|
|
43618
43172
|
const instance = Reflect.construct(Original, args);
|
|
43619
|
-
const
|
|
43620
|
-
const
|
|
43621
|
-
const
|
|
43622
|
-
const
|
|
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);
|
|
43623
43178
|
return instrumentAnthropicAiClient(instance, {
|
|
43624
43179
|
recordInputs,
|
|
43625
43180
|
recordOutputs
|
|
@@ -43662,84 +43217,25 @@ class SentryAnthropicAiInstrumentation extends import_instrumentation17.Instrume
|
|
|
43662
43217
|
}
|
|
43663
43218
|
|
|
43664
43219
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/anthropic-ai/index.js
|
|
43665
|
-
var instrumentAnthropicAi = generateInstrumentOnce(ANTHROPIC_AI_INTEGRATION_NAME, (
|
|
43220
|
+
var instrumentAnthropicAi = generateInstrumentOnce(ANTHROPIC_AI_INTEGRATION_NAME, () => new SentryAnthropicAiInstrumentation({}));
|
|
43666
43221
|
var _anthropicAIIntegration = (options = {}) => {
|
|
43667
43222
|
return {
|
|
43668
43223
|
name: ANTHROPIC_AI_INTEGRATION_NAME,
|
|
43669
43224
|
options,
|
|
43670
43225
|
setupOnce() {
|
|
43671
|
-
instrumentAnthropicAi(
|
|
43226
|
+
instrumentAnthropicAi();
|
|
43672
43227
|
}
|
|
43673
43228
|
};
|
|
43674
43229
|
};
|
|
43675
43230
|
var anthropicAIIntegration = defineIntegration(_anthropicAIIntegration);
|
|
43676
43231
|
|
|
43677
|
-
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/google-genai/instrumentation.js
|
|
43678
|
-
var import_instrumentation19 = __toESM(require_src6(), 1);
|
|
43679
|
-
var supportedVersions3 = [">=0.10.0 <2"];
|
|
43680
|
-
|
|
43681
|
-
class SentryGoogleGenAiInstrumentation extends import_instrumentation19.InstrumentationBase {
|
|
43682
|
-
constructor(config2 = {}) {
|
|
43683
|
-
super("@sentry/instrumentation-google-genai", SDK_VERSION, config2);
|
|
43684
|
-
}
|
|
43685
|
-
init() {
|
|
43686
|
-
const module = new import_instrumentation19.InstrumentationNodeModuleDefinition("@google/genai", supportedVersions3, (exports) => this._patch(exports), (exports) => exports, [
|
|
43687
|
-
new import_instrumentation19.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs", supportedVersions3, (exports) => this._patch(exports), (exports) => exports)
|
|
43688
|
-
]);
|
|
43689
|
-
return module;
|
|
43690
|
-
}
|
|
43691
|
-
_patch(exports) {
|
|
43692
|
-
const Original = exports.GoogleGenAI;
|
|
43693
|
-
const config2 = this.getConfig();
|
|
43694
|
-
if (typeof Original !== "function") {
|
|
43695
|
-
return exports;
|
|
43696
|
-
}
|
|
43697
|
-
const WrappedGoogleGenAI = function(...args) {
|
|
43698
|
-
const instance = Reflect.construct(Original, args);
|
|
43699
|
-
const client = getClient();
|
|
43700
|
-
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
|
|
43701
|
-
const typedConfig = config2;
|
|
43702
|
-
const recordInputs = typedConfig?.recordInputs ?? defaultPii;
|
|
43703
|
-
const recordOutputs = typedConfig?.recordOutputs ?? defaultPii;
|
|
43704
|
-
return instrumentGoogleGenAIClient(instance, {
|
|
43705
|
-
recordInputs,
|
|
43706
|
-
recordOutputs
|
|
43707
|
-
});
|
|
43708
|
-
};
|
|
43709
|
-
Object.setPrototypeOf(WrappedGoogleGenAI, Original);
|
|
43710
|
-
Object.setPrototypeOf(WrappedGoogleGenAI.prototype, Original.prototype);
|
|
43711
|
-
for (const key of Object.getOwnPropertyNames(Original)) {
|
|
43712
|
-
if (!["length", "name", "prototype"].includes(key)) {
|
|
43713
|
-
const descriptor = Object.getOwnPropertyDescriptor(Original, key);
|
|
43714
|
-
if (descriptor) {
|
|
43715
|
-
Object.defineProperty(WrappedGoogleGenAI, key, descriptor);
|
|
43716
|
-
}
|
|
43717
|
-
}
|
|
43718
|
-
}
|
|
43719
|
-
replaceExports(exports, "GoogleGenAI", WrappedGoogleGenAI);
|
|
43720
|
-
return exports;
|
|
43721
|
-
}
|
|
43722
|
-
}
|
|
43723
|
-
|
|
43724
|
-
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/google-genai/index.js
|
|
43725
|
-
var instrumentGoogleGenAI = generateInstrumentOnce(GOOGLE_GENAI_INTEGRATION_NAME, (options) => new SentryGoogleGenAiInstrumentation(options));
|
|
43726
|
-
var _googleGenAIIntegration = (options = {}) => {
|
|
43727
|
-
return {
|
|
43728
|
-
name: GOOGLE_GENAI_INTEGRATION_NAME,
|
|
43729
|
-
setupOnce() {
|
|
43730
|
-
instrumentGoogleGenAI(options);
|
|
43731
|
-
}
|
|
43732
|
-
};
|
|
43733
|
-
};
|
|
43734
|
-
var googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);
|
|
43735
|
-
|
|
43736
43232
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js
|
|
43737
|
-
var
|
|
43233
|
+
var import_instrumentation18 = __toESM(require_src6(), 1);
|
|
43738
43234
|
|
|
43739
43235
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/patches/firestore.js
|
|
43740
|
-
var
|
|
43741
|
-
var
|
|
43742
|
-
var
|
|
43236
|
+
var import_api18 = __toESM(require_src(), 1);
|
|
43237
|
+
var import_instrumentation17 = __toESM(require_src6(), 1);
|
|
43238
|
+
var import_semantic_conventions7 = __toESM(require_src2(), 1);
|
|
43743
43239
|
import * as net2 from "node:net";
|
|
43744
43240
|
function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config2) {
|
|
43745
43241
|
const defaultFirestoreSpanCreationHook = () => {};
|
|
@@ -43747,15 +43243,15 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
|
|
|
43747
43243
|
const configFirestoreSpanCreationHook = config2.firestoreSpanCreationHook;
|
|
43748
43244
|
if (typeof configFirestoreSpanCreationHook === "function") {
|
|
43749
43245
|
firestoreSpanCreationHook = (span) => {
|
|
43750
|
-
|
|
43246
|
+
import_instrumentation17.safeExecuteInTheMiddle(() => configFirestoreSpanCreationHook(span), (error2) => {
|
|
43751
43247
|
if (!error2) {
|
|
43752
43248
|
return;
|
|
43753
43249
|
}
|
|
43754
|
-
|
|
43250
|
+
import_api18.diag.error(error2?.message);
|
|
43755
43251
|
}, true);
|
|
43756
43252
|
};
|
|
43757
43253
|
}
|
|
43758
|
-
const moduleFirestoreCJS = new
|
|
43254
|
+
const moduleFirestoreCJS = new import_instrumentation17.InstrumentationNodeModuleDefinition("@firebase/firestore", firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook));
|
|
43759
43255
|
const files = [
|
|
43760
43256
|
"@firebase/firestore/dist/lite/index.node.cjs.js",
|
|
43761
43257
|
"@firebase/firestore/dist/lite/index.node.mjs.js",
|
|
@@ -43763,7 +43259,7 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
|
|
|
43763
43259
|
"@firebase/firestore/dist/lite/index.cjs.js"
|
|
43764
43260
|
];
|
|
43765
43261
|
for (const file of files) {
|
|
43766
|
-
moduleFirestoreCJS.files.push(new
|
|
43262
|
+
moduleFirestoreCJS.files.push(new import_instrumentation17.InstrumentationNodeModuleFile(file, firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook), (moduleExports) => unwrapMethods(moduleExports, unwrap)));
|
|
43767
43263
|
}
|
|
43768
43264
|
return moduleFirestoreCJS;
|
|
43769
43265
|
}
|
|
@@ -43777,7 +43273,7 @@ function wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationH
|
|
|
43777
43273
|
}
|
|
43778
43274
|
function unwrapMethods(moduleExports, unwrap) {
|
|
43779
43275
|
for (const method of ["addDoc", "getDocs", "setDoc", "deleteDoc"]) {
|
|
43780
|
-
if (
|
|
43276
|
+
if (import_instrumentation17.isWrapped(moduleExports[method])) {
|
|
43781
43277
|
unwrap(moduleExports, method);
|
|
43782
43278
|
}
|
|
43783
43279
|
}
|
|
@@ -43828,8 +43324,8 @@ function patchSetDoc(tracer, firestoreSpanCreationHook) {
|
|
|
43828
43324
|
};
|
|
43829
43325
|
}
|
|
43830
43326
|
function executeContextWithSpan(span, callback) {
|
|
43831
|
-
return
|
|
43832
|
-
return
|
|
43327
|
+
return import_api18.context.with(import_api18.trace.setSpan(import_api18.context.active(), span), () => {
|
|
43328
|
+
return import_instrumentation17.safeExecuteInTheMiddle(() => {
|
|
43833
43329
|
return callback();
|
|
43834
43330
|
}, (err) => {
|
|
43835
43331
|
if (err) {
|
|
@@ -43840,9 +43336,9 @@ function executeContextWithSpan(span, callback) {
|
|
|
43840
43336
|
});
|
|
43841
43337
|
}
|
|
43842
43338
|
function startDBSpan(tracer, spanName, reference) {
|
|
43843
|
-
const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind:
|
|
43339
|
+
const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind: import_api18.SpanKind.CLIENT });
|
|
43844
43340
|
addAttributes(span, reference);
|
|
43845
|
-
span.setAttribute(
|
|
43341
|
+
span.setAttribute(import_semantic_conventions7.ATTR_DB_OPERATION_NAME, spanName);
|
|
43846
43342
|
return span;
|
|
43847
43343
|
}
|
|
43848
43344
|
function getPortAndAddress(settings) {
|
|
@@ -43884,9 +43380,9 @@ function addAttributes(span, reference) {
|
|
|
43884
43380
|
const json = reference.firestore.toJSON() || {};
|
|
43885
43381
|
const settings = json.settings || {};
|
|
43886
43382
|
const attributes = {
|
|
43887
|
-
[
|
|
43888
|
-
[
|
|
43889
|
-
[
|
|
43383
|
+
[import_semantic_conventions7.ATTR_DB_COLLECTION_NAME]: reference.path,
|
|
43384
|
+
[import_semantic_conventions7.ATTR_DB_NAMESPACE]: firestoreApp.name,
|
|
43385
|
+
[import_semantic_conventions7.ATTR_DB_SYSTEM_NAME]: "firebase.firestore",
|
|
43890
43386
|
"firebase.firestore.type": reference.type,
|
|
43891
43387
|
"firebase.firestore.options.projectId": firestoreOptions.projectId,
|
|
43892
43388
|
"firebase.firestore.options.appId": firestoreOptions.appId,
|
|
@@ -43895,10 +43391,10 @@ function addAttributes(span, reference) {
|
|
|
43895
43391
|
};
|
|
43896
43392
|
const { address, port } = getPortAndAddress(settings);
|
|
43897
43393
|
if (address) {
|
|
43898
|
-
attributes[
|
|
43394
|
+
attributes[import_semantic_conventions7.ATTR_SERVER_ADDRESS] = address;
|
|
43899
43395
|
}
|
|
43900
43396
|
if (port) {
|
|
43901
|
-
attributes[
|
|
43397
|
+
attributes[import_semantic_conventions7.ATTR_SERVER_PORT] = port;
|
|
43902
43398
|
}
|
|
43903
43399
|
span.setAttributes(attributes);
|
|
43904
43400
|
}
|
|
@@ -43907,7 +43403,7 @@ function addAttributes(span, reference) {
|
|
|
43907
43403
|
var DefaultFirebaseInstrumentationConfig = {};
|
|
43908
43404
|
var firestoreSupportedVersions = [">=3.0.0 <5"];
|
|
43909
43405
|
|
|
43910
|
-
class FirebaseInstrumentation extends
|
|
43406
|
+
class FirebaseInstrumentation extends import_instrumentation18.InstrumentationBase {
|
|
43911
43407
|
constructor(config2 = DefaultFirebaseInstrumentationConfig) {
|
|
43912
43408
|
super("@sentry/instrumentation-firebase", SDK_VERSION, config2);
|
|
43913
43409
|
}
|
|
@@ -43922,17 +43418,17 @@ class FirebaseInstrumentation extends import_instrumentation22.InstrumentationBa
|
|
|
43922
43418
|
}
|
|
43923
43419
|
|
|
43924
43420
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/firebase.js
|
|
43925
|
-
var
|
|
43421
|
+
var INTEGRATION_NAME40 = "Firebase";
|
|
43926
43422
|
var config2 = {
|
|
43927
43423
|
firestoreSpanCreationHook: (span) => {
|
|
43928
43424
|
addOriginToSpan2(span, "auto.firebase.otel.firestore");
|
|
43929
43425
|
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, "db.query");
|
|
43930
43426
|
}
|
|
43931
43427
|
};
|
|
43932
|
-
var instrumentFirebase = generateInstrumentOnce(
|
|
43428
|
+
var instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME40, () => new FirebaseInstrumentation(config2));
|
|
43933
43429
|
var _firebaseIntegration = () => {
|
|
43934
43430
|
return {
|
|
43935
|
-
name:
|
|
43431
|
+
name: INTEGRATION_NAME40,
|
|
43936
43432
|
setupOnce() {
|
|
43937
43433
|
instrumentFirebase();
|
|
43938
43434
|
}
|
|
@@ -43946,7 +43442,6 @@ function getAutoPerformanceIntegrations() {
|
|
|
43946
43442
|
expressIntegration(),
|
|
43947
43443
|
fastifyIntegration(),
|
|
43948
43444
|
graphqlIntegration(),
|
|
43949
|
-
honoIntegration(),
|
|
43950
43445
|
mongoIntegration(),
|
|
43951
43446
|
mongooseIntegration(),
|
|
43952
43447
|
mysqlIntegration(),
|
|
@@ -43966,16 +43461,15 @@ function getAutoPerformanceIntegrations() {
|
|
|
43966
43461
|
openAIIntegration(),
|
|
43967
43462
|
postgresJsIntegration(),
|
|
43968
43463
|
firebaseIntegration(),
|
|
43969
|
-
anthropicAIIntegration()
|
|
43970
|
-
googleGenAIIntegration()
|
|
43464
|
+
anthropicAIIntegration()
|
|
43971
43465
|
];
|
|
43972
43466
|
}
|
|
43973
43467
|
|
|
43974
43468
|
// ../../node_modules/@sentry/node/build/esm/sdk/initOtel.js
|
|
43975
|
-
var
|
|
43469
|
+
var import_api19 = __toESM(require_src(), 1);
|
|
43976
43470
|
var import_resources = __toESM(require_src8(), 1);
|
|
43977
43471
|
var import_sdk_trace_base2 = __toESM(require_src9(), 1);
|
|
43978
|
-
var
|
|
43472
|
+
var import_semantic_conventions8 = __toESM(require_src2(), 1);
|
|
43979
43473
|
var MAX_MAX_SPAN_WAIT_DURATION = 1e6;
|
|
43980
43474
|
function initOpenTelemetry(client, options = {}) {
|
|
43981
43475
|
if (client.getOptions().debug) {
|
|
@@ -43988,9 +43482,9 @@ function setupOtel(client, options = {}) {
|
|
|
43988
43482
|
const provider = new import_sdk_trace_base2.BasicTracerProvider({
|
|
43989
43483
|
sampler: new SentrySampler(client),
|
|
43990
43484
|
resource: import_resources.defaultResource().merge(import_resources.resourceFromAttributes({
|
|
43991
|
-
[
|
|
43992
|
-
[
|
|
43993
|
-
[
|
|
43485
|
+
[import_semantic_conventions8.ATTR_SERVICE_NAME]: "node",
|
|
43486
|
+
[import_semantic_conventions8.SEMRESATTRS_SERVICE_NAMESPACE]: "sentry",
|
|
43487
|
+
[import_semantic_conventions8.ATTR_SERVICE_VERSION]: SDK_VERSION
|
|
43994
43488
|
})),
|
|
43995
43489
|
forceFlushTimeoutMillis: 500,
|
|
43996
43490
|
spanProcessors: [
|
|
@@ -44000,9 +43494,9 @@ function setupOtel(client, options = {}) {
|
|
|
44000
43494
|
...options.spanProcessors || []
|
|
44001
43495
|
]
|
|
44002
43496
|
});
|
|
44003
|
-
|
|
44004
|
-
|
|
44005
|
-
|
|
43497
|
+
import_api19.trace.setGlobalTracerProvider(provider);
|
|
43498
|
+
import_api19.propagation.setGlobalPropagator(new SentryPropagator);
|
|
43499
|
+
import_api19.context.setGlobalContextManager(new SentryContextManager);
|
|
44006
43500
|
return provider;
|
|
44007
43501
|
}
|
|
44008
43502
|
function _clampSpanProcessorTimeout(maxSpanWaitDuration) {
|
|
@@ -44049,205 +43543,8 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
|
|
|
44049
43543
|
}
|
|
44050
43544
|
// src/index.ts
|
|
44051
43545
|
import sqlPlugin, { createDatabaseAdapter, DatabaseMigrationService } from "@elizaos/plugin-sql";
|
|
44052
|
-
|
|
44053
|
-
// src/managers/PluginLoader.ts
|
|
44054
|
-
import { logger as logger30 } from "@elizaos/core";
|
|
44055
|
-
|
|
44056
|
-
class PluginLoader {
|
|
44057
|
-
isValidPluginShape(obj) {
|
|
44058
|
-
if (!obj || typeof obj !== "object" || !obj.name) {
|
|
44059
|
-
return false;
|
|
44060
|
-
}
|
|
44061
|
-
return !!(obj.init || obj.services || obj.providers || obj.actions || obj.evaluators || obj.description);
|
|
44062
|
-
}
|
|
44063
|
-
validatePlugin(plugin) {
|
|
44064
|
-
const errors = [];
|
|
44065
|
-
if (!plugin) {
|
|
44066
|
-
errors.push("Plugin is null or undefined");
|
|
44067
|
-
return { isValid: false, errors };
|
|
44068
|
-
}
|
|
44069
|
-
if (!plugin.name) {
|
|
44070
|
-
errors.push("Plugin must have a name");
|
|
44071
|
-
}
|
|
44072
|
-
if (plugin.actions) {
|
|
44073
|
-
if (!Array.isArray(plugin.actions)) {
|
|
44074
|
-
errors.push("Plugin actions must be an array");
|
|
44075
|
-
} else {
|
|
44076
|
-
const invalidActions = plugin.actions.filter((a) => typeof a !== "object" || !a);
|
|
44077
|
-
if (invalidActions.length > 0) {
|
|
44078
|
-
errors.push("Plugin actions must be an array of action objects");
|
|
44079
|
-
}
|
|
44080
|
-
}
|
|
44081
|
-
}
|
|
44082
|
-
if (plugin.services) {
|
|
44083
|
-
if (!Array.isArray(plugin.services)) {
|
|
44084
|
-
errors.push("Plugin services must be an array");
|
|
44085
|
-
} else {
|
|
44086
|
-
const invalidServices = plugin.services.filter((s) => typeof s !== "function" && (typeof s !== "object" || !s));
|
|
44087
|
-
if (invalidServices.length > 0) {
|
|
44088
|
-
errors.push("Plugin services must be an array of service classes or objects");
|
|
44089
|
-
}
|
|
44090
|
-
}
|
|
44091
|
-
}
|
|
44092
|
-
if (plugin.providers && !Array.isArray(plugin.providers)) {
|
|
44093
|
-
errors.push("Plugin providers must be an array");
|
|
44094
|
-
}
|
|
44095
|
-
if (plugin.evaluators && !Array.isArray(plugin.evaluators)) {
|
|
44096
|
-
errors.push("Plugin evaluators must be an array");
|
|
44097
|
-
}
|
|
44098
|
-
return {
|
|
44099
|
-
isValid: errors.length === 0,
|
|
44100
|
-
errors
|
|
44101
|
-
};
|
|
44102
|
-
}
|
|
44103
|
-
async loadAndPreparePlugin(pluginName) {
|
|
44104
|
-
try {
|
|
44105
|
-
let pluginModule;
|
|
44106
|
-
try {
|
|
44107
|
-
pluginModule = await import(pluginName);
|
|
44108
|
-
} catch (error2) {
|
|
44109
|
-
logger30.error(`Failed to load plugin ${pluginName}: ${error2}`);
|
|
44110
|
-
return null;
|
|
44111
|
-
}
|
|
44112
|
-
if (!pluginModule) {
|
|
44113
|
-
logger30.error(`Failed to load module for plugin ${pluginName}.`);
|
|
44114
|
-
return null;
|
|
44115
|
-
}
|
|
44116
|
-
const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match3) => match3[1].toUpperCase())}Plugin`;
|
|
44117
|
-
const exportsToCheck = [
|
|
44118
|
-
pluginModule[expectedFunctionName],
|
|
44119
|
-
pluginModule.default,
|
|
44120
|
-
...Object.values(pluginModule)
|
|
44121
|
-
];
|
|
44122
|
-
for (const potentialPlugin of exportsToCheck) {
|
|
44123
|
-
if (this.isValidPluginShape(potentialPlugin)) {
|
|
44124
|
-
return potentialPlugin;
|
|
44125
|
-
}
|
|
44126
|
-
if (typeof potentialPlugin === "function" && potentialPlugin.length === 0) {
|
|
44127
|
-
try {
|
|
44128
|
-
const produced = potentialPlugin();
|
|
44129
|
-
if (this.isValidPluginShape(produced)) {
|
|
44130
|
-
return produced;
|
|
44131
|
-
}
|
|
44132
|
-
} catch (err) {
|
|
44133
|
-
logger30.debug(`Factory export threw for ${pluginName}: ${err}`);
|
|
44134
|
-
}
|
|
44135
|
-
}
|
|
44136
|
-
}
|
|
44137
|
-
logger30.warn(`Could not find a valid plugin export in ${pluginName}.`);
|
|
44138
|
-
return null;
|
|
44139
|
-
} catch (error2) {
|
|
44140
|
-
logger30.error(`Error loading plugin ${pluginName}: ${error2}`);
|
|
44141
|
-
return null;
|
|
44142
|
-
}
|
|
44143
|
-
}
|
|
44144
|
-
resolvePluginDependencies(availablePlugins, isTestMode = false) {
|
|
44145
|
-
const resolutionOrder = [];
|
|
44146
|
-
const visited = new Set;
|
|
44147
|
-
const visiting = new Set;
|
|
44148
|
-
function visit2(pluginName) {
|
|
44149
|
-
if (!availablePlugins.has(pluginName)) {
|
|
44150
|
-
logger30.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
|
|
44151
|
-
return;
|
|
44152
|
-
}
|
|
44153
|
-
if (visited.has(pluginName))
|
|
44154
|
-
return;
|
|
44155
|
-
if (visiting.has(pluginName)) {
|
|
44156
|
-
logger30.error(`Circular dependency detected involving plugin: ${pluginName}`);
|
|
44157
|
-
return;
|
|
44158
|
-
}
|
|
44159
|
-
visiting.add(pluginName);
|
|
44160
|
-
const plugin = availablePlugins.get(pluginName);
|
|
44161
|
-
if (plugin) {
|
|
44162
|
-
const deps = [...plugin.dependencies || []];
|
|
44163
|
-
if (isTestMode) {
|
|
44164
|
-
deps.push(...plugin.testDependencies || []);
|
|
44165
|
-
}
|
|
44166
|
-
for (const dep of deps) {
|
|
44167
|
-
visit2(dep);
|
|
44168
|
-
}
|
|
44169
|
-
}
|
|
44170
|
-
visiting.delete(pluginName);
|
|
44171
|
-
visited.add(pluginName);
|
|
44172
|
-
resolutionOrder.push(pluginName);
|
|
44173
|
-
}
|
|
44174
|
-
for (const name of availablePlugins.keys()) {
|
|
44175
|
-
if (!visited.has(name)) {
|
|
44176
|
-
visit2(name);
|
|
44177
|
-
}
|
|
44178
|
-
}
|
|
44179
|
-
const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
|
|
44180
|
-
logger30.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
|
|
44181
|
-
return finalPlugins;
|
|
44182
|
-
}
|
|
44183
|
-
}
|
|
44184
|
-
|
|
44185
|
-
// src/managers/ConfigManager.ts
|
|
43546
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
44186
43547
|
var import_dotenv2 = __toESM(require_main(), 1);
|
|
44187
|
-
import * as fs6 from "node:fs";
|
|
44188
|
-
import * as path8 from "node:path";
|
|
44189
|
-
|
|
44190
|
-
class ConfigManager {
|
|
44191
|
-
async loadEnvConfig() {
|
|
44192
|
-
const envPath = this.findEnvFile();
|
|
44193
|
-
if (envPath) {
|
|
44194
|
-
import_dotenv2.default.config({ path: envPath });
|
|
44195
|
-
}
|
|
44196
|
-
return process.env;
|
|
44197
|
-
}
|
|
44198
|
-
findEnvFile() {
|
|
44199
|
-
const possiblePaths = [
|
|
44200
|
-
path8.join(process.cwd(), ".env"),
|
|
44201
|
-
path8.join(process.cwd(), ".env.local")
|
|
44202
|
-
];
|
|
44203
|
-
for (const envPath of possiblePaths) {
|
|
44204
|
-
if (fs6.existsSync(envPath)) {
|
|
44205
|
-
return envPath;
|
|
44206
|
-
}
|
|
44207
|
-
}
|
|
44208
|
-
return null;
|
|
44209
|
-
}
|
|
44210
|
-
hasCharacterSecrets(character) {
|
|
44211
|
-
return Boolean(character?.settings?.secrets && Object.keys(character.settings.secrets).length > 0);
|
|
44212
|
-
}
|
|
44213
|
-
ensureCharacterSettings(character) {
|
|
44214
|
-
if (!character.settings) {
|
|
44215
|
-
character.settings = {};
|
|
44216
|
-
}
|
|
44217
|
-
}
|
|
44218
|
-
async loadLocalEnvSecrets() {
|
|
44219
|
-
const envPath = this.findEnvFile();
|
|
44220
|
-
if (!envPath)
|
|
44221
|
-
return null;
|
|
44222
|
-
try {
|
|
44223
|
-
const buf = fs6.readFileSync(envPath);
|
|
44224
|
-
return import_dotenv2.default.parse(buf);
|
|
44225
|
-
} catch {
|
|
44226
|
-
return null;
|
|
44227
|
-
}
|
|
44228
|
-
}
|
|
44229
|
-
async setDefaultSecretsFromEnv(character) {
|
|
44230
|
-
this.ensureCharacterSettings(character);
|
|
44231
|
-
if (this.hasCharacterSecrets(character)) {
|
|
44232
|
-
return false;
|
|
44233
|
-
}
|
|
44234
|
-
const envSecrets = await this.loadLocalEnvSecrets();
|
|
44235
|
-
if (!envSecrets) {
|
|
44236
|
-
return false;
|
|
44237
|
-
}
|
|
44238
|
-
if (!character.settings) {
|
|
44239
|
-
character.settings = {};
|
|
44240
|
-
}
|
|
44241
|
-
character.settings.secrets = envSecrets;
|
|
44242
|
-
return true;
|
|
44243
|
-
}
|
|
44244
|
-
}
|
|
44245
|
-
|
|
44246
|
-
// src/index.ts
|
|
44247
|
-
import { encryptedCharacter, stringToUuid as stringToUuid2 } from "@elizaos/core";
|
|
44248
|
-
import { existsSync as existsSync5 } from "node:fs";
|
|
44249
|
-
var import_dotenv3 = __toESM(require_main(), 1);
|
|
44250
|
-
import { ElizaOS as ElizaOS3 } from "@elizaos/core";
|
|
44251
43548
|
function expandTildePath(filepath) {
|
|
44252
43549
|
if (!filepath) {
|
|
44253
43550
|
return filepath;
|
|
@@ -44256,19 +43553,19 @@ function expandTildePath(filepath) {
|
|
|
44256
43553
|
if (filepath === "~") {
|
|
44257
43554
|
return process.cwd();
|
|
44258
43555
|
} else if (filepath.startsWith("~/")) {
|
|
44259
|
-
return
|
|
43556
|
+
return path8.join(process.cwd(), filepath.slice(2));
|
|
44260
43557
|
} else if (filepath.startsWith("~~")) {
|
|
44261
43558
|
return filepath;
|
|
44262
43559
|
} else {
|
|
44263
|
-
return
|
|
43560
|
+
return path8.join(process.cwd(), filepath.slice(1));
|
|
44264
43561
|
}
|
|
44265
43562
|
}
|
|
44266
43563
|
return filepath;
|
|
44267
43564
|
}
|
|
44268
43565
|
function resolvePgliteDir(dir, fallbackDir) {
|
|
44269
43566
|
const envPath = resolveEnvFile();
|
|
44270
|
-
if (
|
|
44271
|
-
|
|
43567
|
+
if (existsSync4(envPath)) {
|
|
43568
|
+
import_dotenv2.default.config({ path: envPath });
|
|
44272
43569
|
}
|
|
44273
43570
|
if (dir) {
|
|
44274
43571
|
const resolved2 = expandTildePath(dir);
|
|
@@ -44297,229 +43594,119 @@ function isWebUIEnabled() {
|
|
|
44297
43594
|
|
|
44298
43595
|
class AgentServer {
|
|
44299
43596
|
app;
|
|
43597
|
+
agents;
|
|
44300
43598
|
server;
|
|
44301
43599
|
socketIO;
|
|
44302
43600
|
isInitialized = false;
|
|
44303
43601
|
isWebUIEnabled = true;
|
|
44304
43602
|
clientPath;
|
|
44305
|
-
elizaOS;
|
|
44306
|
-
pluginLoader;
|
|
44307
|
-
configManager;
|
|
44308
43603
|
database;
|
|
43604
|
+
startAgent;
|
|
43605
|
+
stopAgent;
|
|
44309
43606
|
loadCharacterTryPath;
|
|
44310
43607
|
jsonToCharacter;
|
|
44311
|
-
async startAgents(characters, plugins = []) {
|
|
44312
|
-
if (!this.elizaOS || !this.pluginLoader || !this.configManager) {
|
|
44313
|
-
throw new Error("Server not properly initialized");
|
|
44314
|
-
}
|
|
44315
|
-
const preparations = await Promise.all(characters.map(async (character) => {
|
|
44316
|
-
character.id ??= stringToUuid2(character.name);
|
|
44317
|
-
if (!this.configManager?.hasCharacterSecrets(character)) {
|
|
44318
|
-
await this.configManager?.setDefaultSecretsFromEnv(character);
|
|
44319
|
-
}
|
|
44320
|
-
const loadedPlugins = new Map;
|
|
44321
|
-
const pluginsToLoad = new Set(character.plugins || []);
|
|
44322
|
-
for (const p of plugins) {
|
|
44323
|
-
if (typeof p === "string") {
|
|
44324
|
-
pluginsToLoad.add(p);
|
|
44325
|
-
} else if (this.pluginLoader?.isValidPluginShape(p) && !loadedPlugins.has(p.name)) {
|
|
44326
|
-
loadedPlugins.set(p.name, p);
|
|
44327
|
-
(p.dependencies || []).forEach((dep) => {
|
|
44328
|
-
pluginsToLoad.add(dep);
|
|
44329
|
-
});
|
|
44330
|
-
}
|
|
44331
|
-
}
|
|
44332
|
-
const allAvailablePlugins = new Map;
|
|
44333
|
-
for (const p of loadedPlugins.values()) {
|
|
44334
|
-
allAvailablePlugins.set(p.name, p);
|
|
44335
|
-
}
|
|
44336
|
-
for (const name of pluginsToLoad) {
|
|
44337
|
-
if (!allAvailablePlugins.has(name)) {
|
|
44338
|
-
const loaded = await this.pluginLoader?.loadAndPreparePlugin(name);
|
|
44339
|
-
if (loaded) {
|
|
44340
|
-
allAvailablePlugins.set(loaded.name, loaded);
|
|
44341
|
-
}
|
|
44342
|
-
}
|
|
44343
|
-
}
|
|
44344
|
-
let haveSql = false;
|
|
44345
|
-
for (const [name] of allAvailablePlugins.entries()) {
|
|
44346
|
-
if (name === sqlPlugin.name || name === "mysql") {
|
|
44347
|
-
haveSql = true;
|
|
44348
|
-
break;
|
|
44349
|
-
}
|
|
44350
|
-
}
|
|
44351
|
-
if (!haveSql) {
|
|
44352
|
-
allAvailablePlugins.set(sqlPlugin.name, sqlPlugin);
|
|
44353
|
-
}
|
|
44354
|
-
allAvailablePlugins.set(messageBusConnectorPlugin.name, messageBusConnectorPlugin);
|
|
44355
|
-
const finalPlugins = this.pluginLoader?.resolvePluginDependencies(allAvailablePlugins, false);
|
|
44356
|
-
const preparedCharacter = encryptedCharacter(character);
|
|
44357
|
-
return { character: preparedCharacter, plugins: finalPlugins };
|
|
44358
|
-
}));
|
|
44359
|
-
const agentIds = await this.elizaOS.addAgents(preparations.map((p) => ({
|
|
44360
|
-
character: p.character,
|
|
44361
|
-
plugins: p.plugins
|
|
44362
|
-
})));
|
|
44363
|
-
await this.elizaOS.startAgents(agentIds);
|
|
44364
|
-
const runtimes = [];
|
|
44365
|
-
const settings = await this.configManager?.loadEnvConfig();
|
|
44366
|
-
for (const id of agentIds) {
|
|
44367
|
-
const runtime = this.elizaOS.getAgent(id);
|
|
44368
|
-
if (runtime) {
|
|
44369
|
-
Object.assign(runtime, { settings });
|
|
44370
|
-
await this.registerAgent(runtime);
|
|
44371
|
-
if (this.database) {
|
|
44372
|
-
try {
|
|
44373
|
-
const existingAgent = await this.database.getAgent(runtime.agentId);
|
|
44374
|
-
if (!existingAgent) {
|
|
44375
|
-
await this.database.createAgent({
|
|
44376
|
-
...runtime.character,
|
|
44377
|
-
id: runtime.agentId
|
|
44378
|
-
});
|
|
44379
|
-
logger31.info(`Persisted agent ${runtime.character.name} (${runtime.agentId}) to database`);
|
|
44380
|
-
}
|
|
44381
|
-
} catch (error2) {
|
|
44382
|
-
logger31.error({ error: error2 }, `Failed to persist agent ${runtime.agentId} to database`);
|
|
44383
|
-
}
|
|
44384
|
-
}
|
|
44385
|
-
runtimes.push(runtime);
|
|
44386
|
-
}
|
|
44387
|
-
}
|
|
44388
|
-
return runtimes;
|
|
44389
|
-
}
|
|
44390
|
-
async stopAgents(agentIds) {
|
|
44391
|
-
if (!this.elizaOS) {
|
|
44392
|
-
throw new Error("ElizaOS not initialized");
|
|
44393
|
-
}
|
|
44394
|
-
await this.elizaOS.stopAgents(agentIds);
|
|
44395
|
-
}
|
|
44396
|
-
getAllAgents() {
|
|
44397
|
-
if (!this.elizaOS) {
|
|
44398
|
-
return [];
|
|
44399
|
-
}
|
|
44400
|
-
return this.elizaOS.getAgents();
|
|
44401
|
-
}
|
|
44402
|
-
getAgent(agentId) {
|
|
44403
|
-
if (!this.elizaOS) {
|
|
44404
|
-
return;
|
|
44405
|
-
}
|
|
44406
|
-
return this.elizaOS.getAgent(agentId);
|
|
44407
|
-
}
|
|
44408
43608
|
constructor() {
|
|
44409
43609
|
try {
|
|
44410
|
-
|
|
43610
|
+
logger30.debug("Initializing AgentServer (constructor)...");
|
|
43611
|
+
this.agents = new Map;
|
|
44411
43612
|
this.loadCharacterTryPath = loadCharacterTryPath;
|
|
44412
43613
|
this.jsonToCharacter = jsonToCharacter;
|
|
44413
43614
|
this.registerSignalHandlers();
|
|
44414
43615
|
} catch (error2) {
|
|
44415
|
-
|
|
43616
|
+
logger30.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
|
|
44416
43617
|
throw error2;
|
|
44417
43618
|
}
|
|
44418
43619
|
}
|
|
44419
43620
|
async initialize(options) {
|
|
44420
43621
|
if (this.isInitialized) {
|
|
44421
|
-
|
|
43622
|
+
logger30.warn("AgentServer is already initialized, skipping initialization");
|
|
44422
43623
|
return;
|
|
44423
43624
|
}
|
|
44424
43625
|
try {
|
|
44425
|
-
|
|
43626
|
+
logger30.debug("Initializing AgentServer (async operations)...");
|
|
44426
43627
|
const agentDataDir = resolvePgliteDir(options?.dataDir);
|
|
44427
|
-
|
|
44428
|
-
const dbDir = path9.dirname(agentDataDir);
|
|
44429
|
-
if (!fs7.existsSync(dbDir)) {
|
|
44430
|
-
fs7.mkdirSync(dbDir, { recursive: true });
|
|
44431
|
-
logger31.info(`[INIT] Created database directory: ${dbDir}`);
|
|
44432
|
-
}
|
|
44433
|
-
const tempServerAgentId = "00000000-0000-0000-0000-000000000000";
|
|
43628
|
+
logger30.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
|
|
44434
43629
|
this.database = createDatabaseAdapter({
|
|
44435
43630
|
dataDir: agentDataDir,
|
|
44436
43631
|
postgresUrl: options?.postgresUrl
|
|
44437
|
-
},
|
|
43632
|
+
}, "00000000-0000-0000-0000-000000000002");
|
|
44438
43633
|
await this.database.init();
|
|
44439
|
-
|
|
44440
|
-
|
|
43634
|
+
logger30.success("Consolidated database initialized successfully");
|
|
43635
|
+
logger30.info("[INIT] Running database migrations for messaging tables...");
|
|
44441
43636
|
try {
|
|
44442
43637
|
const migrationService = new DatabaseMigrationService;
|
|
44443
43638
|
const db = this.database.getDatabase();
|
|
44444
43639
|
await migrationService.initializeWithDatabase(db);
|
|
44445
43640
|
migrationService.discoverAndRegisterPluginSchemas([sqlPlugin]);
|
|
44446
43641
|
await migrationService.runAllPluginMigrations();
|
|
44447
|
-
|
|
43642
|
+
logger30.success("[INIT] Database migrations completed successfully");
|
|
44448
43643
|
} catch (migrationError) {
|
|
44449
|
-
|
|
43644
|
+
logger30.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
|
|
44450
43645
|
throw new Error(`Database migration failed: ${migrationError instanceof Error ? migrationError.message : String(migrationError)}`);
|
|
44451
43646
|
}
|
|
44452
43647
|
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
44453
|
-
|
|
43648
|
+
logger30.info("[INIT] Ensuring default server exists...");
|
|
44454
43649
|
await this.ensureDefaultServer();
|
|
44455
|
-
|
|
44456
|
-
logger31.info("[INIT] Server uses temporary adapter for migrations only");
|
|
44457
|
-
logger31.info("[INIT] Initializing ElizaOS...");
|
|
44458
|
-
logger31.debug("[INIT] ElizaOS will use agent-specific database adapters from SQL plugin");
|
|
44459
|
-
this.elizaOS = new ElizaOS2;
|
|
44460
|
-
this.elizaOS.enableEditableMode();
|
|
44461
|
-
this.pluginLoader = new PluginLoader;
|
|
44462
|
-
this.configManager = new ConfigManager;
|
|
44463
|
-
logger31.success("[INIT] ElizaOS initialized");
|
|
43650
|
+
logger30.success("[INIT] Default server setup complete");
|
|
44464
43651
|
await this.initializeServer(options);
|
|
44465
43652
|
await new Promise((resolve2) => setTimeout(resolve2, 250));
|
|
44466
43653
|
this.isInitialized = true;
|
|
44467
43654
|
} catch (error2) {
|
|
44468
|
-
|
|
43655
|
+
logger30.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
|
|
44469
43656
|
console.trace(error2);
|
|
44470
43657
|
throw error2;
|
|
44471
43658
|
}
|
|
44472
43659
|
}
|
|
44473
43660
|
async ensureDefaultServer() {
|
|
44474
43661
|
try {
|
|
44475
|
-
|
|
43662
|
+
logger30.info("[AgentServer] Checking for default server...");
|
|
44476
43663
|
const servers = await this.database.getMessageServers();
|
|
44477
|
-
|
|
43664
|
+
logger30.debug(`[AgentServer] Found ${servers.length} existing servers`);
|
|
44478
43665
|
servers.forEach((s) => {
|
|
44479
|
-
|
|
43666
|
+
logger30.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
|
|
44480
43667
|
});
|
|
44481
43668
|
const defaultServer = servers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
|
|
44482
43669
|
if (!defaultServer) {
|
|
44483
|
-
|
|
43670
|
+
logger30.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
|
|
44484
43671
|
try {
|
|
44485
43672
|
await this.database.db.execute(`
|
|
44486
43673
|
INSERT INTO message_servers (id, name, source_type, created_at, updated_at)
|
|
44487
43674
|
VALUES ('00000000-0000-0000-0000-000000000000', 'Default Server', 'eliza_default', NOW(), NOW())
|
|
44488
43675
|
ON CONFLICT (id) DO NOTHING
|
|
44489
43676
|
`);
|
|
44490
|
-
|
|
43677
|
+
logger30.success("[AgentServer] Default server created via raw SQL");
|
|
44491
43678
|
const checkResult = await this.database.db.execute("SELECT id, name FROM message_servers WHERE id = '00000000-0000-0000-0000-000000000000'");
|
|
44492
|
-
|
|
43679
|
+
logger30.debug("[AgentServer] Raw SQL check result:", checkResult);
|
|
44493
43680
|
} catch (sqlError) {
|
|
44494
|
-
|
|
43681
|
+
logger30.error("[AgentServer] Raw SQL insert failed:", sqlError);
|
|
44495
43682
|
try {
|
|
44496
43683
|
const server = await this.database.createMessageServer({
|
|
44497
43684
|
id: "00000000-0000-0000-0000-000000000000",
|
|
44498
43685
|
name: "Default Server",
|
|
44499
43686
|
sourceType: "eliza_default"
|
|
44500
43687
|
});
|
|
44501
|
-
|
|
43688
|
+
logger30.success("[AgentServer] Default server created via ORM with ID:", server.id);
|
|
44502
43689
|
} catch (ormError) {
|
|
44503
|
-
|
|
43690
|
+
logger30.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
|
|
44504
43691
|
throw new Error(`Failed to create default server: ${ormError.message}`);
|
|
44505
43692
|
}
|
|
44506
43693
|
}
|
|
44507
43694
|
const verifyServers = await this.database.getMessageServers();
|
|
44508
|
-
|
|
43695
|
+
logger30.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
|
|
44509
43696
|
verifyServers.forEach((s) => {
|
|
44510
|
-
|
|
43697
|
+
logger30.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
|
|
44511
43698
|
});
|
|
44512
43699
|
const verifyDefault = verifyServers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
|
|
44513
43700
|
if (!verifyDefault) {
|
|
44514
43701
|
throw new Error(`Failed to create or verify default server with ID ${DEFAULT_SERVER_ID6}`);
|
|
44515
43702
|
} else {
|
|
44516
|
-
|
|
43703
|
+
logger30.success("[AgentServer] Default server creation verified successfully");
|
|
44517
43704
|
}
|
|
44518
43705
|
} else {
|
|
44519
|
-
|
|
43706
|
+
logger30.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
|
|
44520
43707
|
}
|
|
44521
43708
|
} catch (error2) {
|
|
44522
|
-
|
|
43709
|
+
logger30.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
|
|
44523
43710
|
throw error2;
|
|
44524
43711
|
}
|
|
44525
43712
|
}
|
|
@@ -44530,7 +43717,7 @@ class AgentServer {
|
|
|
44530
43717
|
}
|
|
44531
43718
|
this.app = express33();
|
|
44532
43719
|
const DEFAULT_SENTRY_DSN = "https://c20e2d51b66c14a783b0689d536f7e5c@o4509349865259008.ingest.us.sentry.io/4509352524120064";
|
|
44533
|
-
const sentryDsn = process.env.SENTRY_DSN
|
|
43720
|
+
const sentryDsn = process.env.SENTRY_DSN && process.env.SENTRY_DSN.trim() || DEFAULT_SENTRY_DSN;
|
|
44534
43721
|
const sentryEnabled = Boolean(sentryDsn);
|
|
44535
43722
|
if (sentryEnabled) {
|
|
44536
43723
|
try {
|
|
@@ -44540,16 +43727,16 @@ class AgentServer {
|
|
|
44540
43727
|
integrations: [vercelAIIntegration({ force: sentryEnabled })],
|
|
44541
43728
|
tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE || 0)
|
|
44542
43729
|
});
|
|
44543
|
-
|
|
43730
|
+
logger30.info("[Sentry] Initialized Sentry for @elizaos/server");
|
|
44544
43731
|
} catch (sentryInitError) {
|
|
44545
|
-
|
|
43732
|
+
logger30.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
|
|
44546
43733
|
}
|
|
44547
43734
|
}
|
|
44548
43735
|
const isProd = false;
|
|
44549
|
-
|
|
43736
|
+
logger30.debug("Setting up security headers...");
|
|
44550
43737
|
if (!isProd) {
|
|
44551
|
-
|
|
44552
|
-
|
|
43738
|
+
logger30.debug(`NODE_ENV: ${"development"}`);
|
|
43739
|
+
logger30.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
|
|
44553
43740
|
}
|
|
44554
43741
|
this.app.use(helmet({
|
|
44555
43742
|
contentSecurityPolicy: isProd ? {
|
|
@@ -44597,12 +43784,12 @@ class AgentServer {
|
|
|
44597
43784
|
xssFilter: true
|
|
44598
43785
|
}));
|
|
44599
43786
|
if (options?.middlewares) {
|
|
44600
|
-
|
|
43787
|
+
logger30.debug("Applying custom middlewares...");
|
|
44601
43788
|
for (const middleware2 of options.middlewares) {
|
|
44602
43789
|
this.app.use(middleware2);
|
|
44603
43790
|
}
|
|
44604
43791
|
}
|
|
44605
|
-
|
|
43792
|
+
logger30.debug("Setting up standard middlewares...");
|
|
44606
43793
|
this.app.use(cors2({
|
|
44607
43794
|
origin: process.env.CORS_ORIGIN || true,
|
|
44608
43795
|
credentials: true,
|
|
@@ -44614,28 +43801,28 @@ class AgentServer {
|
|
|
44614
43801
|
}));
|
|
44615
43802
|
const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
|
|
44616
43803
|
if (serverAuthToken) {
|
|
44617
|
-
|
|
43804
|
+
logger30.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
|
|
44618
43805
|
this.app.use("/api", (req, res, next) => {
|
|
44619
43806
|
apiKeyAuthMiddleware(req, res, next);
|
|
44620
43807
|
});
|
|
44621
43808
|
} else {
|
|
44622
|
-
|
|
43809
|
+
logger30.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
|
|
44623
43810
|
}
|
|
44624
43811
|
this.isWebUIEnabled = isWebUIEnabled();
|
|
44625
43812
|
if (this.isWebUIEnabled) {
|
|
44626
|
-
|
|
43813
|
+
logger30.info("Web UI enabled");
|
|
44627
43814
|
} else {
|
|
44628
43815
|
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
44629
43816
|
if (uiEnabledEnv !== undefined && uiEnabledEnv.trim() !== "") {
|
|
44630
|
-
|
|
43817
|
+
logger30.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
|
|
44631
43818
|
} else {
|
|
44632
|
-
|
|
43819
|
+
logger30.info("Web UI disabled for security (production mode)");
|
|
44633
43820
|
}
|
|
44634
43821
|
}
|
|
44635
43822
|
const uploadsBasePath = getUploadsAgentsDir4();
|
|
44636
43823
|
const generatedBasePath = getGeneratedDir2();
|
|
44637
|
-
|
|
44638
|
-
|
|
43824
|
+
fs6.mkdirSync(uploadsBasePath, { recursive: true });
|
|
43825
|
+
fs6.mkdirSync(generatedBasePath, { recursive: true });
|
|
44639
43826
|
this.app.get("/media/uploads/agents/:agentId/:filename", (req, res) => {
|
|
44640
43827
|
const agentId = req.params.agentId;
|
|
44641
43828
|
const filename = req.params.filename;
|
|
@@ -44645,26 +43832,26 @@ class AgentServer {
|
|
|
44645
43832
|
return;
|
|
44646
43833
|
}
|
|
44647
43834
|
const sanitizedFilename = basename2(filename);
|
|
44648
|
-
const agentUploadsPath =
|
|
44649
|
-
const filePath =
|
|
43835
|
+
const agentUploadsPath = join4(uploadsBasePath, agentId);
|
|
43836
|
+
const filePath = join4(agentUploadsPath, sanitizedFilename);
|
|
44650
43837
|
if (!filePath.startsWith(agentUploadsPath)) {
|
|
44651
43838
|
res.status(403).json({ error: "Access denied" });
|
|
44652
43839
|
return;
|
|
44653
43840
|
}
|
|
44654
|
-
if (!
|
|
43841
|
+
if (!fs6.existsSync(filePath)) {
|
|
44655
43842
|
res.status(404).json({ error: "File does not exist!!!!!!!" });
|
|
44656
43843
|
return;
|
|
44657
43844
|
}
|
|
44658
43845
|
res.sendFile(sanitizedFilename, { root: agentUploadsPath }, (err) => {
|
|
44659
43846
|
if (err) {
|
|
44660
43847
|
if (err.message === "Request aborted") {
|
|
44661
|
-
|
|
43848
|
+
logger30.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
|
|
44662
43849
|
} else if (!res.headersSent) {
|
|
44663
|
-
|
|
43850
|
+
logger30.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
|
|
44664
43851
|
res.status(404).json({ error: "File not found" });
|
|
44665
43852
|
}
|
|
44666
43853
|
} else {
|
|
44667
|
-
|
|
43854
|
+
logger30.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
|
|
44668
43855
|
}
|
|
44669
43856
|
});
|
|
44670
43857
|
});
|
|
@@ -44677,17 +43864,17 @@ class AgentServer {
|
|
|
44677
43864
|
return;
|
|
44678
43865
|
}
|
|
44679
43866
|
const sanitizedFilename = basename2(filename);
|
|
44680
|
-
const agentGeneratedPath =
|
|
44681
|
-
const filePath =
|
|
43867
|
+
const agentGeneratedPath = join4(generatedBasePath, agentId);
|
|
43868
|
+
const filePath = join4(agentGeneratedPath, sanitizedFilename);
|
|
44682
43869
|
if (!filePath.startsWith(agentGeneratedPath)) {
|
|
44683
43870
|
res.status(403).json({ error: "Access denied" });
|
|
44684
43871
|
return;
|
|
44685
43872
|
}
|
|
44686
|
-
if (!
|
|
43873
|
+
if (!existsSync4(filePath)) {
|
|
44687
43874
|
res.status(404).json({ error: "File not found" });
|
|
44688
43875
|
return;
|
|
44689
43876
|
}
|
|
44690
|
-
const absolutePath =
|
|
43877
|
+
const absolutePath = path8.resolve(filePath);
|
|
44691
43878
|
const options2 = {
|
|
44692
43879
|
dotfiles: "deny"
|
|
44693
43880
|
};
|
|
@@ -44696,7 +43883,7 @@ class AgentServer {
|
|
|
44696
43883
|
const ext2 = extname(filename).toLowerCase();
|
|
44697
43884
|
const mimeType = ext2 === ".png" ? "image/png" : ext2 === ".jpg" || ext2 === ".jpeg" ? "image/jpeg" : "application/octet-stream";
|
|
44698
43885
|
res.setHeader("Content-Type", mimeType);
|
|
44699
|
-
const stream =
|
|
43886
|
+
const stream = fs6.createReadStream(absolutePath);
|
|
44700
43887
|
stream.on("error", () => res.status(404).json({ error: "File not found" }));
|
|
44701
43888
|
stream.pipe(res);
|
|
44702
43889
|
}
|
|
@@ -44711,20 +43898,20 @@ class AgentServer {
|
|
|
44711
43898
|
return;
|
|
44712
43899
|
}
|
|
44713
43900
|
const sanitizedFilename = basename2(filename);
|
|
44714
|
-
const channelUploadsPath =
|
|
44715
|
-
const filePath =
|
|
43901
|
+
const channelUploadsPath = join4(uploadsBasePath, "channels", channelId);
|
|
43902
|
+
const filePath = join4(channelUploadsPath, sanitizedFilename);
|
|
44716
43903
|
if (!filePath.startsWith(channelUploadsPath)) {
|
|
44717
43904
|
res.status(403).json({ error: "Access denied" });
|
|
44718
43905
|
return;
|
|
44719
43906
|
}
|
|
44720
43907
|
res.sendFile(filePath, (err) => {
|
|
44721
43908
|
if (err) {
|
|
44722
|
-
|
|
43909
|
+
logger30.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
|
|
44723
43910
|
if (!res.headersSent) {
|
|
44724
43911
|
res.status(404).json({ error: "File not found" });
|
|
44725
43912
|
}
|
|
44726
43913
|
} else {
|
|
44727
|
-
|
|
43914
|
+
logger30.debug(`[STATIC] Served channel media file: ${filePath}`);
|
|
44728
43915
|
}
|
|
44729
43916
|
});
|
|
44730
43917
|
});
|
|
@@ -44768,11 +43955,11 @@ class AgentServer {
|
|
|
44768
43955
|
if (this.isWebUIEnabled) {
|
|
44769
43956
|
const possiblePaths = [
|
|
44770
43957
|
this.clientPath,
|
|
44771
|
-
|
|
44772
|
-
|
|
43958
|
+
path8.resolve(__dirname3, "client"),
|
|
43959
|
+
path8.resolve(__dirname3, "../../client/dist"),
|
|
44773
43960
|
(() => {
|
|
44774
43961
|
try {
|
|
44775
|
-
return
|
|
43962
|
+
return path8.resolve(path8.dirname(__require.resolve("@elizaos/client/package.json")), "dist");
|
|
44776
43963
|
} catch {
|
|
44777
43964
|
return null;
|
|
44778
43965
|
}
|
|
@@ -44780,12 +43967,12 @@ class AgentServer {
|
|
|
44780
43967
|
(() => {
|
|
44781
43968
|
try {
|
|
44782
43969
|
if (process.argv[1]) {
|
|
44783
|
-
const serverPath =
|
|
44784
|
-
const possibleClientPath =
|
|
44785
|
-
if (
|
|
43970
|
+
const serverPath = path8.dirname(process.argv[1]);
|
|
43971
|
+
const possibleClientPath = path8.join(serverPath, "client");
|
|
43972
|
+
if (existsSync4(path8.join(possibleClientPath, "index.html"))) {
|
|
44786
43973
|
return possibleClientPath;
|
|
44787
43974
|
}
|
|
44788
|
-
if (
|
|
43975
|
+
if (existsSync4(path8.join(serverPath, "index.html"))) {
|
|
44789
43976
|
return serverPath;
|
|
44790
43977
|
}
|
|
44791
43978
|
}
|
|
@@ -44794,8 +43981,8 @@ class AgentServer {
|
|
|
44794
43981
|
})(),
|
|
44795
43982
|
(() => {
|
|
44796
43983
|
try {
|
|
44797
|
-
const bunGlobalPath =
|
|
44798
|
-
if (
|
|
43984
|
+
const bunGlobalPath = path8.join(os3.homedir(), ".bun/install/global/node_modules/@elizaos/server/dist/client");
|
|
43985
|
+
if (existsSync4(path8.join(bunGlobalPath, "index.html"))) {
|
|
44799
43986
|
return bunGlobalPath;
|
|
44800
43987
|
}
|
|
44801
43988
|
try {
|
|
@@ -44805,8 +43992,8 @@ class AgentServer {
|
|
|
44805
43992
|
});
|
|
44806
43993
|
if (proc.exitCode === 0 && proc.stdout) {
|
|
44807
43994
|
const npmRoot = new TextDecoder().decode(proc.stdout).trim();
|
|
44808
|
-
const globalServerPath =
|
|
44809
|
-
if (
|
|
43995
|
+
const globalServerPath = path8.join(npmRoot, "@elizaos/server/dist/client");
|
|
43996
|
+
if (existsSync4(path8.join(globalServerPath, "index.html"))) {
|
|
44810
43997
|
return globalServerPath;
|
|
44811
43998
|
}
|
|
44812
43999
|
}
|
|
@@ -44817,15 +44004,15 @@ class AgentServer {
|
|
|
44817
44004
|
...[
|
|
44818
44005
|
"/usr/local/lib/node_modules/@elizaos/server/dist/client",
|
|
44819
44006
|
"/usr/lib/node_modules/@elizaos/server/dist/client",
|
|
44820
|
-
|
|
44007
|
+
path8.join(os3.homedir(), ".npm-global/lib/node_modules/@elizaos/server/dist/client"),
|
|
44821
44008
|
(() => {
|
|
44822
44009
|
try {
|
|
44823
|
-
const nvmPath =
|
|
44824
|
-
if (
|
|
44825
|
-
const versions =
|
|
44010
|
+
const nvmPath = path8.join(os3.homedir(), ".nvm/versions/node");
|
|
44011
|
+
if (existsSync4(nvmPath)) {
|
|
44012
|
+
const versions = fs6.readdirSync(nvmPath);
|
|
44826
44013
|
for (const version of versions) {
|
|
44827
|
-
const cliPath =
|
|
44828
|
-
if (
|
|
44014
|
+
const cliPath = path8.join(nvmPath, version, "lib/node_modules/@elizaos/server/dist/client");
|
|
44015
|
+
if (existsSync4(path8.join(cliPath, "index.html"))) {
|
|
44829
44016
|
return cliPath;
|
|
44830
44017
|
}
|
|
44831
44018
|
}
|
|
@@ -44835,37 +44022,37 @@ class AgentServer {
|
|
|
44835
44022
|
})()
|
|
44836
44023
|
].filter(Boolean)
|
|
44837
44024
|
].filter(Boolean);
|
|
44838
|
-
|
|
44839
|
-
|
|
44840
|
-
|
|
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}`);
|
|
44841
44028
|
for (const possiblePath of possiblePaths) {
|
|
44842
|
-
if (possiblePath &&
|
|
44029
|
+
if (possiblePath && existsSync4(path8.join(possiblePath, "index.html"))) {
|
|
44843
44030
|
clientPath = possiblePath;
|
|
44844
|
-
|
|
44031
|
+
logger30.info(`[STATIC] Found client files at: ${clientPath}`);
|
|
44845
44032
|
break;
|
|
44846
44033
|
}
|
|
44847
44034
|
}
|
|
44848
44035
|
if (clientPath) {
|
|
44849
44036
|
this.clientPath = clientPath;
|
|
44850
44037
|
this.app.use(express33.static(clientPath, staticOptions));
|
|
44851
|
-
|
|
44038
|
+
logger30.info(`[STATIC] Serving static files from: ${clientPath}`);
|
|
44852
44039
|
} else {
|
|
44853
|
-
|
|
44040
|
+
logger30.warn("[STATIC] Client dist path not found. Searched locations:");
|
|
44854
44041
|
possiblePaths.forEach((p) => {
|
|
44855
44042
|
if (p)
|
|
44856
|
-
|
|
44043
|
+
logger30.warn(`[STATIC] - ${p}`);
|
|
44857
44044
|
});
|
|
44858
|
-
|
|
44859
|
-
|
|
44860
|
-
|
|
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");
|
|
44861
44048
|
}
|
|
44862
44049
|
}
|
|
44863
|
-
const pluginRouteHandler = createPluginRouteHandler(this.
|
|
44050
|
+
const pluginRouteHandler = createPluginRouteHandler(this.agents);
|
|
44864
44051
|
this.app.use(pluginRouteHandler);
|
|
44865
|
-
const apiRouter = createApiRouter(this.
|
|
44052
|
+
const apiRouter = createApiRouter(this.agents, this);
|
|
44866
44053
|
this.app.use("/api", (req, _res, next) => {
|
|
44867
44054
|
if (req.path !== "/ping") {
|
|
44868
|
-
|
|
44055
|
+
logger30.debug(`API request: ${req.method} ${req.path}`);
|
|
44869
44056
|
}
|
|
44870
44057
|
next();
|
|
44871
44058
|
}, apiRouter, (err, req, res, _next) => {
|
|
@@ -44880,7 +44067,7 @@ class AgentServer {
|
|
|
44880
44067
|
return scope;
|
|
44881
44068
|
});
|
|
44882
44069
|
}
|
|
44883
|
-
|
|
44070
|
+
logger30.error({ err }, `API error: ${req.method} ${req.path}`);
|
|
44884
44071
|
res.status(500).json({
|
|
44885
44072
|
success: false,
|
|
44886
44073
|
error: {
|
|
@@ -44928,29 +44115,29 @@ class AgentServer {
|
|
|
44928
44115
|
}
|
|
44929
44116
|
const resolvedClientPath = clientPath || this.clientPath;
|
|
44930
44117
|
if (resolvedClientPath) {
|
|
44931
|
-
const indexFilePath =
|
|
44932
|
-
if (!
|
|
44933
|
-
|
|
44934
|
-
|
|
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}`);
|
|
44935
44122
|
res.status(404).send("Client application not found");
|
|
44936
44123
|
return;
|
|
44937
44124
|
}
|
|
44938
44125
|
res.sendFile("index.html", { root: resolvedClientPath }, (err) => {
|
|
44939
44126
|
if (err) {
|
|
44940
|
-
|
|
44941
|
-
|
|
44942
|
-
|
|
44943
|
-
|
|
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"}`);
|
|
44944
44131
|
if (!res.headersSent) {
|
|
44945
44132
|
res.status(404).send("Client application not found");
|
|
44946
44133
|
}
|
|
44947
44134
|
} else {
|
|
44948
|
-
|
|
44135
|
+
logger30.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
|
|
44949
44136
|
}
|
|
44950
44137
|
});
|
|
44951
44138
|
} else {
|
|
44952
|
-
|
|
44953
|
-
|
|
44139
|
+
logger30.warn("[STATIC] Client dist path not found in SPA fallback");
|
|
44140
|
+
logger30.warn("[STATIC] Neither local nor instance clientPath variables are set");
|
|
44954
44141
|
res.status(404).send("Client application not found");
|
|
44955
44142
|
}
|
|
44956
44143
|
});
|
|
@@ -44960,10 +44147,10 @@ class AgentServer {
|
|
|
44960
44147
|
});
|
|
44961
44148
|
}
|
|
44962
44149
|
this.server = http4.createServer(this.app);
|
|
44963
|
-
this.socketIO = setupSocketIO(this.server, this.
|
|
44964
|
-
|
|
44150
|
+
this.socketIO = setupSocketIO(this.server, this.agents, this);
|
|
44151
|
+
logger30.success("AgentServer HTTP server and Socket.IO initialized");
|
|
44965
44152
|
} catch (error2) {
|
|
44966
|
-
|
|
44153
|
+
logger30.error({ error: error2 }, "Failed to complete server initialization:");
|
|
44967
44154
|
throw error2;
|
|
44968
44155
|
}
|
|
44969
44156
|
}
|
|
@@ -44978,64 +44165,63 @@ class AgentServer {
|
|
|
44978
44165
|
if (!runtime.character) {
|
|
44979
44166
|
throw new Error("Runtime missing character configuration");
|
|
44980
44167
|
}
|
|
44981
|
-
|
|
44168
|
+
this.agents.set(runtime.agentId, runtime);
|
|
44169
|
+
logger30.debug(`Agent ${runtime.character.name} (${runtime.agentId}) added to agents map`);
|
|
44982
44170
|
try {
|
|
44983
44171
|
if (messageBusConnectorPlugin) {
|
|
44984
44172
|
await runtime.registerPlugin(messageBusConnectorPlugin);
|
|
44985
|
-
|
|
44173
|
+
logger30.info(`[AgentServer] Automatically registered MessageBusConnector for agent ${runtime.character.name}`);
|
|
44986
44174
|
} else {
|
|
44987
|
-
|
|
44175
|
+
logger30.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
|
|
44988
44176
|
}
|
|
44989
44177
|
} catch (e) {
|
|
44990
|
-
|
|
44178
|
+
logger30.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
|
|
44991
44179
|
}
|
|
44992
44180
|
const teePlugin = runtime.plugins.find((p) => p.name === "phala-tee-plugin");
|
|
44993
44181
|
if (teePlugin) {
|
|
44994
|
-
|
|
44182
|
+
logger30.debug(`Found TEE plugin for agent ${runtime.agentId}`);
|
|
44995
44183
|
if (teePlugin.providers) {
|
|
44996
44184
|
for (const provider of teePlugin.providers) {
|
|
44997
44185
|
runtime.registerProvider(provider);
|
|
44998
|
-
|
|
44186
|
+
logger30.debug(`Registered TEE provider: ${provider.name}`);
|
|
44999
44187
|
}
|
|
45000
44188
|
}
|
|
45001
44189
|
if (teePlugin.actions) {
|
|
45002
44190
|
for (const action of teePlugin.actions) {
|
|
45003
44191
|
runtime.registerAction(action);
|
|
45004
|
-
|
|
44192
|
+
logger30.debug(`Registered TEE action: ${action.name}`);
|
|
45005
44193
|
}
|
|
45006
44194
|
}
|
|
45007
44195
|
}
|
|
45008
|
-
|
|
44196
|
+
logger30.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
|
|
45009
44197
|
await this.addAgentToServer(DEFAULT_SERVER_ID6, runtime.agentId);
|
|
45010
|
-
|
|
44198
|
+
logger30.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
|
|
45011
44199
|
} catch (error2) {
|
|
45012
|
-
|
|
44200
|
+
logger30.error({ error: error2 }, "Failed to register agent:");
|
|
45013
44201
|
throw error2;
|
|
45014
44202
|
}
|
|
45015
44203
|
}
|
|
45016
|
-
|
|
44204
|
+
unregisterAgent(agentId) {
|
|
45017
44205
|
if (!agentId) {
|
|
45018
|
-
|
|
44206
|
+
logger30.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
|
|
45019
44207
|
return;
|
|
45020
44208
|
}
|
|
45021
44209
|
try {
|
|
45022
|
-
const agent = this.
|
|
44210
|
+
const agent = this.agents.get(agentId);
|
|
45023
44211
|
if (agent) {
|
|
45024
44212
|
try {
|
|
45025
44213
|
agent.stop().catch((stopError) => {
|
|
45026
|
-
|
|
44214
|
+
logger30.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
|
|
45027
44215
|
});
|
|
45028
|
-
|
|
44216
|
+
logger30.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
|
|
45029
44217
|
} catch (stopError) {
|
|
45030
|
-
|
|
44218
|
+
logger30.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
|
|
45031
44219
|
}
|
|
45032
44220
|
}
|
|
45033
|
-
|
|
45034
|
-
|
|
45035
|
-
}
|
|
45036
|
-
logger31.debug(`Agent ${agentId} unregistered`);
|
|
44221
|
+
this.agents.delete(agentId);
|
|
44222
|
+
logger30.debug(`Agent ${agentId} removed from agents map`);
|
|
45037
44223
|
} catch (error2) {
|
|
45038
|
-
|
|
44224
|
+
logger30.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
|
|
45039
44225
|
}
|
|
45040
44226
|
}
|
|
45041
44227
|
registerMiddleware(middleware2) {
|
|
@@ -45047,9 +44233,9 @@ class AgentServer {
|
|
|
45047
44233
|
if (!port || typeof port !== "number") {
|
|
45048
44234
|
throw new Error(`Invalid port number: ${port}`);
|
|
45049
44235
|
}
|
|
45050
|
-
|
|
45051
|
-
|
|
45052
|
-
|
|
44236
|
+
logger30.debug(`Starting server on port ${port}...`);
|
|
44237
|
+
logger30.debug(`Current agents count: ${this.agents.size}`);
|
|
44238
|
+
logger30.debug(`Environment: ${"development"}`);
|
|
45053
44239
|
const host = process.env.SERVER_HOST || "0.0.0.0";
|
|
45054
44240
|
this.server.listen(port, host, () => {
|
|
45055
44241
|
if (this.isWebUIEnabled && false) {} else if (!this.isWebUIEnabled) {
|
|
@@ -45062,26 +44248,25 @@ class AgentServer {
|
|
|
45062
44248
|
` + ` \x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`);
|
|
45063
44249
|
}
|
|
45064
44250
|
console.log(`AgentServer is listening on port ${port}`);
|
|
45065
|
-
|
|
45066
|
-
|
|
45067
|
-
|
|
45068
|
-
|
|
45069
|
-
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}`);
|
|
45070
44255
|
});
|
|
45071
44256
|
resolve2();
|
|
45072
44257
|
}).on("error", (error2) => {
|
|
45073
|
-
|
|
44258
|
+
logger30.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
|
|
45074
44259
|
if (error2.code === "EADDRINUSE") {
|
|
45075
|
-
|
|
44260
|
+
logger30.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
|
|
45076
44261
|
} else if (error2.code === "EACCES") {
|
|
45077
|
-
|
|
44262
|
+
logger30.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
|
|
45078
44263
|
} else if (error2.code === "EADDRNOTAVAIL") {
|
|
45079
|
-
|
|
44264
|
+
logger30.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
|
|
45080
44265
|
}
|
|
45081
44266
|
reject(error2);
|
|
45082
44267
|
});
|
|
45083
44268
|
} catch (error2) {
|
|
45084
|
-
|
|
44269
|
+
logger30.error({ error: error2 }, "Failed to start server:");
|
|
45085
44270
|
reject(error2);
|
|
45086
44271
|
}
|
|
45087
44272
|
});
|
|
@@ -45089,7 +44274,7 @@ class AgentServer {
|
|
|
45089
44274
|
async stop() {
|
|
45090
44275
|
if (this.server) {
|
|
45091
44276
|
this.server.close(() => {
|
|
45092
|
-
|
|
44277
|
+
logger30.success("Server stopped");
|
|
45093
44278
|
});
|
|
45094
44279
|
}
|
|
45095
44280
|
}
|
|
@@ -45136,7 +44321,7 @@ class AgentServer {
|
|
|
45136
44321
|
for (const message of messages) {
|
|
45137
44322
|
await this.database.deleteMessage(message.id);
|
|
45138
44323
|
}
|
|
45139
|
-
|
|
44324
|
+
logger30.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
|
|
45140
44325
|
}
|
|
45141
44326
|
async findOrCreateCentralDmChannel(user1Id, user2Id, messageServerId) {
|
|
45142
44327
|
return this.database.findOrCreateDmChannel(user1Id, user2Id, messageServerId);
|
|
@@ -45159,7 +44344,7 @@ class AgentServer {
|
|
|
45159
44344
|
metadata: createdMessage.metadata
|
|
45160
44345
|
};
|
|
45161
44346
|
bus_default.emit("new_message", messageForBus);
|
|
45162
|
-
|
|
44347
|
+
logger30.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
|
|
45163
44348
|
}
|
|
45164
44349
|
return createdMessage;
|
|
45165
44350
|
}
|
|
@@ -45170,7 +44355,7 @@ class AgentServer {
|
|
|
45170
44355
|
return this.database.updateMessage(messageId, patch);
|
|
45171
44356
|
}
|
|
45172
44357
|
async removeParticipantFromChannel() {
|
|
45173
|
-
|
|
44358
|
+
logger30.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
|
|
45174
44359
|
}
|
|
45175
44360
|
async addAgentToServer(serverId, agentId) {
|
|
45176
44361
|
const server = await this.getServerById(serverId);
|
|
@@ -45198,32 +44383,31 @@ class AgentServer {
|
|
|
45198
44383
|
}
|
|
45199
44384
|
registerSignalHandlers() {
|
|
45200
44385
|
const gracefulShutdown = async () => {
|
|
45201
|
-
|
|
45202
|
-
|
|
45203
|
-
const
|
|
45204
|
-
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()) {
|
|
45205
44389
|
try {
|
|
45206
44390
|
await agent.stop();
|
|
45207
|
-
|
|
44391
|
+
logger30.debug(`Stopped agent ${id}`);
|
|
45208
44392
|
} catch (error2) {
|
|
45209
|
-
|
|
44393
|
+
logger30.error({ error: error2, agentId: id }, `Error stopping agent ${id}:`);
|
|
45210
44394
|
}
|
|
45211
44395
|
}
|
|
45212
44396
|
if (this.database) {
|
|
45213
44397
|
try {
|
|
45214
44398
|
await this.database.close();
|
|
45215
|
-
|
|
44399
|
+
logger30.info("Database closed.");
|
|
45216
44400
|
} catch (error2) {
|
|
45217
|
-
|
|
44401
|
+
logger30.error({ error: error2 }, "Error closing database:");
|
|
45218
44402
|
}
|
|
45219
44403
|
}
|
|
45220
44404
|
if (this.server) {
|
|
45221
44405
|
this.server.close(() => {
|
|
45222
|
-
|
|
44406
|
+
logger30.success("Server closed successfully");
|
|
45223
44407
|
process.exit(0);
|
|
45224
44408
|
});
|
|
45225
44409
|
setTimeout(() => {
|
|
45226
|
-
|
|
44410
|
+
logger30.error("Could not close connections in time, forcing shutdown");
|
|
45227
44411
|
process.exit(1);
|
|
45228
44412
|
}, 5000);
|
|
45229
44413
|
} else {
|
|
@@ -45232,7 +44416,7 @@ class AgentServer {
|
|
|
45232
44416
|
};
|
|
45233
44417
|
process.on("SIGTERM", gracefulShutdown);
|
|
45234
44418
|
process.on("SIGINT", gracefulShutdown);
|
|
45235
|
-
|
|
44419
|
+
logger30.debug("Shutdown handlers registered");
|
|
45236
44420
|
}
|
|
45237
44421
|
}
|
|
45238
44422
|
export {
|
|
@@ -45246,8 +44430,5 @@ export {
|
|
|
45246
44430
|
isWebUIEnabled,
|
|
45247
44431
|
hasValidRemoteUrls,
|
|
45248
44432
|
expandTildePath,
|
|
45249
|
-
PluginLoader,
|
|
45250
|
-
ElizaOS3 as ElizaOS,
|
|
45251
|
-
ConfigManager,
|
|
45252
44433
|
AgentServer
|
|
45253
44434
|
};
|