@elizaos/server 1.5.12 → 1.5.13-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/characters/default.d.ts +14 -0
- package/dist/client/assets/main-CoxLIDww.js +141 -0
- package/dist/client/assets/main-CoxLIDww.js.map +1 -0
- package/dist/client/assets/{main-Cxu5WF7C.js → main-FtAaPweT.js} +3 -3
- package/dist/client/assets/{main-Cxu5WF7C.js.map → main-FtAaPweT.js.map} +1 -1
- package/dist/client/assets/{react-vendor-BZhB15Ka.js → react-vendor-2Sp1NOb7.js} +31 -31
- package/dist/client/assets/react-vendor-2Sp1NOb7.js.map +1 -0
- package/dist/client/index.html +1 -1
- package/dist/index.d.ts +34 -5
- package/dist/index.js +1454 -562
- package/dist/managers/ConfigManager.d.ts +32 -0
- package/dist/managers/PluginInstaller.d.ts +10 -0
- package/dist/managers/PluginLoader.d.ts +27 -0
- package/dist/socketio/index.d.ts +3 -4
- package/package.json +5 -5
- package/dist/client/assets/main-Dbnvjs-Q.js +0 -119
- package/dist/client/assets/main-Dbnvjs-Q.js.map +0 -1
- package/dist/client/assets/react-vendor-BZhB15Ka.js.map +0 -1
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 AttributeNames3;
|
|
20657
|
+
(function(AttributeNames4) {
|
|
20658
|
+
AttributeNames4["KOA_TYPE"] = "koa.type";
|
|
20659
|
+
AttributeNames4["KOA_NAME"] = "koa.name";
|
|
20660
|
+
})(AttributeNames3 = 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 = (context11, 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: context11._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 (context11, next) => {
|
|
20775
20775
|
const parent = api2.trace.getSpan(api2.context.active());
|
|
20776
20776
|
if (parent === undefined) {
|
|
20777
|
-
return middlewareLayer(
|
|
20777
|
+
return middlewareLayer(context11, next);
|
|
20778
20778
|
}
|
|
20779
|
-
const metadata = (0, utils_1.getMiddlewareMetadata)(
|
|
20779
|
+
const metadata = (0, utils_1.getMiddlewareMetadata)(context11, 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 && context11._matchedRoute) {
|
|
20785
|
+
rpcMetadata.route = context11._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: context11,
|
|
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(context11, 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 AttributeNames3;
|
|
20839
|
+
(function(AttributeNames4) {
|
|
20840
|
+
AttributeNames4["CONNECT_TYPE"] = "connect.type";
|
|
20841
|
+
AttributeNames4["CONNECT_NAME"] = "connect.name";
|
|
20842
|
+
})(AttributeNames3 = 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 = (context11) => {
|
|
21508
|
+
return context11.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);
|
|
21509
21509
|
};
|
|
21510
21510
|
exports.markConfirmChannelTracing = markConfirmChannelTracing;
|
|
21511
|
-
var unmarkConfirmChannelTracing = (
|
|
21512
|
-
return
|
|
21511
|
+
var unmarkConfirmChannelTracing = (context11) => {
|
|
21512
|
+
return context11.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);
|
|
21513
21513
|
};
|
|
21514
21514
|
exports.unmarkConfirmChannelTracing = unmarkConfirmChannelTracing;
|
|
21515
|
-
var isConfirmChannelTracing = (
|
|
21516
|
-
return
|
|
21515
|
+
var isConfirmChannelTracing = (context11) => {
|
|
21516
|
+
return context11.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) === true;
|
|
21517
21517
|
};
|
|
21518
21518
|
exports.isConfirmChannelTracing = isConfirmChannelTracing;
|
|
21519
21519
|
});
|
|
@@ -21934,11 +21934,12 @@ var require_src32 = __commonJS((exports) => {
|
|
|
21934
21934
|
|
|
21935
21935
|
// src/index.ts
|
|
21936
21936
|
import {
|
|
21937
|
-
logger as
|
|
21937
|
+
logger as logger32,
|
|
21938
21938
|
parseBooleanFromText,
|
|
21939
21939
|
getDatabaseDir,
|
|
21940
21940
|
getGeneratedDir as getGeneratedDir2,
|
|
21941
|
-
getUploadsAgentsDir as getUploadsAgentsDir4
|
|
21941
|
+
getUploadsAgentsDir as getUploadsAgentsDir4,
|
|
21942
|
+
ElizaOS as ElizaOS2
|
|
21942
21943
|
} from "@elizaos/core";
|
|
21943
21944
|
import cors2 from "cors";
|
|
21944
21945
|
import express33 from "express";
|
|
@@ -22483,10 +22484,10 @@ var helmet = Object.assign(function helmet2(options = {}) {
|
|
|
22483
22484
|
});
|
|
22484
22485
|
|
|
22485
22486
|
// src/index.ts
|
|
22486
|
-
import * as
|
|
22487
|
+
import * as fs7 from "node:fs";
|
|
22487
22488
|
import http4 from "node:http";
|
|
22488
22489
|
import os3 from "node:os";
|
|
22489
|
-
import
|
|
22490
|
+
import path9, { basename as basename2, dirname as dirname3, extname, join as join5 } from "node:path";
|
|
22490
22491
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
22491
22492
|
|
|
22492
22493
|
// src/api/index.ts
|
|
@@ -22529,7 +22530,7 @@ var sendSuccess = (res, data, status = 200) => {
|
|
|
22529
22530
|
};
|
|
22530
22531
|
|
|
22531
22532
|
// src/api/agents/crud.ts
|
|
22532
|
-
function createAgentCrudRouter(
|
|
22533
|
+
function createAgentCrudRouter(elizaOS, serverInstance) {
|
|
22533
22534
|
const router = express.Router();
|
|
22534
22535
|
const db = serverInstance?.database;
|
|
22535
22536
|
router.get("/", async (_, res) => {
|
|
@@ -22538,7 +22539,7 @@ function createAgentCrudRouter(agents, serverInstance) {
|
|
|
22538
22539
|
return sendError(res, 500, "DB_ERROR", "Database not available");
|
|
22539
22540
|
}
|
|
22540
22541
|
const allAgents = await db.getAgents();
|
|
22541
|
-
const runtimes =
|
|
22542
|
+
const runtimes = elizaOS.getAgents().map((a) => a.agentId);
|
|
22542
22543
|
const response = allAgents.map((agent) => ({
|
|
22543
22544
|
id: agent.id,
|
|
22544
22545
|
name: agent.name || "",
|
|
@@ -22570,7 +22571,7 @@ function createAgentCrudRouter(agents, serverInstance) {
|
|
|
22570
22571
|
if (!agent) {
|
|
22571
22572
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22572
22573
|
}
|
|
22573
|
-
const runtime =
|
|
22574
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22574
22575
|
const response = {
|
|
22575
22576
|
...agent,
|
|
22576
22577
|
status: runtime ? "active" : "inactive"
|
|
@@ -22670,12 +22671,13 @@ function createAgentCrudRouter(agents, serverInstance) {
|
|
|
22670
22671
|
await db.updateAgent(agentId, updates);
|
|
22671
22672
|
}
|
|
22672
22673
|
const updatedAgent = await db.getAgent(agentId);
|
|
22673
|
-
const
|
|
22674
|
-
if (
|
|
22675
|
-
|
|
22676
|
-
await
|
|
22674
|
+
const activeRuntime = elizaOS.getAgent(agentId);
|
|
22675
|
+
if (activeRuntime && updatedAgent) {
|
|
22676
|
+
const { enabled, status: status2, createdAt, updatedAt, ...characterData } = updatedAgent;
|
|
22677
|
+
await elizaOS.updateAgent(agentId, characterData);
|
|
22678
|
+
logger.debug(`[AGENT UPDATE] Updated active agent ${agentId} without restart`);
|
|
22677
22679
|
}
|
|
22678
|
-
const runtime =
|
|
22680
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22679
22681
|
const status = runtime ? "active" : "inactive";
|
|
22680
22682
|
sendSuccess(res, { ...updatedAgent, status });
|
|
22681
22683
|
} catch (error) {
|
|
@@ -22719,11 +22721,11 @@ function createAgentCrudRouter(agents, serverInstance) {
|
|
|
22719
22721
|
let lastError = null;
|
|
22720
22722
|
while (retryCount <= MAX_RETRIES) {
|
|
22721
22723
|
try {
|
|
22722
|
-
const runtime =
|
|
22724
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22723
22725
|
if (runtime) {
|
|
22724
22726
|
logger.debug(`[AGENT DELETE] Agent ${agentId} is running, unregistering from server`);
|
|
22725
22727
|
try {
|
|
22726
|
-
serverInstance?.unregisterAgent(agentId);
|
|
22728
|
+
await serverInstance?.unregisterAgent(agentId);
|
|
22727
22729
|
logger.debug(`[AGENT DELETE] Agent ${agentId} unregistered successfully`);
|
|
22728
22730
|
} catch (stopError) {
|
|
22729
22731
|
logger.error(`[AGENT DELETE] Error stopping agent ${agentId}:`, stopError instanceof Error ? stopError.message : String(stopError));
|
|
@@ -22782,7 +22784,7 @@ function createAgentCrudRouter(agents, serverInstance) {
|
|
|
22782
22784
|
// src/api/agents/lifecycle.ts
|
|
22783
22785
|
import { validateUuid as validateUuid2, logger as logger2 } from "@elizaos/core";
|
|
22784
22786
|
import express2 from "express";
|
|
22785
|
-
function createAgentLifecycleRouter(
|
|
22787
|
+
function createAgentLifecycleRouter(elizaOS, serverInstance) {
|
|
22786
22788
|
const router = express2.Router();
|
|
22787
22789
|
const db = serverInstance?.database;
|
|
22788
22790
|
router.post("/:agentId/start", async (req, res) => {
|
|
@@ -22799,7 +22801,7 @@ function createAgentLifecycleRouter(agents, serverInstance) {
|
|
|
22799
22801
|
logger2.debug("[AGENT START] Agent not found");
|
|
22800
22802
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22801
22803
|
}
|
|
22802
|
-
const isActive = !!
|
|
22804
|
+
const isActive = !!elizaOS.getAgent(agentId);
|
|
22803
22805
|
if (isActive) {
|
|
22804
22806
|
logger2.debug(`[AGENT START] Agent ${agentId} is already running`);
|
|
22805
22807
|
return sendSuccess(res, {
|
|
@@ -22808,8 +22810,8 @@ function createAgentLifecycleRouter(agents, serverInstance) {
|
|
|
22808
22810
|
status: "active"
|
|
22809
22811
|
});
|
|
22810
22812
|
}
|
|
22811
|
-
await serverInstance?.
|
|
22812
|
-
const runtime =
|
|
22813
|
+
await serverInstance?.startAgents([agent]);
|
|
22814
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22813
22815
|
if (!runtime) {
|
|
22814
22816
|
throw new Error("Failed to start agent");
|
|
22815
22817
|
}
|
|
@@ -22830,11 +22832,11 @@ function createAgentLifecycleRouter(agents, serverInstance) {
|
|
|
22830
22832
|
logger2.debug("[AGENT STOP] Invalid agent ID format");
|
|
22831
22833
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
22832
22834
|
}
|
|
22833
|
-
const runtime =
|
|
22835
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22834
22836
|
if (!runtime) {
|
|
22835
22837
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22836
22838
|
}
|
|
22837
|
-
serverInstance?.unregisterAgent(agentId);
|
|
22839
|
+
await serverInstance?.unregisterAgent(agentId);
|
|
22838
22840
|
logger2.debug(`[AGENT STOP] Successfully stopped agent: ${runtime.character.name} (${agentId})`);
|
|
22839
22841
|
sendSuccess(res, {
|
|
22840
22842
|
message: "Agent stopped"
|
|
@@ -22846,11 +22848,11 @@ function createAgentLifecycleRouter(agents, serverInstance) {
|
|
|
22846
22848
|
// src/api/agents/worlds.ts
|
|
22847
22849
|
import { validateUuid as validateUuid3, logger as logger3, createUniqueUuid } from "@elizaos/core";
|
|
22848
22850
|
import express3 from "express";
|
|
22849
|
-
function createAgentWorldsRouter(
|
|
22851
|
+
function createAgentWorldsRouter(elizaOS) {
|
|
22850
22852
|
const router = express3.Router();
|
|
22851
22853
|
router.get("/worlds", async (_req, res) => {
|
|
22852
22854
|
try {
|
|
22853
|
-
const runtime =
|
|
22855
|
+
const runtime = elizaOS.getAgents()[0];
|
|
22854
22856
|
if (!runtime) {
|
|
22855
22857
|
return sendError(res, 404, "NOT_FOUND", "No active agents found to get worlds");
|
|
22856
22858
|
}
|
|
@@ -22887,7 +22889,7 @@ function createAgentWorldsRouter(agents) {
|
|
|
22887
22889
|
if (!agentId) {
|
|
22888
22890
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
22889
22891
|
}
|
|
22890
|
-
const runtime =
|
|
22892
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22891
22893
|
if (!runtime) {
|
|
22892
22894
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22893
22895
|
}
|
|
@@ -22899,7 +22901,7 @@ function createAgentWorldsRouter(agents) {
|
|
|
22899
22901
|
if (!agentId || !worldId) {
|
|
22900
22902
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID or world ID format");
|
|
22901
22903
|
}
|
|
22902
|
-
const runtime =
|
|
22904
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22903
22905
|
if (!runtime) {
|
|
22904
22906
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22905
22907
|
}
|
|
@@ -22928,14 +22930,14 @@ function createAgentWorldsRouter(agents) {
|
|
|
22928
22930
|
// src/api/agents/panels.ts
|
|
22929
22931
|
import { validateUuid as validateUuid4, logger as logger4 } from "@elizaos/core";
|
|
22930
22932
|
import express4 from "express";
|
|
22931
|
-
function createAgentPanelsRouter(
|
|
22933
|
+
function createAgentPanelsRouter(elizaOS) {
|
|
22932
22934
|
const router = express4.Router();
|
|
22933
22935
|
router.get("/:agentId/panels", async (req, res) => {
|
|
22934
22936
|
const agentId = validateUuid4(req.params.agentId);
|
|
22935
22937
|
if (!agentId) {
|
|
22936
22938
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
22937
22939
|
}
|
|
22938
|
-
const runtime =
|
|
22940
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22939
22941
|
if (!runtime) {
|
|
22940
22942
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22941
22943
|
}
|
|
@@ -22956,7 +22958,7 @@ function createAgentPanelsRouter(agents) {
|
|
|
22956
22958
|
// src/api/agents/logs.ts
|
|
22957
22959
|
import { validateUuid as validateUuid5, logger as logger5 } from "@elizaos/core";
|
|
22958
22960
|
import express5 from "express";
|
|
22959
|
-
function createAgentLogsRouter(
|
|
22961
|
+
function createAgentLogsRouter(elizaOS) {
|
|
22960
22962
|
const router = express5.Router();
|
|
22961
22963
|
router.get("/:agentId/logs", async (req, res) => {
|
|
22962
22964
|
const agentId = validateUuid5(req.params.agentId);
|
|
@@ -22964,7 +22966,7 @@ function createAgentLogsRouter(agents) {
|
|
|
22964
22966
|
if (!agentId) {
|
|
22965
22967
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
22966
22968
|
}
|
|
22967
|
-
const runtime =
|
|
22969
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
22968
22970
|
if (!runtime) {
|
|
22969
22971
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
22970
22972
|
}
|
|
@@ -23010,7 +23012,7 @@ function createAgentLogsRouter(agents) {
|
|
|
23010
23012
|
if (!agentId || !logId) {
|
|
23011
23013
|
return sendError(res, 400, "INVALID_ID", "Invalid agent or log ID format");
|
|
23012
23014
|
}
|
|
23013
|
-
const runtime =
|
|
23015
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23014
23016
|
if (!runtime) {
|
|
23015
23017
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23016
23018
|
}
|
|
@@ -23028,14 +23030,14 @@ function createAgentLogsRouter(agents) {
|
|
|
23028
23030
|
// src/api/agents/runs.ts
|
|
23029
23031
|
import { validateUuid as validateUuid6 } from "@elizaos/core";
|
|
23030
23032
|
import express6 from "express";
|
|
23031
|
-
function createAgentRunsRouter(
|
|
23033
|
+
function createAgentRunsRouter(elizaOS) {
|
|
23032
23034
|
const router = express6.Router();
|
|
23033
23035
|
router.get("/:agentId/runs", async (req, res) => {
|
|
23034
23036
|
const agentId = validateUuid6(req.params.agentId);
|
|
23035
23037
|
if (!agentId) {
|
|
23036
23038
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
23037
23039
|
}
|
|
23038
|
-
const runtime =
|
|
23040
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23039
23041
|
if (!runtime) {
|
|
23040
23042
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23041
23043
|
}
|
|
@@ -23184,7 +23186,7 @@ function createAgentRunsRouter(agents) {
|
|
|
23184
23186
|
if (roomId && !validateUuid6(roomId)) {
|
|
23185
23187
|
return sendError(res, 400, "INVALID_ID", "Invalid room ID format");
|
|
23186
23188
|
}
|
|
23187
|
-
const runtime =
|
|
23189
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23188
23190
|
if (!runtime) {
|
|
23189
23191
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23190
23192
|
}
|
|
@@ -23320,7 +23322,7 @@ function createAgentRunsRouter(agents) {
|
|
|
23320
23322
|
import { MemoryType, createUniqueUuid as createUniqueUuid2 } from "@elizaos/core";
|
|
23321
23323
|
import { validateUuid as validateUuid7, logger as logger6 } from "@elizaos/core";
|
|
23322
23324
|
import express7 from "express";
|
|
23323
|
-
function createAgentMemoryRouter(
|
|
23325
|
+
function createAgentMemoryRouter(elizaOS) {
|
|
23324
23326
|
const router = express7.Router();
|
|
23325
23327
|
router.get("/:agentId/rooms/:roomId/memories", async (req, res) => {
|
|
23326
23328
|
const agentId = validateUuid7(req.params.agentId);
|
|
@@ -23328,7 +23330,7 @@ function createAgentMemoryRouter(agents) {
|
|
|
23328
23330
|
if (!agentId || !roomId) {
|
|
23329
23331
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID or room ID format");
|
|
23330
23332
|
}
|
|
23331
|
-
const runtime =
|
|
23333
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23332
23334
|
if (!runtime) {
|
|
23333
23335
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23334
23336
|
}
|
|
@@ -23358,7 +23360,7 @@ function createAgentMemoryRouter(agents) {
|
|
|
23358
23360
|
if (!agentId) {
|
|
23359
23361
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID");
|
|
23360
23362
|
}
|
|
23361
|
-
const runtime =
|
|
23363
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23362
23364
|
if (!runtime) {
|
|
23363
23365
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23364
23366
|
}
|
|
@@ -23402,7 +23404,7 @@ function createAgentMemoryRouter(agents) {
|
|
|
23402
23404
|
if (!agentId || !memoryId) {
|
|
23403
23405
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID or memory ID format");
|
|
23404
23406
|
}
|
|
23405
|
-
const runtime =
|
|
23407
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23406
23408
|
if (!runtime) {
|
|
23407
23409
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23408
23410
|
}
|
|
@@ -23435,7 +23437,7 @@ function createAgentMemoryRouter(agents) {
|
|
|
23435
23437
|
if (!agentId) {
|
|
23436
23438
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID");
|
|
23437
23439
|
}
|
|
23438
|
-
const runtime =
|
|
23440
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23439
23441
|
if (!runtime) {
|
|
23440
23442
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23441
23443
|
}
|
|
@@ -23457,7 +23459,7 @@ function createAgentMemoryRouter(agents) {
|
|
|
23457
23459
|
if (!roomId) {
|
|
23458
23460
|
return sendError(res, 400, "INVALID_ID", "Invalid room ID");
|
|
23459
23461
|
}
|
|
23460
|
-
const runtime =
|
|
23462
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23461
23463
|
if (!runtime) {
|
|
23462
23464
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23463
23465
|
}
|
|
@@ -23476,7 +23478,7 @@ function createAgentMemoryRouter(agents) {
|
|
|
23476
23478
|
if (!agentId || !memoryId) {
|
|
23477
23479
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID or memory ID format");
|
|
23478
23480
|
}
|
|
23479
|
-
const runtime =
|
|
23481
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23480
23482
|
if (!runtime) {
|
|
23481
23483
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23482
23484
|
}
|
|
@@ -23493,14 +23495,14 @@ function createAgentMemoryRouter(agents) {
|
|
|
23493
23495
|
// src/api/memory/rooms.ts
|
|
23494
23496
|
import { validateUuid as validateUuid8, logger as logger7, createUniqueUuid as createUniqueUuid3, ChannelType } from "@elizaos/core";
|
|
23495
23497
|
import express8 from "express";
|
|
23496
|
-
function createRoomManagementRouter(
|
|
23498
|
+
function createRoomManagementRouter(elizaOS) {
|
|
23497
23499
|
const router = express8.Router();
|
|
23498
23500
|
router.post("/:agentId/rooms", async (req, res) => {
|
|
23499
23501
|
const agentId = validateUuid8(req.params.agentId);
|
|
23500
23502
|
if (!agentId) {
|
|
23501
23503
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
23502
23504
|
}
|
|
23503
|
-
const runtime =
|
|
23505
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23504
23506
|
if (!runtime) {
|
|
23505
23507
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23506
23508
|
}
|
|
@@ -23557,7 +23559,7 @@ function createRoomManagementRouter(agents) {
|
|
|
23557
23559
|
if (!agentId) {
|
|
23558
23560
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID format");
|
|
23559
23561
|
}
|
|
23560
|
-
const runtime =
|
|
23562
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23561
23563
|
if (!runtime) {
|
|
23562
23564
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23563
23565
|
}
|
|
@@ -23587,7 +23589,7 @@ function createRoomManagementRouter(agents) {
|
|
|
23587
23589
|
if (!agentId || !roomId) {
|
|
23588
23590
|
return sendError(res, 400, "INVALID_ID", "Invalid agent ID or room ID format");
|
|
23589
23591
|
}
|
|
23590
|
-
const runtime =
|
|
23592
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
23591
23593
|
if (!runtime) {
|
|
23592
23594
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
23593
23595
|
}
|
|
@@ -23614,16 +23616,16 @@ function createRoomManagementRouter(agents) {
|
|
|
23614
23616
|
}
|
|
23615
23617
|
|
|
23616
23618
|
// src/api/agents/index.ts
|
|
23617
|
-
function agentsRouter(
|
|
23619
|
+
function agentsRouter(elizaOS, serverInstance) {
|
|
23618
23620
|
const router = express9.Router();
|
|
23619
|
-
router.use("/", createAgentCrudRouter(
|
|
23620
|
-
router.use("/", createAgentLifecycleRouter(
|
|
23621
|
-
router.use("/", createAgentWorldsRouter(
|
|
23622
|
-
router.use("/", createAgentPanelsRouter(
|
|
23623
|
-
router.use("/", createAgentLogsRouter(
|
|
23624
|
-
router.use("/", createAgentRunsRouter(
|
|
23625
|
-
router.use("/", createAgentMemoryRouter(
|
|
23626
|
-
router.use("/", createRoomManagementRouter(
|
|
23621
|
+
router.use("/", createAgentCrudRouter(elizaOS, serverInstance));
|
|
23622
|
+
router.use("/", createAgentLifecycleRouter(elizaOS, serverInstance));
|
|
23623
|
+
router.use("/", createAgentWorldsRouter(elizaOS));
|
|
23624
|
+
router.use("/", createAgentPanelsRouter(elizaOS));
|
|
23625
|
+
router.use("/", createAgentLogsRouter(elizaOS));
|
|
23626
|
+
router.use("/", createAgentRunsRouter(elizaOS));
|
|
23627
|
+
router.use("/", createAgentMemoryRouter(elizaOS));
|
|
23628
|
+
router.use("/", createRoomManagementRouter(elizaOS));
|
|
23627
23629
|
return router;
|
|
23628
23630
|
}
|
|
23629
23631
|
|
|
@@ -24178,8 +24180,8 @@ import { validateUuid as validateUuid12, logger as logger11 } from "@elizaos/cor
|
|
|
24178
24180
|
|
|
24179
24181
|
// src/api/shared/validation.ts
|
|
24180
24182
|
import { validateUuid as validateUuid11, logger as logger10 } from "@elizaos/core";
|
|
24181
|
-
var getRuntime = (
|
|
24182
|
-
const runtime =
|
|
24183
|
+
var getRuntime = (elizaOS, agentId) => {
|
|
24184
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
24183
24185
|
if (!runtime) {
|
|
24184
24186
|
throw new Error(`Agent not found: ${agentId}`);
|
|
24185
24187
|
}
|
|
@@ -24921,7 +24923,7 @@ async function saveChannelUploadedFile(file, channelId) {
|
|
|
24921
24923
|
const url = `/media/uploads/channels/${channelId}/${filename}`;
|
|
24922
24924
|
return { filename, url };
|
|
24923
24925
|
}
|
|
24924
|
-
function createChannelsRouter(
|
|
24926
|
+
function createChannelsRouter(elizaOS, serverInstance) {
|
|
24925
24927
|
const router = express12.Router();
|
|
24926
24928
|
router.post("/central-channels/:channelId/messages", async (req, res) => {
|
|
24927
24929
|
const channelIdParam = validateUuid13(req.params.channelId);
|
|
@@ -25494,7 +25496,7 @@ function createChannelsRouter(agents, serverInstance) {
|
|
|
25494
25496
|
});
|
|
25495
25497
|
}
|
|
25496
25498
|
try {
|
|
25497
|
-
const runtime =
|
|
25499
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
25498
25500
|
if (!runtime) {
|
|
25499
25501
|
return res.status(404).json({
|
|
25500
25502
|
success: false,
|
|
@@ -26000,7 +26002,7 @@ function asyncHandler(fn) {
|
|
|
26000
26002
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
26001
26003
|
};
|
|
26002
26004
|
}
|
|
26003
|
-
function createSessionsRouter(
|
|
26005
|
+
function createSessionsRouter(elizaOS, serverInstance) {
|
|
26004
26006
|
const router = express13.Router();
|
|
26005
26007
|
router.get("/sessions/health", (_req, res) => {
|
|
26006
26008
|
const now = Date.now();
|
|
@@ -26040,7 +26042,7 @@ function createSessionsRouter(agents, serverInstance) {
|
|
|
26040
26042
|
if (!validateUuid14(body.userId)) {
|
|
26041
26043
|
throw new InvalidUuidError("userId", body.userId);
|
|
26042
26044
|
}
|
|
26043
|
-
const agent =
|
|
26045
|
+
const agent = elizaOS.getAgent(body.agentId);
|
|
26044
26046
|
if (!agent) {
|
|
26045
26047
|
throw new AgentNotFoundError(body.agentId);
|
|
26046
26048
|
}
|
|
@@ -26348,7 +26350,7 @@ function createSessionsRouter(agents, serverInstance) {
|
|
|
26348
26350
|
}
|
|
26349
26351
|
}
|
|
26350
26352
|
}
|
|
26351
|
-
const agent =
|
|
26353
|
+
const agent = elizaOS.getAgent(session.agentId);
|
|
26352
26354
|
const agentConfig = agent ? getAgentTimeoutConfig(agent) : undefined;
|
|
26353
26355
|
session.timeoutConfig = mergeTimeoutConfigs(newConfig, agentConfig);
|
|
26354
26356
|
session.expiresAt = calculateExpirationDate(session.createdAt, session.lastActivity, session.timeoutConfig, session.renewalCount);
|
|
@@ -26465,15 +26467,15 @@ function createSessionsRouter(agents, serverInstance) {
|
|
|
26465
26467
|
}
|
|
26466
26468
|
|
|
26467
26469
|
// src/api/messaging/index.ts
|
|
26468
|
-
function messagingRouter(
|
|
26470
|
+
function messagingRouter(elizaOS, serverInstance) {
|
|
26469
26471
|
const router = express14.Router();
|
|
26470
26472
|
if (!serverInstance) {
|
|
26471
26473
|
throw new Error("ServerInstance is required for messaging router");
|
|
26472
26474
|
}
|
|
26473
26475
|
router.use("/", createMessagingCoreRouter(serverInstance));
|
|
26474
26476
|
router.use("/", createServersRouter(serverInstance));
|
|
26475
|
-
router.use("/", createChannelsRouter(
|
|
26476
|
-
router.use("/", createSessionsRouter(
|
|
26477
|
+
router.use("/", createChannelsRouter(elizaOS, serverInstance));
|
|
26478
|
+
router.use("/", createSessionsRouter(elizaOS, serverInstance));
|
|
26477
26479
|
return router;
|
|
26478
26480
|
}
|
|
26479
26481
|
|
|
@@ -26669,7 +26671,7 @@ function validateAudioFile(file) {
|
|
|
26669
26671
|
return ALLOWED_AUDIO_MIME_TYPES.some((allowed) => allowed === file.mimetype);
|
|
26670
26672
|
}
|
|
26671
26673
|
// src/api/memory/groups.ts
|
|
26672
|
-
function createGroupMemoryRouter(
|
|
26674
|
+
function createGroupMemoryRouter(elizaOS, serverInstance) {
|
|
26673
26675
|
const router = express18.Router();
|
|
26674
26676
|
const db = serverInstance?.database;
|
|
26675
26677
|
router.post("/groups/:serverId", async (req, res) => {
|
|
@@ -26682,7 +26684,7 @@ function createGroupMemoryRouter(agents, serverInstance) {
|
|
|
26682
26684
|
let errors = [];
|
|
26683
26685
|
for (const agentId of agentIds) {
|
|
26684
26686
|
try {
|
|
26685
|
-
const runtime = getRuntime(
|
|
26687
|
+
const runtime = getRuntime(elizaOS, agentId);
|
|
26686
26688
|
const roomId = createUniqueUuid4(runtime, serverId);
|
|
26687
26689
|
const roomName = name || `Chat ${new Date().toLocaleString()}`;
|
|
26688
26690
|
await runtime.ensureWorldExists({
|
|
@@ -26774,11 +26776,11 @@ function createGroupMemoryRouter(agents, serverInstance) {
|
|
|
26774
26776
|
}
|
|
26775
26777
|
|
|
26776
26778
|
// src/api/memory/index.ts
|
|
26777
|
-
function memoryRouter(
|
|
26779
|
+
function memoryRouter(elizaOS, serverInstance) {
|
|
26778
26780
|
const router = express19.Router();
|
|
26779
|
-
router.use("/", createAgentMemoryRouter(
|
|
26780
|
-
router.use("/", createGroupMemoryRouter(
|
|
26781
|
-
router.use("/", createRoomManagementRouter(
|
|
26781
|
+
router.use("/", createAgentMemoryRouter(elizaOS));
|
|
26782
|
+
router.use("/", createGroupMemoryRouter(elizaOS, serverInstance));
|
|
26783
|
+
router.use("/", createRoomManagementRouter(elizaOS));
|
|
26782
26784
|
return router;
|
|
26783
26785
|
}
|
|
26784
26786
|
|
|
@@ -26788,7 +26790,7 @@ import express23 from "express";
|
|
|
26788
26790
|
// src/api/audio/processing.ts
|
|
26789
26791
|
import { logger as logger19, ModelType as ModelType2, validateUuid as validateUuid19 } from "@elizaos/core";
|
|
26790
26792
|
import express20 from "express";
|
|
26791
|
-
function createAudioProcessingRouter(
|
|
26793
|
+
function createAudioProcessingRouter(elizaOS) {
|
|
26792
26794
|
const router = express20.Router();
|
|
26793
26795
|
router.use(createUploadRateLimit());
|
|
26794
26796
|
router.use(createFileSystemRateLimit());
|
|
@@ -26803,7 +26805,7 @@ function createAudioProcessingRouter(agents) {
|
|
|
26803
26805
|
if (!audioFile) {
|
|
26804
26806
|
return sendError(res, 400, "INVALID_REQUEST", "No audio file provided");
|
|
26805
26807
|
}
|
|
26806
|
-
const runtime =
|
|
26808
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
26807
26809
|
if (!runtime) {
|
|
26808
26810
|
cleanupUploadedFile(audioFile);
|
|
26809
26811
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
@@ -26838,7 +26840,7 @@ function createAudioProcessingRouter(agents) {
|
|
|
26838
26840
|
if (!audioFile) {
|
|
26839
26841
|
return sendError(res, 400, "INVALID_REQUEST", "No audio file provided");
|
|
26840
26842
|
}
|
|
26841
|
-
const runtime =
|
|
26843
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
26842
26844
|
if (!runtime) {
|
|
26843
26845
|
cleanupUploadedFile(audioFile);
|
|
26844
26846
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
@@ -26927,7 +26929,7 @@ async function convertToAudioBuffer(speechResponse, detectMimeType) {
|
|
|
26927
26929
|
}
|
|
26928
26930
|
|
|
26929
26931
|
// src/api/audio/synthesis.ts
|
|
26930
|
-
function createSynthesisRouter(
|
|
26932
|
+
function createSynthesisRouter(elizaOS) {
|
|
26931
26933
|
const router = express21.Router();
|
|
26932
26934
|
router.post("/:agentId/audio-messages/synthesize", async (req, res) => {
|
|
26933
26935
|
const agentId = validateUuid20(req.params.agentId);
|
|
@@ -26938,7 +26940,7 @@ function createSynthesisRouter(agents) {
|
|
|
26938
26940
|
if (!text) {
|
|
26939
26941
|
return sendError(res, 400, "INVALID_REQUEST", "Text is required for speech synthesis");
|
|
26940
26942
|
}
|
|
26941
|
-
const runtime =
|
|
26943
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
26942
26944
|
if (!runtime) {
|
|
26943
26945
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
26944
26946
|
}
|
|
@@ -26966,7 +26968,7 @@ function createSynthesisRouter(agents) {
|
|
|
26966
26968
|
if (!text) {
|
|
26967
26969
|
return sendError(res, 400, "INVALID_REQUEST", "Text is required for speech synthesis");
|
|
26968
26970
|
}
|
|
26969
|
-
const runtime =
|
|
26971
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
26970
26972
|
if (!runtime) {
|
|
26971
26973
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
26972
26974
|
}
|
|
@@ -27001,7 +27003,7 @@ import {
|
|
|
27001
27003
|
messageHandlerTemplate
|
|
27002
27004
|
} from "@elizaos/core";
|
|
27003
27005
|
import express22 from "express";
|
|
27004
|
-
function createConversationRouter(
|
|
27006
|
+
function createConversationRouter(elizaOS) {
|
|
27005
27007
|
const router = express22.Router();
|
|
27006
27008
|
router.post("/:agentId/speech/conversation", async (req, res) => {
|
|
27007
27009
|
const agentId = validateUuid21(req.params.agentId);
|
|
@@ -27012,7 +27014,7 @@ function createConversationRouter(agents) {
|
|
|
27012
27014
|
if (!text) {
|
|
27013
27015
|
return sendError(res, 400, "INVALID_REQUEST", "Text is required for conversation");
|
|
27014
27016
|
}
|
|
27015
|
-
const runtime =
|
|
27017
|
+
const runtime = elizaOS.getAgent(agentId);
|
|
27016
27018
|
if (!runtime) {
|
|
27017
27019
|
return sendError(res, 404, "NOT_FOUND", "Agent not found");
|
|
27018
27020
|
}
|
|
@@ -27105,11 +27107,11 @@ function createConversationRouter(agents) {
|
|
|
27105
27107
|
}
|
|
27106
27108
|
|
|
27107
27109
|
// src/api/audio/index.ts
|
|
27108
|
-
function audioRouter(
|
|
27110
|
+
function audioRouter(elizaOS) {
|
|
27109
27111
|
const router = express23.Router();
|
|
27110
|
-
router.use("/", createAudioProcessingRouter(
|
|
27111
|
-
router.use("/", createSynthesisRouter(
|
|
27112
|
-
router.use("/", createConversationRouter(
|
|
27112
|
+
router.use("/", createAudioProcessingRouter(elizaOS));
|
|
27113
|
+
router.use("/", createSynthesisRouter(elizaOS));
|
|
27114
|
+
router.use("/", createConversationRouter(elizaOS));
|
|
27113
27115
|
return router;
|
|
27114
27116
|
}
|
|
27115
27117
|
|
|
@@ -27119,7 +27121,7 @@ import express27 from "express";
|
|
|
27119
27121
|
// src/api/runtime/health.ts
|
|
27120
27122
|
import { logger as logger22 } from "@elizaos/core";
|
|
27121
27123
|
import express24 from "express";
|
|
27122
|
-
function createHealthRouter(
|
|
27124
|
+
function createHealthRouter(elizaOS, serverInstance) {
|
|
27123
27125
|
const router = express24.Router();
|
|
27124
27126
|
router.get("/ping", (_req, res) => {
|
|
27125
27127
|
res.json({ pong: true, timestamp: Date.now() });
|
|
@@ -27134,7 +27136,7 @@ function createHealthRouter(agents, serverInstance) {
|
|
|
27134
27136
|
res.setHeader("Content-Type", "application/json");
|
|
27135
27137
|
res.send(JSON.stringify({
|
|
27136
27138
|
status: "ok",
|
|
27137
|
-
agentCount:
|
|
27139
|
+
agentCount: elizaOS.getAgents().length,
|
|
27138
27140
|
timestamp: new Date().toISOString()
|
|
27139
27141
|
}));
|
|
27140
27142
|
});
|
|
@@ -27145,7 +27147,7 @@ function createHealthRouter(agents, serverInstance) {
|
|
|
27145
27147
|
version: process.env.APP_VERSION || "unknown",
|
|
27146
27148
|
timestamp: new Date().toISOString(),
|
|
27147
27149
|
dependencies: {
|
|
27148
|
-
agents:
|
|
27150
|
+
agents: elizaOS.getAgents().length > 0 ? "healthy" : "no_agents"
|
|
27149
27151
|
}
|
|
27150
27152
|
};
|
|
27151
27153
|
const statusCode = healthcheck.dependencies.agents === "healthy" ? 200 : 503;
|
|
@@ -27316,9 +27318,9 @@ function createDebugRouter(serverInstance) {
|
|
|
27316
27318
|
}
|
|
27317
27319
|
|
|
27318
27320
|
// src/api/runtime/index.ts
|
|
27319
|
-
function runtimeRouter(
|
|
27321
|
+
function runtimeRouter(elizaOS, serverInstance) {
|
|
27320
27322
|
const router = express27.Router();
|
|
27321
|
-
router.use("/", createHealthRouter(
|
|
27323
|
+
router.use("/", createHealthRouter(elizaOS, serverInstance));
|
|
27322
27324
|
router.use("/", createLoggingRouter());
|
|
27323
27325
|
router.use("/debug", createDebugRouter(serverInstance));
|
|
27324
27326
|
return router;
|
|
@@ -27452,7 +27454,7 @@ import express30 from "express";
|
|
|
27452
27454
|
// package.json
|
|
27453
27455
|
var package_default = {
|
|
27454
27456
|
name: "@elizaos/server",
|
|
27455
|
-
version: "1.5.
|
|
27457
|
+
version: "1.5.13-alpha.2",
|
|
27456
27458
|
description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
27457
27459
|
publishConfig: {
|
|
27458
27460
|
access: "public",
|
|
@@ -27575,16 +27577,16 @@ import {
|
|
|
27575
27577
|
var DEFAULT_SERVER_ID5 = "00000000-0000-0000-0000-000000000000";
|
|
27576
27578
|
|
|
27577
27579
|
class SocketIORouter {
|
|
27578
|
-
|
|
27580
|
+
elizaOS;
|
|
27579
27581
|
connections;
|
|
27580
27582
|
logStreamConnections;
|
|
27581
27583
|
serverInstance;
|
|
27582
|
-
constructor(
|
|
27583
|
-
this.
|
|
27584
|
+
constructor(elizaOS, serverInstance) {
|
|
27585
|
+
this.elizaOS = elizaOS;
|
|
27584
27586
|
this.connections = new Map;
|
|
27585
27587
|
this.logStreamConnections = new Map;
|
|
27586
27588
|
this.serverInstance = serverInstance;
|
|
27587
|
-
logger25.info(`[SocketIO] Router initialized with ${this.
|
|
27589
|
+
logger25.info(`[SocketIO] Router initialized with ${this.elizaOS.getAgents().length} agents`);
|
|
27588
27590
|
}
|
|
27589
27591
|
setupListeners(io) {
|
|
27590
27592
|
logger25.info(`[SocketIO] Setting up Socket.IO event listeners`);
|
|
@@ -27676,7 +27678,7 @@ class SocketIORouter {
|
|
|
27676
27678
|
const finalServerId = serverId || DEFAULT_SERVER_ID5;
|
|
27677
27679
|
const isDm = metadata?.isDm || metadata?.channelType === ChannelType6.DM;
|
|
27678
27680
|
logger25.info(`[SocketIO] Emitting ENTITY_JOINED event for entityId: ${entityId}, serverId: ${finalServerId}, isDm: ${isDm}`);
|
|
27679
|
-
const runtime =
|
|
27681
|
+
const runtime = this.elizaOS.getAgents()[0];
|
|
27680
27682
|
if (runtime) {
|
|
27681
27683
|
runtime.emitEvent(EventType.ENTITY_JOINED, {
|
|
27682
27684
|
entityId,
|
|
@@ -27722,7 +27724,7 @@ class SocketIORouter {
|
|
|
27722
27724
|
const isDmForWorldSetup = metadata?.isDm || metadata?.channelType === ChannelType6.DM;
|
|
27723
27725
|
if (isDmForWorldSetup && senderId) {
|
|
27724
27726
|
logger25.info(`[SocketIO] Detected DM channel during message submission, emitting ENTITY_JOINED for proper world setup`);
|
|
27725
|
-
const runtime =
|
|
27727
|
+
const runtime = this.elizaOS.getAgents()[0];
|
|
27726
27728
|
if (runtime) {
|
|
27727
27729
|
runtime.emitEvent(EventType.ENTITY_JOINED, {
|
|
27728
27730
|
entityId: senderId,
|
|
@@ -27914,14 +27916,14 @@ class SocketIORouter {
|
|
|
27914
27916
|
}
|
|
27915
27917
|
|
|
27916
27918
|
// src/api/index.ts
|
|
27917
|
-
function setupSocketIO(server,
|
|
27919
|
+
function setupSocketIO(server, elizaOS, serverInstance) {
|
|
27918
27920
|
const io = new SocketIOServer(server, {
|
|
27919
27921
|
cors: {
|
|
27920
27922
|
origin: "*",
|
|
27921
27923
|
methods: ["GET", "POST"]
|
|
27922
27924
|
}
|
|
27923
27925
|
});
|
|
27924
|
-
const centralSocketRouter = new SocketIORouter(
|
|
27926
|
+
const centralSocketRouter = new SocketIORouter(elizaOS, serverInstance);
|
|
27925
27927
|
centralSocketRouter.setupListeners(io);
|
|
27926
27928
|
setupLogStreaming(io, centralSocketRouter);
|
|
27927
27929
|
return io;
|
|
@@ -27952,7 +27954,7 @@ function setupLogStreaming(io, router) {
|
|
|
27952
27954
|
};
|
|
27953
27955
|
}
|
|
27954
27956
|
}
|
|
27955
|
-
function createPluginRouteHandler(
|
|
27957
|
+
function createPluginRouteHandler(elizaOS) {
|
|
27956
27958
|
return (req, res, next) => {
|
|
27957
27959
|
logger26.debug("Handling plugin request in the plugin route handler", `path: ${req.path}, method: ${req.method}`, {
|
|
27958
27960
|
path: req.path,
|
|
@@ -27976,7 +27978,7 @@ function createPluginRouteHandler(agents) {
|
|
|
27976
27978
|
logger26.debug(`JavaScript request in plugin handler: ${req.method} ${req.path}`);
|
|
27977
27979
|
res.setHeader("Content-Type", "application/javascript");
|
|
27978
27980
|
}
|
|
27979
|
-
if (
|
|
27981
|
+
if (elizaOS.getAgents().length === 0) {
|
|
27980
27982
|
logger26.debug("No agents available, skipping plugin route handling.");
|
|
27981
27983
|
return next();
|
|
27982
27984
|
}
|
|
@@ -28054,7 +28056,7 @@ function createPluginRouteHandler(agents) {
|
|
|
28054
28056
|
return handled;
|
|
28055
28057
|
}
|
|
28056
28058
|
if (agentIdFromQuery && validateUuid23(agentIdFromQuery)) {
|
|
28057
|
-
const runtime =
|
|
28059
|
+
const runtime = elizaOS.getAgent(agentIdFromQuery);
|
|
28058
28060
|
if (runtime) {
|
|
28059
28061
|
logger26.debug(`Agent-scoped request for Agent ID: ${agentIdFromQuery} from query. Path: ${reqPath}`);
|
|
28060
28062
|
handled = findRouteInRuntime(runtime);
|
|
@@ -28089,7 +28091,7 @@ function createPluginRouteHandler(agents) {
|
|
|
28089
28091
|
}
|
|
28090
28092
|
} else {
|
|
28091
28093
|
logger26.debug(`No valid agentId in query. Trying global match for path: ${reqPath}`);
|
|
28092
|
-
for (const
|
|
28094
|
+
for (const runtime of elizaOS.getAgents()) {
|
|
28093
28095
|
if (handled)
|
|
28094
28096
|
break;
|
|
28095
28097
|
handled = findRouteInRuntime(runtime);
|
|
@@ -28102,7 +28104,7 @@ function createPluginRouteHandler(agents) {
|
|
|
28102
28104
|
next();
|
|
28103
28105
|
};
|
|
28104
28106
|
}
|
|
28105
|
-
function createApiRouter(
|
|
28107
|
+
function createApiRouter(elizaOS, serverInstance) {
|
|
28106
28108
|
const router = express32.Router();
|
|
28107
28109
|
router.use(helmet({
|
|
28108
28110
|
contentSecurityPolicy: false,
|
|
@@ -28121,14 +28123,14 @@ function createApiRouter(agents, serverInstance) {
|
|
|
28121
28123
|
router.use(securityMiddleware());
|
|
28122
28124
|
router.use("/media", mediaRouter());
|
|
28123
28125
|
router.use(validateContentTypeMiddleware());
|
|
28124
|
-
router.use("/agents", agentsRouter(
|
|
28125
|
-
router.use("/messaging", messagingRouter(
|
|
28126
|
-
router.use("/memory", memoryRouter(
|
|
28127
|
-
router.use("/audio", audioRouter(
|
|
28128
|
-
router.use("/server", runtimeRouter(
|
|
28126
|
+
router.use("/agents", agentsRouter(elizaOS, serverInstance));
|
|
28127
|
+
router.use("/messaging", messagingRouter(elizaOS, serverInstance));
|
|
28128
|
+
router.use("/memory", memoryRouter(elizaOS, serverInstance));
|
|
28129
|
+
router.use("/audio", audioRouter(elizaOS));
|
|
28130
|
+
router.use("/server", runtimeRouter(elizaOS, serverInstance));
|
|
28129
28131
|
router.use("/tee", teeRouter());
|
|
28130
28132
|
router.use("/system", systemRouter());
|
|
28131
|
-
router.use(createPluginRouteHandler(
|
|
28133
|
+
router.use(createPluginRouteHandler(elizaOS));
|
|
28132
28134
|
return router;
|
|
28133
28135
|
}
|
|
28134
28136
|
|
|
@@ -29009,7 +29011,7 @@ var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
|
29009
29011
|
var GLOBAL_OBJ = globalThis;
|
|
29010
29012
|
|
|
29011
29013
|
// ../../node_modules/@sentry/core/build/esm/utils/version.js
|
|
29012
|
-
var SDK_VERSION = "10.
|
|
29014
|
+
var SDK_VERSION = "10.15.0";
|
|
29013
29015
|
|
|
29014
29016
|
// ../../node_modules/@sentry/core/build/esm/carrier.js
|
|
29015
29017
|
function getMainCarrier() {
|
|
@@ -30353,16 +30355,39 @@ function getSpanStatusFromHttpCode(httpStatus) {
|
|
|
30353
30355
|
// ../../node_modules/@sentry/core/build/esm/tracing/utils.js
|
|
30354
30356
|
var SCOPE_ON_START_SPAN_FIELD = "_sentryScope";
|
|
30355
30357
|
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
|
+
}
|
|
30356
30380
|
function setCapturedScopesOnSpan(span, scope, isolationScope) {
|
|
30357
30381
|
if (span) {
|
|
30358
|
-
addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
|
|
30382
|
+
addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, wrapScopeWithWeakRef(isolationScope));
|
|
30359
30383
|
addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
|
|
30360
30384
|
}
|
|
30361
30385
|
}
|
|
30362
30386
|
function getCapturedScopesOnSpan(span) {
|
|
30387
|
+
const spanWithScopes = span;
|
|
30363
30388
|
return {
|
|
30364
|
-
scope:
|
|
30365
|
-
isolationScope:
|
|
30389
|
+
scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],
|
|
30390
|
+
isolationScope: unwrapScopeFromWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD])
|
|
30366
30391
|
};
|
|
30367
30392
|
}
|
|
30368
30393
|
|
|
@@ -30795,7 +30820,7 @@ function getActiveSpan() {
|
|
|
30795
30820
|
function showSpanDropWarning() {
|
|
30796
30821
|
if (!hasShownSpanDropWarning) {
|
|
30797
30822
|
consoleSandbox(() => {
|
|
30798
|
-
console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly
|
|
30823
|
+
console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.");
|
|
30799
30824
|
});
|
|
30800
30825
|
hasShownSpanDropWarning = true;
|
|
30801
30826
|
}
|
|
@@ -30830,6 +30855,50 @@ function hasSpansEnabled(maybeOptions) {
|
|
|
30830
30855
|
return !!options && (options.tracesSampleRate != null || !!options.tracesSampler);
|
|
30831
30856
|
}
|
|
30832
30857
|
|
|
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
|
+
|
|
30833
30902
|
// ../../node_modules/@sentry/core/build/esm/constants.js
|
|
30834
30903
|
var DEFAULT_ENVIRONMENT = "production";
|
|
30835
30904
|
|
|
@@ -31187,45 +31256,6 @@ function createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn) {
|
|
|
31187
31256
|
};
|
|
31188
31257
|
}
|
|
31189
31258
|
|
|
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
|
-
|
|
31229
31259
|
// ../../node_modules/@sentry/core/build/esm/envelope.js
|
|
31230
31260
|
function _enhanceEventWithSdkInfo(event, newSdkInfo) {
|
|
31231
31261
|
if (!newSdkInfo) {
|
|
@@ -31582,7 +31612,7 @@ function sendSpanEnvelope(envelope) {
|
|
|
31582
31612
|
}
|
|
31583
31613
|
|
|
31584
31614
|
// ../../node_modules/@sentry/core/build/esm/utils/handleCallbackErrors.js
|
|
31585
|
-
function handleCallbackErrors(fn, onError, onFinally = () => {}) {
|
|
31615
|
+
function handleCallbackErrors(fn, onError, onFinally = () => {}, onSuccess = () => {}) {
|
|
31586
31616
|
let maybePromiseResult;
|
|
31587
31617
|
try {
|
|
31588
31618
|
maybePromiseResult = fn();
|
|
@@ -31591,12 +31621,13 @@ function handleCallbackErrors(fn, onError, onFinally = () => {}) {
|
|
|
31591
31621
|
onFinally();
|
|
31592
31622
|
throw e;
|
|
31593
31623
|
}
|
|
31594
|
-
return maybeHandlePromiseRejection(maybePromiseResult, onError, onFinally);
|
|
31624
|
+
return maybeHandlePromiseRejection(maybePromiseResult, onError, onFinally, onSuccess);
|
|
31595
31625
|
}
|
|
31596
|
-
function maybeHandlePromiseRejection(value, onError, onFinally) {
|
|
31626
|
+
function maybeHandlePromiseRejection(value, onError, onFinally, onSuccess) {
|
|
31597
31627
|
if (isThenable(value)) {
|
|
31598
31628
|
return value.then((res) => {
|
|
31599
31629
|
onFinally();
|
|
31630
|
+
onSuccess(res);
|
|
31600
31631
|
return res;
|
|
31601
31632
|
}, (e) => {
|
|
31602
31633
|
onError(e);
|
|
@@ -31605,6 +31636,7 @@ function maybeHandlePromiseRejection(value, onError, onFinally) {
|
|
|
31605
31636
|
});
|
|
31606
31637
|
}
|
|
31607
31638
|
onFinally();
|
|
31639
|
+
onSuccess(value);
|
|
31608
31640
|
return value;
|
|
31609
31641
|
}
|
|
31610
31642
|
|
|
@@ -32705,23 +32737,21 @@ class Client {
|
|
|
32705
32737
|
getTransport() {
|
|
32706
32738
|
return this._transport;
|
|
32707
32739
|
}
|
|
32708
|
-
flush(timeout) {
|
|
32740
|
+
async flush(timeout) {
|
|
32709
32741
|
const transport = this._transport;
|
|
32710
|
-
if (transport) {
|
|
32711
|
-
|
|
32712
|
-
return this._isClientDoneProcessing(timeout).then((clientFinished) => {
|
|
32713
|
-
return transport.flush(timeout).then((transportFlushed) => clientFinished && transportFlushed);
|
|
32714
|
-
});
|
|
32715
|
-
} else {
|
|
32716
|
-
return resolvedSyncPromise(true);
|
|
32742
|
+
if (!transport) {
|
|
32743
|
+
return true;
|
|
32717
32744
|
}
|
|
32745
|
+
this.emit("flush");
|
|
32746
|
+
const clientFinished = await this._isClientDoneProcessing(timeout);
|
|
32747
|
+
const transportFlushed = await transport.flush(timeout);
|
|
32748
|
+
return clientFinished && transportFlushed;
|
|
32718
32749
|
}
|
|
32719
|
-
close(timeout) {
|
|
32720
|
-
|
|
32721
|
-
|
|
32722
|
-
|
|
32723
|
-
|
|
32724
|
-
});
|
|
32750
|
+
async close(timeout) {
|
|
32751
|
+
const result = await this.flush(timeout);
|
|
32752
|
+
this.getOptions().enabled = false;
|
|
32753
|
+
this.emit("close");
|
|
32754
|
+
return result;
|
|
32725
32755
|
}
|
|
32726
32756
|
getEventProcessors() {
|
|
32727
32757
|
return this._eventProcessors;
|
|
@@ -32783,13 +32813,11 @@ class Client {
|
|
|
32783
32813
|
}
|
|
32784
32814
|
}
|
|
32785
32815
|
on(hook, callback) {
|
|
32786
|
-
const
|
|
32787
|
-
|
|
32816
|
+
const hookCallbacks = this._hooks[hook] = this._hooks[hook] || new Set;
|
|
32817
|
+
const uniqueCallback = (...args) => callback(...args);
|
|
32818
|
+
hookCallbacks.add(uniqueCallback);
|
|
32788
32819
|
return () => {
|
|
32789
|
-
|
|
32790
|
-
if (cbIndex > -1) {
|
|
32791
|
-
hooks.splice(cbIndex, 1);
|
|
32792
|
-
}
|
|
32820
|
+
hookCallbacks.delete(uniqueCallback);
|
|
32793
32821
|
};
|
|
32794
32822
|
}
|
|
32795
32823
|
emit(hook, ...rest) {
|
|
@@ -32798,16 +32826,18 @@ class Client {
|
|
|
32798
32826
|
callbacks.forEach((callback) => callback(...rest));
|
|
32799
32827
|
}
|
|
32800
32828
|
}
|
|
32801
|
-
sendEnvelope(envelope) {
|
|
32829
|
+
async sendEnvelope(envelope) {
|
|
32802
32830
|
this.emit("beforeEnvelope", envelope);
|
|
32803
32831
|
if (this._isEnabled() && this._transport) {
|
|
32804
|
-
|
|
32832
|
+
try {
|
|
32833
|
+
return await this._transport.send(envelope);
|
|
32834
|
+
} catch (reason) {
|
|
32805
32835
|
DEBUG_BUILD && debug.error("Error while sending envelope:", reason);
|
|
32806
32836
|
return {};
|
|
32807
|
-
}
|
|
32837
|
+
}
|
|
32808
32838
|
}
|
|
32809
32839
|
DEBUG_BUILD && debug.error("Transport disabled");
|
|
32810
|
-
return
|
|
32840
|
+
return {};
|
|
32811
32841
|
}
|
|
32812
32842
|
_setupIntegrations() {
|
|
32813
32843
|
const { integrations } = this._options;
|
|
@@ -32838,23 +32868,16 @@ class Client {
|
|
|
32838
32868
|
this.captureSession(session);
|
|
32839
32869
|
}
|
|
32840
32870
|
}
|
|
32841
|
-
_isClientDoneProcessing(timeout) {
|
|
32842
|
-
|
|
32843
|
-
|
|
32844
|
-
|
|
32845
|
-
|
|
32846
|
-
|
|
32847
|
-
|
|
32848
|
-
|
|
32849
|
-
|
|
32850
|
-
|
|
32851
|
-
if (timeout && ticked >= timeout) {
|
|
32852
|
-
clearInterval(interval);
|
|
32853
|
-
resolve(false);
|
|
32854
|
-
}
|
|
32855
|
-
}
|
|
32856
|
-
}, tick);
|
|
32857
|
-
});
|
|
32871
|
+
async _isClientDoneProcessing(timeout) {
|
|
32872
|
+
let ticked = 0;
|
|
32873
|
+
while (!timeout || ticked < timeout) {
|
|
32874
|
+
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
32875
|
+
if (!this._numProcessing) {
|
|
32876
|
+
return true;
|
|
32877
|
+
}
|
|
32878
|
+
ticked++;
|
|
32879
|
+
}
|
|
32880
|
+
return false;
|
|
32858
32881
|
}
|
|
32859
32882
|
_isEnabled() {
|
|
32860
32883
|
return this.getOptions().enabled !== false && this._transport !== undefined;
|
|
@@ -33165,7 +33188,7 @@ function createLogEnvelope(logs, metadata, tunnel, dsn) {
|
|
|
33165
33188
|
return createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
|
|
33166
33189
|
}
|
|
33167
33190
|
|
|
33168
|
-
// ../../node_modules/@sentry/core/build/esm/logs/
|
|
33191
|
+
// ../../node_modules/@sentry/core/build/esm/logs/internal.js
|
|
33169
33192
|
function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
|
|
33170
33193
|
const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
|
|
33171
33194
|
if (logBuffer.length === 0) {
|
|
@@ -33566,7 +33589,7 @@ function createTransport(options, makeRequest, buffer = makePromiseBuffer(option
|
|
|
33566
33589
|
}
|
|
33567
33590
|
});
|
|
33568
33591
|
if (filteredEnvelopeItems.length === 0) {
|
|
33569
|
-
return
|
|
33592
|
+
return Promise.resolve({});
|
|
33570
33593
|
}
|
|
33571
33594
|
const filteredEnvelope = createEnvelope(envelope[0], filteredEnvelopeItems);
|
|
33572
33595
|
const recordEnvelopeLoss = (reason) => {
|
|
@@ -33589,7 +33612,7 @@ function createTransport(options, makeRequest, buffer = makePromiseBuffer(option
|
|
|
33589
33612
|
if (error2 === SENTRY_BUFFER_FULL_ERROR) {
|
|
33590
33613
|
DEBUG_BUILD && debug.error("Skipped sending event because buffer is full.");
|
|
33591
33614
|
recordEnvelopeLoss("queue_overflow");
|
|
33592
|
-
return
|
|
33615
|
+
return Promise.resolve({});
|
|
33593
33616
|
} else {
|
|
33594
33617
|
throw error2;
|
|
33595
33618
|
}
|
|
@@ -35059,6 +35082,9 @@ function getFinalOperationName(methodPath) {
|
|
|
35059
35082
|
if (methodPath.includes("models")) {
|
|
35060
35083
|
return "models";
|
|
35061
35084
|
}
|
|
35085
|
+
if (methodPath.includes("chat")) {
|
|
35086
|
+
return "chat";
|
|
35087
|
+
}
|
|
35062
35088
|
return methodPath.split(".").pop() || "unknown";
|
|
35063
35089
|
}
|
|
35064
35090
|
function getSpanOperation2(methodPath) {
|
|
@@ -35086,18 +35112,6 @@ function setTokenUsageAttributes2(span, promptTokens, completionTokens, cachedIn
|
|
|
35086
35112
|
}
|
|
35087
35113
|
}
|
|
35088
35114
|
|
|
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
|
-
|
|
35101
35115
|
// ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/streaming.js
|
|
35102
35116
|
function isErrorEvent3(event, span) {
|
|
35103
35117
|
if ("type" in event && typeof event.type === "string") {
|
|
@@ -35247,6 +35261,18 @@ async function* instrumentStream2(stream, span, recordOutputs) {
|
|
|
35247
35261
|
}
|
|
35248
35262
|
}
|
|
35249
35263
|
|
|
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
|
+
|
|
35250
35276
|
// ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/utils.js
|
|
35251
35277
|
function shouldInstrument2(methodPath) {
|
|
35252
35278
|
return ANTHROPIC_AI_INSTRUMENTED_METHODS.includes(methodPath);
|
|
@@ -35365,19 +35391,8 @@ function addResponseAttributes2(span, response, recordOutputs) {
|
|
|
35365
35391
|
}
|
|
35366
35392
|
addMetadataAttributes(span, response);
|
|
35367
35393
|
}
|
|
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
|
-
}
|
|
35378
35394
|
function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
35379
35395
|
return async function instrumentedMethod(...args) {
|
|
35380
|
-
const finalOptions = options || getRecordingOptionsFromIntegration();
|
|
35381
35396
|
const requestAttributes = extractRequestAttributes2(args, methodPath);
|
|
35382
35397
|
const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
|
|
35383
35398
|
const operationName = getFinalOperationName(methodPath);
|
|
@@ -35391,11 +35406,11 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35391
35406
|
attributes: requestAttributes
|
|
35392
35407
|
}, async (span) => {
|
|
35393
35408
|
try {
|
|
35394
|
-
if (
|
|
35409
|
+
if (options.recordInputs && params) {
|
|
35395
35410
|
addPrivateRequestAttributes(span, params);
|
|
35396
35411
|
}
|
|
35397
35412
|
const result = await originalMethod.apply(context, args);
|
|
35398
|
-
return instrumentStream2(result, span,
|
|
35413
|
+
return instrumentStream2(result, span, options.recordOutputs ?? false);
|
|
35399
35414
|
} catch (error2) {
|
|
35400
35415
|
span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
|
|
35401
35416
|
captureException(error2, {
|
|
@@ -35416,15 +35431,11 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35416
35431
|
name: `${operationName} ${model}`,
|
|
35417
35432
|
op: getSpanOperation2(methodPath),
|
|
35418
35433
|
attributes: requestAttributes
|
|
35419
|
-
},
|
|
35420
|
-
|
|
35421
|
-
|
|
35422
|
-
|
|
35423
|
-
|
|
35424
|
-
const result = await originalMethod.apply(context, args);
|
|
35425
|
-
addResponseAttributes2(span, result, finalOptions.recordOutputs);
|
|
35426
|
-
return result;
|
|
35427
|
-
} catch (error2) {
|
|
35434
|
+
}, (span) => {
|
|
35435
|
+
if (options.recordInputs && params) {
|
|
35436
|
+
addPrivateRequestAttributes(span, params);
|
|
35437
|
+
}
|
|
35438
|
+
return handleCallbackErrors(() => originalMethod.apply(context, args), (error2) => {
|
|
35428
35439
|
captureException(error2, {
|
|
35429
35440
|
mechanism: {
|
|
35430
35441
|
handled: false,
|
|
@@ -35434,8 +35445,7 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35434
35445
|
}
|
|
35435
35446
|
}
|
|
35436
35447
|
});
|
|
35437
|
-
|
|
35438
|
-
}
|
|
35448
|
+
}, () => {}, (result) => addResponseAttributes2(span, result, options.recordOutputs));
|
|
35439
35449
|
});
|
|
35440
35450
|
};
|
|
35441
35451
|
}
|
|
@@ -35457,8 +35467,195 @@ function createDeepProxy2(target, currentPath = "", options) {
|
|
|
35457
35467
|
}
|
|
35458
35468
|
});
|
|
35459
35469
|
}
|
|
35460
|
-
function instrumentAnthropicAiClient(
|
|
35461
|
-
|
|
35470
|
+
function instrumentAnthropicAiClient(anthropicAiClient, options) {
|
|
35471
|
+
const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);
|
|
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);
|
|
35462
35659
|
}
|
|
35463
35660
|
// ../../node_modules/@sentry/core/build/esm/utils/breadcrumb-log-level.js
|
|
35464
35661
|
function getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {
|
|
@@ -35472,18 +35669,47 @@ function getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {
|
|
|
35472
35669
|
return;
|
|
35473
35670
|
}
|
|
35474
35671
|
}
|
|
35475
|
-
// ../../node_modules/@sentry/core/build/esm/utils/
|
|
35476
|
-
function
|
|
35477
|
-
const
|
|
35478
|
-
|
|
35479
|
-
|
|
35480
|
-
|
|
35481
|
-
|
|
35482
|
-
|
|
35483
|
-
|
|
35484
|
-
|
|
35485
|
-
|
|
35486
|
-
|
|
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
|
+
// ../../node_modules/@sentry/core/build/esm/utils/node-stack-trace.js
|
|
35702
|
+
function filenameIsInApp(filename, isNative = false) {
|
|
35703
|
+
const isInternal = isNative || filename && !filename.startsWith("/") && !filename.match(/^[A-Z]:/) && !filename.startsWith(".") && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//);
|
|
35704
|
+
return !isInternal && filename !== undefined && !filename.includes("node_modules/");
|
|
35705
|
+
}
|
|
35706
|
+
function node(getModule) {
|
|
35707
|
+
const FILENAME_MATCH = /^\s*[-]{4,}$/;
|
|
35708
|
+
const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
|
|
35709
|
+
const DATA_URI_MATCH = /at (?:async )?(.+?) \(data:(.*?),/;
|
|
35710
|
+
return (line) => {
|
|
35711
|
+
const dataUriMatch = line.match(DATA_URI_MATCH);
|
|
35712
|
+
if (dataUriMatch) {
|
|
35487
35713
|
return {
|
|
35488
35714
|
filename: `<data:${dataUriMatch[2]}>`,
|
|
35489
35715
|
function: dataUriMatch[1]
|
|
@@ -35599,6 +35825,9 @@ class LRUMap {
|
|
|
35599
35825
|
return values;
|
|
35600
35826
|
}
|
|
35601
35827
|
}
|
|
35828
|
+
// ../../node_modules/@sentry/node-core/build/esm/debug-build.js
|
|
35829
|
+
var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
35830
|
+
|
|
35602
35831
|
// ../../node_modules/@sentry/node-core/build/esm/otel/instrument.js
|
|
35603
35832
|
var import_instrumentation = __toESM(require_src6(), 1);
|
|
35604
35833
|
var INSTRUMENTED = {};
|
|
@@ -35674,9 +35903,6 @@ var import_core40 = __toESM(require_src3(), 1);
|
|
|
35674
35903
|
var import_instrumentation2 = __toESM(require_src6(), 1);
|
|
35675
35904
|
import { subscribe, unsubscribe } from "node:diagnostics_channel";
|
|
35676
35905
|
|
|
35677
|
-
// ../../node_modules/@sentry/node-core/build/esm/debug-build.js
|
|
35678
|
-
var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
35679
|
-
|
|
35680
35906
|
// ../../node_modules/@sentry/node-core/build/esm/utils/getRequestUrl.js
|
|
35681
35907
|
function getRequestUrl(requestOptions) {
|
|
35682
35908
|
const protocol = requestOptions.protocol || "";
|
|
@@ -37490,7 +37716,8 @@ var instrumentSentryHttp = generateInstrumentOnce(`${INTEGRATION_NAME6}.sentry`,
|
|
|
37490
37716
|
var httpIntegration = defineIntegration((options = {}) => {
|
|
37491
37717
|
const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
|
|
37492
37718
|
[401, 404],
|
|
37493
|
-
[
|
|
37719
|
+
[301, 303],
|
|
37720
|
+
[305, 399]
|
|
37494
37721
|
];
|
|
37495
37722
|
return {
|
|
37496
37723
|
name: INTEGRATION_NAME6,
|
|
@@ -37505,20 +37732,27 @@ var httpIntegration = defineIntegration((options = {}) => {
|
|
|
37505
37732
|
processEvent(event) {
|
|
37506
37733
|
if (event.type === "transaction") {
|
|
37507
37734
|
const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
|
|
37508
|
-
if (typeof statusCode === "number"
|
|
37509
|
-
|
|
37510
|
-
|
|
37735
|
+
if (typeof statusCode === "number") {
|
|
37736
|
+
const shouldDrop = shouldFilterStatusCode(statusCode, dropSpansForIncomingRequestStatusCodes);
|
|
37737
|
+
if (shouldDrop) {
|
|
37738
|
+
DEBUG_BUILD2 && debug.log("Dropping transaction due to status code", statusCode);
|
|
37739
|
+
return null;
|
|
37511
37740
|
}
|
|
37512
|
-
const [min, max] = code;
|
|
37513
|
-
return statusCode >= min && statusCode <= max;
|
|
37514
|
-
})) {
|
|
37515
|
-
return null;
|
|
37516
37741
|
}
|
|
37517
37742
|
}
|
|
37518
37743
|
return event;
|
|
37519
37744
|
}
|
|
37520
37745
|
};
|
|
37521
37746
|
});
|
|
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
|
+
}
|
|
37522
37756
|
// ../../node_modules/@sentry/node-core/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js
|
|
37523
37757
|
var import_api5 = __toESM(require_src(), 1);
|
|
37524
37758
|
var import_core44 = __toESM(require_src3(), 1);
|
|
@@ -37871,7 +38105,9 @@ var PLATFORM_NAMES = {
|
|
|
37871
38105
|
freebsd: "FreeBSD",
|
|
37872
38106
|
openbsd: "OpenBSD",
|
|
37873
38107
|
sunos: "SunOS",
|
|
37874
|
-
win32: "Windows"
|
|
38108
|
+
win32: "Windows",
|
|
38109
|
+
ohos: "OpenHarmony",
|
|
38110
|
+
android: "Android"
|
|
37875
38111
|
};
|
|
37876
38112
|
var LINUX_DISTROS = [
|
|
37877
38113
|
{ name: "fedora-release", distros: ["Fedora"] },
|
|
@@ -38306,7 +38542,7 @@ function functionNamesMatch(a, b) {
|
|
|
38306
38542
|
}
|
|
38307
38543
|
|
|
38308
38544
|
// ../../node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js
|
|
38309
|
-
var base64WorkerScript = "
|
|
38545
|
+
var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjE1LjAgKGQxMzY2ZjQpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
|
|
38310
38546
|
function log2(...args) {
|
|
38311
38547
|
debug.log("[LocalVariables]", ...args);
|
|
38312
38548
|
}
|
|
@@ -39578,7 +39814,7 @@ class NodeClient extends ServerRuntimeClient {
|
|
|
39578
39814
|
}
|
|
39579
39815
|
return super.flush(timeout);
|
|
39580
39816
|
}
|
|
39581
|
-
close(timeout) {
|
|
39817
|
+
async close(timeout) {
|
|
39582
39818
|
if (this._clientReportInterval) {
|
|
39583
39819
|
clearInterval(this._clientReportInterval);
|
|
39584
39820
|
}
|
|
@@ -39588,7 +39824,11 @@ class NodeClient extends ServerRuntimeClient {
|
|
|
39588
39824
|
if (this._logOnExitFlushListener) {
|
|
39589
39825
|
process.off("beforeExit", this._logOnExitFlushListener);
|
|
39590
39826
|
}
|
|
39591
|
-
|
|
39827
|
+
const allEventsSent = await super.close(timeout);
|
|
39828
|
+
if (this.traceProvider) {
|
|
39829
|
+
await this.traceProvider.shutdown();
|
|
39830
|
+
}
|
|
39831
|
+
return allEventsSent;
|
|
39592
39832
|
}
|
|
39593
39833
|
startClientReportTracking() {
|
|
39594
39834
|
const clientOptions = this.getOptions();
|
|
@@ -39766,6 +40006,9 @@ function updateScopeFromEnvVariables() {
|
|
|
39766
40006
|
function addOriginToSpan2(span, origin) {
|
|
39767
40007
|
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
|
|
39768
40008
|
}
|
|
40009
|
+
// ../../node_modules/@sentry/node/build/esm/debug-build.js
|
|
40010
|
+
var DEBUG_BUILD4 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
40011
|
+
|
|
39769
40012
|
// ../../node_modules/@sentry/node/build/esm/integrations/http.js
|
|
39770
40013
|
var INTEGRATION_NAME18 = "Http";
|
|
39771
40014
|
var INSTRUMENTATION_NAME2 = "@opentelemetry_sentry-patched/instrumentation-http";
|
|
@@ -39800,7 +40043,8 @@ function _shouldUseOtelHttpInstrumentation(options, clientOptions = {}) {
|
|
|
39800
40043
|
var httpIntegration2 = defineIntegration((options = {}) => {
|
|
39801
40044
|
const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [
|
|
39802
40045
|
[401, 404],
|
|
39803
|
-
[
|
|
40046
|
+
[301, 303],
|
|
40047
|
+
[305, 399]
|
|
39804
40048
|
];
|
|
39805
40049
|
return {
|
|
39806
40050
|
name: INTEGRATION_NAME18,
|
|
@@ -39822,14 +40066,12 @@ var httpIntegration2 = defineIntegration((options = {}) => {
|
|
|
39822
40066
|
processEvent(event) {
|
|
39823
40067
|
if (event.type === "transaction") {
|
|
39824
40068
|
const statusCode = event.contexts?.trace?.data?.["http.response.status_code"];
|
|
39825
|
-
if (typeof statusCode === "number"
|
|
39826
|
-
|
|
39827
|
-
|
|
40069
|
+
if (typeof statusCode === "number") {
|
|
40070
|
+
const shouldDrop = shouldFilterStatusCode2(statusCode, dropSpansForIncomingRequestStatusCodes);
|
|
40071
|
+
if (shouldDrop) {
|
|
40072
|
+
DEBUG_BUILD4 && debug.log("Dropping transaction due to status code", statusCode);
|
|
40073
|
+
return null;
|
|
39828
40074
|
}
|
|
39829
|
-
const [min, max] = code;
|
|
39830
|
-
return statusCode >= min && statusCode <= max;
|
|
39831
|
-
})) {
|
|
39832
|
-
return null;
|
|
39833
40075
|
}
|
|
39834
40076
|
}
|
|
39835
40077
|
return event;
|
|
@@ -39863,6 +40105,15 @@ function getConfigWithDefaults(options = {}) {
|
|
|
39863
40105
|
};
|
|
39864
40106
|
return instrumentationConfig;
|
|
39865
40107
|
}
|
|
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
|
+
}
|
|
39866
40117
|
|
|
39867
40118
|
// ../../node_modules/@sentry/node/build/esm/integrations/node-fetch.js
|
|
39868
40119
|
var import_instrumentation_undici = __toESM(require_src11(), 1);
|
|
@@ -39919,11 +40170,6 @@ function getConfigWithDefaults2(options = {}) {
|
|
|
39919
40170
|
|
|
39920
40171
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/express.js
|
|
39921
40172
|
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
|
|
39927
40173
|
var INTEGRATION_NAME20 = "Express";
|
|
39928
40174
|
function requestHook(span) {
|
|
39929
40175
|
addOriginToSpan2(span, "auto.http.otel.express");
|
|
@@ -42763,11 +43009,219 @@ var _hapiIntegration = () => {
|
|
|
42763
43009
|
};
|
|
42764
43010
|
var hapiIntegration = defineIntegration(_hapiIntegration);
|
|
42765
43011
|
|
|
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
|
+
|
|
42766
43220
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/koa.js
|
|
42767
43221
|
var import_instrumentation_koa = __toESM(require_src28(), 1);
|
|
42768
|
-
var
|
|
42769
|
-
var
|
|
42770
|
-
var instrumentKoa = generateInstrumentOnce(
|
|
43222
|
+
var import_semantic_conventions7 = __toESM(require_src2(), 1);
|
|
43223
|
+
var INTEGRATION_NAME35 = "Koa";
|
|
43224
|
+
var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME35, import_instrumentation_koa.KoaInstrumentation, (options = {}) => {
|
|
42771
43225
|
return {
|
|
42772
43226
|
ignoreLayersType: options.ignoreLayersType,
|
|
42773
43227
|
requestHook(span, info) {
|
|
@@ -42785,7 +43239,7 @@ var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME34, import_instrument
|
|
|
42785
43239
|
DEBUG_BUILD4 && debug.warn("Isolation scope is default isolation scope - skipping setting transactionName");
|
|
42786
43240
|
return;
|
|
42787
43241
|
}
|
|
42788
|
-
const route = attributes[
|
|
43242
|
+
const route = attributes[import_semantic_conventions7.ATTR_HTTP_ROUTE];
|
|
42789
43243
|
const method = info.context?.request?.method?.toUpperCase() || "GET";
|
|
42790
43244
|
if (route) {
|
|
42791
43245
|
getIsolationScope().setTransactionName(`${method} ${route}`);
|
|
@@ -42795,7 +43249,7 @@ var instrumentKoa = generateInstrumentOnce(INTEGRATION_NAME34, import_instrument
|
|
|
42795
43249
|
});
|
|
42796
43250
|
var _koaIntegration = (options = {}) => {
|
|
42797
43251
|
return {
|
|
42798
|
-
name:
|
|
43252
|
+
name: INTEGRATION_NAME35,
|
|
42799
43253
|
setupOnce() {
|
|
42800
43254
|
instrumentKoa(options);
|
|
42801
43255
|
}
|
|
@@ -42805,11 +43259,11 @@ var koaIntegration = defineIntegration(_koaIntegration);
|
|
|
42805
43259
|
|
|
42806
43260
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/connect.js
|
|
42807
43261
|
var import_instrumentation_connect = __toESM(require_src29(), 1);
|
|
42808
|
-
var
|
|
42809
|
-
var instrumentConnect = generateInstrumentOnce(
|
|
43262
|
+
var INTEGRATION_NAME36 = "Connect";
|
|
43263
|
+
var instrumentConnect = generateInstrumentOnce(INTEGRATION_NAME36, () => new import_instrumentation_connect.ConnectInstrumentation);
|
|
42810
43264
|
var _connectIntegration = () => {
|
|
42811
43265
|
return {
|
|
42812
|
-
name:
|
|
43266
|
+
name: INTEGRATION_NAME36,
|
|
42813
43267
|
setupOnce() {
|
|
42814
43268
|
instrumentConnect();
|
|
42815
43269
|
}
|
|
@@ -42827,12 +43281,12 @@ var TEDIUS_INSTRUMENTED_METHODS = new Set([
|
|
|
42827
43281
|
"prepare",
|
|
42828
43282
|
"execute"
|
|
42829
43283
|
]);
|
|
42830
|
-
var
|
|
42831
|
-
var instrumentTedious = generateInstrumentOnce(
|
|
43284
|
+
var INTEGRATION_NAME37 = "Tedious";
|
|
43285
|
+
var instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME37, () => new import_instrumentation_tedious.TediousInstrumentation({}));
|
|
42832
43286
|
var _tediousIntegration = () => {
|
|
42833
43287
|
let instrumentationWrappedCallback;
|
|
42834
43288
|
return {
|
|
42835
|
-
name:
|
|
43289
|
+
name: INTEGRATION_NAME37,
|
|
42836
43290
|
setupOnce() {
|
|
42837
43291
|
const instrumentation = instrumentTedious();
|
|
42838
43292
|
instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
|
|
@@ -42855,12 +43309,12 @@ var tediousIntegration = defineIntegration(_tediousIntegration);
|
|
|
42855
43309
|
|
|
42856
43310
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/genericPool.js
|
|
42857
43311
|
var import_instrumentation_generic_pool = __toESM(require_src31(), 1);
|
|
42858
|
-
var
|
|
42859
|
-
var instrumentGenericPool = generateInstrumentOnce(
|
|
43312
|
+
var INTEGRATION_NAME38 = "GenericPool";
|
|
43313
|
+
var instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME38, () => new import_instrumentation_generic_pool.GenericPoolInstrumentation({}));
|
|
42860
43314
|
var _genericPoolIntegration = () => {
|
|
42861
43315
|
let instrumentationWrappedCallback;
|
|
42862
43316
|
return {
|
|
42863
|
-
name:
|
|
43317
|
+
name: INTEGRATION_NAME38,
|
|
42864
43318
|
setupOnce() {
|
|
42865
43319
|
const instrumentation = instrumentGenericPool();
|
|
42866
43320
|
instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
|
|
@@ -42881,7 +43335,7 @@ var genericPoolIntegration = defineIntegration(_genericPoolIntegration);
|
|
|
42881
43335
|
|
|
42882
43336
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/amqplib.js
|
|
42883
43337
|
var import_instrumentation_amqplib = __toESM(require_src32(), 1);
|
|
42884
|
-
var
|
|
43338
|
+
var INTEGRATION_NAME39 = "Amqplib";
|
|
42885
43339
|
var config = {
|
|
42886
43340
|
consumeEndHook: (span) => {
|
|
42887
43341
|
addOriginToSpan2(span, "auto.amqplib.otel.consumer");
|
|
@@ -42890,10 +43344,10 @@ var config = {
|
|
|
42890
43344
|
addOriginToSpan2(span, "auto.amqplib.otel.publisher");
|
|
42891
43345
|
}
|
|
42892
43346
|
};
|
|
42893
|
-
var instrumentAmqplib = generateInstrumentOnce(
|
|
43347
|
+
var instrumentAmqplib = generateInstrumentOnce(INTEGRATION_NAME39, () => new import_instrumentation_amqplib.AmqplibInstrumentation(config));
|
|
42894
43348
|
var _amqplibIntegration = () => {
|
|
42895
43349
|
return {
|
|
42896
|
-
name:
|
|
43350
|
+
name: INTEGRATION_NAME39,
|
|
42897
43351
|
setupOnce() {
|
|
42898
43352
|
instrumentAmqplib();
|
|
42899
43353
|
}
|
|
@@ -42902,10 +43356,10 @@ var _amqplibIntegration = () => {
|
|
|
42902
43356
|
var amqplibIntegration = defineIntegration(_amqplibIntegration);
|
|
42903
43357
|
|
|
42904
43358
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/constants.js
|
|
42905
|
-
var
|
|
43359
|
+
var INTEGRATION_NAME40 = "VercelAI";
|
|
42906
43360
|
|
|
42907
43361
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/instrumentation.js
|
|
42908
|
-
var
|
|
43362
|
+
var import_instrumentation13 = __toESM(require_src6(), 1);
|
|
42909
43363
|
var INSTRUMENTED_METHODS2 = [
|
|
42910
43364
|
"generateText",
|
|
42911
43365
|
"streamText",
|
|
@@ -42972,7 +43426,7 @@ function determineRecordingSettings(integrationRecordingOptions, methodTelemetry
|
|
|
42972
43426
|
return { recordInputs, recordOutputs };
|
|
42973
43427
|
}
|
|
42974
43428
|
|
|
42975
|
-
class SentryVercelAiInstrumentation extends
|
|
43429
|
+
class SentryVercelAiInstrumentation extends import_instrumentation13.InstrumentationBase {
|
|
42976
43430
|
__init() {
|
|
42977
43431
|
this._isPatched = false;
|
|
42978
43432
|
}
|
|
@@ -42985,7 +43439,7 @@ class SentryVercelAiInstrumentation extends import_instrumentation11.Instrumenta
|
|
|
42985
43439
|
SentryVercelAiInstrumentation.prototype.__init2.call(this);
|
|
42986
43440
|
}
|
|
42987
43441
|
init() {
|
|
42988
|
-
const module = new
|
|
43442
|
+
const module = new import_instrumentation13.InstrumentationNodeModuleDefinition("ai", [">=3.0.0 <6"], this._patch.bind(this));
|
|
42989
43443
|
return module;
|
|
42990
43444
|
}
|
|
42991
43445
|
callWhenPatched(callback) {
|
|
@@ -42999,36 +43453,32 @@ class SentryVercelAiInstrumentation extends import_instrumentation11.Instrumenta
|
|
|
42999
43453
|
this._isPatched = true;
|
|
43000
43454
|
this._callbacks.forEach((callback) => callback());
|
|
43001
43455
|
this._callbacks = [];
|
|
43002
|
-
|
|
43003
|
-
return (
|
|
43004
|
-
|
|
43005
|
-
|
|
43006
|
-
|
|
43007
|
-
|
|
43008
|
-
|
|
43009
|
-
|
|
43010
|
-
|
|
43011
|
-
|
|
43012
|
-
|
|
43013
|
-
|
|
43014
|
-
|
|
43015
|
-
|
|
43016
|
-
|
|
43017
|
-
|
|
43018
|
-
|
|
43019
|
-
|
|
43020
|
-
|
|
43021
|
-
|
|
43022
|
-
}
|
|
43023
|
-
|
|
43024
|
-
|
|
43025
|
-
}
|
|
43026
|
-
|
|
43027
|
-
|
|
43028
|
-
}
|
|
43029
|
-
});
|
|
43030
|
-
};
|
|
43031
|
-
}
|
|
43456
|
+
const generatePatch = (originalMethod) => {
|
|
43457
|
+
return new Proxy(originalMethod, {
|
|
43458
|
+
apply: (target, thisArg, args) => {
|
|
43459
|
+
const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
|
|
43460
|
+
const isEnabled3 = existingExperimentalTelemetry.isEnabled;
|
|
43461
|
+
const client = getClient();
|
|
43462
|
+
const integration = client?.getIntegrationByName(INTEGRATION_NAME40);
|
|
43463
|
+
const integrationOptions = integration?.options;
|
|
43464
|
+
const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;
|
|
43465
|
+
const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOptions, existingExperimentalTelemetry, isEnabled3, shouldRecordInputsAndOutputs);
|
|
43466
|
+
args[0].experimental_telemetry = {
|
|
43467
|
+
...existingExperimentalTelemetry,
|
|
43468
|
+
isEnabled: isEnabled3 !== undefined ? isEnabled3 : true,
|
|
43469
|
+
recordInputs,
|
|
43470
|
+
recordOutputs
|
|
43471
|
+
};
|
|
43472
|
+
return handleCallbackErrors(() => Reflect.apply(target, thisArg, args), (error2) => {
|
|
43473
|
+
if (error2 && typeof error2 === "object") {
|
|
43474
|
+
addNonEnumerableProperty(error2, "_sentry_active_span", getActiveSpan());
|
|
43475
|
+
}
|
|
43476
|
+
}, () => {}, (result) => {
|
|
43477
|
+
checkResultForToolErrors(result);
|
|
43478
|
+
});
|
|
43479
|
+
}
|
|
43480
|
+
});
|
|
43481
|
+
};
|
|
43032
43482
|
if (Object.prototype.toString.call(moduleExports) === "[object Module]") {
|
|
43033
43483
|
for (const method of INSTRUMENTED_METHODS2) {
|
|
43034
43484
|
moduleExports[method] = generatePatch(moduleExports[method]);
|
|
@@ -43045,7 +43495,7 @@ class SentryVercelAiInstrumentation extends import_instrumentation11.Instrumenta
|
|
|
43045
43495
|
}
|
|
43046
43496
|
|
|
43047
43497
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/vercelai/index.js
|
|
43048
|
-
var instrumentVercelAi = generateInstrumentOnce(
|
|
43498
|
+
var instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME40, () => new SentryVercelAiInstrumentation({}));
|
|
43049
43499
|
function shouldForceIntegration(client) {
|
|
43050
43500
|
const modules = client.getIntegrationByName("Modules");
|
|
43051
43501
|
return !!modules?.getModules?.()?.ai;
|
|
@@ -43053,7 +43503,7 @@ function shouldForceIntegration(client) {
|
|
|
43053
43503
|
var _vercelAIIntegration = (options = {}) => {
|
|
43054
43504
|
let instrumentation;
|
|
43055
43505
|
return {
|
|
43056
|
-
name:
|
|
43506
|
+
name: INTEGRATION_NAME40,
|
|
43057
43507
|
options,
|
|
43058
43508
|
setupOnce() {
|
|
43059
43509
|
instrumentation = instrumentVercelAi();
|
|
@@ -43070,7 +43520,7 @@ var _vercelAIIntegration = (options = {}) => {
|
|
|
43070
43520
|
};
|
|
43071
43521
|
var vercelAIIntegration = defineIntegration(_vercelAIIntegration);
|
|
43072
43522
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/openai/instrumentation.js
|
|
43073
|
-
var
|
|
43523
|
+
var import_instrumentation15 = __toESM(require_src6(), 1);
|
|
43074
43524
|
var supportedVersions = [">=4.0.0 <6"];
|
|
43075
43525
|
function determineRecordingSettings2(integrationOptions, defaultEnabled) {
|
|
43076
43526
|
const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;
|
|
@@ -43078,22 +43528,22 @@ function determineRecordingSettings2(integrationOptions, defaultEnabled) {
|
|
|
43078
43528
|
return { recordInputs, recordOutputs };
|
|
43079
43529
|
}
|
|
43080
43530
|
|
|
43081
|
-
class SentryOpenAiInstrumentation extends
|
|
43531
|
+
class SentryOpenAiInstrumentation extends import_instrumentation15.InstrumentationBase {
|
|
43082
43532
|
constructor(config2 = {}) {
|
|
43083
43533
|
super("@sentry/instrumentation-openai", SDK_VERSION, config2);
|
|
43084
43534
|
}
|
|
43085
43535
|
init() {
|
|
43086
|
-
const module = new
|
|
43536
|
+
const module = new import_instrumentation15.InstrumentationNodeModuleDefinition("openai", supportedVersions, this._patch.bind(this));
|
|
43087
43537
|
return module;
|
|
43088
43538
|
}
|
|
43089
43539
|
_patch(exports) {
|
|
43090
43540
|
const Original = exports.OpenAI;
|
|
43091
43541
|
const WrappedOpenAI = function(...args) {
|
|
43092
43542
|
const instance = Reflect.construct(Original, args);
|
|
43093
|
-
const
|
|
43094
|
-
const integration =
|
|
43543
|
+
const client = getClient();
|
|
43544
|
+
const integration = client?.getIntegrationByName(OPENAI_INTEGRATION_NAME);
|
|
43095
43545
|
const integrationOpts = integration?.options;
|
|
43096
|
-
const defaultPii = Boolean(
|
|
43546
|
+
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
|
|
43097
43547
|
const { recordInputs, recordOutputs } = determineRecordingSettings2(integrationOpts, defaultPii);
|
|
43098
43548
|
return instrumentOpenAiClient(instance, {
|
|
43099
43549
|
recordInputs,
|
|
@@ -43150,31 +43600,26 @@ var _openAiIntegration = (options = {}) => {
|
|
|
43150
43600
|
var openAIIntegration = defineIntegration(_openAiIntegration);
|
|
43151
43601
|
|
|
43152
43602
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/anthropic-ai/instrumentation.js
|
|
43153
|
-
var
|
|
43603
|
+
var import_instrumentation17 = __toESM(require_src6(), 1);
|
|
43154
43604
|
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
|
-
}
|
|
43160
43605
|
|
|
43161
|
-
class SentryAnthropicAiInstrumentation extends
|
|
43606
|
+
class SentryAnthropicAiInstrumentation extends import_instrumentation17.InstrumentationBase {
|
|
43162
43607
|
constructor(config2 = {}) {
|
|
43163
43608
|
super("@sentry/instrumentation-anthropic-ai", SDK_VERSION, config2);
|
|
43164
43609
|
}
|
|
43165
43610
|
init() {
|
|
43166
|
-
const module = new
|
|
43611
|
+
const module = new import_instrumentation17.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk", supportedVersions2, this._patch.bind(this));
|
|
43167
43612
|
return module;
|
|
43168
43613
|
}
|
|
43169
43614
|
_patch(exports) {
|
|
43170
43615
|
const Original = exports.Anthropic;
|
|
43616
|
+
const config2 = this.getConfig();
|
|
43171
43617
|
const WrappedAnthropic = function(...args) {
|
|
43172
43618
|
const instance = Reflect.construct(Original, args);
|
|
43173
|
-
const
|
|
43174
|
-
const
|
|
43175
|
-
const
|
|
43176
|
-
const
|
|
43177
|
-
const { recordInputs, recordOutputs } = determineRecordingSettings3(integrationOpts, defaultPii);
|
|
43619
|
+
const client = getClient();
|
|
43620
|
+
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
|
|
43621
|
+
const recordInputs = config2.recordInputs ?? defaultPii;
|
|
43622
|
+
const recordOutputs = config2.recordOutputs ?? defaultPii;
|
|
43178
43623
|
return instrumentAnthropicAiClient(instance, {
|
|
43179
43624
|
recordInputs,
|
|
43180
43625
|
recordOutputs
|
|
@@ -43217,25 +43662,84 @@ class SentryAnthropicAiInstrumentation extends import_instrumentation15.Instrume
|
|
|
43217
43662
|
}
|
|
43218
43663
|
|
|
43219
43664
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/anthropic-ai/index.js
|
|
43220
|
-
var instrumentAnthropicAi = generateInstrumentOnce(ANTHROPIC_AI_INTEGRATION_NAME, () => new SentryAnthropicAiInstrumentation(
|
|
43665
|
+
var instrumentAnthropicAi = generateInstrumentOnce(ANTHROPIC_AI_INTEGRATION_NAME, (options) => new SentryAnthropicAiInstrumentation(options));
|
|
43221
43666
|
var _anthropicAIIntegration = (options = {}) => {
|
|
43222
43667
|
return {
|
|
43223
43668
|
name: ANTHROPIC_AI_INTEGRATION_NAME,
|
|
43224
43669
|
options,
|
|
43225
43670
|
setupOnce() {
|
|
43226
|
-
instrumentAnthropicAi();
|
|
43671
|
+
instrumentAnthropicAi(options);
|
|
43227
43672
|
}
|
|
43228
43673
|
};
|
|
43229
43674
|
};
|
|
43230
43675
|
var anthropicAIIntegration = defineIntegration(_anthropicAIIntegration);
|
|
43231
43676
|
|
|
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
|
+
|
|
43232
43736
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js
|
|
43233
|
-
var
|
|
43737
|
+
var import_instrumentation22 = __toESM(require_src6(), 1);
|
|
43234
43738
|
|
|
43235
43739
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/otel/patches/firestore.js
|
|
43236
|
-
var
|
|
43237
|
-
var
|
|
43238
|
-
var
|
|
43740
|
+
var import_api19 = __toESM(require_src(), 1);
|
|
43741
|
+
var import_instrumentation21 = __toESM(require_src6(), 1);
|
|
43742
|
+
var import_semantic_conventions8 = __toESM(require_src2(), 1);
|
|
43239
43743
|
import * as net2 from "node:net";
|
|
43240
43744
|
function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config2) {
|
|
43241
43745
|
const defaultFirestoreSpanCreationHook = () => {};
|
|
@@ -43243,15 +43747,15 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
|
|
|
43243
43747
|
const configFirestoreSpanCreationHook = config2.firestoreSpanCreationHook;
|
|
43244
43748
|
if (typeof configFirestoreSpanCreationHook === "function") {
|
|
43245
43749
|
firestoreSpanCreationHook = (span) => {
|
|
43246
|
-
|
|
43750
|
+
import_instrumentation21.safeExecuteInTheMiddle(() => configFirestoreSpanCreationHook(span), (error2) => {
|
|
43247
43751
|
if (!error2) {
|
|
43248
43752
|
return;
|
|
43249
43753
|
}
|
|
43250
|
-
|
|
43754
|
+
import_api19.diag.error(error2?.message);
|
|
43251
43755
|
}, true);
|
|
43252
43756
|
};
|
|
43253
43757
|
}
|
|
43254
|
-
const moduleFirestoreCJS = new
|
|
43758
|
+
const moduleFirestoreCJS = new import_instrumentation21.InstrumentationNodeModuleDefinition("@firebase/firestore", firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook));
|
|
43255
43759
|
const files = [
|
|
43256
43760
|
"@firebase/firestore/dist/lite/index.node.cjs.js",
|
|
43257
43761
|
"@firebase/firestore/dist/lite/index.node.mjs.js",
|
|
@@ -43259,7 +43763,7 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
|
|
|
43259
43763
|
"@firebase/firestore/dist/lite/index.cjs.js"
|
|
43260
43764
|
];
|
|
43261
43765
|
for (const file of files) {
|
|
43262
|
-
moduleFirestoreCJS.files.push(new
|
|
43766
|
+
moduleFirestoreCJS.files.push(new import_instrumentation21.InstrumentationNodeModuleFile(file, firestoreSupportedVersions, (moduleExports) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook), (moduleExports) => unwrapMethods(moduleExports, unwrap)));
|
|
43263
43767
|
}
|
|
43264
43768
|
return moduleFirestoreCJS;
|
|
43265
43769
|
}
|
|
@@ -43273,7 +43777,7 @@ function wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationH
|
|
|
43273
43777
|
}
|
|
43274
43778
|
function unwrapMethods(moduleExports, unwrap) {
|
|
43275
43779
|
for (const method of ["addDoc", "getDocs", "setDoc", "deleteDoc"]) {
|
|
43276
|
-
if (
|
|
43780
|
+
if (import_instrumentation21.isWrapped(moduleExports[method])) {
|
|
43277
43781
|
unwrap(moduleExports, method);
|
|
43278
43782
|
}
|
|
43279
43783
|
}
|
|
@@ -43324,8 +43828,8 @@ function patchSetDoc(tracer, firestoreSpanCreationHook) {
|
|
|
43324
43828
|
};
|
|
43325
43829
|
}
|
|
43326
43830
|
function executeContextWithSpan(span, callback) {
|
|
43327
|
-
return
|
|
43328
|
-
return
|
|
43831
|
+
return import_api19.context.with(import_api19.trace.setSpan(import_api19.context.active(), span), () => {
|
|
43832
|
+
return import_instrumentation21.safeExecuteInTheMiddle(() => {
|
|
43329
43833
|
return callback();
|
|
43330
43834
|
}, (err) => {
|
|
43331
43835
|
if (err) {
|
|
@@ -43336,9 +43840,9 @@ function executeContextWithSpan(span, callback) {
|
|
|
43336
43840
|
});
|
|
43337
43841
|
}
|
|
43338
43842
|
function startDBSpan(tracer, spanName, reference) {
|
|
43339
|
-
const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind:
|
|
43843
|
+
const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind: import_api19.SpanKind.CLIENT });
|
|
43340
43844
|
addAttributes(span, reference);
|
|
43341
|
-
span.setAttribute(
|
|
43845
|
+
span.setAttribute(import_semantic_conventions8.ATTR_DB_OPERATION_NAME, spanName);
|
|
43342
43846
|
return span;
|
|
43343
43847
|
}
|
|
43344
43848
|
function getPortAndAddress(settings) {
|
|
@@ -43380,9 +43884,9 @@ function addAttributes(span, reference) {
|
|
|
43380
43884
|
const json = reference.firestore.toJSON() || {};
|
|
43381
43885
|
const settings = json.settings || {};
|
|
43382
43886
|
const attributes = {
|
|
43383
|
-
[
|
|
43384
|
-
[
|
|
43385
|
-
[
|
|
43887
|
+
[import_semantic_conventions8.ATTR_DB_COLLECTION_NAME]: reference.path,
|
|
43888
|
+
[import_semantic_conventions8.ATTR_DB_NAMESPACE]: firestoreApp.name,
|
|
43889
|
+
[import_semantic_conventions8.ATTR_DB_SYSTEM_NAME]: "firebase.firestore",
|
|
43386
43890
|
"firebase.firestore.type": reference.type,
|
|
43387
43891
|
"firebase.firestore.options.projectId": firestoreOptions.projectId,
|
|
43388
43892
|
"firebase.firestore.options.appId": firestoreOptions.appId,
|
|
@@ -43391,10 +43895,10 @@ function addAttributes(span, reference) {
|
|
|
43391
43895
|
};
|
|
43392
43896
|
const { address, port } = getPortAndAddress(settings);
|
|
43393
43897
|
if (address) {
|
|
43394
|
-
attributes[
|
|
43898
|
+
attributes[import_semantic_conventions8.ATTR_SERVER_ADDRESS] = address;
|
|
43395
43899
|
}
|
|
43396
43900
|
if (port) {
|
|
43397
|
-
attributes[
|
|
43901
|
+
attributes[import_semantic_conventions8.ATTR_SERVER_PORT] = port;
|
|
43398
43902
|
}
|
|
43399
43903
|
span.setAttributes(attributes);
|
|
43400
43904
|
}
|
|
@@ -43403,7 +43907,7 @@ function addAttributes(span, reference) {
|
|
|
43403
43907
|
var DefaultFirebaseInstrumentationConfig = {};
|
|
43404
43908
|
var firestoreSupportedVersions = [">=3.0.0 <5"];
|
|
43405
43909
|
|
|
43406
|
-
class FirebaseInstrumentation extends
|
|
43910
|
+
class FirebaseInstrumentation extends import_instrumentation22.InstrumentationBase {
|
|
43407
43911
|
constructor(config2 = DefaultFirebaseInstrumentationConfig) {
|
|
43408
43912
|
super("@sentry/instrumentation-firebase", SDK_VERSION, config2);
|
|
43409
43913
|
}
|
|
@@ -43418,17 +43922,17 @@ class FirebaseInstrumentation extends import_instrumentation18.InstrumentationBa
|
|
|
43418
43922
|
}
|
|
43419
43923
|
|
|
43420
43924
|
// ../../node_modules/@sentry/node/build/esm/integrations/tracing/firebase/firebase.js
|
|
43421
|
-
var
|
|
43925
|
+
var INTEGRATION_NAME41 = "Firebase";
|
|
43422
43926
|
var config2 = {
|
|
43423
43927
|
firestoreSpanCreationHook: (span) => {
|
|
43424
43928
|
addOriginToSpan2(span, "auto.firebase.otel.firestore");
|
|
43425
43929
|
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, "db.query");
|
|
43426
43930
|
}
|
|
43427
43931
|
};
|
|
43428
|
-
var instrumentFirebase = generateInstrumentOnce(
|
|
43932
|
+
var instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME41, () => new FirebaseInstrumentation(config2));
|
|
43429
43933
|
var _firebaseIntegration = () => {
|
|
43430
43934
|
return {
|
|
43431
|
-
name:
|
|
43935
|
+
name: INTEGRATION_NAME41,
|
|
43432
43936
|
setupOnce() {
|
|
43433
43937
|
instrumentFirebase();
|
|
43434
43938
|
}
|
|
@@ -43442,6 +43946,7 @@ function getAutoPerformanceIntegrations() {
|
|
|
43442
43946
|
expressIntegration(),
|
|
43443
43947
|
fastifyIntegration(),
|
|
43444
43948
|
graphqlIntegration(),
|
|
43949
|
+
honoIntegration(),
|
|
43445
43950
|
mongoIntegration(),
|
|
43446
43951
|
mongooseIntegration(),
|
|
43447
43952
|
mysqlIntegration(),
|
|
@@ -43461,15 +43966,16 @@ function getAutoPerformanceIntegrations() {
|
|
|
43461
43966
|
openAIIntegration(),
|
|
43462
43967
|
postgresJsIntegration(),
|
|
43463
43968
|
firebaseIntegration(),
|
|
43464
|
-
anthropicAIIntegration()
|
|
43969
|
+
anthropicAIIntegration(),
|
|
43970
|
+
googleGenAIIntegration()
|
|
43465
43971
|
];
|
|
43466
43972
|
}
|
|
43467
43973
|
|
|
43468
43974
|
// ../../node_modules/@sentry/node/build/esm/sdk/initOtel.js
|
|
43469
|
-
var
|
|
43975
|
+
var import_api20 = __toESM(require_src(), 1);
|
|
43470
43976
|
var import_resources = __toESM(require_src8(), 1);
|
|
43471
43977
|
var import_sdk_trace_base2 = __toESM(require_src9(), 1);
|
|
43472
|
-
var
|
|
43978
|
+
var import_semantic_conventions9 = __toESM(require_src2(), 1);
|
|
43473
43979
|
var MAX_MAX_SPAN_WAIT_DURATION = 1e6;
|
|
43474
43980
|
function initOpenTelemetry(client, options = {}) {
|
|
43475
43981
|
if (client.getOptions().debug) {
|
|
@@ -43482,9 +43988,9 @@ function setupOtel(client, options = {}) {
|
|
|
43482
43988
|
const provider = new import_sdk_trace_base2.BasicTracerProvider({
|
|
43483
43989
|
sampler: new SentrySampler(client),
|
|
43484
43990
|
resource: import_resources.defaultResource().merge(import_resources.resourceFromAttributes({
|
|
43485
|
-
[
|
|
43486
|
-
[
|
|
43487
|
-
[
|
|
43991
|
+
[import_semantic_conventions9.ATTR_SERVICE_NAME]: "node",
|
|
43992
|
+
[import_semantic_conventions9.SEMRESATTRS_SERVICE_NAMESPACE]: "sentry",
|
|
43993
|
+
[import_semantic_conventions9.ATTR_SERVICE_VERSION]: SDK_VERSION
|
|
43488
43994
|
})),
|
|
43489
43995
|
forceFlushTimeoutMillis: 500,
|
|
43490
43996
|
spanProcessors: [
|
|
@@ -43494,9 +44000,9 @@ function setupOtel(client, options = {}) {
|
|
|
43494
44000
|
...options.spanProcessors || []
|
|
43495
44001
|
]
|
|
43496
44002
|
});
|
|
43497
|
-
|
|
43498
|
-
|
|
43499
|
-
|
|
44003
|
+
import_api20.trace.setGlobalTracerProvider(provider);
|
|
44004
|
+
import_api20.propagation.setGlobalPropagator(new SentryPropagator);
|
|
44005
|
+
import_api20.context.setGlobalContextManager(new SentryContextManager);
|
|
43500
44006
|
return provider;
|
|
43501
44007
|
}
|
|
43502
44008
|
function _clampSpanProcessorTimeout(maxSpanWaitDuration) {
|
|
@@ -43543,8 +44049,278 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
|
|
|
43543
44049
|
}
|
|
43544
44050
|
// src/index.ts
|
|
43545
44051
|
import sqlPlugin, { createDatabaseAdapter, DatabaseMigrationService } from "@elizaos/plugin-sql";
|
|
43546
|
-
|
|
44052
|
+
|
|
44053
|
+
// src/managers/PluginLoader.ts
|
|
44054
|
+
import { logger as logger31 } from "@elizaos/core";
|
|
44055
|
+
|
|
44056
|
+
// src/managers/PluginInstaller.ts
|
|
44057
|
+
import { logger as logger30 } from "@elizaos/core";
|
|
44058
|
+
|
|
44059
|
+
class PluginInstaller {
|
|
44060
|
+
attempted = new Set;
|
|
44061
|
+
async tryInstall(pluginName) {
|
|
44062
|
+
try {
|
|
44063
|
+
if (!this.isAllowed()) {
|
|
44064
|
+
logger30.debug(`Auto-install disabled or not allowed in this environment. Skipping install for ${pluginName}.`);
|
|
44065
|
+
return false;
|
|
44066
|
+
}
|
|
44067
|
+
if (this.attempted.has(pluginName)) {
|
|
44068
|
+
logger30.debug(`Auto-install already attempted for ${pluginName}. Skipping.`);
|
|
44069
|
+
return false;
|
|
44070
|
+
}
|
|
44071
|
+
this.attempted.add(pluginName);
|
|
44072
|
+
try {
|
|
44073
|
+
const check = Bun.spawn(["bun", "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
44074
|
+
const code = await check.exited;
|
|
44075
|
+
if (code !== 0) {
|
|
44076
|
+
logger30.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
44077
|
+
return false;
|
|
44078
|
+
}
|
|
44079
|
+
} catch {
|
|
44080
|
+
logger30.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
44081
|
+
return false;
|
|
44082
|
+
}
|
|
44083
|
+
logger30.info(`Attempting to auto-install missing plugin: ${pluginName}`);
|
|
44084
|
+
const install = Bun.spawn(["bun", "add", pluginName], {
|
|
44085
|
+
cwd: process.cwd(),
|
|
44086
|
+
env: process.env,
|
|
44087
|
+
stdout: "inherit",
|
|
44088
|
+
stderr: "inherit"
|
|
44089
|
+
});
|
|
44090
|
+
const exit = await install.exited;
|
|
44091
|
+
if (exit === 0) {
|
|
44092
|
+
logger30.info(`Successfully installed ${pluginName}. Retrying import...`);
|
|
44093
|
+
return true;
|
|
44094
|
+
}
|
|
44095
|
+
logger30.error(`bun add ${pluginName} failed with exit code ${exit}. Please install manually.`);
|
|
44096
|
+
return false;
|
|
44097
|
+
} catch (e) {
|
|
44098
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
44099
|
+
logger30.error(`Unexpected error during auto-install of ${pluginName}: ${message}`);
|
|
44100
|
+
return false;
|
|
44101
|
+
}
|
|
44102
|
+
}
|
|
44103
|
+
isAllowed() {
|
|
44104
|
+
if (process.env.ELIZA_NO_AUTO_INSTALL === "true")
|
|
44105
|
+
return false;
|
|
44106
|
+
if (process.env.ELIZA_NO_PLUGIN_AUTO_INSTALL === "true")
|
|
44107
|
+
return false;
|
|
44108
|
+
if (process.env.CI === "true")
|
|
44109
|
+
return false;
|
|
44110
|
+
if (process.env.ELIZA_TEST_MODE === "true")
|
|
44111
|
+
return false;
|
|
44112
|
+
if (false)
|
|
44113
|
+
;
|
|
44114
|
+
return true;
|
|
44115
|
+
}
|
|
44116
|
+
}
|
|
44117
|
+
var pluginInstaller = new PluginInstaller;
|
|
44118
|
+
|
|
44119
|
+
// src/managers/PluginLoader.ts
|
|
44120
|
+
class PluginLoader {
|
|
44121
|
+
isValidPluginShape(obj) {
|
|
44122
|
+
if (!obj || typeof obj !== "object" || !obj.name) {
|
|
44123
|
+
return false;
|
|
44124
|
+
}
|
|
44125
|
+
return !!(obj.init || obj.services || obj.providers || obj.actions || obj.evaluators || obj.description);
|
|
44126
|
+
}
|
|
44127
|
+
validatePlugin(plugin) {
|
|
44128
|
+
const errors = [];
|
|
44129
|
+
if (!plugin) {
|
|
44130
|
+
errors.push("Plugin is null or undefined");
|
|
44131
|
+
return { isValid: false, errors };
|
|
44132
|
+
}
|
|
44133
|
+
if (!plugin.name) {
|
|
44134
|
+
errors.push("Plugin must have a name");
|
|
44135
|
+
}
|
|
44136
|
+
if (plugin.actions) {
|
|
44137
|
+
if (!Array.isArray(plugin.actions)) {
|
|
44138
|
+
errors.push("Plugin actions must be an array");
|
|
44139
|
+
} else {
|
|
44140
|
+
const invalidActions = plugin.actions.filter((a) => typeof a !== "object" || !a);
|
|
44141
|
+
if (invalidActions.length > 0) {
|
|
44142
|
+
errors.push("Plugin actions must be an array of action objects");
|
|
44143
|
+
}
|
|
44144
|
+
}
|
|
44145
|
+
}
|
|
44146
|
+
if (plugin.services) {
|
|
44147
|
+
if (!Array.isArray(plugin.services)) {
|
|
44148
|
+
errors.push("Plugin services must be an array");
|
|
44149
|
+
} else {
|
|
44150
|
+
const invalidServices = plugin.services.filter((s) => typeof s !== "function" && (typeof s !== "object" || !s));
|
|
44151
|
+
if (invalidServices.length > 0) {
|
|
44152
|
+
errors.push("Plugin services must be an array of service classes or objects");
|
|
44153
|
+
}
|
|
44154
|
+
}
|
|
44155
|
+
}
|
|
44156
|
+
if (plugin.providers && !Array.isArray(plugin.providers)) {
|
|
44157
|
+
errors.push("Plugin providers must be an array");
|
|
44158
|
+
}
|
|
44159
|
+
if (plugin.evaluators && !Array.isArray(plugin.evaluators)) {
|
|
44160
|
+
errors.push("Plugin evaluators must be an array");
|
|
44161
|
+
}
|
|
44162
|
+
return {
|
|
44163
|
+
isValid: errors.length === 0,
|
|
44164
|
+
errors
|
|
44165
|
+
};
|
|
44166
|
+
}
|
|
44167
|
+
async loadAndPreparePlugin(pluginName) {
|
|
44168
|
+
try {
|
|
44169
|
+
let pluginModule;
|
|
44170
|
+
try {
|
|
44171
|
+
pluginModule = await import(pluginName);
|
|
44172
|
+
} catch (error2) {
|
|
44173
|
+
logger31.error(`Failed to load plugin ${pluginName}: ${error2}`);
|
|
44174
|
+
const attempted = await pluginInstaller.tryInstall(pluginName);
|
|
44175
|
+
if (!attempted) {
|
|
44176
|
+
return null;
|
|
44177
|
+
}
|
|
44178
|
+
try {
|
|
44179
|
+
pluginModule = await import(pluginName);
|
|
44180
|
+
} catch (secondError) {
|
|
44181
|
+
logger31.error(`Auto-install attempted for ${pluginName} but import still failed: ${secondError}`);
|
|
44182
|
+
return null;
|
|
44183
|
+
}
|
|
44184
|
+
}
|
|
44185
|
+
if (!pluginModule) {
|
|
44186
|
+
logger31.error(`Failed to load module for plugin ${pluginName}.`);
|
|
44187
|
+
return null;
|
|
44188
|
+
}
|
|
44189
|
+
const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match3) => match3[1].toUpperCase())}Plugin`;
|
|
44190
|
+
const exportsToCheck = [
|
|
44191
|
+
pluginModule[expectedFunctionName],
|
|
44192
|
+
pluginModule.default,
|
|
44193
|
+
...Object.values(pluginModule)
|
|
44194
|
+
];
|
|
44195
|
+
for (const potentialPlugin of exportsToCheck) {
|
|
44196
|
+
if (this.isValidPluginShape(potentialPlugin)) {
|
|
44197
|
+
return potentialPlugin;
|
|
44198
|
+
}
|
|
44199
|
+
if (typeof potentialPlugin === "function" && potentialPlugin.length === 0) {
|
|
44200
|
+
try {
|
|
44201
|
+
const produced = potentialPlugin();
|
|
44202
|
+
if (this.isValidPluginShape(produced)) {
|
|
44203
|
+
return produced;
|
|
44204
|
+
}
|
|
44205
|
+
} catch (err) {
|
|
44206
|
+
logger31.debug(`Factory export threw for ${pluginName}: ${err}`);
|
|
44207
|
+
}
|
|
44208
|
+
}
|
|
44209
|
+
}
|
|
44210
|
+
logger31.warn(`Could not find a valid plugin export in ${pluginName}.`);
|
|
44211
|
+
return null;
|
|
44212
|
+
} catch (error2) {
|
|
44213
|
+
logger31.error(`Error loading plugin ${pluginName}: ${error2}`);
|
|
44214
|
+
return null;
|
|
44215
|
+
}
|
|
44216
|
+
}
|
|
44217
|
+
resolvePluginDependencies(availablePlugins, isTestMode = false) {
|
|
44218
|
+
const resolutionOrder = [];
|
|
44219
|
+
const visited = new Set;
|
|
44220
|
+
const visiting = new Set;
|
|
44221
|
+
function visit2(pluginName) {
|
|
44222
|
+
if (!availablePlugins.has(pluginName)) {
|
|
44223
|
+
logger31.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
|
|
44224
|
+
return;
|
|
44225
|
+
}
|
|
44226
|
+
if (visited.has(pluginName))
|
|
44227
|
+
return;
|
|
44228
|
+
if (visiting.has(pluginName)) {
|
|
44229
|
+
logger31.error(`Circular dependency detected involving plugin: ${pluginName}`);
|
|
44230
|
+
return;
|
|
44231
|
+
}
|
|
44232
|
+
visiting.add(pluginName);
|
|
44233
|
+
const plugin = availablePlugins.get(pluginName);
|
|
44234
|
+
if (plugin) {
|
|
44235
|
+
const deps = [...plugin.dependencies || []];
|
|
44236
|
+
if (isTestMode) {
|
|
44237
|
+
deps.push(...plugin.testDependencies || []);
|
|
44238
|
+
}
|
|
44239
|
+
for (const dep of deps) {
|
|
44240
|
+
visit2(dep);
|
|
44241
|
+
}
|
|
44242
|
+
}
|
|
44243
|
+
visiting.delete(pluginName);
|
|
44244
|
+
visited.add(pluginName);
|
|
44245
|
+
resolutionOrder.push(pluginName);
|
|
44246
|
+
}
|
|
44247
|
+
for (const name of availablePlugins.keys()) {
|
|
44248
|
+
if (!visited.has(name)) {
|
|
44249
|
+
visit2(name);
|
|
44250
|
+
}
|
|
44251
|
+
}
|
|
44252
|
+
const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
|
|
44253
|
+
logger31.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
|
|
44254
|
+
return finalPlugins;
|
|
44255
|
+
}
|
|
44256
|
+
}
|
|
44257
|
+
|
|
44258
|
+
// src/managers/ConfigManager.ts
|
|
43547
44259
|
var import_dotenv2 = __toESM(require_main(), 1);
|
|
44260
|
+
import * as fs6 from "node:fs";
|
|
44261
|
+
import * as path8 from "node:path";
|
|
44262
|
+
|
|
44263
|
+
class ConfigManager {
|
|
44264
|
+
async loadEnvConfig() {
|
|
44265
|
+
const envPath = this.findEnvFile();
|
|
44266
|
+
if (envPath) {
|
|
44267
|
+
import_dotenv2.default.config({ path: envPath });
|
|
44268
|
+
}
|
|
44269
|
+
return process.env;
|
|
44270
|
+
}
|
|
44271
|
+
findEnvFile() {
|
|
44272
|
+
const possiblePaths = [
|
|
44273
|
+
path8.join(process.cwd(), ".env"),
|
|
44274
|
+
path8.join(process.cwd(), ".env.local")
|
|
44275
|
+
];
|
|
44276
|
+
for (const envPath of possiblePaths) {
|
|
44277
|
+
if (fs6.existsSync(envPath)) {
|
|
44278
|
+
return envPath;
|
|
44279
|
+
}
|
|
44280
|
+
}
|
|
44281
|
+
return null;
|
|
44282
|
+
}
|
|
44283
|
+
hasCharacterSecrets(character) {
|
|
44284
|
+
return Boolean(character?.settings?.secrets && Object.keys(character.settings.secrets).length > 0);
|
|
44285
|
+
}
|
|
44286
|
+
ensureCharacterSettings(character) {
|
|
44287
|
+
if (!character.settings) {
|
|
44288
|
+
character.settings = {};
|
|
44289
|
+
}
|
|
44290
|
+
}
|
|
44291
|
+
async loadLocalEnvSecrets() {
|
|
44292
|
+
const envPath = this.findEnvFile();
|
|
44293
|
+
if (!envPath)
|
|
44294
|
+
return null;
|
|
44295
|
+
try {
|
|
44296
|
+
const buf = fs6.readFileSync(envPath);
|
|
44297
|
+
return import_dotenv2.default.parse(buf);
|
|
44298
|
+
} catch {
|
|
44299
|
+
return null;
|
|
44300
|
+
}
|
|
44301
|
+
}
|
|
44302
|
+
async setDefaultSecretsFromEnv(character) {
|
|
44303
|
+
this.ensureCharacterSettings(character);
|
|
44304
|
+
if (this.hasCharacterSecrets(character)) {
|
|
44305
|
+
return false;
|
|
44306
|
+
}
|
|
44307
|
+
const envSecrets = await this.loadLocalEnvSecrets();
|
|
44308
|
+
if (!envSecrets) {
|
|
44309
|
+
return false;
|
|
44310
|
+
}
|
|
44311
|
+
if (!character.settings) {
|
|
44312
|
+
character.settings = {};
|
|
44313
|
+
}
|
|
44314
|
+
character.settings.secrets = envSecrets;
|
|
44315
|
+
return true;
|
|
44316
|
+
}
|
|
44317
|
+
}
|
|
44318
|
+
|
|
44319
|
+
// src/index.ts
|
|
44320
|
+
import { encryptedCharacter, stringToUuid as stringToUuid2 } from "@elizaos/core";
|
|
44321
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
44322
|
+
var import_dotenv3 = __toESM(require_main(), 1);
|
|
44323
|
+
import { ElizaOS as ElizaOS3 } from "@elizaos/core";
|
|
43548
44324
|
function expandTildePath(filepath) {
|
|
43549
44325
|
if (!filepath) {
|
|
43550
44326
|
return filepath;
|
|
@@ -43553,19 +44329,19 @@ function expandTildePath(filepath) {
|
|
|
43553
44329
|
if (filepath === "~") {
|
|
43554
44330
|
return process.cwd();
|
|
43555
44331
|
} else if (filepath.startsWith("~/")) {
|
|
43556
|
-
return
|
|
44332
|
+
return path9.join(process.cwd(), filepath.slice(2));
|
|
43557
44333
|
} else if (filepath.startsWith("~~")) {
|
|
43558
44334
|
return filepath;
|
|
43559
44335
|
} else {
|
|
43560
|
-
return
|
|
44336
|
+
return path9.join(process.cwd(), filepath.slice(1));
|
|
43561
44337
|
}
|
|
43562
44338
|
}
|
|
43563
44339
|
return filepath;
|
|
43564
44340
|
}
|
|
43565
44341
|
function resolvePgliteDir(dir, fallbackDir) {
|
|
43566
44342
|
const envPath = resolveEnvFile();
|
|
43567
|
-
if (
|
|
43568
|
-
|
|
44343
|
+
if (existsSync5(envPath)) {
|
|
44344
|
+
import_dotenv3.default.config({ path: envPath });
|
|
43569
44345
|
}
|
|
43570
44346
|
if (dir) {
|
|
43571
44347
|
const resolved2 = expandTildePath(dir);
|
|
@@ -43594,119 +44370,229 @@ function isWebUIEnabled() {
|
|
|
43594
44370
|
|
|
43595
44371
|
class AgentServer {
|
|
43596
44372
|
app;
|
|
43597
|
-
agents;
|
|
43598
44373
|
server;
|
|
43599
44374
|
socketIO;
|
|
43600
44375
|
isInitialized = false;
|
|
43601
44376
|
isWebUIEnabled = true;
|
|
43602
44377
|
clientPath;
|
|
44378
|
+
elizaOS;
|
|
44379
|
+
pluginLoader;
|
|
44380
|
+
configManager;
|
|
43603
44381
|
database;
|
|
43604
|
-
startAgent;
|
|
43605
|
-
stopAgent;
|
|
43606
44382
|
loadCharacterTryPath;
|
|
43607
44383
|
jsonToCharacter;
|
|
44384
|
+
async startAgents(characters, plugins = []) {
|
|
44385
|
+
if (!this.elizaOS || !this.pluginLoader || !this.configManager) {
|
|
44386
|
+
throw new Error("Server not properly initialized");
|
|
44387
|
+
}
|
|
44388
|
+
const preparations = await Promise.all(characters.map(async (character) => {
|
|
44389
|
+
character.id ??= stringToUuid2(character.name);
|
|
44390
|
+
if (!this.configManager?.hasCharacterSecrets(character)) {
|
|
44391
|
+
await this.configManager?.setDefaultSecretsFromEnv(character);
|
|
44392
|
+
}
|
|
44393
|
+
const loadedPlugins = new Map;
|
|
44394
|
+
const pluginsToLoad = new Set(character.plugins || []);
|
|
44395
|
+
for (const p of plugins) {
|
|
44396
|
+
if (typeof p === "string") {
|
|
44397
|
+
pluginsToLoad.add(p);
|
|
44398
|
+
} else if (this.pluginLoader?.isValidPluginShape(p) && !loadedPlugins.has(p.name)) {
|
|
44399
|
+
loadedPlugins.set(p.name, p);
|
|
44400
|
+
(p.dependencies || []).forEach((dep) => {
|
|
44401
|
+
pluginsToLoad.add(dep);
|
|
44402
|
+
});
|
|
44403
|
+
}
|
|
44404
|
+
}
|
|
44405
|
+
const allAvailablePlugins = new Map;
|
|
44406
|
+
for (const p of loadedPlugins.values()) {
|
|
44407
|
+
allAvailablePlugins.set(p.name, p);
|
|
44408
|
+
}
|
|
44409
|
+
for (const name of pluginsToLoad) {
|
|
44410
|
+
if (!allAvailablePlugins.has(name)) {
|
|
44411
|
+
const loaded = await this.pluginLoader?.loadAndPreparePlugin(name);
|
|
44412
|
+
if (loaded) {
|
|
44413
|
+
allAvailablePlugins.set(loaded.name, loaded);
|
|
44414
|
+
}
|
|
44415
|
+
}
|
|
44416
|
+
}
|
|
44417
|
+
let haveSql = false;
|
|
44418
|
+
for (const [name] of allAvailablePlugins.entries()) {
|
|
44419
|
+
if (name === sqlPlugin.name || name === "mysql") {
|
|
44420
|
+
haveSql = true;
|
|
44421
|
+
break;
|
|
44422
|
+
}
|
|
44423
|
+
}
|
|
44424
|
+
if (!haveSql) {
|
|
44425
|
+
allAvailablePlugins.set(sqlPlugin.name, sqlPlugin);
|
|
44426
|
+
}
|
|
44427
|
+
allAvailablePlugins.set(messageBusConnectorPlugin.name, messageBusConnectorPlugin);
|
|
44428
|
+
const finalPlugins = this.pluginLoader?.resolvePluginDependencies(allAvailablePlugins, false);
|
|
44429
|
+
const preparedCharacter = encryptedCharacter(character);
|
|
44430
|
+
return { character: preparedCharacter, plugins: finalPlugins };
|
|
44431
|
+
}));
|
|
44432
|
+
const settings = await this.configManager?.loadEnvConfig();
|
|
44433
|
+
const agentIds = await this.elizaOS.addAgents(preparations.map((p) => ({
|
|
44434
|
+
character: p.character,
|
|
44435
|
+
plugins: p.plugins,
|
|
44436
|
+
settings: settings || {}
|
|
44437
|
+
})));
|
|
44438
|
+
await this.elizaOS.startAgents(agentIds);
|
|
44439
|
+
const runtimes = [];
|
|
44440
|
+
for (const id of agentIds) {
|
|
44441
|
+
const runtime = this.elizaOS.getAgent(id);
|
|
44442
|
+
if (runtime) {
|
|
44443
|
+
await this.registerAgent(runtime);
|
|
44444
|
+
if (this.database) {
|
|
44445
|
+
try {
|
|
44446
|
+
const existingAgent = await this.database.getAgent(runtime.agentId);
|
|
44447
|
+
if (!existingAgent) {
|
|
44448
|
+
await this.database.createAgent({
|
|
44449
|
+
...runtime.character,
|
|
44450
|
+
id: runtime.agentId
|
|
44451
|
+
});
|
|
44452
|
+
logger32.info(`Persisted agent ${runtime.character.name} (${runtime.agentId}) to database`);
|
|
44453
|
+
}
|
|
44454
|
+
} catch (error2) {
|
|
44455
|
+
logger32.error({ error: error2 }, `Failed to persist agent ${runtime.agentId} to database`);
|
|
44456
|
+
}
|
|
44457
|
+
}
|
|
44458
|
+
runtimes.push(runtime);
|
|
44459
|
+
}
|
|
44460
|
+
}
|
|
44461
|
+
return runtimes;
|
|
44462
|
+
}
|
|
44463
|
+
async stopAgents(agentIds) {
|
|
44464
|
+
if (!this.elizaOS) {
|
|
44465
|
+
throw new Error("ElizaOS not initialized");
|
|
44466
|
+
}
|
|
44467
|
+
await this.elizaOS.stopAgents(agentIds);
|
|
44468
|
+
}
|
|
44469
|
+
getAllAgents() {
|
|
44470
|
+
if (!this.elizaOS) {
|
|
44471
|
+
return [];
|
|
44472
|
+
}
|
|
44473
|
+
return this.elizaOS.getAgents();
|
|
44474
|
+
}
|
|
44475
|
+
getAgent(agentId) {
|
|
44476
|
+
if (!this.elizaOS) {
|
|
44477
|
+
return;
|
|
44478
|
+
}
|
|
44479
|
+
return this.elizaOS.getAgent(agentId);
|
|
44480
|
+
}
|
|
43608
44481
|
constructor() {
|
|
43609
44482
|
try {
|
|
43610
|
-
|
|
43611
|
-
this.agents = new Map;
|
|
44483
|
+
logger32.debug("Initializing AgentServer (constructor)...");
|
|
43612
44484
|
this.loadCharacterTryPath = loadCharacterTryPath;
|
|
43613
44485
|
this.jsonToCharacter = jsonToCharacter;
|
|
43614
44486
|
this.registerSignalHandlers();
|
|
43615
44487
|
} catch (error2) {
|
|
43616
|
-
|
|
44488
|
+
logger32.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
|
|
43617
44489
|
throw error2;
|
|
43618
44490
|
}
|
|
43619
44491
|
}
|
|
43620
44492
|
async initialize(options) {
|
|
43621
44493
|
if (this.isInitialized) {
|
|
43622
|
-
|
|
44494
|
+
logger32.warn("AgentServer is already initialized, skipping initialization");
|
|
43623
44495
|
return;
|
|
43624
44496
|
}
|
|
43625
44497
|
try {
|
|
43626
|
-
|
|
44498
|
+
logger32.debug("Initializing AgentServer (async operations)...");
|
|
43627
44499
|
const agentDataDir = resolvePgliteDir(options?.dataDir);
|
|
43628
|
-
|
|
44500
|
+
logger32.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
|
|
44501
|
+
const dbDir = path9.dirname(agentDataDir);
|
|
44502
|
+
if (!fs7.existsSync(dbDir)) {
|
|
44503
|
+
fs7.mkdirSync(dbDir, { recursive: true });
|
|
44504
|
+
logger32.info(`[INIT] Created database directory: ${dbDir}`);
|
|
44505
|
+
}
|
|
44506
|
+
const tempServerAgentId = "00000000-0000-0000-0000-000000000000";
|
|
43629
44507
|
this.database = createDatabaseAdapter({
|
|
43630
44508
|
dataDir: agentDataDir,
|
|
43631
44509
|
postgresUrl: options?.postgresUrl
|
|
43632
|
-
},
|
|
44510
|
+
}, tempServerAgentId);
|
|
43633
44511
|
await this.database.init();
|
|
43634
|
-
|
|
43635
|
-
|
|
44512
|
+
logger32.success("Database initialized for server operations");
|
|
44513
|
+
logger32.info("[INIT] Running database migrations for messaging tables...");
|
|
43636
44514
|
try {
|
|
43637
44515
|
const migrationService = new DatabaseMigrationService;
|
|
43638
44516
|
const db = this.database.getDatabase();
|
|
43639
44517
|
await migrationService.initializeWithDatabase(db);
|
|
43640
44518
|
migrationService.discoverAndRegisterPluginSchemas([sqlPlugin]);
|
|
43641
44519
|
await migrationService.runAllPluginMigrations();
|
|
43642
|
-
|
|
44520
|
+
logger32.success("[INIT] Database migrations completed successfully");
|
|
43643
44521
|
} catch (migrationError) {
|
|
43644
|
-
|
|
44522
|
+
logger32.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
|
|
43645
44523
|
throw new Error(`Database migration failed: ${migrationError instanceof Error ? migrationError.message : String(migrationError)}`);
|
|
43646
44524
|
}
|
|
43647
44525
|
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
43648
|
-
|
|
44526
|
+
logger32.info("[INIT] Ensuring default server exists...");
|
|
43649
44527
|
await this.ensureDefaultServer();
|
|
43650
|
-
|
|
44528
|
+
logger32.success("[INIT] Default server setup complete");
|
|
44529
|
+
logger32.info("[INIT] Server uses temporary adapter for migrations only");
|
|
44530
|
+
logger32.info("[INIT] Initializing ElizaOS...");
|
|
44531
|
+
logger32.debug("[INIT] ElizaOS will use agent-specific database adapters from SQL plugin");
|
|
44532
|
+
this.elizaOS = new ElizaOS2;
|
|
44533
|
+
this.elizaOS.enableEditableMode();
|
|
44534
|
+
this.pluginLoader = new PluginLoader;
|
|
44535
|
+
this.configManager = new ConfigManager;
|
|
44536
|
+
logger32.success("[INIT] ElizaOS initialized");
|
|
43651
44537
|
await this.initializeServer(options);
|
|
43652
44538
|
await new Promise((resolve2) => setTimeout(resolve2, 250));
|
|
43653
44539
|
this.isInitialized = true;
|
|
43654
44540
|
} catch (error2) {
|
|
43655
|
-
|
|
44541
|
+
logger32.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
|
|
43656
44542
|
console.trace(error2);
|
|
43657
44543
|
throw error2;
|
|
43658
44544
|
}
|
|
43659
44545
|
}
|
|
43660
44546
|
async ensureDefaultServer() {
|
|
43661
44547
|
try {
|
|
43662
|
-
|
|
44548
|
+
logger32.info("[AgentServer] Checking for default server...");
|
|
43663
44549
|
const servers = await this.database.getMessageServers();
|
|
43664
|
-
|
|
44550
|
+
logger32.debug(`[AgentServer] Found ${servers.length} existing servers`);
|
|
43665
44551
|
servers.forEach((s) => {
|
|
43666
|
-
|
|
44552
|
+
logger32.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
|
|
43667
44553
|
});
|
|
43668
44554
|
const defaultServer = servers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
|
|
43669
44555
|
if (!defaultServer) {
|
|
43670
|
-
|
|
44556
|
+
logger32.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
|
|
43671
44557
|
try {
|
|
43672
44558
|
await this.database.db.execute(`
|
|
43673
44559
|
INSERT INTO message_servers (id, name, source_type, created_at, updated_at)
|
|
43674
44560
|
VALUES ('00000000-0000-0000-0000-000000000000', 'Default Server', 'eliza_default', NOW(), NOW())
|
|
43675
44561
|
ON CONFLICT (id) DO NOTHING
|
|
43676
44562
|
`);
|
|
43677
|
-
|
|
44563
|
+
logger32.success("[AgentServer] Default server created via raw SQL");
|
|
43678
44564
|
const checkResult = await this.database.db.execute("SELECT id, name FROM message_servers WHERE id = '00000000-0000-0000-0000-000000000000'");
|
|
43679
|
-
|
|
44565
|
+
logger32.debug("[AgentServer] Raw SQL check result:", checkResult);
|
|
43680
44566
|
} catch (sqlError) {
|
|
43681
|
-
|
|
44567
|
+
logger32.error("[AgentServer] Raw SQL insert failed:", sqlError);
|
|
43682
44568
|
try {
|
|
43683
44569
|
const server = await this.database.createMessageServer({
|
|
43684
44570
|
id: "00000000-0000-0000-0000-000000000000",
|
|
43685
44571
|
name: "Default Server",
|
|
43686
44572
|
sourceType: "eliza_default"
|
|
43687
44573
|
});
|
|
43688
|
-
|
|
44574
|
+
logger32.success("[AgentServer] Default server created via ORM with ID:", server.id);
|
|
43689
44575
|
} catch (ormError) {
|
|
43690
|
-
|
|
44576
|
+
logger32.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
|
|
43691
44577
|
throw new Error(`Failed to create default server: ${ormError.message}`);
|
|
43692
44578
|
}
|
|
43693
44579
|
}
|
|
43694
44580
|
const verifyServers = await this.database.getMessageServers();
|
|
43695
|
-
|
|
44581
|
+
logger32.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
|
|
43696
44582
|
verifyServers.forEach((s) => {
|
|
43697
|
-
|
|
44583
|
+
logger32.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
|
|
43698
44584
|
});
|
|
43699
44585
|
const verifyDefault = verifyServers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
|
|
43700
44586
|
if (!verifyDefault) {
|
|
43701
44587
|
throw new Error(`Failed to create or verify default server with ID ${DEFAULT_SERVER_ID6}`);
|
|
43702
44588
|
} else {
|
|
43703
|
-
|
|
44589
|
+
logger32.success("[AgentServer] Default server creation verified successfully");
|
|
43704
44590
|
}
|
|
43705
44591
|
} else {
|
|
43706
|
-
|
|
44592
|
+
logger32.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
|
|
43707
44593
|
}
|
|
43708
44594
|
} catch (error2) {
|
|
43709
|
-
|
|
44595
|
+
logger32.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
|
|
43710
44596
|
throw error2;
|
|
43711
44597
|
}
|
|
43712
44598
|
}
|
|
@@ -43717,7 +44603,7 @@ class AgentServer {
|
|
|
43717
44603
|
}
|
|
43718
44604
|
this.app = express33();
|
|
43719
44605
|
const DEFAULT_SENTRY_DSN = "https://c20e2d51b66c14a783b0689d536f7e5c@o4509349865259008.ingest.us.sentry.io/4509352524120064";
|
|
43720
|
-
const sentryDsn = process.env.SENTRY_DSN
|
|
44606
|
+
const sentryDsn = process.env.SENTRY_DSN?.trim() || DEFAULT_SENTRY_DSN;
|
|
43721
44607
|
const sentryEnabled = Boolean(sentryDsn);
|
|
43722
44608
|
if (sentryEnabled) {
|
|
43723
44609
|
try {
|
|
@@ -43727,16 +44613,16 @@ class AgentServer {
|
|
|
43727
44613
|
integrations: [vercelAIIntegration({ force: sentryEnabled })],
|
|
43728
44614
|
tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE || 0)
|
|
43729
44615
|
});
|
|
43730
|
-
|
|
44616
|
+
logger32.info("[Sentry] Initialized Sentry for @elizaos/server");
|
|
43731
44617
|
} catch (sentryInitError) {
|
|
43732
|
-
|
|
44618
|
+
logger32.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
|
|
43733
44619
|
}
|
|
43734
44620
|
}
|
|
43735
44621
|
const isProd = false;
|
|
43736
|
-
|
|
44622
|
+
logger32.debug("Setting up security headers...");
|
|
43737
44623
|
if (!isProd) {
|
|
43738
|
-
|
|
43739
|
-
|
|
44624
|
+
logger32.debug(`NODE_ENV: ${"development"}`);
|
|
44625
|
+
logger32.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
|
|
43740
44626
|
}
|
|
43741
44627
|
this.app.use(helmet({
|
|
43742
44628
|
contentSecurityPolicy: isProd ? {
|
|
@@ -43784,12 +44670,12 @@ class AgentServer {
|
|
|
43784
44670
|
xssFilter: true
|
|
43785
44671
|
}));
|
|
43786
44672
|
if (options?.middlewares) {
|
|
43787
|
-
|
|
44673
|
+
logger32.debug("Applying custom middlewares...");
|
|
43788
44674
|
for (const middleware2 of options.middlewares) {
|
|
43789
44675
|
this.app.use(middleware2);
|
|
43790
44676
|
}
|
|
43791
44677
|
}
|
|
43792
|
-
|
|
44678
|
+
logger32.debug("Setting up standard middlewares...");
|
|
43793
44679
|
this.app.use(cors2({
|
|
43794
44680
|
origin: process.env.CORS_ORIGIN || true,
|
|
43795
44681
|
credentials: true,
|
|
@@ -43801,28 +44687,28 @@ class AgentServer {
|
|
|
43801
44687
|
}));
|
|
43802
44688
|
const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
|
|
43803
44689
|
if (serverAuthToken) {
|
|
43804
|
-
|
|
44690
|
+
logger32.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
|
|
43805
44691
|
this.app.use("/api", (req, res, next) => {
|
|
43806
44692
|
apiKeyAuthMiddleware(req, res, next);
|
|
43807
44693
|
});
|
|
43808
44694
|
} else {
|
|
43809
|
-
|
|
44695
|
+
logger32.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
|
|
43810
44696
|
}
|
|
43811
44697
|
this.isWebUIEnabled = isWebUIEnabled();
|
|
43812
44698
|
if (this.isWebUIEnabled) {
|
|
43813
|
-
|
|
44699
|
+
logger32.info("Web UI enabled");
|
|
43814
44700
|
} else {
|
|
43815
44701
|
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
43816
44702
|
if (uiEnabledEnv !== undefined && uiEnabledEnv.trim() !== "") {
|
|
43817
|
-
|
|
44703
|
+
logger32.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
|
|
43818
44704
|
} else {
|
|
43819
|
-
|
|
44705
|
+
logger32.info("Web UI disabled for security (production mode)");
|
|
43820
44706
|
}
|
|
43821
44707
|
}
|
|
43822
44708
|
const uploadsBasePath = getUploadsAgentsDir4();
|
|
43823
44709
|
const generatedBasePath = getGeneratedDir2();
|
|
43824
|
-
|
|
43825
|
-
|
|
44710
|
+
fs7.mkdirSync(uploadsBasePath, { recursive: true });
|
|
44711
|
+
fs7.mkdirSync(generatedBasePath, { recursive: true });
|
|
43826
44712
|
this.app.get("/media/uploads/agents/:agentId/:filename", (req, res) => {
|
|
43827
44713
|
const agentId = req.params.agentId;
|
|
43828
44714
|
const filename = req.params.filename;
|
|
@@ -43832,26 +44718,26 @@ class AgentServer {
|
|
|
43832
44718
|
return;
|
|
43833
44719
|
}
|
|
43834
44720
|
const sanitizedFilename = basename2(filename);
|
|
43835
|
-
const agentUploadsPath =
|
|
43836
|
-
const filePath =
|
|
44721
|
+
const agentUploadsPath = join5(uploadsBasePath, agentId);
|
|
44722
|
+
const filePath = join5(agentUploadsPath, sanitizedFilename);
|
|
43837
44723
|
if (!filePath.startsWith(agentUploadsPath)) {
|
|
43838
44724
|
res.status(403).json({ error: "Access denied" });
|
|
43839
44725
|
return;
|
|
43840
44726
|
}
|
|
43841
|
-
if (!
|
|
44727
|
+
if (!fs7.existsSync(filePath)) {
|
|
43842
44728
|
res.status(404).json({ error: "File does not exist!!!!!!!" });
|
|
43843
44729
|
return;
|
|
43844
44730
|
}
|
|
43845
44731
|
res.sendFile(sanitizedFilename, { root: agentUploadsPath }, (err) => {
|
|
43846
44732
|
if (err) {
|
|
43847
44733
|
if (err.message === "Request aborted") {
|
|
43848
|
-
|
|
44734
|
+
logger32.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
|
|
43849
44735
|
} else if (!res.headersSent) {
|
|
43850
|
-
|
|
44736
|
+
logger32.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
|
|
43851
44737
|
res.status(404).json({ error: "File not found" });
|
|
43852
44738
|
}
|
|
43853
44739
|
} else {
|
|
43854
|
-
|
|
44740
|
+
logger32.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
|
|
43855
44741
|
}
|
|
43856
44742
|
});
|
|
43857
44743
|
});
|
|
@@ -43864,17 +44750,17 @@ class AgentServer {
|
|
|
43864
44750
|
return;
|
|
43865
44751
|
}
|
|
43866
44752
|
const sanitizedFilename = basename2(filename);
|
|
43867
|
-
const agentGeneratedPath =
|
|
43868
|
-
const filePath =
|
|
44753
|
+
const agentGeneratedPath = join5(generatedBasePath, agentId);
|
|
44754
|
+
const filePath = join5(agentGeneratedPath, sanitizedFilename);
|
|
43869
44755
|
if (!filePath.startsWith(agentGeneratedPath)) {
|
|
43870
44756
|
res.status(403).json({ error: "Access denied" });
|
|
43871
44757
|
return;
|
|
43872
44758
|
}
|
|
43873
|
-
if (!
|
|
44759
|
+
if (!existsSync5(filePath)) {
|
|
43874
44760
|
res.status(404).json({ error: "File not found" });
|
|
43875
44761
|
return;
|
|
43876
44762
|
}
|
|
43877
|
-
const absolutePath =
|
|
44763
|
+
const absolutePath = path9.resolve(filePath);
|
|
43878
44764
|
const options2 = {
|
|
43879
44765
|
dotfiles: "deny"
|
|
43880
44766
|
};
|
|
@@ -43883,7 +44769,7 @@ class AgentServer {
|
|
|
43883
44769
|
const ext2 = extname(filename).toLowerCase();
|
|
43884
44770
|
const mimeType = ext2 === ".png" ? "image/png" : ext2 === ".jpg" || ext2 === ".jpeg" ? "image/jpeg" : "application/octet-stream";
|
|
43885
44771
|
res.setHeader("Content-Type", mimeType);
|
|
43886
|
-
const stream =
|
|
44772
|
+
const stream = fs7.createReadStream(absolutePath);
|
|
43887
44773
|
stream.on("error", () => res.status(404).json({ error: "File not found" }));
|
|
43888
44774
|
stream.pipe(res);
|
|
43889
44775
|
}
|
|
@@ -43898,20 +44784,20 @@ class AgentServer {
|
|
|
43898
44784
|
return;
|
|
43899
44785
|
}
|
|
43900
44786
|
const sanitizedFilename = basename2(filename);
|
|
43901
|
-
const channelUploadsPath =
|
|
43902
|
-
const filePath =
|
|
44787
|
+
const channelUploadsPath = join5(uploadsBasePath, "channels", channelId);
|
|
44788
|
+
const filePath = join5(channelUploadsPath, sanitizedFilename);
|
|
43903
44789
|
if (!filePath.startsWith(channelUploadsPath)) {
|
|
43904
44790
|
res.status(403).json({ error: "Access denied" });
|
|
43905
44791
|
return;
|
|
43906
44792
|
}
|
|
43907
44793
|
res.sendFile(filePath, (err) => {
|
|
43908
44794
|
if (err) {
|
|
43909
|
-
|
|
44795
|
+
logger32.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
|
|
43910
44796
|
if (!res.headersSent) {
|
|
43911
44797
|
res.status(404).json({ error: "File not found" });
|
|
43912
44798
|
}
|
|
43913
44799
|
} else {
|
|
43914
|
-
|
|
44800
|
+
logger32.debug(`[STATIC] Served channel media file: ${filePath}`);
|
|
43915
44801
|
}
|
|
43916
44802
|
});
|
|
43917
44803
|
});
|
|
@@ -43955,11 +44841,11 @@ class AgentServer {
|
|
|
43955
44841
|
if (this.isWebUIEnabled) {
|
|
43956
44842
|
const possiblePaths = [
|
|
43957
44843
|
this.clientPath,
|
|
43958
|
-
|
|
43959
|
-
|
|
44844
|
+
path9.resolve(__dirname3, "client"),
|
|
44845
|
+
path9.resolve(__dirname3, "../../client/dist"),
|
|
43960
44846
|
(() => {
|
|
43961
44847
|
try {
|
|
43962
|
-
return
|
|
44848
|
+
return path9.resolve(path9.dirname(__require.resolve("@elizaos/client/package.json")), "dist");
|
|
43963
44849
|
} catch {
|
|
43964
44850
|
return null;
|
|
43965
44851
|
}
|
|
@@ -43967,12 +44853,12 @@ class AgentServer {
|
|
|
43967
44853
|
(() => {
|
|
43968
44854
|
try {
|
|
43969
44855
|
if (process.argv[1]) {
|
|
43970
|
-
const serverPath =
|
|
43971
|
-
const possibleClientPath =
|
|
43972
|
-
if (
|
|
44856
|
+
const serverPath = path9.dirname(process.argv[1]);
|
|
44857
|
+
const possibleClientPath = path9.join(serverPath, "client");
|
|
44858
|
+
if (existsSync5(path9.join(possibleClientPath, "index.html"))) {
|
|
43973
44859
|
return possibleClientPath;
|
|
43974
44860
|
}
|
|
43975
|
-
if (
|
|
44861
|
+
if (existsSync5(path9.join(serverPath, "index.html"))) {
|
|
43976
44862
|
return serverPath;
|
|
43977
44863
|
}
|
|
43978
44864
|
}
|
|
@@ -43981,8 +44867,8 @@ class AgentServer {
|
|
|
43981
44867
|
})(),
|
|
43982
44868
|
(() => {
|
|
43983
44869
|
try {
|
|
43984
|
-
const bunGlobalPath =
|
|
43985
|
-
if (
|
|
44870
|
+
const bunGlobalPath = path9.join(os3.homedir(), ".bun/install/global/node_modules/@elizaos/server/dist/client");
|
|
44871
|
+
if (existsSync5(path9.join(bunGlobalPath, "index.html"))) {
|
|
43986
44872
|
return bunGlobalPath;
|
|
43987
44873
|
}
|
|
43988
44874
|
try {
|
|
@@ -43992,8 +44878,8 @@ class AgentServer {
|
|
|
43992
44878
|
});
|
|
43993
44879
|
if (proc.exitCode === 0 && proc.stdout) {
|
|
43994
44880
|
const npmRoot = new TextDecoder().decode(proc.stdout).trim();
|
|
43995
|
-
const globalServerPath =
|
|
43996
|
-
if (
|
|
44881
|
+
const globalServerPath = path9.join(npmRoot, "@elizaos/server/dist/client");
|
|
44882
|
+
if (existsSync5(path9.join(globalServerPath, "index.html"))) {
|
|
43997
44883
|
return globalServerPath;
|
|
43998
44884
|
}
|
|
43999
44885
|
}
|
|
@@ -44004,15 +44890,15 @@ class AgentServer {
|
|
|
44004
44890
|
...[
|
|
44005
44891
|
"/usr/local/lib/node_modules/@elizaos/server/dist/client",
|
|
44006
44892
|
"/usr/lib/node_modules/@elizaos/server/dist/client",
|
|
44007
|
-
|
|
44893
|
+
path9.join(os3.homedir(), ".npm-global/lib/node_modules/@elizaos/server/dist/client"),
|
|
44008
44894
|
(() => {
|
|
44009
44895
|
try {
|
|
44010
|
-
const nvmPath =
|
|
44011
|
-
if (
|
|
44012
|
-
const versions =
|
|
44896
|
+
const nvmPath = path9.join(os3.homedir(), ".nvm/versions/node");
|
|
44897
|
+
if (existsSync5(nvmPath)) {
|
|
44898
|
+
const versions = fs7.readdirSync(nvmPath);
|
|
44013
44899
|
for (const version of versions) {
|
|
44014
|
-
const cliPath =
|
|
44015
|
-
if (
|
|
44900
|
+
const cliPath = path9.join(nvmPath, version, "lib/node_modules/@elizaos/server/dist/client");
|
|
44901
|
+
if (existsSync5(path9.join(cliPath, "index.html"))) {
|
|
44016
44902
|
return cliPath;
|
|
44017
44903
|
}
|
|
44018
44904
|
}
|
|
@@ -44022,37 +44908,37 @@ class AgentServer {
|
|
|
44022
44908
|
})()
|
|
44023
44909
|
].filter(Boolean)
|
|
44024
44910
|
].filter(Boolean);
|
|
44025
|
-
|
|
44026
|
-
|
|
44027
|
-
|
|
44911
|
+
logger32.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
|
|
44912
|
+
logger32.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
|
|
44913
|
+
logger32.debug(`[STATIC] __dirname: ${__dirname3}`);
|
|
44028
44914
|
for (const possiblePath of possiblePaths) {
|
|
44029
|
-
if (possiblePath &&
|
|
44915
|
+
if (possiblePath && existsSync5(path9.join(possiblePath, "index.html"))) {
|
|
44030
44916
|
clientPath = possiblePath;
|
|
44031
|
-
|
|
44917
|
+
logger32.info(`[STATIC] Found client files at: ${clientPath}`);
|
|
44032
44918
|
break;
|
|
44033
44919
|
}
|
|
44034
44920
|
}
|
|
44035
44921
|
if (clientPath) {
|
|
44036
44922
|
this.clientPath = clientPath;
|
|
44037
44923
|
this.app.use(express33.static(clientPath, staticOptions));
|
|
44038
|
-
|
|
44924
|
+
logger32.info(`[STATIC] Serving static files from: ${clientPath}`);
|
|
44039
44925
|
} else {
|
|
44040
|
-
|
|
44926
|
+
logger32.warn("[STATIC] Client dist path not found. Searched locations:");
|
|
44041
44927
|
possiblePaths.forEach((p) => {
|
|
44042
44928
|
if (p)
|
|
44043
|
-
|
|
44929
|
+
logger32.warn(`[STATIC] - ${p}`);
|
|
44044
44930
|
});
|
|
44045
|
-
|
|
44046
|
-
|
|
44047
|
-
|
|
44931
|
+
logger32.warn("[STATIC] The web UI will not be available.");
|
|
44932
|
+
logger32.warn("[STATIC] To fix this, ensure the client is built: cd packages/client && bun run build");
|
|
44933
|
+
logger32.warn("[STATIC] Then rebuild the server: cd packages/server && bun run build");
|
|
44048
44934
|
}
|
|
44049
44935
|
}
|
|
44050
|
-
const pluginRouteHandler = createPluginRouteHandler(this.
|
|
44936
|
+
const pluginRouteHandler = createPluginRouteHandler(this.elizaOS);
|
|
44051
44937
|
this.app.use(pluginRouteHandler);
|
|
44052
|
-
const apiRouter = createApiRouter(this.
|
|
44938
|
+
const apiRouter = createApiRouter(this.elizaOS, this);
|
|
44053
44939
|
this.app.use("/api", (req, _res, next) => {
|
|
44054
44940
|
if (req.path !== "/ping") {
|
|
44055
|
-
|
|
44941
|
+
logger32.debug(`API request: ${req.method} ${req.path}`);
|
|
44056
44942
|
}
|
|
44057
44943
|
next();
|
|
44058
44944
|
}, apiRouter, (err, req, res, _next) => {
|
|
@@ -44067,7 +44953,7 @@ class AgentServer {
|
|
|
44067
44953
|
return scope;
|
|
44068
44954
|
});
|
|
44069
44955
|
}
|
|
44070
|
-
|
|
44956
|
+
logger32.error({ err }, `API error: ${req.method} ${req.path}`);
|
|
44071
44957
|
res.status(500).json({
|
|
44072
44958
|
success: false,
|
|
44073
44959
|
error: {
|
|
@@ -44115,29 +45001,29 @@ class AgentServer {
|
|
|
44115
45001
|
}
|
|
44116
45002
|
const resolvedClientPath = clientPath || this.clientPath;
|
|
44117
45003
|
if (resolvedClientPath) {
|
|
44118
|
-
const indexFilePath =
|
|
44119
|
-
if (!
|
|
44120
|
-
|
|
44121
|
-
|
|
45004
|
+
const indexFilePath = path9.join(resolvedClientPath, "index.html");
|
|
45005
|
+
if (!existsSync5(indexFilePath)) {
|
|
45006
|
+
logger32.error(`[STATIC] index.html not found at expected path: ${indexFilePath}`);
|
|
45007
|
+
logger32.error(`[STATIC] Client path was: ${resolvedClientPath}`);
|
|
44122
45008
|
res.status(404).send("Client application not found");
|
|
44123
45009
|
return;
|
|
44124
45010
|
}
|
|
44125
45011
|
res.sendFile("index.html", { root: resolvedClientPath }, (err) => {
|
|
44126
45012
|
if (err) {
|
|
44127
|
-
|
|
44128
|
-
|
|
44129
|
-
|
|
44130
|
-
|
|
45013
|
+
logger32.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
|
|
45014
|
+
logger32.warn(`[STATIC] Attempted root: ${resolvedClientPath}`);
|
|
45015
|
+
logger32.warn(`[STATIC] Full path was: ${indexFilePath}`);
|
|
45016
|
+
logger32.warn(`[STATIC] Error code: ${err.code || "unknown"}`);
|
|
44131
45017
|
if (!res.headersSent) {
|
|
44132
45018
|
res.status(404).send("Client application not found");
|
|
44133
45019
|
}
|
|
44134
45020
|
} else {
|
|
44135
|
-
|
|
45021
|
+
logger32.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
|
|
44136
45022
|
}
|
|
44137
45023
|
});
|
|
44138
45024
|
} else {
|
|
44139
|
-
|
|
44140
|
-
|
|
45025
|
+
logger32.warn("[STATIC] Client dist path not found in SPA fallback");
|
|
45026
|
+
logger32.warn("[STATIC] Neither local nor instance clientPath variables are set");
|
|
44141
45027
|
res.status(404).send("Client application not found");
|
|
44142
45028
|
}
|
|
44143
45029
|
});
|
|
@@ -44147,10 +45033,10 @@ class AgentServer {
|
|
|
44147
45033
|
});
|
|
44148
45034
|
}
|
|
44149
45035
|
this.server = http4.createServer(this.app);
|
|
44150
|
-
this.socketIO = setupSocketIO(this.server, this.
|
|
44151
|
-
|
|
45036
|
+
this.socketIO = setupSocketIO(this.server, this.elizaOS, this);
|
|
45037
|
+
logger32.success("AgentServer HTTP server and Socket.IO initialized");
|
|
44152
45038
|
} catch (error2) {
|
|
44153
|
-
|
|
45039
|
+
logger32.error({ error: error2 }, "Failed to complete server initialization:");
|
|
44154
45040
|
throw error2;
|
|
44155
45041
|
}
|
|
44156
45042
|
}
|
|
@@ -44165,63 +45051,64 @@ class AgentServer {
|
|
|
44165
45051
|
if (!runtime.character) {
|
|
44166
45052
|
throw new Error("Runtime missing character configuration");
|
|
44167
45053
|
}
|
|
44168
|
-
|
|
44169
|
-
logger30.debug(`Agent ${runtime.character.name} (${runtime.agentId}) added to agents map`);
|
|
45054
|
+
logger32.debug(`Agent ${runtime.character.name} (${runtime.agentId}) registered`);
|
|
44170
45055
|
try {
|
|
44171
45056
|
if (messageBusConnectorPlugin) {
|
|
44172
45057
|
await runtime.registerPlugin(messageBusConnectorPlugin);
|
|
44173
|
-
|
|
45058
|
+
logger32.info(`[AgentServer] Automatically registered MessageBusConnector for agent ${runtime.character.name}`);
|
|
44174
45059
|
} else {
|
|
44175
|
-
|
|
45060
|
+
logger32.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
|
|
44176
45061
|
}
|
|
44177
45062
|
} catch (e) {
|
|
44178
|
-
|
|
45063
|
+
logger32.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
|
|
44179
45064
|
}
|
|
44180
45065
|
const teePlugin = runtime.plugins.find((p) => p.name === "phala-tee-plugin");
|
|
44181
45066
|
if (teePlugin) {
|
|
44182
|
-
|
|
45067
|
+
logger32.debug(`Found TEE plugin for agent ${runtime.agentId}`);
|
|
44183
45068
|
if (teePlugin.providers) {
|
|
44184
45069
|
for (const provider of teePlugin.providers) {
|
|
44185
45070
|
runtime.registerProvider(provider);
|
|
44186
|
-
|
|
45071
|
+
logger32.debug(`Registered TEE provider: ${provider.name}`);
|
|
44187
45072
|
}
|
|
44188
45073
|
}
|
|
44189
45074
|
if (teePlugin.actions) {
|
|
44190
45075
|
for (const action of teePlugin.actions) {
|
|
44191
45076
|
runtime.registerAction(action);
|
|
44192
|
-
|
|
45077
|
+
logger32.debug(`Registered TEE action: ${action.name}`);
|
|
44193
45078
|
}
|
|
44194
45079
|
}
|
|
44195
45080
|
}
|
|
44196
|
-
|
|
45081
|
+
logger32.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
|
|
44197
45082
|
await this.addAgentToServer(DEFAULT_SERVER_ID6, runtime.agentId);
|
|
44198
|
-
|
|
45083
|
+
logger32.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
|
|
44199
45084
|
} catch (error2) {
|
|
44200
|
-
|
|
45085
|
+
logger32.error({ error: error2 }, "Failed to register agent:");
|
|
44201
45086
|
throw error2;
|
|
44202
45087
|
}
|
|
44203
45088
|
}
|
|
44204
|
-
unregisterAgent(agentId) {
|
|
45089
|
+
async unregisterAgent(agentId) {
|
|
44205
45090
|
if (!agentId) {
|
|
44206
|
-
|
|
45091
|
+
logger32.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
|
|
44207
45092
|
return;
|
|
44208
45093
|
}
|
|
44209
45094
|
try {
|
|
44210
|
-
const agent = this.
|
|
45095
|
+
const agent = this.elizaOS?.getAgent(agentId);
|
|
44211
45096
|
if (agent) {
|
|
44212
45097
|
try {
|
|
44213
45098
|
agent.stop().catch((stopError) => {
|
|
44214
|
-
|
|
45099
|
+
logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
|
|
44215
45100
|
});
|
|
44216
|
-
|
|
45101
|
+
logger32.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
|
|
44217
45102
|
} catch (stopError) {
|
|
44218
|
-
|
|
45103
|
+
logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
|
|
44219
45104
|
}
|
|
44220
45105
|
}
|
|
44221
|
-
this.
|
|
44222
|
-
|
|
45106
|
+
if (this.elizaOS) {
|
|
45107
|
+
await this.elizaOS.deleteAgents([agentId]);
|
|
45108
|
+
}
|
|
45109
|
+
logger32.debug(`Agent ${agentId} unregistered`);
|
|
44223
45110
|
} catch (error2) {
|
|
44224
|
-
|
|
45111
|
+
logger32.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
|
|
44225
45112
|
}
|
|
44226
45113
|
}
|
|
44227
45114
|
registerMiddleware(middleware2) {
|
|
@@ -44233,9 +45120,9 @@ class AgentServer {
|
|
|
44233
45120
|
if (!port || typeof port !== "number") {
|
|
44234
45121
|
throw new Error(`Invalid port number: ${port}`);
|
|
44235
45122
|
}
|
|
44236
|
-
|
|
44237
|
-
|
|
44238
|
-
|
|
45123
|
+
logger32.debug(`Starting server on port ${port}...`);
|
|
45124
|
+
logger32.debug(`Current agents count: ${this.elizaOS?.getAgents().length || 0}`);
|
|
45125
|
+
logger32.debug(`Environment: ${"development"}`);
|
|
44239
45126
|
const host = process.env.SERVER_HOST || "0.0.0.0";
|
|
44240
45127
|
this.server.listen(port, host, () => {
|
|
44241
45128
|
if (this.isWebUIEnabled && false) {} else if (!this.isWebUIEnabled) {
|
|
@@ -44248,25 +45135,26 @@ class AgentServer {
|
|
|
44248
45135
|
` + ` \x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`);
|
|
44249
45136
|
}
|
|
44250
45137
|
console.log(`AgentServer is listening on port ${port}`);
|
|
44251
|
-
|
|
44252
|
-
|
|
44253
|
-
|
|
44254
|
-
|
|
45138
|
+
logger32.success(`REST API bound to ${host}:${port}. If running locally, access it at http://localhost:${port}.`);
|
|
45139
|
+
const agents = this.elizaOS?.getAgents() || [];
|
|
45140
|
+
logger32.debug(`Active agents: ${agents.length}`);
|
|
45141
|
+
agents.forEach((agent) => {
|
|
45142
|
+
logger32.debug(`- Agent ${agent.agentId}: ${agent.character.name}`);
|
|
44255
45143
|
});
|
|
44256
45144
|
resolve2();
|
|
44257
45145
|
}).on("error", (error2) => {
|
|
44258
|
-
|
|
45146
|
+
logger32.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
|
|
44259
45147
|
if (error2.code === "EADDRINUSE") {
|
|
44260
|
-
|
|
45148
|
+
logger32.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
|
|
44261
45149
|
} else if (error2.code === "EACCES") {
|
|
44262
|
-
|
|
45150
|
+
logger32.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
|
|
44263
45151
|
} else if (error2.code === "EADDRNOTAVAIL") {
|
|
44264
|
-
|
|
45152
|
+
logger32.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
|
|
44265
45153
|
}
|
|
44266
45154
|
reject(error2);
|
|
44267
45155
|
});
|
|
44268
45156
|
} catch (error2) {
|
|
44269
|
-
|
|
45157
|
+
logger32.error({ error: error2 }, "Failed to start server:");
|
|
44270
45158
|
reject(error2);
|
|
44271
45159
|
}
|
|
44272
45160
|
});
|
|
@@ -44274,7 +45162,7 @@ class AgentServer {
|
|
|
44274
45162
|
async stop() {
|
|
44275
45163
|
if (this.server) {
|
|
44276
45164
|
this.server.close(() => {
|
|
44277
|
-
|
|
45165
|
+
logger32.success("Server stopped");
|
|
44278
45166
|
});
|
|
44279
45167
|
}
|
|
44280
45168
|
}
|
|
@@ -44321,7 +45209,7 @@ class AgentServer {
|
|
|
44321
45209
|
for (const message of messages) {
|
|
44322
45210
|
await this.database.deleteMessage(message.id);
|
|
44323
45211
|
}
|
|
44324
|
-
|
|
45212
|
+
logger32.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
|
|
44325
45213
|
}
|
|
44326
45214
|
async findOrCreateCentralDmChannel(user1Id, user2Id, messageServerId) {
|
|
44327
45215
|
return this.database.findOrCreateDmChannel(user1Id, user2Id, messageServerId);
|
|
@@ -44344,7 +45232,7 @@ class AgentServer {
|
|
|
44344
45232
|
metadata: createdMessage.metadata
|
|
44345
45233
|
};
|
|
44346
45234
|
bus_default.emit("new_message", messageForBus);
|
|
44347
|
-
|
|
45235
|
+
logger32.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
|
|
44348
45236
|
}
|
|
44349
45237
|
return createdMessage;
|
|
44350
45238
|
}
|
|
@@ -44355,7 +45243,7 @@ class AgentServer {
|
|
|
44355
45243
|
return this.database.updateMessage(messageId, patch);
|
|
44356
45244
|
}
|
|
44357
45245
|
async removeParticipantFromChannel() {
|
|
44358
|
-
|
|
45246
|
+
logger32.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
|
|
44359
45247
|
}
|
|
44360
45248
|
async addAgentToServer(serverId, agentId) {
|
|
44361
45249
|
const server = await this.getServerById(serverId);
|
|
@@ -44383,31 +45271,32 @@ class AgentServer {
|
|
|
44383
45271
|
}
|
|
44384
45272
|
registerSignalHandlers() {
|
|
44385
45273
|
const gracefulShutdown = async () => {
|
|
44386
|
-
|
|
44387
|
-
|
|
44388
|
-
|
|
45274
|
+
logger32.info("Received shutdown signal, initiating graceful shutdown...");
|
|
45275
|
+
logger32.debug("Stopping all agents...");
|
|
45276
|
+
const agents = this.elizaOS?.getAgents() || [];
|
|
45277
|
+
for (const agent of agents) {
|
|
44389
45278
|
try {
|
|
44390
45279
|
await agent.stop();
|
|
44391
|
-
|
|
45280
|
+
logger32.debug(`Stopped agent ${agent.agentId}`);
|
|
44392
45281
|
} catch (error2) {
|
|
44393
|
-
|
|
45282
|
+
logger32.error({ error: error2, agentId: agent.agentId }, `Error stopping agent ${agent.agentId}:`);
|
|
44394
45283
|
}
|
|
44395
45284
|
}
|
|
44396
45285
|
if (this.database) {
|
|
44397
45286
|
try {
|
|
44398
45287
|
await this.database.close();
|
|
44399
|
-
|
|
45288
|
+
logger32.info("Database closed.");
|
|
44400
45289
|
} catch (error2) {
|
|
44401
|
-
|
|
45290
|
+
logger32.error({ error: error2 }, "Error closing database:");
|
|
44402
45291
|
}
|
|
44403
45292
|
}
|
|
44404
45293
|
if (this.server) {
|
|
44405
45294
|
this.server.close(() => {
|
|
44406
|
-
|
|
45295
|
+
logger32.success("Server closed successfully");
|
|
44407
45296
|
process.exit(0);
|
|
44408
45297
|
});
|
|
44409
45298
|
setTimeout(() => {
|
|
44410
|
-
|
|
45299
|
+
logger32.error("Could not close connections in time, forcing shutdown");
|
|
44411
45300
|
process.exit(1);
|
|
44412
45301
|
}, 5000);
|
|
44413
45302
|
} else {
|
|
@@ -44416,7 +45305,7 @@ class AgentServer {
|
|
|
44416
45305
|
};
|
|
44417
45306
|
process.on("SIGTERM", gracefulShutdown);
|
|
44418
45307
|
process.on("SIGINT", gracefulShutdown);
|
|
44419
|
-
|
|
45308
|
+
logger32.debug("Shutdown handlers registered");
|
|
44420
45309
|
}
|
|
44421
45310
|
}
|
|
44422
45311
|
export {
|
|
@@ -44430,5 +45319,8 @@ export {
|
|
|
44430
45319
|
isWebUIEnabled,
|
|
44431
45320
|
hasValidRemoteUrls,
|
|
44432
45321
|
expandTildePath,
|
|
45322
|
+
PluginLoader,
|
|
45323
|
+
ElizaOS3 as ElizaOS,
|
|
45324
|
+
ConfigManager,
|
|
44433
45325
|
AgentServer
|
|
44434
45326
|
};
|