@elizaos/server 1.6.0-beta.1 → 1.6.1-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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
7
7
  <title>ElizaOS - Client</title>
8
- <script type="module" crossorigin src="/assets/main-BXR0yfv8.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-C4q5_rtN.js"></script>
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
package/dist/index.js CHANGED
@@ -23032,6 +23032,16 @@ import { validateUuid as validateUuid6 } from "@elizaos/core";
23032
23032
  import express6 from "express";
23033
23033
  function createAgentRunsRouter(elizaOS) {
23034
23034
  const router = express6.Router();
23035
+ const RUNS_CACHE_TTL = 15000;
23036
+ const runsCache = new Map;
23037
+ const buildCacheKey = (agentId, query) => JSON.stringify({
23038
+ agentId,
23039
+ roomId: query.roomId || null,
23040
+ status: query.status || null,
23041
+ limit: query.limit || null,
23042
+ from: query.from || null,
23043
+ to: query.to || null
23044
+ });
23035
23045
  router.get("/:agentId/runs", async (req, res) => {
23036
23046
  const agentId = validateUuid6(req.params.agentId);
23037
23047
  if (!agentId) {
@@ -23049,74 +23059,179 @@ function createAgentRunsRouter(elizaOS) {
23049
23059
  const limitNum = Math.min(Number(limit) || 20, 100);
23050
23060
  const fromTime = from ? Number(from) : undefined;
23051
23061
  const toTime = to ? Number(to) : undefined;
23052
- const runEventLogs = await runtime.getLogs({
23062
+ const cacheKey = !fromTime && !toTime ? buildCacheKey(agentId, { roomId, status, limit: limitNum }) : null;
23063
+ if (cacheKey) {
23064
+ const cached = runsCache.get(cacheKey);
23065
+ if (cached && cached.expiresAt > Date.now()) {
23066
+ return sendSuccess(res, cached.payload);
23067
+ }
23068
+ }
23069
+ const adapter = runtime.adapter;
23070
+ const allowedStatuses = [
23071
+ "started",
23072
+ "completed",
23073
+ "timeout",
23074
+ "error",
23075
+ "all"
23076
+ ];
23077
+ const statusFilter = typeof status === "string" && allowedStatuses.includes(status) ? status : undefined;
23078
+ if (adapter?.getAgentRunSummaries) {
23079
+ try {
23080
+ const fastResult = await adapter.getAgentRunSummaries({
23081
+ limit: limitNum,
23082
+ roomId: roomId ? roomId : undefined,
23083
+ status: statusFilter,
23084
+ from: fromTime,
23085
+ to: toTime
23086
+ });
23087
+ if (cacheKey) {
23088
+ runsCache.set(cacheKey, {
23089
+ payload: fastResult,
23090
+ expiresAt: Date.now() + RUNS_CACHE_TTL
23091
+ });
23092
+ }
23093
+ return sendSuccess(res, fastResult);
23094
+ } catch (error) {
23095
+ runtime.logger?.warn?.(`Optimized run summary query failed, falling back to log aggregation: ${error instanceof Error ? error.message : String(error)}`);
23096
+ }
23097
+ }
23098
+ const directAgentRunEventsPromise = runtime.getLogs({
23053
23099
  entityId: agentId,
23054
23100
  roomId: roomId ? roomId : undefined,
23055
23101
  type: "run_event",
23056
- count: limitNum * 3
23057
- });
23102
+ count: 1000
23103
+ }).catch(() => []);
23104
+ const directRunEvents = await directAgentRunEventsPromise;
23058
23105
  const runMap = new Map;
23059
- for (const log of runEventLogs) {
23060
- const body = log.body;
23061
- const runId = body.runId;
23062
- if (!runId)
23063
- continue;
23064
- const logTime = new Date(log.createdAt).getTime();
23065
- if (fromTime && logTime < fromTime)
23066
- continue;
23067
- if (toTime && logTime > toTime)
23068
- continue;
23069
- if (!runMap.has(runId)) {
23070
- runMap.set(runId, {
23071
- runId,
23072
- status: "started",
23073
- startedAt: null,
23074
- endedAt: null,
23075
- durationMs: null,
23076
- messageId: body.messageId,
23077
- roomId: body.roomId,
23078
- entityId: body.entityId,
23079
- metadata: body.metadata || {}
23080
- });
23081
- }
23082
- const run = runMap.get(runId);
23083
- const eventStatus = body.status;
23084
- if (eventStatus === "started") {
23085
- run.startedAt = logTime;
23086
- } else if (eventStatus === "completed" || eventStatus === "timeout" || eventStatus === "error") {
23087
- run.status = eventStatus;
23088
- run.endedAt = logTime;
23089
- if (run.startedAt) {
23090
- run.durationMs = logTime - run.startedAt;
23106
+ const ingestRunEvents = (logs) => {
23107
+ for (const log of logs) {
23108
+ const body = log.body;
23109
+ const runId = body.runId;
23110
+ if (!runId)
23111
+ continue;
23112
+ const logTime = new Date(log.createdAt).getTime();
23113
+ if (fromTime && logTime < fromTime)
23114
+ continue;
23115
+ if (toTime && logTime > toTime)
23116
+ continue;
23117
+ if (!runMap.has(runId)) {
23118
+ runMap.set(runId, {
23119
+ runId,
23120
+ status: "started",
23121
+ startedAt: null,
23122
+ endedAt: null,
23123
+ durationMs: null,
23124
+ messageId: body.messageId,
23125
+ roomId: body.roomId,
23126
+ entityId: body.entityId,
23127
+ metadata: body.metadata || {}
23128
+ });
23129
+ }
23130
+ const run = runMap.get(runId);
23131
+ const eventStatus = body.status;
23132
+ if (eventStatus === "started") {
23133
+ run.startedAt = logTime;
23134
+ } else if (eventStatus === "completed" || eventStatus === "timeout" || eventStatus === "error") {
23135
+ run.status = eventStatus;
23136
+ run.endedAt = logTime;
23137
+ if (run.startedAt) {
23138
+ run.durationMs = logTime - run.startedAt;
23139
+ }
23091
23140
  }
23092
23141
  }
23142
+ };
23143
+ ingestRunEvents(directRunEvents);
23144
+ const needsMoreRuns = () => runMap.size < limitNum;
23145
+ if (needsMoreRuns()) {
23146
+ try {
23147
+ const recentMessages = await runtime.getMemories({
23148
+ tableName: "messages",
23149
+ roomId: roomId ? roomId : undefined,
23150
+ count: 200
23151
+ });
23152
+ const authorIds = Array.from(new Set(recentMessages.map((m) => m.entityId).filter((eid) => Boolean(eid) && eid !== agentId))).slice(0, 10);
23153
+ const authorRunEvents = await Promise.all(authorIds.map((authorId) => runtime.getLogs({
23154
+ entityId: authorId,
23155
+ roomId: roomId ? roomId : undefined,
23156
+ type: "run_event",
23157
+ count: 500
23158
+ }).catch(() => [])));
23159
+ for (const logs of authorRunEvents) {
23160
+ ingestRunEvents(logs);
23161
+ if (!needsMoreRuns())
23162
+ break;
23163
+ }
23164
+ } catch {}
23165
+ }
23166
+ if (!roomId && needsMoreRuns()) {
23167
+ try {
23168
+ const worlds = await runtime.getAllWorlds();
23169
+ const roomIds = [];
23170
+ for (const w of worlds) {
23171
+ try {
23172
+ const rooms = await runtime.getRooms(w.id);
23173
+ roomIds.push(...rooms.map((r) => r.id));
23174
+ } catch {}
23175
+ if (roomIds.length > 20)
23176
+ break;
23177
+ }
23178
+ const participantLogs = await Promise.all(roomIds.map(async (rId) => {
23179
+ try {
23180
+ const participants = await runtime.getParticipantsForRoom(rId);
23181
+ const otherParticipants = participants.filter((pid) => pid !== agentId).slice(0, 5);
23182
+ const logsPerParticipant = await Promise.all(otherParticipants.map((participantId) => runtime.getLogs({
23183
+ entityId: participantId,
23184
+ roomId: rId,
23185
+ type: "run_event",
23186
+ count: 300
23187
+ }).catch(() => [])));
23188
+ return logsPerParticipant.flat();
23189
+ } catch {
23190
+ return [];
23191
+ }
23192
+ }));
23193
+ for (const logs of participantLogs) {
23194
+ ingestRunEvents(logs);
23195
+ if (!needsMoreRuns())
23196
+ break;
23197
+ }
23198
+ } catch {}
23093
23199
  }
23094
23200
  let runs = Array.from(runMap.values());
23095
- if (status && status !== "all") {
23096
- runs = runs.filter((run) => run.status === status);
23201
+ if (statusFilter && statusFilter !== "all") {
23202
+ runs = runs.filter((run) => run.status === statusFilter);
23097
23203
  }
23098
23204
  runs.sort((a, b) => (b.startedAt || 0) - (a.startedAt || 0));
23099
23205
  const limitedRuns = runs.slice(0, limitNum);
23100
23206
  const runIdSet = new Set(limitedRuns.map((r) => r.runId));
23101
- const [actionLogs, evaluatorLogs, genericLogs] = await Promise.all([
23102
- runtime.getLogs({
23103
- entityId: agentId,
23104
- roomId: roomId ? roomId : undefined,
23105
- type: "action",
23106
- count: 5000
23107
- }),
23108
- runtime.getLogs({
23109
- entityId: agentId,
23110
- roomId: roomId ? roomId : undefined,
23111
- type: "evaluator",
23112
- count: 5000
23113
- }),
23114
- runtime.getLogs({
23115
- entityId: agentId,
23116
- roomId: roomId ? roomId : undefined,
23117
- count: 5000
23118
- })
23119
- ]);
23207
+ let actionLogs = [];
23208
+ let evaluatorLogs = [];
23209
+ let genericLogs = [];
23210
+ if (runIdSet.size > 0) {
23211
+ const logFetchCount = Math.max(200, limitNum * 50);
23212
+ const [action, evaluator, generic] = await Promise.all([
23213
+ runtime.getLogs({
23214
+ entityId: agentId,
23215
+ roomId: roomId ? roomId : undefined,
23216
+ type: "action",
23217
+ count: logFetchCount
23218
+ }).catch(() => []),
23219
+ runtime.getLogs({
23220
+ entityId: agentId,
23221
+ roomId: roomId ? roomId : undefined,
23222
+ type: "evaluator",
23223
+ count: logFetchCount
23224
+ }).catch(() => []),
23225
+ runtime.getLogs({
23226
+ entityId: agentId,
23227
+ roomId: roomId ? roomId : undefined,
23228
+ count: logFetchCount
23229
+ }).catch(() => [])
23230
+ ]);
23231
+ actionLogs = action;
23232
+ evaluatorLogs = evaluator;
23233
+ genericLogs = generic;
23234
+ }
23120
23235
  const countsByRunId = {};
23121
23236
  for (const run of limitedRuns) {
23122
23237
  countsByRunId[run.runId] = { actions: 0, modelCalls: 0, errors: 0, evaluators: 0 };
@@ -23171,6 +23286,12 @@ function createAgentRunsRouter(elizaOS) {
23171
23286
  total: runs.length,
23172
23287
  hasMore: runs.length > limitNum
23173
23288
  };
23289
+ if (cacheKey) {
23290
+ runsCache.set(cacheKey, {
23291
+ payload: response,
23292
+ expiresAt: Date.now() + RUNS_CACHE_TTL
23293
+ });
23294
+ }
23174
23295
  sendSuccess(res, response);
23175
23296
  } catch (error) {
23176
23297
  sendError(res, 500, "RUNS_ERROR", "Error retrieving agent runs", error instanceof Error ? error.message : String(error));
@@ -23196,7 +23317,25 @@ function createAgentRunsRouter(elizaOS) {
23196
23317
  roomId: roomId ? roomId : undefined,
23197
23318
  count: 2000
23198
23319
  });
23199
- const related = logs.filter((l) => l.body.runId === runId);
23320
+ const recentForDetail = await runtime.getMemories({
23321
+ tableName: "messages",
23322
+ roomId: roomId ? roomId : undefined,
23323
+ count: 300
23324
+ });
23325
+ const detailAuthorIds = Array.from(new Set(recentForDetail.map((m) => m.entityId).filter((eid) => Boolean(eid) && eid !== agentId)));
23326
+ const participantRunEvents = [];
23327
+ for (const authorId of detailAuthorIds) {
23328
+ try {
23329
+ const rLogs = await runtime.getLogs({
23330
+ entityId: authorId,
23331
+ roomId: roomId ? roomId : undefined,
23332
+ type: "run_event",
23333
+ count: 2000
23334
+ });
23335
+ participantRunEvents.push(...rLogs);
23336
+ } catch {}
23337
+ }
23338
+ const related = logs.concat(participantRunEvents).filter((l) => l.body.runId === runId);
23200
23339
  const runEvents = related.filter((l) => l.type === "run_event").sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
23201
23340
  const started = runEvents.find((e) => e.body.status === "started");
23202
23341
  const last = runEvents[runEvents.length - 1];
@@ -27388,7 +27527,17 @@ function resolveEnvFile(startDir = process.cwd()) {
27388
27527
  }
27389
27528
  function createEnvironmentRouter() {
27390
27529
  const router = express29.Router();
27530
+ const isProd = false;
27391
27531
  router.get("/local", async (_req, res) => {
27532
+ if (isProd) {
27533
+ return res.status(403).json({
27534
+ success: false,
27535
+ error: {
27536
+ code: "FORBIDDEN",
27537
+ message: "Local environment inspection is disabled in production"
27538
+ }
27539
+ });
27540
+ }
27392
27541
  try {
27393
27542
  const localEnvPath = getLocalEnvPath();
27394
27543
  if (!localEnvPath) {
@@ -27418,6 +27567,15 @@ function createEnvironmentRouter() {
27418
27567
  }
27419
27568
  });
27420
27569
  router.post("/local", async (req, res) => {
27570
+ if (isProd) {
27571
+ return res.status(403).json({
27572
+ success: false,
27573
+ error: {
27574
+ code: "FORBIDDEN",
27575
+ message: "Local environment updates are disabled in production"
27576
+ }
27577
+ });
27578
+ }
27421
27579
  try {
27422
27580
  const { content } = req.body;
27423
27581
  if (!content || typeof content !== "object") {
@@ -27458,7 +27616,7 @@ import express30 from "express";
27458
27616
  // package.json
27459
27617
  var package_default = {
27460
27618
  name: "@elizaos/server",
27461
- version: "1.6.0-beta.1",
27619
+ version: "1.6.1-alpha.2",
27462
27620
  description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
27463
27621
  publishConfig: {
27464
27622
  access: "public",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/server",
3
- "version": "1.6.0-beta.1",
3
+ "version": "1.6.1-alpha.2",
4
4
  "description": "ElizaOS Server - Core server infrastructure for ElizaOS agents",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -44,7 +44,7 @@
44
44
  "dev": "bun run build.ts --watch"
45
45
  },
46
46
  "devDependencies": {
47
- "@elizaos/client": "1.6.0-beta.1",
47
+ "@elizaos/client": "1.6.1-alpha.2",
48
48
  "@types/node": "^24.0.1",
49
49
  "prettier": "3.5.3",
50
50
  "tsx": "4.19.4",
@@ -52,10 +52,10 @@
52
52
  "which": "^4.0.0",
53
53
  "ws": "^8.18.0"
54
54
  },
55
- "gitHead": "0432e28a2c39c59e34737a4bd0ca67b3290b7334",
55
+ "gitHead": "bc4c3def4ba6a556c86c62f24a2bbda3b8b734e4",
56
56
  "dependencies": {
57
- "@elizaos/core": "1.6.0-beta.1",
58
- "@elizaos/plugin-sql": "1.6.0-beta.1",
57
+ "@elizaos/core": "1.6.1-alpha.2",
58
+ "@elizaos/plugin-sql": "1.6.1-alpha.2",
59
59
  "@sentry/node": "^10.11.0",
60
60
  "@types/express": "^5.0.2",
61
61
  "@types/helmet": "^4.0.0",