@elizaos/core 1.6.5-alpha.15 → 1.6.5-alpha.16

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.
@@ -9894,6 +9894,530 @@ var require_picocolors = __commonJS((exports, module) => {
9894
9894
  module.exports.createColors = createColors;
9895
9895
  });
9896
9896
 
9897
+ // ../../node_modules/fast-redact/lib/validator.js
9898
+ var require_validator = __commonJS((exports, module) => {
9899
+ module.exports = validator2;
9900
+ function validator2(opts = {}) {
9901
+ const {
9902
+ ERR_PATHS_MUST_BE_STRINGS = () => "fast-redact - Paths must be (non-empty) strings",
9903
+ ERR_INVALID_PATH = (s) => `fast-redact – Invalid path (${s})`
9904
+ } = opts;
9905
+ return function validate({ paths }) {
9906
+ paths.forEach((s) => {
9907
+ if (typeof s !== "string") {
9908
+ throw Error(ERR_PATHS_MUST_BE_STRINGS());
9909
+ }
9910
+ try {
9911
+ if (/〇/.test(s))
9912
+ throw Error();
9913
+ const expr = (s[0] === "[" ? "" : ".") + s.replace(/^\*/, "〇").replace(/\.\*/g, ".〇").replace(/\[\*\]/g, "[〇]");
9914
+ if (/\n|\r|;/.test(expr))
9915
+ throw Error();
9916
+ if (/\/\*/.test(expr))
9917
+ throw Error();
9918
+ Function(`
9919
+ 'use strict'
9920
+ const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });
9921
+ const 〇 = null;
9922
+ o${expr}
9923
+ if ([o${expr}].length !== 1) throw Error()`)();
9924
+ } catch (e) {
9925
+ throw Error(ERR_INVALID_PATH(s));
9926
+ }
9927
+ });
9928
+ };
9929
+ }
9930
+ });
9931
+
9932
+ // ../../node_modules/fast-redact/lib/rx.js
9933
+ var require_rx = __commonJS((exports, module) => {
9934
+ module.exports = /[^.[\]]+|\[((?:.)*?)\]/g;
9935
+ });
9936
+
9937
+ // ../../node_modules/fast-redact/lib/parse.js
9938
+ var require_parse4 = __commonJS((exports, module) => {
9939
+ var rx = require_rx();
9940
+ module.exports = parse4;
9941
+ function parse4({ paths }) {
9942
+ const wildcards = [];
9943
+ var wcLen = 0;
9944
+ const secret = paths.reduce(function(o, strPath, ix) {
9945
+ var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
9946
+ const leadingBracket = strPath[0] === "[";
9947
+ path = path.map((p) => {
9948
+ if (p[0] === "[")
9949
+ return p.substr(1, p.length - 2);
9950
+ else
9951
+ return p;
9952
+ });
9953
+ const star = path.indexOf("*");
9954
+ if (star > -1) {
9955
+ const before = path.slice(0, star);
9956
+ const beforeStr = before.join(".");
9957
+ const after = path.slice(star + 1, path.length);
9958
+ const nested = after.length > 0;
9959
+ wcLen++;
9960
+ wildcards.push({
9961
+ before,
9962
+ beforeStr,
9963
+ after,
9964
+ nested
9965
+ });
9966
+ } else {
9967
+ o[strPath] = {
9968
+ path,
9969
+ val: undefined,
9970
+ precensored: false,
9971
+ circle: "",
9972
+ escPath: JSON.stringify(strPath),
9973
+ leadingBracket
9974
+ };
9975
+ }
9976
+ return o;
9977
+ }, {});
9978
+ return { wildcards, wcLen, secret };
9979
+ }
9980
+ });
9981
+
9982
+ // ../../node_modules/fast-redact/lib/redactor.js
9983
+ var require_redactor = __commonJS((exports, module) => {
9984
+ var rx = require_rx();
9985
+ module.exports = redactor;
9986
+ function redactor({ secret, serialize: serialize3, wcLen, strict, isCensorFct, censorFctTakesPath }, state) {
9987
+ const redact = Function("o", `
9988
+ if (typeof o !== 'object' || o == null) {
9989
+ ${strictImpl(strict, serialize3)}
9990
+ }
9991
+ const { censor, secret } = this
9992
+ const originalSecret = {}
9993
+ const secretKeys = Object.keys(secret)
9994
+ for (var i = 0; i < secretKeys.length; i++) {
9995
+ originalSecret[secretKeys[i]] = secret[secretKeys[i]]
9996
+ }
9997
+
9998
+ ${redactTmpl(secret, isCensorFct, censorFctTakesPath)}
9999
+ this.compileRestore()
10000
+ ${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)}
10001
+ this.secret = originalSecret
10002
+ ${resultTmpl(serialize3)}
10003
+ `).bind(state);
10004
+ redact.state = state;
10005
+ if (serialize3 === false) {
10006
+ redact.restore = (o) => state.restore(o);
10007
+ }
10008
+ return redact;
10009
+ }
10010
+ function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
10011
+ return Object.keys(secret).map((path) => {
10012
+ const { escPath, leadingBracket, path: arrPath } = secret[path];
10013
+ const skip = leadingBracket ? 1 : 0;
10014
+ const delim = leadingBracket ? "" : ".";
10015
+ const hops = [];
10016
+ var match;
10017
+ while ((match = rx.exec(path)) !== null) {
10018
+ const [, ix] = match;
10019
+ const { index, input } = match;
10020
+ if (index > skip)
10021
+ hops.push(input.substring(0, index - (ix ? 0 : 1)));
10022
+ }
10023
+ var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
10024
+ if (existence.length === 0)
10025
+ existence += `o${delim}${path} != null`;
10026
+ else
10027
+ existence += ` && o${delim}${path} != null`;
10028
+ const circularDetection = `
10029
+ switch (true) {
10030
+ ${hops.reverse().map((p) => `
10031
+ case o${delim}${p} === censor:
10032
+ secret[${escPath}].circle = ${JSON.stringify(p)}
10033
+ break
10034
+ `).join(`
10035
+ `)}
10036
+ }
10037
+ `;
10038
+ const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
10039
+ return `
10040
+ if (${existence}) {
10041
+ const val = o${delim}${path}
10042
+ if (val === censor) {
10043
+ secret[${escPath}].precensored = true
10044
+ } else {
10045
+ secret[${escPath}].val = val
10046
+ o${delim}${path} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
10047
+ ${circularDetection}
10048
+ }
10049
+ }
10050
+ `;
10051
+ }).join(`
10052
+ `);
10053
+ }
10054
+ function dynamicRedactTmpl(hasWildcards, isCensorFct, censorFctTakesPath) {
10055
+ return hasWildcards === true ? `
10056
+ {
10057
+ const { wildcards, wcLen, groupRedact, nestedRedact } = this
10058
+ for (var i = 0; i < wcLen; i++) {
10059
+ const { before, beforeStr, after, nested } = wildcards[i]
10060
+ if (nested === true) {
10061
+ secret[beforeStr] = secret[beforeStr] || []
10062
+ nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct}, ${censorFctTakesPath})
10063
+ } else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct}, ${censorFctTakesPath})
10064
+ }
10065
+ }
10066
+ ` : "";
10067
+ }
10068
+ function resultTmpl(serialize3) {
10069
+ return serialize3 === false ? `return o` : `
10070
+ var s = this.serialize(o)
10071
+ this.restore(o)
10072
+ return s
10073
+ `;
10074
+ }
10075
+ function strictImpl(strict, serialize3) {
10076
+ return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : serialize3 === false ? `return o` : `return this.serialize(o)`;
10077
+ }
10078
+ });
10079
+
10080
+ // ../../node_modules/fast-redact/lib/modifiers.js
10081
+ var require_modifiers = __commonJS((exports, module) => {
10082
+ module.exports = {
10083
+ groupRedact,
10084
+ groupRestore,
10085
+ nestedRedact,
10086
+ nestedRestore
10087
+ };
10088
+ function groupRestore({ keys: keys2, values, target }) {
10089
+ if (target == null || typeof target === "string")
10090
+ return;
10091
+ const length = keys2.length;
10092
+ for (var i = 0;i < length; i++) {
10093
+ const k = keys2[i];
10094
+ target[k] = values[i];
10095
+ }
10096
+ }
10097
+ function groupRedact(o, path, censor, isCensorFct, censorFctTakesPath) {
10098
+ const target = get(o, path);
10099
+ if (target == null || typeof target === "string")
10100
+ return { keys: null, values: null, target, flat: true };
10101
+ const keys2 = Object.keys(target);
10102
+ const keysLength = keys2.length;
10103
+ const pathLength = path.length;
10104
+ const pathWithKey = censorFctTakesPath ? [...path] : undefined;
10105
+ const values = new Array(keysLength);
10106
+ for (var i = 0;i < keysLength; i++) {
10107
+ const key = keys2[i];
10108
+ values[i] = target[key];
10109
+ if (censorFctTakesPath) {
10110
+ pathWithKey[pathLength] = key;
10111
+ target[key] = censor(target[key], pathWithKey);
10112
+ } else if (isCensorFct) {
10113
+ target[key] = censor(target[key]);
10114
+ } else {
10115
+ target[key] = censor;
10116
+ }
10117
+ }
10118
+ return { keys: keys2, values, target, flat: true };
10119
+ }
10120
+ function nestedRestore(instructions) {
10121
+ for (let i = 0;i < instructions.length; i++) {
10122
+ const { target, path, value } = instructions[i];
10123
+ let current = target;
10124
+ for (let i2 = path.length - 1;i2 > 0; i2--) {
10125
+ current = current[path[i2]];
10126
+ }
10127
+ current[path[0]] = value;
10128
+ }
10129
+ }
10130
+ function nestedRedact(store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
10131
+ const target = get(o, path);
10132
+ if (target == null)
10133
+ return;
10134
+ const keys2 = Object.keys(target);
10135
+ const keysLength = keys2.length;
10136
+ for (var i = 0;i < keysLength; i++) {
10137
+ const key = keys2[i];
10138
+ specialSet(store, target, key, path, ns, censor, isCensorFct, censorFctTakesPath);
10139
+ }
10140
+ return store;
10141
+ }
10142
+ function has(obj, prop) {
10143
+ return obj !== undefined && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
10144
+ }
10145
+ function specialSet(store, o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
10146
+ const afterPathLen = afterPath.length;
10147
+ const lastPathIndex = afterPathLen - 1;
10148
+ const originalKey = k;
10149
+ var i = -1;
10150
+ var n;
10151
+ var nv;
10152
+ var ov;
10153
+ var oov = null;
10154
+ var wc = null;
10155
+ var kIsWc;
10156
+ var wcov;
10157
+ var consecutive = false;
10158
+ var level = 0;
10159
+ var depth = 0;
10160
+ var redactPathCurrent = tree();
10161
+ ov = n = o[k];
10162
+ if (typeof n !== "object")
10163
+ return;
10164
+ while (n != null && ++i < afterPathLen) {
10165
+ depth += 1;
10166
+ k = afterPath[i];
10167
+ oov = ov;
10168
+ if (k !== "*" && !wc && !(typeof n === "object" && (k in n))) {
10169
+ break;
10170
+ }
10171
+ if (k === "*") {
10172
+ if (wc === "*") {
10173
+ consecutive = true;
10174
+ }
10175
+ wc = k;
10176
+ if (i !== lastPathIndex) {
10177
+ continue;
10178
+ }
10179
+ }
10180
+ if (wc) {
10181
+ const wcKeys = Object.keys(n);
10182
+ for (var j = 0;j < wcKeys.length; j++) {
10183
+ const wck = wcKeys[j];
10184
+ wcov = n[wck];
10185
+ kIsWc = k === "*";
10186
+ if (consecutive) {
10187
+ redactPathCurrent = node(redactPathCurrent, wck, depth);
10188
+ level = i;
10189
+ ov = iterateNthLevel(wcov, level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
10190
+ } else {
10191
+ if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
10192
+ if (kIsWc) {
10193
+ ov = wcov;
10194
+ } else {
10195
+ ov = wcov[k];
10196
+ }
10197
+ nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
10198
+ if (kIsWc) {
10199
+ const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
10200
+ store.push(rv);
10201
+ n[wck] = nv;
10202
+ } else {
10203
+ if (wcov[k] === nv) {} else if (nv === undefined && censor !== undefined || has(wcov, k) && nv === ov) {
10204
+ redactPathCurrent = node(redactPathCurrent, wck, depth);
10205
+ } else {
10206
+ redactPathCurrent = node(redactPathCurrent, wck, depth);
10207
+ const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, o[originalKey]);
10208
+ store.push(rv);
10209
+ wcov[k] = nv;
10210
+ }
10211
+ }
10212
+ }
10213
+ }
10214
+ }
10215
+ wc = null;
10216
+ } else {
10217
+ ov = n[k];
10218
+ redactPathCurrent = node(redactPathCurrent, k, depth);
10219
+ nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
10220
+ if (has(n, k) && nv === ov || nv === undefined && censor !== undefined) {} else {
10221
+ const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
10222
+ store.push(rv);
10223
+ n[k] = nv;
10224
+ }
10225
+ n = n[k];
10226
+ }
10227
+ if (typeof n !== "object")
10228
+ break;
10229
+ if (ov === oov || typeof ov === "undefined") {}
10230
+ }
10231
+ }
10232
+ function get(o, p) {
10233
+ var i = -1;
10234
+ var l = p.length;
10235
+ var n = o;
10236
+ while (n != null && ++i < l) {
10237
+ n = n[p[i]];
10238
+ }
10239
+ return n;
10240
+ }
10241
+ function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
10242
+ if (level === 0) {
10243
+ if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
10244
+ if (kIsWc) {
10245
+ ov = wcov;
10246
+ } else {
10247
+ ov = wcov[k];
10248
+ }
10249
+ nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
10250
+ if (kIsWc) {
10251
+ const rv = restoreInstr(redactPathCurrent, ov, parent);
10252
+ store.push(rv);
10253
+ n[wck] = nv;
10254
+ } else {
10255
+ if (wcov[k] === nv) {} else if (nv === undefined && censor !== undefined || has(wcov, k) && nv === ov) {} else {
10256
+ const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, parent);
10257
+ store.push(rv);
10258
+ wcov[k] = nv;
10259
+ }
10260
+ }
10261
+ }
10262
+ }
10263
+ for (const key in wcov) {
10264
+ if (typeof wcov[key] === "object") {
10265
+ redactPathCurrent = node(redactPathCurrent, key, depth);
10266
+ iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
10267
+ }
10268
+ }
10269
+ }
10270
+ function tree() {
10271
+ return { parent: null, key: null, children: [], depth: 0 };
10272
+ }
10273
+ function node(parent, key, depth) {
10274
+ if (parent.depth === depth) {
10275
+ return node(parent.parent, key, depth);
10276
+ }
10277
+ var child = {
10278
+ parent,
10279
+ key,
10280
+ depth,
10281
+ children: []
10282
+ };
10283
+ parent.children.push(child);
10284
+ return child;
10285
+ }
10286
+ function restoreInstr(node2, value, target) {
10287
+ let current = node2;
10288
+ const path = [];
10289
+ do {
10290
+ path.push(current.key);
10291
+ current = current.parent;
10292
+ } while (current.parent != null);
10293
+ return { path, value, target };
10294
+ }
10295
+ });
10296
+
10297
+ // ../../node_modules/fast-redact/lib/restorer.js
10298
+ var require_restorer = __commonJS((exports, module) => {
10299
+ var { groupRestore, nestedRestore } = require_modifiers();
10300
+ module.exports = restorer;
10301
+ function restorer() {
10302
+ return function compileRestore() {
10303
+ if (this.restore) {
10304
+ this.restore.state.secret = this.secret;
10305
+ return;
10306
+ }
10307
+ const { secret, wcLen } = this;
10308
+ const paths = Object.keys(secret);
10309
+ const resetters = resetTmpl(secret, paths);
10310
+ const hasWildcards = wcLen > 0;
10311
+ const state = hasWildcards ? { secret, groupRestore, nestedRestore } : { secret };
10312
+ this.restore = Function("o", restoreTmpl(resetters, paths, hasWildcards)).bind(state);
10313
+ this.restore.state = state;
10314
+ };
10315
+ }
10316
+ function resetTmpl(secret, paths) {
10317
+ return paths.map((path) => {
10318
+ const { circle, escPath, leadingBracket } = secret[path];
10319
+ const delim = leadingBracket ? "" : ".";
10320
+ const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path} = secret[${escPath}].val`;
10321
+ const clear = `secret[${escPath}].val = undefined`;
10322
+ return `
10323
+ if (secret[${escPath}].val !== undefined) {
10324
+ try { ${reset} } catch (e) {}
10325
+ ${clear}
10326
+ }
10327
+ `;
10328
+ }).join("");
10329
+ }
10330
+ function restoreTmpl(resetters, paths, hasWildcards) {
10331
+ const dynamicReset = hasWildcards === true ? `
10332
+ const keys = Object.keys(secret)
10333
+ const len = keys.length
10334
+ for (var i = len - 1; i >= ${paths.length}; i--) {
10335
+ const k = keys[i]
10336
+ const o = secret[k]
10337
+ if (o) {
10338
+ if (o.flat === true) this.groupRestore(o)
10339
+ else this.nestedRestore(o)
10340
+ secret[k] = null
10341
+ }
10342
+ }
10343
+ ` : "";
10344
+ return `
10345
+ const secret = this.secret
10346
+ ${dynamicReset}
10347
+ ${resetters}
10348
+ return o
10349
+ `;
10350
+ }
10351
+ });
10352
+
10353
+ // ../../node_modules/fast-redact/lib/state.js
10354
+ var require_state = __commonJS((exports, module) => {
10355
+ module.exports = state;
10356
+ function state(o) {
10357
+ const {
10358
+ secret,
10359
+ censor,
10360
+ compileRestore,
10361
+ serialize: serialize3,
10362
+ groupRedact,
10363
+ nestedRedact,
10364
+ wildcards,
10365
+ wcLen
10366
+ } = o;
10367
+ const builder = [{ secret, censor, compileRestore }];
10368
+ if (serialize3 !== false)
10369
+ builder.push({ serialize: serialize3 });
10370
+ if (wcLen > 0)
10371
+ builder.push({ groupRedact, nestedRedact, wildcards, wcLen });
10372
+ return Object.assign(...builder);
10373
+ }
10374
+ });
10375
+
10376
+ // ../../node_modules/fast-redact/index.js
10377
+ var require_fast_redact = __commonJS((exports, module) => {
10378
+ var validator2 = require_validator();
10379
+ var parse4 = require_parse4();
10380
+ var redactor = require_redactor();
10381
+ var restorer = require_restorer();
10382
+ var { groupRedact, nestedRedact } = require_modifiers();
10383
+ var state = require_state();
10384
+ var rx = require_rx();
10385
+ var validate5 = validator2();
10386
+ var noop = (o) => o;
10387
+ noop.restore = noop;
10388
+ var DEFAULT_CENSOR = "[REDACTED]";
10389
+ fastRedact.rx = rx;
10390
+ fastRedact.validator = validator2;
10391
+ module.exports = fastRedact;
10392
+ function fastRedact(opts = {}) {
10393
+ const paths = Array.from(new Set(opts.paths || []));
10394
+ const serialize3 = "serialize" in opts ? opts.serialize === false ? opts.serialize : typeof opts.serialize === "function" ? opts.serialize : JSON.stringify : JSON.stringify;
10395
+ const remove = opts.remove;
10396
+ if (remove === true && serialize3 !== JSON.stringify) {
10397
+ throw Error("fast-redact – remove option may only be set when serializer is JSON.stringify");
10398
+ }
10399
+ const censor = remove === true ? undefined : ("censor" in opts) ? opts.censor : DEFAULT_CENSOR;
10400
+ const isCensorFct = typeof censor === "function";
10401
+ const censorFctTakesPath = isCensorFct && censor.length > 1;
10402
+ if (paths.length === 0)
10403
+ return serialize3 || noop;
10404
+ validate5({ paths, serialize: serialize3, censor });
10405
+ const { wildcards, wcLen, secret } = parse4({ paths, censor });
10406
+ const compileRestore = restorer();
10407
+ const strict = "strict" in opts ? opts.strict : true;
10408
+ return redactor({ secret, wcLen, serialize: serialize3, strict, isCensorFct, censorFctTakesPath }, state({
10409
+ secret,
10410
+ censor,
10411
+ compileRestore,
10412
+ serialize: serialize3,
10413
+ groupRedact,
10414
+ nestedRedact,
10415
+ wildcards,
10416
+ wcLen
10417
+ }));
10418
+ }
10419
+ });
10420
+
9897
10421
  // ../../node_modules/randombytes/index.js
9898
10422
  var require_randombytes = __commonJS((exports, module) => {
9899
10423
  module.exports = __require("crypto").randomBytes;
@@ -11605,31 +12129,31 @@ var require_pbkdf2 = __commonJS((exports) => {
11605
12129
 
11606
12130
  // ../../node_modules/browserify-cipher/index.js
11607
12131
  var require_browserify_cipher = __commonJS((exports) => {
11608
- var crypto = __require("crypto");
11609
- exports.createCipher = exports.Cipher = crypto.createCipher;
11610
- exports.createCipheriv = exports.Cipheriv = crypto.createCipheriv;
11611
- exports.createDecipher = exports.Decipher = crypto.createDecipher;
11612
- exports.createDecipheriv = exports.Decipheriv = crypto.createDecipheriv;
11613
- exports.listCiphers = exports.getCiphers = crypto.getCiphers;
12132
+ var crypto2 = __require("crypto");
12133
+ exports.createCipher = exports.Cipher = crypto2.createCipher;
12134
+ exports.createCipheriv = exports.Cipheriv = crypto2.createCipheriv;
12135
+ exports.createDecipher = exports.Decipher = crypto2.createDecipher;
12136
+ exports.createDecipheriv = exports.Decipheriv = crypto2.createDecipheriv;
12137
+ exports.listCiphers = exports.getCiphers = crypto2.getCiphers;
11614
12138
  });
11615
12139
 
11616
12140
  // ../../node_modules/diffie-hellman/index.js
11617
12141
  var require_diffie_hellman = __commonJS((exports) => {
11618
- var crypto = __require("crypto");
11619
- exports.DiffieHellmanGroup = crypto.DiffieHellmanGroup;
11620
- exports.createDiffieHellmanGroup = crypto.createDiffieHellmanGroup;
11621
- exports.getDiffieHellman = crypto.getDiffieHellman;
11622
- exports.createDiffieHellman = crypto.createDiffieHellman;
11623
- exports.DiffieHellman = crypto.DiffieHellman;
12142
+ var crypto2 = __require("crypto");
12143
+ exports.DiffieHellmanGroup = crypto2.DiffieHellmanGroup;
12144
+ exports.createDiffieHellmanGroup = crypto2.createDiffieHellmanGroup;
12145
+ exports.getDiffieHellman = crypto2.getDiffieHellman;
12146
+ exports.createDiffieHellman = crypto2.createDiffieHellman;
12147
+ exports.DiffieHellman = crypto2.DiffieHellman;
11624
12148
  });
11625
12149
 
11626
12150
  // ../../node_modules/browserify-sign/index.js
11627
12151
  var require_browserify_sign = __commonJS((exports) => {
11628
- var crypto = __require("crypto");
11629
- exports.createSign = crypto.createSign;
11630
- exports.Sign = crypto.Sign;
11631
- exports.createVerify = crypto.createVerify;
11632
- exports.Verify = crypto.Verify;
12152
+ var crypto2 = __require("crypto");
12153
+ exports.createSign = crypto2.createSign;
12154
+ exports.Sign = crypto2.Sign;
12155
+ exports.createVerify = crypto2.createVerify;
12156
+ exports.Verify = crypto2.Verify;
11633
12157
  });
11634
12158
 
11635
12159
  // ../../node_modules/elliptic/package.json
@@ -14736,15 +15260,15 @@ var require_brorand = __commonJS((exports, module) => {
14736
15260
  }
14737
15261
  } else {
14738
15262
  try {
14739
- crypto = __require("crypto");
14740
- if (typeof crypto.randomBytes !== "function")
15263
+ crypto2 = __require("crypto");
15264
+ if (typeof crypto2.randomBytes !== "function")
14741
15265
  throw new Error("Not supported");
14742
15266
  Rand.prototype._rand = function _rand(n) {
14743
- return crypto.randomBytes(n);
15267
+ return crypto2.randomBytes(n);
14744
15268
  };
14745
15269
  } catch (e) {}
14746
15270
  }
14747
- var crypto;
15271
+ var crypto2;
14748
15272
  });
14749
15273
 
14750
15274
  // ../../node_modules/elliptic/lib/elliptic/curve/base.js
@@ -21360,12 +21884,12 @@ var require_evp_bytestokey = __commonJS((exports, module) => {
21360
21884
 
21361
21885
  // ../../node_modules/browserify-aes/index.js
21362
21886
  var require_browserify_aes = __commonJS((exports) => {
21363
- var crypto = __require("crypto");
21364
- exports.createCipher = exports.Cipher = crypto.createCipher;
21365
- exports.createCipheriv = exports.Cipheriv = crypto.createCipheriv;
21366
- exports.createDecipher = exports.Decipher = crypto.createDecipher;
21367
- exports.createDecipheriv = exports.Decipheriv = crypto.createDecipheriv;
21368
- exports.listCiphers = exports.getCiphers = crypto.getCiphers;
21887
+ var crypto2 = __require("crypto");
21888
+ exports.createCipher = exports.Cipher = crypto2.createCipher;
21889
+ exports.createCipheriv = exports.Cipheriv = crypto2.createCipheriv;
21890
+ exports.createDecipher = exports.Decipher = crypto2.createDecipher;
21891
+ exports.createDecipheriv = exports.Decipheriv = crypto2.createDecipheriv;
21892
+ exports.listCiphers = exports.getCiphers = crypto2.getCiphers;
21369
21893
  });
21370
21894
 
21371
21895
  // ../../node_modules/parse-asn1/fixProc.js
@@ -24708,21 +25232,21 @@ var require_browser2 = __commonJS((exports) => {
24708
25232
 
24709
25233
  // ../../node_modules/public-encrypt/index.js
24710
25234
  var require_public_encrypt = __commonJS((exports) => {
24711
- var crypto = __require("crypto");
24712
- if (typeof crypto.publicEncrypt !== "function") {
24713
- crypto = require_browser2();
25235
+ var crypto2 = __require("crypto");
25236
+ if (typeof crypto2.publicEncrypt !== "function") {
25237
+ crypto2 = require_browser2();
24714
25238
  }
24715
- exports.publicEncrypt = crypto.publicEncrypt;
24716
- exports.privateDecrypt = crypto.privateDecrypt;
24717
- if (typeof crypto.privateEncrypt !== "function") {
25239
+ exports.publicEncrypt = crypto2.publicEncrypt;
25240
+ exports.privateDecrypt = crypto2.privateDecrypt;
25241
+ if (typeof crypto2.privateEncrypt !== "function") {
24718
25242
  exports.privateEncrypt = require_browser2().privateEncrypt;
24719
25243
  } else {
24720
- exports.privateEncrypt = crypto.privateEncrypt;
25244
+ exports.privateEncrypt = crypto2.privateEncrypt;
24721
25245
  }
24722
- if (typeof crypto.publicDecrypt !== "function") {
25246
+ if (typeof crypto2.publicDecrypt !== "function") {
24723
25247
  exports.publicDecrypt = require_browser2().publicDecrypt;
24724
25248
  } else {
24725
- exports.publicDecrypt = crypto.publicDecrypt;
25249
+ exports.publicDecrypt = crypto2.publicDecrypt;
24726
25250
  }
24727
25251
  });
24728
25252
 
@@ -24732,7 +25256,7 @@ var require_browser3 = __commonJS((exports) => {
24732
25256
  var randombytes = require_randombytes();
24733
25257
  var Buffer2 = safeBuffer.Buffer;
24734
25258
  var kBufferMaxLength = safeBuffer.kMaxLength;
24735
- var crypto = global.crypto || global.msCrypto;
25259
+ var crypto2 = global.crypto || global.msCrypto;
24736
25260
  var kMaxUint32 = Math.pow(2, 32) - 1;
24737
25261
  function assertOffset(offset, length) {
24738
25262
  if (typeof offset !== "number" || offset !== offset) {
@@ -24756,7 +25280,7 @@ var require_browser3 = __commonJS((exports) => {
24756
25280
  throw new RangeError("buffer too small");
24757
25281
  }
24758
25282
  }
24759
- if (crypto && crypto.getRandomValues || true) {
25283
+ if (crypto2 && crypto2.getRandomValues || true) {
24760
25284
  exports.randomFill = randomFill;
24761
25285
  exports.randomFillSync = randomFillSync2;
24762
25286
  } else {}
@@ -24814,10 +25338,10 @@ var require_browser3 = __commonJS((exports) => {
24814
25338
 
24815
25339
  // ../../node_modules/randomfill/index.js
24816
25340
  var require_randomfill = __commonJS((exports, module) => {
24817
- var crypto = __require("crypto");
24818
- if (typeof crypto.randomFill === "function" && typeof crypto.randomFillSync === "function") {
24819
- exports.randomFill = crypto.randomFill;
24820
- exports.randomFillSync = crypto.randomFillSync;
25341
+ var crypto2 = __require("crypto");
25342
+ if (typeof crypto2.randomFill === "function" && typeof crypto2.randomFillSync === "function") {
25343
+ exports.randomFill = crypto2.randomFill;
25344
+ exports.randomFillSync = crypto2.randomFillSync;
24821
25345
  } else {
24822
25346
  module.exports = require_browser3();
24823
25347
  }
@@ -42500,6 +43024,7 @@ var console_styles = Object.freeze(styles_raw);
42500
43024
  var dist_default = Log;
42501
43025
 
42502
43026
  // src/logger.ts
43027
+ var import_fast_redact = __toESM(require_fast_redact(), 1);
42503
43028
  var __loggerTestHooks = {
42504
43029
  __noop: () => {}
42505
43030
  };
@@ -42553,6 +43078,37 @@ function parseBooleanFromText(value) {
42553
43078
  const normalized = value.toLowerCase().trim();
42554
43079
  return normalized === "true" || normalized === "1" || normalized === "yes" || normalized === "on";
42555
43080
  }
43081
+ function formatExtraValue(value) {
43082
+ if (value === null)
43083
+ return "null";
43084
+ if (value === undefined)
43085
+ return "undefined";
43086
+ if (typeof value === "string")
43087
+ return value;
43088
+ if (typeof value === "number" || typeof value === "boolean")
43089
+ return String(value);
43090
+ if (value instanceof Error)
43091
+ return value.message;
43092
+ return safeStringify(value);
43093
+ }
43094
+ function formatPrettyLog(context, message, isJsonMode) {
43095
+ if (isJsonMode) {
43096
+ return message;
43097
+ }
43098
+ const src = context.src;
43099
+ const srcPart = src ? `[${src.toUpperCase()}] ` : "";
43100
+ const excludeKeys = ["src", "agentId", "agentName"];
43101
+ const extraPairs = [];
43102
+ for (const [key, value] of Object.entries(context)) {
43103
+ if (excludeKeys.includes(key))
43104
+ continue;
43105
+ if (value === undefined)
43106
+ continue;
43107
+ extraPairs.push(`${key}=${formatExtraValue(value)}`);
43108
+ }
43109
+ const extrasPart = extraPairs.length > 0 ? ` (${extraPairs.join(", ")})` : "";
43110
+ return `${srcPart}${message}${extrasPart}`;
43111
+ }
42556
43112
  var DEFAULT_LOG_LEVEL = "info";
42557
43113
  var effectiveLogLevel = getEnv3("LOG_LEVEL") || DEFAULT_LOG_LEVEL;
42558
43114
  var customLevels = {
@@ -42568,6 +43124,46 @@ var customLevels = {
42568
43124
  };
42569
43125
  var raw = parseBooleanFromText(getEnv3("LOG_JSON_FORMAT"));
42570
43126
  var showTimestamps = parseBooleanFromText(getEnv3("LOG_TIMESTAMPS") ?? "true");
43127
+ var serverId = getEnv3("SERVER_ID") || (typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID().slice(0, 8) : Math.random().toString(36).slice(2, 10));
43128
+ var redact = import_fast_redact.default({
43129
+ paths: [
43130
+ "password",
43131
+ "passwd",
43132
+ "secret",
43133
+ "token",
43134
+ "apiKey",
43135
+ "api_key",
43136
+ "apiSecret",
43137
+ "api_secret",
43138
+ "authorization",
43139
+ "auth",
43140
+ "credential",
43141
+ "credentials",
43142
+ "privateKey",
43143
+ "private_key",
43144
+ "accessToken",
43145
+ "access_token",
43146
+ "refreshToken",
43147
+ "refresh_token",
43148
+ "cookie",
43149
+ "session",
43150
+ "jwt",
43151
+ "bearer",
43152
+ "*.password",
43153
+ "*.secret",
43154
+ "*.token",
43155
+ "*.apiKey",
43156
+ "*.api_key",
43157
+ "*.authorization",
43158
+ "*.credential",
43159
+ "*.credentials",
43160
+ "*.privateKey",
43161
+ "*.accessToken",
43162
+ "*.refreshToken"
43163
+ ],
43164
+ serialize: false,
43165
+ censor: "[REDACTED]"
43166
+ });
42571
43167
  function createInMemoryDestination(maxLogs = 100) {
42572
43168
  const logs = [];
42573
43169
  return {
@@ -42716,24 +43312,31 @@ function sealAdze(base) {
42716
43312
  const metaBase = { ...base };
42717
43313
  delete metaBase.namespace;
42718
43314
  delete metaBase.namespaces;
42719
- if (raw) {
42720
- if (!metaBase.name) {
42721
- metaBase.name = "elizaos";
42722
- }
42723
- if (!metaBase.hostname) {
42724
- let hostname = "unknown";
42725
- if (typeof process !== "undefined" && process.platform) {
42726
- try {
42727
- const os = __require("os");
42728
- hostname = os.hostname();
42729
- } catch {
42730
- hostname = "localhost";
42731
- }
42732
- } else if (typeof window !== "undefined" && window.location) {
42733
- hostname = window.location.hostname || "browser";
43315
+ if (!metaBase.name) {
43316
+ metaBase.name = "elizaos";
43317
+ }
43318
+ if (!metaBase.pid && typeof process !== "undefined" && process.pid) {
43319
+ metaBase.pid = process.pid;
43320
+ }
43321
+ if (!metaBase.environment && typeof process !== "undefined" && process.env) {
43322
+ metaBase.environment = "development";
43323
+ }
43324
+ if (!metaBase.serverId) {
43325
+ metaBase.serverId = serverId;
43326
+ }
43327
+ if (raw && !metaBase.hostname) {
43328
+ let hostname = "unknown";
43329
+ if (typeof process !== "undefined" && process.platform) {
43330
+ try {
43331
+ const os = __require("os");
43332
+ hostname = os.hostname();
43333
+ } catch {
43334
+ hostname = "localhost";
42734
43335
  }
42735
- metaBase.hostname = hostname;
43336
+ } else if (typeof window !== "undefined" && window.location) {
43337
+ hostname = window.location.hostname || "browser";
42736
43338
  }
43339
+ metaBase.hostname = hostname;
42737
43340
  }
42738
43341
  const globalConfig = {
42739
43342
  activeLevel: getAdzeActiveLevel(),
@@ -42788,6 +43391,15 @@ function createLogger(bindings = false) {
42788
43391
  console[consoleMethod](message);
42789
43392
  }
42790
43393
  };
43394
+ const safeRedact2 = (obj) => {
43395
+ try {
43396
+ const copy = { ...obj };
43397
+ redact(copy);
43398
+ return copy;
43399
+ } catch {
43400
+ return obj;
43401
+ }
43402
+ };
42791
43403
  const adaptArgs2 = (obj, msg, ...args) => {
42792
43404
  if (typeof obj === "string") {
42793
43405
  return msg !== undefined ? [obj, msg, ...args] : [obj, ...args];
@@ -42795,10 +43407,13 @@ function createLogger(bindings = false) {
42795
43407
  if (obj instanceof Error) {
42796
43408
  return msg !== undefined ? [obj.message, msg, ...args] : [obj.message, ...args];
42797
43409
  }
43410
+ const redactedObj = safeRedact2(obj);
42798
43411
  if (msg !== undefined) {
42799
- return [msg, obj, ...args];
43412
+ const formatted2 = formatPrettyLog(redactedObj, msg, false);
43413
+ return [formatted2, ...args];
42800
43414
  }
42801
- return [obj, ...args];
43415
+ const formatted = formatPrettyLog(redactedObj, "", false);
43416
+ return formatted ? [formatted, ...args] : [...args];
42802
43417
  };
42803
43418
  return {
42804
43419
  level: currentLevel2,
@@ -42867,6 +43482,15 @@ function createLogger(bindings = false) {
42867
43482
  console.log(`[${method.toUpperCase()}]`, ...args);
42868
43483
  }
42869
43484
  };
43485
+ const safeRedact = (obj) => {
43486
+ try {
43487
+ const copy = { ...obj };
43488
+ redact(copy);
43489
+ return copy;
43490
+ } catch {
43491
+ return obj;
43492
+ }
43493
+ };
42870
43494
  const adaptArgs = (obj, msg, ...args) => {
42871
43495
  if (typeof obj === "string") {
42872
43496
  return msg !== undefined ? [obj, msg, ...args] : [obj, ...args];
@@ -42874,10 +43498,19 @@ function createLogger(bindings = false) {
42874
43498
  if (obj instanceof Error) {
42875
43499
  return msg !== undefined ? [obj.message, { error: obj }, msg, ...args] : [obj.message, { error: obj }, ...args];
42876
43500
  }
43501
+ const redactedObj = safeRedact(obj);
42877
43502
  if (msg !== undefined) {
42878
- return [msg, obj, ...args];
43503
+ if (!raw) {
43504
+ const formatted = formatPrettyLog(redactedObj, msg, raw);
43505
+ return [formatted, ...args];
43506
+ }
43507
+ return [msg, redactedObj, ...args];
42879
43508
  }
42880
- return [obj, ...args];
43509
+ if (!raw) {
43510
+ const formatted = formatPrettyLog(redactedObj, "", raw);
43511
+ return formatted ? [formatted, ...args] : [...args];
43512
+ }
43513
+ return [redactedObj, ...args];
42881
43514
  };
42882
43515
  const trace = (obj, msg, ...args) => invoke("verbose", ...adaptArgs(obj, msg, ...args));
42883
43516
  const debug = (obj, msg, ...args) => invoke("debug", ...adaptArgs(obj, msg, ...args));
@@ -42986,7 +43619,7 @@ var formatPosts = ({
42986
43619
  const messageStrings = roomMessages.filter((message) => message.entityId).map((message) => {
42987
43620
  const entity = entities.find((entity2) => entity2.id === message.entityId);
42988
43621
  if (!entity) {
42989
- logger_default.warn({ entityId: message.entityId }, "core::prompts:formatPosts - no entity for");
43622
+ logger_default.warn({ src: "core:utils", entityId: message.entityId }, "No entity found for message");
42990
43623
  }
42991
43624
  const userName = entity?.names[0] || "Unknown User";
42992
43625
  const displayName = entity?.names[0] || "unknown";
@@ -43071,7 +43704,6 @@ function parseKeyValueXml(text) {
43071
43704
  let xmlContent;
43072
43705
  if (xmlBlockMatch) {
43073
43706
  xmlContent = xmlBlockMatch[1];
43074
- logger_default.debug("Found response XML block");
43075
43707
  } else {
43076
43708
  const findFirstXmlBlock = (input) => {
43077
43709
  let i = 0;
@@ -43144,12 +43776,10 @@ function parseKeyValueXml(text) {
43144
43776
  };
43145
43777
  const fb = findFirstXmlBlock(text);
43146
43778
  if (!fb) {
43147
- logger_default.warn("Could not find XML block in text");
43148
- logger_default.debug({ textPreview: text.substring(0, 200) + "..." }, "Text content");
43779
+ logger_default.warn({ src: "core:utils" }, "Could not find XML block in text");
43149
43780
  return null;
43150
43781
  }
43151
43782
  xmlContent = fb.content;
43152
- logger_default.debug(`Found XML block with tag: ${fb.tag}`);
43153
43783
  }
43154
43784
  const result = {};
43155
43785
  const extractDirectChildren = (input) => {
@@ -43234,8 +43864,7 @@ function parseKeyValueXml(text) {
43234
43864
  }
43235
43865
  }
43236
43866
  if (Object.keys(result).length === 0) {
43237
- logger_default.warn("No key-value pairs extracted from XML content");
43238
- logger_default.debug({ xmlPreview: xmlContent.substring(0, 200) + "..." }, "XML content was");
43867
+ logger_default.warn({ src: "core:utils" }, "No key-value pairs extracted from XML content");
43239
43868
  return null;
43240
43869
  }
43241
43870
  return result;
@@ -43286,17 +43915,12 @@ function truncateToCompleteSentence(text, maxLength) {
43286
43915
  return `${hardTruncated}...`;
43287
43916
  }
43288
43917
  async function splitChunks(content, chunkSize = 512, bleed = 20) {
43289
- logger_default.debug("[splitChunks] Starting text split");
43290
43918
  const characterstoTokens = 3.5;
43291
43919
  const textSplitter = new RecursiveCharacterTextSplitter({
43292
43920
  chunkSize: Number(Math.floor(chunkSize * characterstoTokens)),
43293
43921
  chunkOverlap: Number(Math.floor(bleed * characterstoTokens))
43294
43922
  });
43295
43923
  const chunks = await textSplitter.splitText(content);
43296
- logger_default.debug({
43297
- numberOfChunks: chunks.length,
43298
- averageChunkSize: chunks.reduce((acc, chunk) => acc + chunk.length, 0) / chunks.length
43299
- }, "[splitChunks] Split complete");
43300
43924
  return chunks;
43301
43925
  }
43302
43926
  async function trimTokens(prompt, maxTokens, runtime) {
@@ -44373,8 +44997,8 @@ Here are the actions taken by the assistant to fulfill the request:
44373
44997
  `;
44374
44998
 
44375
44999
  // src/roles.ts
44376
- async function getUserServerRole(runtime, entityId, serverId) {
44377
- const worldId = createUniqueUuid(runtime, serverId);
45000
+ async function getUserServerRole(runtime, entityId, serverId2) {
45001
+ const worldId = createUniqueUuid(runtime, serverId2);
44378
45002
  const world = await runtime.getWorld(worldId);
44379
45003
  if (!world || !world.metadata?.roles) {
44380
45004
  return "NONE" /* NONE */;
@@ -44389,12 +45013,12 @@ async function getUserServerRole(runtime, entityId, serverId) {
44389
45013
  }
44390
45014
  async function findWorldsForOwner(runtime, entityId) {
44391
45015
  if (!entityId) {
44392
- logger.error("User ID is required to find server");
45016
+ logger.error({ src: "core:roles", agentId: runtime.agentId }, "User ID is required to find server");
44393
45017
  return null;
44394
45018
  }
44395
45019
  const worlds = await runtime.getAllWorlds();
44396
45020
  if (!worlds || worlds.length === 0) {
44397
- logger.info("No worlds found for this agent");
45021
+ logger.debug({ src: "core:roles", agentId: runtime.agentId }, "No worlds found for agent");
44398
45022
  return null;
44399
45023
  }
44400
45024
  const ownerWorlds = [];
@@ -44511,7 +45135,7 @@ class DefaultMessageService {
44511
45135
  let timeoutId = undefined;
44512
45136
  const responseId = v4_default();
44513
45137
  try {
44514
- runtime.logger.info(`[MessageService] Message received from ${message.entityId} in room ${message.roomId}`);
45138
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, entityId: message.entityId, roomId: message.roomId }, "Message received");
44515
45139
  if (!latestResponseIds.has(runtime.agentId)) {
44516
45140
  latestResponseIds.set(runtime.agentId, new Map);
44517
45141
  }
@@ -44520,7 +45144,7 @@ class DefaultMessageService {
44520
45144
  throw new Error("Agent responses map not found");
44521
45145
  const previousResponseId = agentResponses.get(message.roomId);
44522
45146
  if (previousResponseId) {
44523
- logger.warn(`[MessageService] Updating response ID for room ${message.roomId} from ${previousResponseId} to ${responseId}`);
45147
+ logger.debug({ src: "service:message", roomId: message.roomId, previousResponseId, responseId }, "Updating response ID");
44524
45148
  }
44525
45149
  agentResponses.set(message.roomId, responseId);
44526
45150
  const runId = runtime.startRun(message.roomId);
@@ -44560,7 +45184,7 @@ class DefaultMessageService {
44560
45184
  return result;
44561
45185
  } catch (error) {
44562
45186
  clearTimeout(timeoutId);
44563
- runtime.logger.error({ error }, "[MessageService] Error in handleMessage:");
45187
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId, error }, "Error in handleMessage");
44564
45188
  throw error;
44565
45189
  }
44566
45190
  }
@@ -44570,7 +45194,7 @@ class DefaultMessageService {
44570
45194
  if (!agentResponses)
44571
45195
  throw new Error("Agent responses map not found");
44572
45196
  if (message.entityId === runtime.agentId) {
44573
- runtime.logger.debug(`[MessageService] Skipping message from self (${runtime.agentId})`);
45197
+ runtime.logger.debug({ src: "service:message", agentId: runtime.agentId }, "Skipping message from self");
44574
45198
  await this.emitRunEnded(runtime, runId, message, startTime, "self");
44575
45199
  return {
44576
45200
  didRespond: false,
@@ -44580,13 +45204,13 @@ class DefaultMessageService {
44580
45204
  mode: "none"
44581
45205
  };
44582
45206
  }
44583
- runtime.logger.debug(`[MessageService] Processing message: ${truncateToCompleteSentence(message.content.text || "", 50)}...`);
44584
- runtime.logger.debug("[MessageService] Saving message to memory and queueing embeddings");
45207
+ runtime.logger.debug({ src: "service:message", messagePreview: truncateToCompleteSentence(message.content.text || "", 50) }, "Processing message");
45208
+ runtime.logger.debug({ src: "service:message" }, "Saving message to memory");
44585
45209
  let memoryToQueue;
44586
45210
  if (message.id) {
44587
45211
  const existingMemory = await runtime.getMemoryById(message.id);
44588
45212
  if (existingMemory) {
44589
- runtime.logger.debug("[MessageService] Memory already exists, skipping creation");
45213
+ runtime.logger.debug({ src: "service:message" }, "Memory already exists, skipping creation");
44590
45214
  memoryToQueue = existingMemory;
44591
45215
  } else {
44592
45216
  const createdMemoryId = await runtime.createMemory(message, "messages");
@@ -44602,7 +45226,7 @@ class DefaultMessageService {
44602
45226
  const agentUserState = await runtime.getParticipantUserState(message.roomId, runtime.agentId);
44603
45227
  const defLllmOff = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_DEFLLMOFF"));
44604
45228
  if (defLllmOff && agentUserState === null) {
44605
- runtime.logger.debug("[MessageService] LLM is off by default");
45229
+ runtime.logger.debug({ src: "service:message" }, "LLM is off by default");
44606
45230
  await this.emitRunEnded(runtime, runId, message, startTime, "off");
44607
45231
  return {
44608
45232
  didRespond: false,
@@ -44613,7 +45237,7 @@ class DefaultMessageService {
44613
45237
  };
44614
45238
  }
44615
45239
  if (agentUserState === "MUTED" && !message.content.text?.toLowerCase().includes(runtime.character.name.toLowerCase())) {
44616
- runtime.logger.debug(`[MessageService] Ignoring muted room ${message.roomId}`);
45240
+ runtime.logger.debug({ src: "service:message", roomId: message.roomId }, "Ignoring muted room");
44617
45241
  await this.emitRunEnded(runtime, runId, message, startTime, "muted");
44618
45242
  return {
44619
45243
  didRespond: false,
@@ -44633,24 +45257,23 @@ class DefaultMessageService {
44633
45257
  }
44634
45258
  }
44635
45259
  const responseDecision = this.shouldRespond(runtime, message, room ?? undefined, mentionContext);
44636
- runtime.logger.debug(`[MessageService] Response decision: ${JSON.stringify(responseDecision)}`);
45260
+ runtime.logger.debug({ src: "service:message", responseDecision }, "Response decision");
44637
45261
  let shouldRespondToMessage = true;
44638
45262
  if (responseDecision.skipEvaluation) {
44639
- runtime.logger.debug(`[MessageService] Skipping evaluation for ${runtime.character.name} (${responseDecision.reason})`);
45263
+ runtime.logger.debug({ src: "service:message", agentName: runtime.character.name, reason: responseDecision.reason }, "Skipping LLM evaluation");
44640
45264
  shouldRespondToMessage = responseDecision.shouldRespond;
44641
45265
  } else {
44642
45266
  const shouldRespondPrompt = composePromptFromState({
44643
45267
  state,
44644
45268
  template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
44645
45269
  });
44646
- runtime.logger.debug(`[MessageService] Using LLM evaluation for ${runtime.character.name} (${responseDecision.reason})`);
45270
+ runtime.logger.debug({ src: "service:message", agentName: runtime.character.name, reason: responseDecision.reason }, "Using LLM evaluation");
44647
45271
  const response = await runtime.useModel(ModelType.TEXT_SMALL, {
44648
45272
  prompt: shouldRespondPrompt
44649
45273
  });
44650
- runtime.logger.debug(`[MessageService] LLM evaluation result:
44651
- ${response}`);
45274
+ runtime.logger.debug({ src: "service:message", response }, "LLM evaluation result");
44652
45275
  const responseObject = parseKeyValueXml(response);
44653
- runtime.logger.debug({ responseObject }, "[MessageService] Parsed evaluation result:");
45276
+ runtime.logger.debug({ src: "service:message", responseObject }, "Parsed evaluation result");
44654
45277
  const nonResponseActions = ["IGNORE", "NONE"];
44655
45278
  shouldRespondToMessage = responseObject?.action && !nonResponseActions.includes(responseObject.action.toUpperCase());
44656
45279
  }
@@ -44665,7 +45288,7 @@ ${response}`);
44665
45288
  mode = result.mode;
44666
45289
  const currentResponseId = agentResponses.get(message.roomId);
44667
45290
  if (currentResponseId !== responseId) {
44668
- runtime.logger.info(`Response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`);
45291
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, roomId: message.roomId }, "Response discarded - newer message being processed");
44669
45292
  return {
44670
45293
  didRespond: false,
44671
45294
  responseContent: null,
@@ -44683,14 +45306,14 @@ ${response}`);
44683
45306
  if (responseContent) {
44684
45307
  if (mode === "simple") {
44685
45308
  if (responseContent.providers && responseContent.providers.length > 0) {
44686
- runtime.logger.debug({ providers: responseContent.providers }, "[MessageService] Simple response used providers");
45309
+ runtime.logger.debug({ src: "service:message", providers: responseContent.providers }, "Simple response used providers");
44687
45310
  }
44688
45311
  if (callback) {
44689
45312
  await callback(responseContent);
44690
45313
  }
44691
45314
  } else if (mode === "actions") {
44692
45315
  await runtime.processActions(message, responseMessages, state, async (content) => {
44693
- runtime.logger.debug({ content }, "action callback");
45316
+ runtime.logger.debug({ src: "service:message", content }, "Action callback");
44694
45317
  responseContent.actionCallbacks = content;
44695
45318
  if (callback) {
44696
45319
  return callback(content);
@@ -44700,11 +45323,11 @@ ${response}`);
44700
45323
  }
44701
45324
  }
44702
45325
  } else {
44703
- runtime.logger.debug("[MessageService] Agent decided not to respond (shouldRespond is false).");
45326
+ runtime.logger.debug({ src: "service:message" }, "Agent decided not to respond");
44704
45327
  const currentResponseId = agentResponses.get(message.roomId);
44705
45328
  const keepResp = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_KEEP_RESP"));
44706
45329
  if (currentResponseId !== responseId && !keepResp) {
44707
- runtime.logger.info(`Ignore response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`);
45330
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, roomId: message.roomId }, "Ignore response discarded - newer message being processed");
44708
45331
  await this.emitRunEnded(runtime, runId, message, startTime, "replaced");
44709
45332
  return {
44710
45333
  didRespond: false,
@@ -44715,7 +45338,7 @@ ${response}`);
44715
45338
  };
44716
45339
  }
44717
45340
  if (!message.id) {
44718
- runtime.logger.error("[MessageService] Message ID is missing, cannot create ignore response.");
45341
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId }, "Message ID is missing, cannot create ignore response");
44719
45342
  await this.emitRunEnded(runtime, runId, message, startTime, "noMessageId");
44720
45343
  return {
44721
45344
  didRespond: false,
@@ -44743,14 +45366,14 @@ ${response}`);
44743
45366
  createdAt: Date.now()
44744
45367
  };
44745
45368
  await runtime.createMemory(ignoreMemory, "messages");
44746
- runtime.logger.debug("[MessageService] Saved ignore response to memory", `memoryId: ${ignoreMemory.id}`);
45369
+ runtime.logger.debug({ src: "service:message", memoryId: ignoreMemory.id }, "Saved ignore response to memory");
44747
45370
  }
44748
45371
  agentResponses.delete(message.roomId);
44749
45372
  if (agentResponses.size === 0) {
44750
45373
  latestResponseIds.delete(runtime.agentId);
44751
45374
  }
44752
45375
  await runtime.evaluate(message, state, shouldRespondToMessage, async (content) => {
44753
- runtime.logger.debug({ content }, "evaluate callback");
45376
+ runtime.logger.debug({ src: "service:message", content }, "Evaluate callback");
44754
45377
  if (responseContent) {
44755
45378
  responseContent.evalCallbacks = content;
44756
45379
  }
@@ -44823,7 +45446,7 @@ ${response}`);
44823
45446
  mode
44824
45447
  };
44825
45448
  } catch (error) {
44826
- console.error("error is", error);
45449
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId, error }, "Error processing message");
44827
45450
  await runtime.emitEvent("RUN_ENDED" /* RUN_ENDED */, {
44828
45451
  runtime,
44829
45452
  runId,
@@ -44884,7 +45507,7 @@ ${response}`);
44884
45507
  if (!attachments || attachments.length === 0) {
44885
45508
  return [];
44886
45509
  }
44887
- runtime.logger.debug(`[MessageService] Processing ${attachments.length} attachment(s)`);
45510
+ runtime.logger.debug({ src: "service:message", count: attachments.length }, "Processing attachments");
44888
45511
  const processedAttachments = [];
44889
45512
  for (const attachment of attachments) {
44890
45513
  try {
@@ -44892,7 +45515,7 @@ ${response}`);
44892
45515
  const isRemote = /^(http|https):\/\//.test(attachment.url);
44893
45516
  const url = isRemote ? attachment.url : getLocalServerUrl(attachment.url);
44894
45517
  if (attachment.contentType === "image" /* IMAGE */ && !attachment.description) {
44895
- runtime.logger.debug(`[MessageService] Generating description for image: ${attachment.url}`);
45518
+ runtime.logger.debug({ src: "service:message", imageUrl: attachment.url }, "Generating image description");
44896
45519
  let imageUrl = url;
44897
45520
  if (!isRemote) {
44898
45521
  const res = await fetch(url);
@@ -44914,7 +45537,7 @@ ${response}`);
44914
45537
  processedAttachment.description = parsedXml.description || "";
44915
45538
  processedAttachment.title = parsedXml.title || "Image";
44916
45539
  processedAttachment.text = parsedXml.text || parsedXml.description || "";
44917
- runtime.logger.debug(`[MessageService] Generated description: ${processedAttachment.description?.substring(0, 100)}...`);
45540
+ runtime.logger.debug({ src: "service:message", descriptionPreview: processedAttachment.description?.substring(0, 100) }, "Generated image description");
44918
45541
  } else {
44919
45542
  const responseStr = response;
44920
45543
  const titleMatch = responseStr.match(/<title>([^<]+)<\/title>/);
@@ -44924,21 +45547,21 @@ ${response}`);
44924
45547
  processedAttachment.title = titleMatch?.[1] || "Image";
44925
45548
  processedAttachment.description = descMatch?.[1] || "";
44926
45549
  processedAttachment.text = textMatch?.[1] || descMatch?.[1] || "";
44927
- runtime.logger.debug(`[MessageService] Used fallback XML parsing - description: ${processedAttachment.description?.substring(0, 100)}...`);
45550
+ runtime.logger.debug({ src: "service:message", descriptionPreview: processedAttachment.description?.substring(0, 100) }, "Used fallback XML parsing for description");
44928
45551
  } else {
44929
- runtime.logger.warn(`[MessageService] Failed to parse XML response for image description`);
45552
+ runtime.logger.warn({ src: "service:message" }, "Failed to parse XML response for image description");
44930
45553
  }
44931
45554
  }
44932
45555
  } else if (response && typeof response === "object" && "description" in response) {
44933
45556
  processedAttachment.description = response.description;
44934
45557
  processedAttachment.title = response.title || "Image";
44935
45558
  processedAttachment.text = response.description;
44936
- runtime.logger.debug(`[MessageService] Generated description: ${processedAttachment.description?.substring(0, 100)}...`);
45559
+ runtime.logger.debug({ src: "service:message", descriptionPreview: processedAttachment.description?.substring(0, 100) }, "Generated image description");
44937
45560
  } else {
44938
- runtime.logger.warn(`[MessageService] Unexpected response format for image description`);
45561
+ runtime.logger.warn({ src: "service:message" }, "Unexpected response format for image description");
44939
45562
  }
44940
45563
  } catch (error) {
44941
- runtime.logger.error({ error }, `[MessageService] Error generating image description:`);
45564
+ runtime.logger.error({ src: "service:message", error }, "Error generating image description");
44942
45565
  }
44943
45566
  } else if (attachment.contentType === "document" /* DOCUMENT */ && !attachment.text) {
44944
45567
  const res = await fetch(url);
@@ -44947,18 +45570,18 @@ ${response}`);
44947
45570
  const contentType = res.headers.get("content-type") || "";
44948
45571
  const isPlainText = contentType.startsWith("text/plain");
44949
45572
  if (isPlainText) {
44950
- runtime.logger.debug(`[MessageService] Processing plain text document: ${attachment.url}`);
45573
+ runtime.logger.debug({ src: "service:message", documentUrl: attachment.url }, "Processing plain text document");
44951
45574
  const textContent = await res.text();
44952
45575
  processedAttachment.text = textContent;
44953
45576
  processedAttachment.title = processedAttachment.title || "Text File";
44954
- runtime.logger.debug(`[MessageService] Extracted text content (first 100 chars): ${processedAttachment.text?.substring(0, 100)}...`);
45577
+ runtime.logger.debug({ src: "service:message", textPreview: processedAttachment.text?.substring(0, 100) }, "Extracted text content");
44955
45578
  } else {
44956
- runtime.logger.warn(`[MessageService] Skipping non-plain-text document: ${contentType}`);
45579
+ runtime.logger.warn({ src: "service:message", contentType }, "Skipping non-plain-text document");
44957
45580
  }
44958
45581
  }
44959
45582
  processedAttachments.push(processedAttachment);
44960
45583
  } catch (error) {
44961
- runtime.logger.error({ error, attachmentUrl: attachment.url }, `[MessageService] Failed to process attachment ${attachment.url}:`);
45584
+ runtime.logger.error({ src: "service:message", error, attachmentUrl: attachment.url }, "Failed to process attachment");
44962
45585
  processedAttachments.push(attachment);
44963
45586
  }
44964
45587
  }
@@ -44967,7 +45590,7 @@ ${response}`);
44967
45590
  async runSingleShotCore(runtime, message, state, opts) {
44968
45591
  state = await runtime.composeState(message, ["ACTIONS"]);
44969
45592
  if (!state.values?.actionNames) {
44970
- runtime.logger.warn("actionNames data missing from state, even though it was requested");
45593
+ runtime.logger.warn({ src: "service:message" }, "actionNames data missing from state");
44971
45594
  }
44972
45595
  const prompt = composePromptFromState({
44973
45596
  state,
@@ -44977,9 +45600,9 @@ ${response}`);
44977
45600
  let retries = 0;
44978
45601
  while (retries < opts.maxRetries && (!responseContent?.thought || !responseContent?.actions)) {
44979
45602
  const response = await runtime.useModel(ModelType.TEXT_LARGE, { prompt });
44980
- runtime.logger.debug({ response }, "[MessageService] *** Raw LLM Response ***");
45603
+ runtime.logger.debug({ src: "service:message", response }, "Raw LLM response");
44981
45604
  const parsedXml = parseKeyValueXml(response);
44982
- runtime.logger.debug({ parsedXml }, "[MessageService] *** Parsed XML Content ***");
45605
+ runtime.logger.debug({ src: "service:message", parsedXml }, "Parsed XML content");
44983
45606
  if (parsedXml) {
44984
45607
  responseContent = {
44985
45608
  ...parsedXml,
@@ -44994,7 +45617,7 @@ ${response}`);
44994
45617
  }
44995
45618
  retries++;
44996
45619
  if (!responseContent?.thought || !responseContent?.actions) {
44997
- runtime.logger.warn({ response, parsedXml, responseContent }, "[MessageService] *** Missing required fields (thought or actions), retrying... ***");
45620
+ runtime.logger.warn({ src: "service:message", retries, maxRetries: opts.maxRetries }, "Missing required fields (thought or actions), retrying");
44998
45621
  }
44999
45622
  }
45000
45623
  if (!responseContent) {
@@ -45037,7 +45660,7 @@ ${response}`);
45037
45660
  let iterationCount = 0;
45038
45661
  while (iterationCount < opts.maxMultiStepIterations) {
45039
45662
  iterationCount++;
45040
- runtime.logger.debug(`[MultiStep] Starting iteration ${iterationCount}/${opts.maxMultiStepIterations}`);
45663
+ runtime.logger.debug({ src: "service:message", iteration: iterationCount, maxIterations: opts.maxMultiStepIterations }, "Starting multi-step iteration");
45041
45664
  accumulatedState = await runtime.composeState(message, [
45042
45665
  "RECENT_MESSAGES",
45043
45666
  "ACTION_STATE"
@@ -45050,7 +45673,7 @@ ${response}`);
45050
45673
  const stepResultRaw = await runtime.useModel(ModelType.TEXT_LARGE, { prompt });
45051
45674
  const parsedStep = parseKeyValueXml(stepResultRaw);
45052
45675
  if (!parsedStep) {
45053
- runtime.logger.warn(`[MultiStep] Failed to parse step result at iteration ${iterationCount}`);
45676
+ runtime.logger.warn({ src: "service:message", iteration: iterationCount }, "Failed to parse multi-step result");
45054
45677
  traceActionResult.push({
45055
45678
  data: { actionName: "parse_error" },
45056
45679
  success: false,
@@ -45060,7 +45683,7 @@ ${response}`);
45060
45683
  }
45061
45684
  const { thought, providers = [], action, isFinish } = parsedStep;
45062
45685
  if (isFinish === "true" || isFinish === true) {
45063
- runtime.logger.info(`[MultiStep] Task marked as complete at iteration ${iterationCount}`);
45686
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, iteration: iterationCount }, "Multi-step task completed");
45064
45687
  if (callback) {
45065
45688
  await callback({
45066
45689
  text: "",
@@ -45070,14 +45693,14 @@ ${response}`);
45070
45693
  break;
45071
45694
  }
45072
45695
  if ((!providers || providers.length === 0) && !action) {
45073
- runtime.logger.warn(`[MultiStep] No providers or action specified at iteration ${iterationCount}, forcing completion`);
45696
+ runtime.logger.warn({ src: "service:message", iteration: iterationCount }, "No providers or action specified, forcing completion");
45074
45697
  break;
45075
45698
  }
45076
45699
  try {
45077
45700
  for (const providerName of providers) {
45078
45701
  const provider = runtime.providers.find((p) => p.name === providerName);
45079
45702
  if (!provider) {
45080
- runtime.logger.warn(`[MultiStep] Provider not found: ${providerName}`);
45703
+ runtime.logger.warn({ src: "service:message", providerName }, "Provider not found");
45081
45704
  traceActionResult.push({
45082
45705
  data: { actionName: providerName },
45083
45706
  success: false,
@@ -45087,7 +45710,7 @@ ${response}`);
45087
45710
  }
45088
45711
  const providerResult = await provider.get(runtime, message, state);
45089
45712
  if (!providerResult) {
45090
- runtime.logger.warn(`[MultiStep] Provider returned no result: ${providerName}`);
45713
+ runtime.logger.warn({ src: "service:message", providerName }, "Provider returned no result");
45091
45714
  traceActionResult.push({
45092
45715
  data: { actionName: providerName },
45093
45716
  success: false,
@@ -45140,7 +45763,7 @@ ${response}`);
45140
45763
  });
45141
45764
  }
45142
45765
  } catch (err) {
45143
- runtime.logger.error({ err }, "[MultiStep] Error executing step");
45766
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId, error: err }, "Error executing multi-step action");
45144
45767
  traceActionResult.push({
45145
45768
  data: { actionName: action || "unknown" },
45146
45769
  success: false,
@@ -45149,7 +45772,7 @@ ${response}`);
45149
45772
  }
45150
45773
  }
45151
45774
  if (iterationCount >= opts.maxMultiStepIterations) {
45152
- runtime.logger.warn(`[MultiStep] Reached maximum iterations (${opts.maxMultiStepIterations}), forcing completion`);
45775
+ runtime.logger.warn({ src: "service:message", maxIterations: opts.maxMultiStepIterations }, "Reached maximum iterations, forcing completion");
45153
45776
  }
45154
45777
  accumulatedState = await runtime.composeState(message, [
45155
45778
  "RECENT_MESSAGES",
@@ -45204,25 +45827,25 @@ ${response}`);
45204
45827
  async deleteMessage(runtime, message) {
45205
45828
  try {
45206
45829
  if (!message.id) {
45207
- runtime.logger.error("[MessageService] Cannot delete memory: message ID is missing");
45830
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId }, "Cannot delete memory: message ID is missing");
45208
45831
  return;
45209
45832
  }
45210
- runtime.logger.info("[MessageService] Deleting memory for message", message.id, "from room", message.roomId);
45833
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, messageId: message.id, roomId: message.roomId }, "Deleting memory");
45211
45834
  await runtime.deleteMemory(message.id);
45212
- runtime.logger.debug({ messageId: message.id }, "[MessageService] Successfully deleted memory for message");
45835
+ runtime.logger.debug({ src: "service:message", messageId: message.id }, "Successfully deleted memory");
45213
45836
  } catch (error) {
45214
- runtime.logger.error({ error }, "[MessageService] Error in deleteMessage:");
45837
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId, error }, "Error in deleteMessage");
45215
45838
  throw error;
45216
45839
  }
45217
45840
  }
45218
45841
  async clearChannel(runtime, roomId, channelId) {
45219
45842
  try {
45220
- runtime.logger.info(`[MessageService] Clearing message memories from channel ${channelId} -> room ${roomId}`);
45843
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, channelId, roomId }, "Clearing message memories from channel");
45221
45844
  const memories = await runtime.getMemoriesByRoomIds({
45222
45845
  tableName: "messages",
45223
45846
  roomIds: [roomId]
45224
45847
  });
45225
- runtime.logger.info(`[MessageService] Found ${memories.length} message memories to delete from channel ${channelId}`);
45848
+ runtime.logger.debug({ src: "service:message", channelId, count: memories.length }, "Found message memories to delete");
45226
45849
  let deletedCount = 0;
45227
45850
  for (const memory of memories) {
45228
45851
  if (memory.id) {
@@ -45230,13 +45853,13 @@ ${response}`);
45230
45853
  await runtime.deleteMemory(memory.id);
45231
45854
  deletedCount++;
45232
45855
  } catch (error) {
45233
- runtime.logger.warn({ error, memoryId: memory.id }, `[MessageService] Failed to delete message memory ${memory.id}:`);
45856
+ runtime.logger.warn({ src: "service:message", error, memoryId: memory.id }, "Failed to delete message memory");
45234
45857
  }
45235
45858
  }
45236
45859
  }
45237
- runtime.logger.info(`[MessageService] Successfully cleared ${deletedCount}/${memories.length} message memories from channel ${channelId}`);
45860
+ runtime.logger.info({ src: "service:message", agentId: runtime.agentId, channelId, deletedCount, totalCount: memories.length }, "Cleared message memories from channel");
45238
45861
  } catch (error) {
45239
- runtime.logger.error({ error }, "[MessageService] Error in clearChannel:");
45862
+ runtime.logger.error({ src: "service:message", agentId: runtime.agentId, error }, "Error in clearChannel");
45240
45863
  throw error;
45241
45864
  }
45242
45865
  }
@@ -46115,7 +46738,6 @@ class AgentRuntime {
46115
46738
  initPromise;
46116
46739
  initResolver;
46117
46740
  initRejecter;
46118
- migratedPlugins = new Set;
46119
46741
  currentRunId;
46120
46742
  currentRoomId;
46121
46743
  currentActionContext;
@@ -46146,7 +46768,7 @@ class AgentRuntime {
46146
46768
  }
46147
46769
  }
46148
46770
  }
46149
- this.logger.debug(`Success: Agent ID: ${this.agentId}`);
46771
+ this.logger.debug({ src: "agent", agentId: this.agentId, agentName: this.character?.name }, "Initialized");
46150
46772
  this.currentRunId = undefined;
46151
46773
  if (opts.settings?.MAX_WORKING_MEMORY_ENTRIES) {
46152
46774
  this.maxWorkingMemoryEntries = parseInt(opts.settings.MAX_WORKING_MEMORY_ENTRIES, 10) || 50;
@@ -46175,20 +46797,20 @@ class AgentRuntime {
46175
46797
  async registerPlugin(plugin) {
46176
46798
  if (!plugin?.name) {
46177
46799
  const errorMsg = "Plugin or plugin name is undefined";
46178
- this.logger.error(`*** registerPlugin: ${errorMsg}`);
46179
- throw new Error(`*** registerPlugin: ${errorMsg}`);
46800
+ this.logger.error({ src: "agent", agentId: this.agentId, error: errorMsg }, "Plugin registration failed");
46801
+ throw new Error(`registerPlugin: ${errorMsg}`);
46180
46802
  }
46181
46803
  const existingPlugin = this.plugins.find((p) => p.name === plugin.name);
46182
46804
  if (existingPlugin) {
46183
- this.logger.warn(`${this.character.name}(${this.agentId}) - Plugin ${plugin.name} is already registered. Skipping re-registration.`);
46805
+ this.logger.warn({ src: "agent", agentId: this.agentId, plugin: plugin.name }, "Plugin already registered, skipping");
46184
46806
  return;
46185
46807
  }
46186
46808
  this.plugins.push(plugin);
46187
- this.logger.debug(`Success: Plugin ${plugin.name} added to active plugins for ${this.character.name}(${this.agentId}).`);
46809
+ this.logger.debug({ src: "agent", agentId: this.agentId, plugin: plugin.name }, "Plugin added");
46188
46810
  if (plugin.init) {
46189
46811
  try {
46190
46812
  await plugin.init(plugin.config || {}, this);
46191
- this.logger.debug(`Success: Plugin ${plugin.name} initialized successfully`);
46813
+ this.logger.debug({ src: "agent", agentId: this.agentId, plugin: plugin.name }, "Plugin initialized");
46192
46814
  } catch (error) {
46193
46815
  const errorMessage = error instanceof Error ? error.message : String(error);
46194
46816
  if (errorMessage.includes("API key") || errorMessage.includes("environment variables") || errorMessage.includes("Invalid plugin configuration")) {
@@ -46201,7 +46823,7 @@ class AgentRuntime {
46201
46823
  }
46202
46824
  }
46203
46825
  if (plugin.adapter) {
46204
- this.logger.debug(`Registering database adapter for plugin ${plugin.name}`);
46826
+ this.logger.debug({ src: "agent", agentId: this.agentId, plugin: plugin.name }, "Registering database adapter");
46205
46827
  this.registerDatabaseAdapter(plugin.adapter);
46206
46828
  }
46207
46829
  if (plugin.actions) {
@@ -46240,14 +46862,13 @@ class AgentRuntime {
46240
46862
  if (plugin.services) {
46241
46863
  for (const service of plugin.services) {
46242
46864
  const serviceType = service.serviceType;
46243
- const serviceName = service.name || "Unknown";
46244
- this.logger.debug(`Plugin ${plugin.name} registering service: ${serviceType}`);
46865
+ this.logger.debug({ src: "agent", agentId: this.agentId, plugin: plugin.name, serviceType }, "Registering service");
46245
46866
  if (!this.servicePromises.has(serviceType)) {
46246
46867
  this._createServiceResolver(serviceType);
46247
46868
  }
46248
46869
  this.serviceRegistrationStatus.set(serviceType, "pending");
46249
46870
  this.registerService(service).catch((error) => {
46250
- this.logger.error(`Plugin ${plugin.name} failed to register service ${serviceType}: ${error instanceof Error ? error.message : String(error)}`);
46871
+ this.logger.error({ src: "agent", agentId: this.agentId, plugin: plugin.name, serviceType, error: error instanceof Error ? error.message : String(error) }, "Service registration failed");
46251
46872
  const handler = this.servicePromiseHandlers.get(serviceType);
46252
46873
  if (handler) {
46253
46874
  const serviceError = new Error(`Service ${serviceType} from plugin ${plugin.name} failed to register: ${error instanceof Error ? error.message : String(error)}`);
@@ -46264,9 +46885,9 @@ class AgentRuntime {
46264
46885
  return this.services;
46265
46886
  }
46266
46887
  async stop() {
46267
- this.logger.debug(`runtime::stop - character ${this.character.name}`);
46268
- for (const [serviceName, services] of this.services) {
46269
- this.logger.debug(`runtime::stop - requesting service stop for ${serviceName}`);
46888
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Stopping runtime");
46889
+ for (const [serviceType, services] of this.services) {
46890
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType }, "Stopping service");
46270
46891
  for (const service of services) {
46271
46892
  await service.stop();
46272
46893
  }
@@ -46284,8 +46905,7 @@ class AgentRuntime {
46284
46905
  }
46285
46906
  await Promise.all(pluginRegistrationPromises);
46286
46907
  if (!this.adapter) {
46287
- const errorMsg = "Database adapter not initialized. Make sure @elizaos/plugin-sql is included in your plugins.";
46288
- this.logger.error(errorMsg);
46908
+ this.logger.error({ src: "agent", agentId: this.agentId }, "Database adapter not initialized");
46289
46909
  throw new Error("Database adapter not initialized. The SQL plugin (@elizaos/plugin-sql) is required for agent initialization. Please ensure it is included in your character configuration.");
46290
46910
  }
46291
46911
  if (!await this.adapter.isReady()) {
@@ -46294,11 +46914,11 @@ class AgentRuntime {
46294
46914
  this.messageService = new DefaultMessageService;
46295
46915
  const skipMigrations = options?.skipMigrations ?? false;
46296
46916
  if (skipMigrations) {
46297
- this.logger.info("Skipping plugin migrations (skipMigrations=true)");
46917
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Skipping plugin migrations");
46298
46918
  } else {
46299
- this.logger.info("Running plugin migrations...");
46919
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Running plugin migrations");
46300
46920
  await this.runPluginMigrations();
46301
- this.logger.info("Plugin migrations completed.");
46921
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Plugin migrations completed");
46302
46922
  }
46303
46923
  const existingAgent = await this.ensureAgentExists({
46304
46924
  ...this.character,
@@ -46341,7 +46961,7 @@ class AgentRuntime {
46341
46961
  agentEntity = await this.getEntityById(this.agentId);
46342
46962
  if (!agentEntity)
46343
46963
  throw new Error(`Agent entity not found for ${this.agentId}`);
46344
- this.logger.debug(`Success: Agent entity created successfully for ${this.character.name}`);
46964
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Agent entity created");
46345
46965
  }
46346
46966
  const room = await this.getRoom(this.agentId);
46347
46967
  if (!room) {
@@ -46359,14 +46979,13 @@ class AgentRuntime {
46359
46979
  if (!participants.includes(this.agentId)) {
46360
46980
  const added = await this.addParticipant(this.agentId, this.agentId);
46361
46981
  if (!added) {
46362
- const errorMsg = `Failed to add agent ${this.agentId} as participant to its own room`;
46363
- throw new Error(errorMsg);
46982
+ throw new Error(`Failed to add agent ${this.agentId} as participant to its own room`);
46364
46983
  }
46365
- this.logger.debug(`Agent ${this.character.name} linked to its own room successfully`);
46984
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Agent linked to room");
46366
46985
  }
46367
46986
  const embeddingModel = this.getModel(ModelType.TEXT_EMBEDDING);
46368
46987
  if (!embeddingModel) {
46369
- this.logger.warn(`[AgentRuntime][${this.character.name}] No TEXT_EMBEDDING model registered. Skipping embedding dimension setup.`);
46988
+ this.logger.warn({ src: "agent", agentId: this.agentId }, "No TEXT_EMBEDDING model registered, skipping embedding setup");
46370
46989
  } else {
46371
46990
  await this.ensureEmbeddingDimension();
46372
46991
  }
@@ -46376,7 +46995,7 @@ class AgentRuntime {
46376
46995
  }
46377
46996
  } catch (error) {
46378
46997
  const errorMsg = error instanceof Error ? error.message : String(error);
46379
- this.logger.error(`Runtime initialization failed: ${errorMsg}`);
46998
+ this.logger.error({ src: "agent", agentId: this.agentId, error: errorMsg }, "Runtime initialization failed");
46380
46999
  if (this.initRejecter) {
46381
47000
  this.initRejecter(error);
46382
47001
  this.initRejecter = undefined;
@@ -46396,31 +47015,30 @@ class AgentRuntime {
46396
47015
  }
46397
47016
  async runPluginMigrations() {
46398
47017
  if (!this.adapter) {
46399
- this.logger.warn("Database adapter not found, skipping plugin migrations.");
47018
+ this.logger.warn({ src: "agent", agentId: this.agentId }, "Database adapter not found, skipping plugin migrations");
46400
47019
  return;
46401
47020
  }
46402
47021
  if (typeof this.adapter.runPluginMigrations !== "function") {
46403
- this.logger.warn("Database adapter does not support plugin migrations.");
47022
+ this.logger.warn({ src: "agent", agentId: this.agentId }, "Database adapter does not support plugin migrations");
46404
47023
  return;
46405
47024
  }
46406
47025
  const pluginsWithSchemas = this.plugins.filter((p) => p.schema).map((p) => ({ name: p.name, schema: p.schema }));
46407
47026
  if (pluginsWithSchemas.length === 0) {
46408
- this.logger.info("No plugins with schemas found, skipping migrations.");
47027
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "No plugins with schemas, skipping migrations");
46409
47028
  return;
46410
47029
  }
46411
- this.logger.info(`Found ${pluginsWithSchemas.length} plugins with schemas to migrate.`);
47030
+ this.logger.debug({ src: "agent", agentId: this.agentId, count: pluginsWithSchemas.length }, "Found plugins with schemas");
46412
47031
  try {
46413
47032
  const isProduction = false;
46414
47033
  const forceDestructive = process.env.ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS === "true";
46415
- const options = {
47034
+ await this.adapter.runPluginMigrations(pluginsWithSchemas, {
46416
47035
  verbose: !isProduction,
46417
47036
  force: forceDestructive,
46418
47037
  dryRun: false
46419
- };
46420
- await this.adapter.runPluginMigrations(pluginsWithSchemas, options);
46421
- this.logger.info("Plugin migrations completed successfully.");
47038
+ });
47039
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Plugin migrations completed");
46422
47040
  } catch (error) {
46423
- this.logger.error(error instanceof Error ? error : new Error(String(error)), "Failed to run plugin migrations");
47041
+ this.logger.error({ src: "agent", agentId: this.agentId, error: error instanceof Error ? error.message : String(error) }, "Plugin migrations failed");
46424
47042
  throw error;
46425
47043
  }
46426
47044
  }
@@ -46457,26 +47075,22 @@ class AgentRuntime {
46457
47075
  }
46458
47076
  registerDatabaseAdapter(adapter) {
46459
47077
  if (this.adapter) {
46460
- this.logger.warn("Database adapter already registered. Additional adapters will be ignored. This may lead to unexpected behavior.");
47078
+ this.logger.warn({ src: "agent", agentId: this.agentId }, "Database adapter already registered, ignoring");
46461
47079
  } else {
46462
47080
  this.adapter = adapter;
46463
- this.logger.debug("Success: Database adapter registered successfully.");
47081
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "Database adapter registered");
46464
47082
  }
46465
47083
  }
46466
47084
  registerProvider(provider) {
46467
47085
  this.providers.push(provider);
46468
- this.logger.debug(`Success: Provider ${provider.name} registered successfully.`);
47086
+ this.logger.debug({ src: "agent", agentId: this.agentId, provider: provider.name }, "Provider registered");
46469
47087
  }
46470
47088
  registerAction(action) {
46471
47089
  if (this.actions.find((a) => a.name === action.name)) {
46472
- this.logger.warn(`${this.character.name}(${this.agentId}) - Action ${action.name} already exists. Skipping registration.`);
47090
+ this.logger.warn({ src: "agent", agentId: this.agentId, action: action.name }, "Action already registered, skipping");
46473
47091
  } else {
46474
- try {
46475
- this.actions.push(action);
46476
- this.logger.success(`${this.character.name}(${this.agentId}) - Action ${action.name} registered successfully.`);
46477
- } catch (e) {
46478
- console.error("Error registering action", e);
46479
- }
47092
+ this.actions.push(action);
47093
+ this.logger.debug({ src: "agent", agentId: this.agentId, action: action.name }, "Action registered");
46480
47094
  }
46481
47095
  }
46482
47096
  registerEvaluator(evaluator) {
@@ -46487,7 +47101,7 @@ class AgentRuntime {
46487
47101
  }
46488
47102
  updateActionStep(plan, index, stepUpdates) {
46489
47103
  if (!plan.steps || index < 0 || index >= plan.steps.length) {
46490
- this.logger.warn(`Invalid step index: ${index} for plan with ${plan.steps?.length || 0} steps`);
47104
+ this.logger.warn({ src: "agent", agentId: this.agentId, index, stepsCount: plan.steps?.length || 0 }, "Invalid step index");
46491
47105
  return plan;
46492
47106
  }
46493
47107
  return {
@@ -46526,13 +47140,13 @@ class AgentRuntime {
46526
47140
  return actionString.toLowerCase().replace(/_/g, "");
46527
47141
  };
46528
47142
  if (!response.content?.actions || response.content.actions.length === 0) {
46529
- this.logger.warn("No action found in the response content.");
47143
+ this.logger.warn({ src: "agent", agentId: this.agentId }, "No action found in response");
46530
47144
  continue;
46531
47145
  }
46532
47146
  const actions = response.content.actions;
46533
47147
  const actionResults = [];
46534
47148
  let accumulatedState = state;
46535
- this.logger.debug(`Found actions: ${this.actions.map((a) => normalizeAction(a.name))}`);
47149
+ this.logger.trace({ src: "agent", agentId: this.agentId, actions: this.actions.map((a) => normalizeAction(a.name)) }, "Available actions");
46536
47150
  for (const responseAction of actions) {
46537
47151
  if (actionPlan) {
46538
47152
  actionPlan = this.updateActionPlan(actionPlan, { currentStep: actionIndex + 1 });
@@ -46545,34 +47159,31 @@ class AgentRuntime {
46545
47159
  accumulatedState.data.actionPlan = actionPlan;
46546
47160
  accumulatedState.data.actionResults = actionResults;
46547
47161
  }
46548
- this.logger.debug(`Success: Calling action: ${responseAction}`);
47162
+ this.logger.debug({ src: "agent", agentId: this.agentId, action: responseAction }, "Processing action");
46549
47163
  const normalizedResponseAction = normalizeAction(responseAction);
46550
47164
  let action = this.actions.find((a) => normalizeAction(a.name) === normalizedResponseAction);
46551
47165
  if (!action) {
46552
47166
  action = this.actions.find((a) => normalizeAction(a.name).includes(normalizedResponseAction) || normalizedResponseAction.includes(normalizeAction(a.name)));
46553
47167
  }
46554
- if (action) {
46555
- this.logger.debug(`Success: Found action: ${action?.name}`);
46556
- } else {
46557
- this.logger.debug("Attempting to find action in similes.");
47168
+ if (!action) {
46558
47169
  for (const _action of this.actions) {
46559
47170
  const exactSimileMatch = _action.similes?.find((simile) => normalizeAction(simile) === normalizedResponseAction);
46560
47171
  if (exactSimileMatch) {
46561
47172
  action = _action;
46562
- this.logger.debug(`Success: Action found in similes (exact match): ${action.name}`);
47173
+ this.logger.debug({ src: "agent", agentId: this.agentId, action: action.name, match: "simile" }, "Action resolved via simile");
46563
47174
  break;
46564
47175
  }
46565
47176
  const fuzzySimileMatch = _action.similes?.find((simile) => normalizeAction(simile).includes(normalizedResponseAction) || normalizedResponseAction.includes(normalizeAction(simile)));
46566
47177
  if (fuzzySimileMatch) {
46567
47178
  action = _action;
46568
- this.logger.debug(`Success: Action found in similes (fuzzy match): ${action.name}`);
47179
+ this.logger.debug({ src: "agent", agentId: this.agentId, action: action.name, match: "fuzzy" }, "Action resolved via fuzzy match");
46569
47180
  break;
46570
47181
  }
46571
47182
  }
46572
47183
  }
46573
47184
  if (!action) {
46574
- const errorMsg = `No action found for: ${responseAction}`;
46575
- this.logger.error(errorMsg);
47185
+ const errorMsg = `Action not found: ${responseAction}`;
47186
+ this.logger.error({ src: "agent", agentId: this.agentId, action: responseAction }, "Action not found");
46576
47187
  if (actionPlan && actionPlan.steps[actionIndex]) {
46577
47188
  actionPlan = this.updateActionStep(actionPlan, actionIndex, {
46578
47189
  status: "failed",
@@ -46598,7 +47209,7 @@ class AgentRuntime {
46598
47209
  continue;
46599
47210
  }
46600
47211
  if (!action.handler) {
46601
- this.logger.error(`Action ${action.name} has no handler.`);
47212
+ this.logger.error({ src: "agent", agentId: this.agentId, action: action.name }, "Action has no handler");
46602
47213
  if (actionPlan && actionPlan.steps[actionIndex]) {
46603
47214
  actionPlan = this.updateActionStep(actionPlan, actionIndex, {
46604
47215
  status: "failed",
@@ -46609,7 +47220,7 @@ class AgentRuntime {
46609
47220
  continue;
46610
47221
  }
46611
47222
  try {
46612
- this.logger.debug(`Executing handler for action: ${action.name}`);
47223
+ this.logger.debug({ src: "agent", agentId: this.agentId, action: action.name }, "Executing action");
46613
47224
  const actionId = v4_default();
46614
47225
  this.currentActionContext = {
46615
47226
  actionName: action.name,
@@ -46634,7 +47245,6 @@ class AgentRuntime {
46634
47245
  };
46635
47246
  }
46636
47247
  try {
46637
- this.logger.debug(`Creating action start message for: ${action.name}`);
46638
47248
  await this.emitEvent("ACTION_STARTED" /* ACTION_STARTED */, {
46639
47249
  messageId: actionId,
46640
47250
  roomId: message.roomId,
@@ -46651,7 +47261,7 @@ class AgentRuntime {
46651
47261
  }
46652
47262
  });
46653
47263
  } catch (error) {
46654
- this.logger.error("Failed to create action start message:", String(error));
47264
+ this.logger.error({ src: "agent", agentId: this.agentId, action: action.name, error: String(error) }, "Failed to emit action start event");
46655
47265
  }
46656
47266
  let storedCallbackData = [];
46657
47267
  const storageCallback = async (response2) => {
@@ -46736,8 +47346,7 @@ class AgentRuntime {
46736
47346
  }
46737
47347
  });
46738
47348
  } catch (error) {
46739
- const errorMessage = error instanceof Error ? error.message : String(error);
46740
- this.logger.error(`Failed to emit ACTION_COMPLETED event for action ${action.name} (${actionId}): ${errorMessage}`);
47349
+ this.logger.error({ src: "agent", agentId: this.agentId, action: action.name, error: error instanceof Error ? error.message : String(error) }, "Failed to emit ACTION_COMPLETED event");
46741
47350
  }
46742
47351
  if (callback) {
46743
47352
  for (const content of storedCallbackData) {
@@ -46775,13 +47384,7 @@ class AgentRuntime {
46775
47384
  }
46776
47385
  };
46777
47386
  await this.createMemory(actionMemory, "messages");
46778
- this.logger.debug(`Action ${action.name} completed`, JSON.stringify({
46779
- isLegacyReturn,
46780
- result: isLegacyReturn ? result : undefined,
46781
- hasValues: actionResult ? !!actionResult.values : false,
46782
- hasData: actionResult ? !!actionResult.data : false,
46783
- hasText: actionResult ? !!actionResult.text : false
46784
- }));
47387
+ this.logger.debug({ src: "agent", agentId: this.agentId, action: action.name }, "Action completed");
46785
47388
  await this.adapter.log({
46786
47389
  entityId: message.entityId,
46787
47390
  roomId: message.roomId,
@@ -46808,7 +47411,7 @@ class AgentRuntime {
46808
47411
  this.currentActionContext = undefined;
46809
47412
  } catch (error) {
46810
47413
  const errorMessage = error instanceof Error ? error.message : String(error);
46811
- this.logger.error(error);
47414
+ this.logger.error({ src: "agent", agentId: this.agentId, action: action.name, error: errorMessage }, "Action execution failed");
46812
47415
  if (actionPlan && actionPlan.steps[actionIndex]) {
46813
47416
  actionPlan = this.updateActionStep(actionPlan, actionIndex, {
46814
47417
  status: "failed",
@@ -46891,7 +47494,7 @@ class AgentRuntime {
46891
47494
  }
46892
47495
  return null;
46893
47496
  } catch (error) {
46894
- this.logger.error({ error, evaluatorName: evaluator.name }, `Error validating evaluator ${evaluator.name}`);
47497
+ this.logger.error({ src: "agent", agentId: this.agentId, evaluator: evaluator.name, error: error instanceof Error ? error.message : String(error) }, "Evaluator validation failed");
46895
47498
  return null;
46896
47499
  }
46897
47500
  });
@@ -46918,24 +47521,24 @@ class AgentRuntime {
46918
47521
  });
46919
47522
  }
46920
47523
  } catch (error) {
46921
- this.logger.error({ error, evaluatorName: evaluator.name }, `Error executing evaluator ${evaluator.name}`);
47524
+ this.logger.error({ src: "agent", agentId: this.agentId, evaluator: evaluator.name, error: error instanceof Error ? error.message : String(error) }, "Evaluator execution failed");
46922
47525
  }
46923
47526
  }));
46924
47527
  return evaluators;
46925
47528
  } catch (error) {
46926
- this.logger.error({ error, messageId: message.id, roomId: message.roomId }, "Error in evaluate method");
47529
+ this.logger.error({ src: "agent", agentId: this.agentId, messageId: message.id, channelId: message.roomId, error: error instanceof Error ? error.message : String(error) }, "Evaluate method failed");
46927
47530
  return [];
46928
47531
  }
46929
47532
  }
46930
47533
  async ensureConnections(entities, rooms, source, world) {
46931
47534
  if (!entities) {
46932
47535
  console.trace();
46933
- this.logger.error("ensureConnections - no entities");
47536
+ this.logger.error({ src: "agent", agentId: this.agentId }, "ensureConnections called without entities");
46934
47537
  return;
46935
47538
  }
46936
47539
  if (!rooms || rooms.length === 0) {
46937
47540
  console.trace();
46938
- this.logger.error("ensureConnections - no rooms");
47541
+ this.logger.error({ src: "agent", agentId: this.agentId }, "ensureConnections called without rooms");
46939
47542
  return;
46940
47543
  }
46941
47544
  await this.ensureWorldExists({ ...world, agentId: this.agentId });
@@ -46957,7 +47560,7 @@ class AgentRuntime {
46957
47560
  agentId: this.agentId
46958
47561
  };
46959
47562
  if (roomsToCreate.length) {
46960
- this.logger.debug("runtime/ensureConnections - create", roomsToCreate.length.toLocaleString(), "rooms");
47563
+ this.logger.debug({ src: "agent", agentId: this.agentId, count: roomsToCreate.length }, "Creating rooms");
46961
47564
  const roomObjsToCreate = rooms.filter((r2) => roomsToCreate.includes(r2.id)).map((r2) => ({ ...r2, ...rf }));
46962
47565
  await this.createRooms(roomObjsToCreate);
46963
47566
  }
@@ -46975,7 +47578,7 @@ class AgentRuntime {
46975
47578
  messageServerId: world.messageServerId
46976
47579
  };
46977
47580
  if (entitiesToCreate.length) {
46978
- this.logger.debug("runtime/ensureConnections - creating", entitiesToCreate.length.toLocaleString(), "entities...");
47581
+ this.logger.debug({ src: "agent", agentId: this.agentId, count: entitiesToCreate.length }, "Creating entities");
46979
47582
  const ef = {
46980
47583
  ...r,
46981
47584
  ...wf,
@@ -46993,13 +47596,13 @@ class AgentRuntime {
46993
47596
  const entityIdsInFirstRoomFiltered = entityIdsInFirstRoom.filter(Boolean);
46994
47597
  const missingIdsInRoom = entityIds.filter((id) => !entityIdsInFirstRoomFiltered.includes(id));
46995
47598
  if (missingIdsInRoom.length) {
46996
- this.logger.debug("runtime/ensureConnections - Missing", missingIdsInRoom.length.toLocaleString(), "connections in", firstRoom.id);
47599
+ this.logger.debug({ src: "agent", agentId: this.agentId, count: missingIdsInRoom.length, channelId: firstRoom.id }, "Adding missing participants");
46997
47600
  const batches = chunkArray(missingIdsInRoom, 5000);
46998
47601
  for (const batch of batches) {
46999
47602
  await this.addParticipantsRoom(batch, firstRoom.id);
47000
47603
  }
47001
47604
  }
47002
- this.logger.success(`Success: Successfully connected world`);
47605
+ this.logger.success({ src: "agent", agentId: this.agentId, worldId: world.id }, "World connected");
47003
47606
  }
47004
47607
  async ensureConnection({
47005
47608
  entityId,
@@ -47037,13 +47640,13 @@ class AgentRuntime {
47037
47640
  agentId: this.agentId
47038
47641
  });
47039
47642
  if (success) {
47040
- this.logger.debug(`Created new entity ${entityId} for user ${name || userName || "unknown"}`);
47643
+ this.logger.debug({ src: "agent", agentId: this.agentId, entityId, userName: name || userName }, "Entity created");
47041
47644
  } else {
47042
47645
  throw new Error(`Failed to create entity ${entityId}`);
47043
47646
  }
47044
47647
  } catch (error) {
47045
47648
  if (error.message?.includes("duplicate key") || error.code === "23505") {
47046
- this.logger.debug(`Entity ${entityId} exists in database but not for this agent. This is normal in multi-agent setups.`);
47649
+ this.logger.debug({ src: "agent", agentId: this.agentId, entityId }, "Entity exists in database (multi-agent setup)");
47047
47650
  } else {
47048
47651
  throw error;
47049
47652
  }
@@ -47088,22 +47691,22 @@ class AgentRuntime {
47088
47691
  if (!added) {
47089
47692
  throw new Error(`Failed to add participant ${entityId} to room ${roomId}`);
47090
47693
  }
47091
- this.logger.debug(`Added participant ${entityId} to room ${roomId} directly`);
47694
+ this.logger.debug({ src: "agent", agentId: this.agentId, entityId, channelId: roomId }, "Participant added");
47092
47695
  } else {
47093
47696
  throw error;
47094
47697
  }
47095
47698
  }
47096
47699
  await this.ensureParticipantInRoom(this.agentId, roomId);
47097
- this.logger.debug(`Success: Successfully connected entity ${entityId} in room ${roomId}`);
47700
+ this.logger.debug({ src: "agent", agentId: this.agentId, entityId, channelId: roomId }, "Entity connected");
47098
47701
  } catch (error) {
47099
- this.logger.error(`Failed to ensure connection: ${error instanceof Error ? error.message : String(error)}`);
47702
+ this.logger.error({ src: "agent", agentId: this.agentId, entityId, channelId: roomId, error: error instanceof Error ? error.message : String(error) }, "Connection setup failed");
47100
47703
  throw error;
47101
47704
  }
47102
47705
  }
47103
47706
  async ensureParticipantInRoom(entityId, roomId) {
47104
47707
  const entity = await this.getEntityById(entityId);
47105
47708
  if (!entity && entityId !== this.agentId) {
47106
- this.logger.warn(`Entity ${entityId} not directly accessible to agent ${this.agentId}. Will attempt to add as participant anyway.`);
47709
+ this.logger.warn({ src: "agent", agentId: this.agentId, entityId }, "Entity not accessible, attempting to add as participant");
47107
47710
  } else if (!entity && entityId === this.agentId) {
47108
47711
  throw new Error(`Agent entity ${entityId} not found, cannot add as participant.`);
47109
47712
  } else if (!entity) {
@@ -47116,9 +47719,9 @@ class AgentRuntime {
47116
47719
  throw new Error(`Failed to add participant ${entityId} to room ${roomId}`);
47117
47720
  }
47118
47721
  if (entityId === this.agentId) {
47119
- this.logger.debug(`Agent ${this.character.name} linked to room ${roomId} successfully.`);
47722
+ this.logger.debug({ src: "agent", agentId: this.agentId, channelId: roomId }, "Agent linked to room");
47120
47723
  } else {
47121
- this.logger.debug(`User ${entityId} linked to room ${roomId} successfully.`);
47724
+ this.logger.debug({ src: "agent", agentId: this.agentId, entityId, channelId: roomId }, "User linked to room");
47122
47725
  }
47123
47726
  }
47124
47727
  }
@@ -47143,12 +47746,7 @@ class AgentRuntime {
47143
47746
  async ensureWorldExists({ id, name, messageServerId, metadata }) {
47144
47747
  const world = await this.getWorld(id);
47145
47748
  if (!world) {
47146
- this.logger.debug("Creating world:", JSON.stringify({
47147
- id,
47148
- name,
47149
- messageServerId,
47150
- agentId: this.agentId
47151
- }));
47749
+ this.logger.debug({ src: "agent", agentId: this.agentId, worldId: id, name, messageServerId }, "Creating world");
47152
47750
  await this.adapter.createWorld({
47153
47751
  id,
47154
47752
  name,
@@ -47156,7 +47754,7 @@ class AgentRuntime {
47156
47754
  messageServerId,
47157
47755
  metadata
47158
47756
  });
47159
- this.logger.debug(`World ${id} created successfully.`);
47757
+ this.logger.debug({ src: "agent", agentId: this.agentId, worldId: id, messageServerId }, "World created");
47160
47758
  }
47161
47759
  }
47162
47760
  async ensureRoomExists({
@@ -47184,7 +47782,7 @@ class AgentRuntime {
47184
47782
  worldId,
47185
47783
  metadata
47186
47784
  });
47187
- this.logger.debug(`Room ${id} created successfully.`);
47785
+ this.logger.debug({ src: "agent", agentId: this.agentId, channelId: id }, "Room created");
47188
47786
  }
47189
47787
  }
47190
47788
  async composeState(message, includeList = null, onlyInclude = false, skipCache = false) {
@@ -47211,7 +47809,7 @@ class AgentRuntime {
47211
47809
  const result = await provider.get(this, message, cachedState);
47212
47810
  const duration = Date.now() - start;
47213
47811
  if (duration > 100) {
47214
- this.logger.debug(`${provider.name} Provider took ${duration}ms to respond`);
47812
+ this.logger.debug({ src: "agent", agentId: this.agentId, provider: provider.name, duration }, "Slow provider");
47215
47813
  }
47216
47814
  return {
47217
47815
  ...result,
@@ -47269,7 +47867,7 @@ class AgentRuntime {
47269
47867
  getService(serviceName) {
47270
47868
  const serviceInstances = this.services.get(serviceName);
47271
47869
  if (!serviceInstances || serviceInstances.length === 0) {
47272
- this.logger.debug(`Service ${serviceName} not found`);
47870
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceName }, "Service not found");
47273
47871
  return null;
47274
47872
  }
47275
47873
  return serviceInstances[0];
@@ -47280,7 +47878,7 @@ class AgentRuntime {
47280
47878
  getServicesByType(serviceName) {
47281
47879
  const serviceInstances = this.services.get(serviceName);
47282
47880
  if (!serviceInstances || serviceInstances.length === 0) {
47283
- this.logger.debug(`No services found for type ${serviceName}`);
47881
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceName }, "No services found for type");
47284
47882
  return [];
47285
47883
  }
47286
47884
  return serviceInstances;
@@ -47319,13 +47917,13 @@ class AgentRuntime {
47319
47917
  const serviceType = serviceDef.serviceType;
47320
47918
  const serviceName = serviceDef.name || "Unknown";
47321
47919
  if (!serviceType) {
47322
- this.logger.warn(`Service ${serviceName} is missing serviceType. Please define a static serviceType property.`);
47920
+ this.logger.warn({ src: "agent", agentId: this.agentId, serviceName }, "Service missing serviceType property");
47323
47921
  return;
47324
47922
  }
47325
- this.logger.info(`Registering service: ${serviceType}`);
47923
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType }, "Registering service");
47326
47924
  this.serviceRegistrationStatus.set(serviceType, "registering");
47327
47925
  try {
47328
- this.logger.debug(`Service ${serviceType} waiting for initialization...`);
47926
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType }, "Service waiting for init");
47329
47927
  const initTimeout = new Promise((_, reject) => {
47330
47928
  setTimeout(() => {
47331
47929
  reject(new Error(`Service ${serviceType} registration timed out waiting for runtime initialization (30s timeout)`));
@@ -47352,17 +47950,20 @@ class AgentRuntime {
47352
47950
  handler.resolve(serviceInstance);
47353
47951
  this.servicePromiseHandlers.delete(serviceType);
47354
47952
  } else {
47355
- this.logger.debug(`${this.character.name} - Service ${serviceType} has no servicePromiseHandler`);
47953
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType }, "Service has no promise handler");
47356
47954
  }
47357
47955
  if (typeof serviceDef.registerSendHandlers === "function") {
47358
47956
  serviceDef.registerSendHandlers(this, serviceInstance);
47359
47957
  }
47360
47958
  this.serviceRegistrationStatus.set(serviceType, "registered");
47361
- this.logger.info(`Service ${serviceType} registered successfully`);
47959
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType }, "Service registered");
47362
47960
  } catch (error) {
47363
47961
  const errorMessage = error instanceof Error ? error.message : String(error);
47364
47962
  const errorStack = error instanceof Error ? error.stack : undefined;
47365
- this.logger.error(`Failed to register service ${serviceType}: ${errorMessage}`);
47963
+ this.logger.error({ src: "agent", agentId: this.agentId, serviceType, error: errorMessage }, "Service registration failed");
47964
+ if (errorStack) {
47965
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType, stack: errorStack }, "Service error stack");
47966
+ }
47366
47967
  if (error?.message?.includes("timed out waiting for runtime initialization")) {
47367
47968
  this.logger.error(`Service ${serviceType} failed due to runtime initialization timeout. Check if runtime.initialize() is being called and completing successfully.`);
47368
47969
  } else if (error?.message?.includes("Not implemented")) {
@@ -47373,10 +47974,10 @@ class AgentRuntime {
47373
47974
  } else if (error?.message?.includes("Service") && error?.message?.includes("failed to start")) {
47374
47975
  this.logger.error(`Service ${serviceType} (${serviceName}) failed to start. Check service implementation and dependencies.`);
47375
47976
  } else if (error?.message?.includes("does not have a static start method")) {
47376
- this.logger.error(`Service ${serviceType} (${serviceName}) is missing required static start() method implementation.`);
47977
+ this.logger.error({ src: "agent", agentId: this.agentId, serviceType, serviceName, error: error?.message }, "Service missing required static start() method implementation");
47377
47978
  } else {
47378
47979
  if (errorStack) {
47379
- this.logger.debug(`Service ${serviceType} (${serviceName}) error stack: ${errorStack}`);
47980
+ this.logger.debug({ src: "agent", agentId: this.agentId, serviceType, serviceName, stack: errorStack }, "Service error stack");
47380
47981
  }
47381
47982
  }
47382
47983
  this.serviceRegistrationStatus.set(serviceType, "failed");
@@ -47440,13 +48041,13 @@ class AgentRuntime {
47440
48041
  if (provider) {
47441
48042
  const modelWithProvider = models.find((m) => m.provider === provider);
47442
48043
  if (modelWithProvider) {
47443
- this.logger.debug(`[AgentRuntime][${this.character.name}] Using model ${modelKey} from provider ${provider}`);
48044
+ this.logger.debug({ src: "agent", agentId: this.agentId, model: modelKey, provider }, "Using model");
47444
48045
  return modelWithProvider.handler;
47445
48046
  } else {
47446
- this.logger.warn(`[AgentRuntime][${this.character.name}] No model found for provider ${provider}`);
48047
+ this.logger.warn({ src: "agent", agentId: this.agentId, model: modelKey, provider }, "Model provider not found");
47447
48048
  }
47448
48049
  }
47449
- this.logger.debug(`[AgentRuntime][${this.character.name}] Using model ${modelKey} from provider ${models[0].provider}`);
48050
+ this.logger.debug({ src: "agent", agentId: this.agentId, model: modelKey, provider: models[0].provider }, "Using model");
47450
48051
  return models[0].handler;
47451
48052
  }
47452
48053
  getModelSettings(modelType) {
@@ -47525,8 +48126,7 @@ class AgentRuntime {
47525
48126
  ModelType.VIDEO
47526
48127
  ];
47527
48128
  if (!binaryModels.includes(modelKey)) {
47528
- this.logger.debug(`[useModel] ${modelKey} input: ` + JSON.stringify(params, safeReplacer(), 2).replace(/\\n/g, `
47529
- `));
48129
+ this.logger.trace({ src: "agent", agentId: this.agentId, model: modelKey, params }, "Model input");
47530
48130
  } else {
47531
48131
  let sizeInfo = "unknown size";
47532
48132
  if (Buffer.isBuffer(params)) {
@@ -47540,7 +48140,7 @@ class AgentRuntime {
47540
48140
  sizeInfo = `${params.audio.size} bytes`;
47541
48141
  }
47542
48142
  }
47543
- this.logger.debug(`[useModel] ${modelKey} input: <binary data: ${sizeInfo}>`);
48143
+ this.logger.trace({ src: "agent", agentId: this.agentId, model: modelKey, size: sizeInfo }, "Model input (binary)");
47544
48144
  }
47545
48145
  let modelParams;
47546
48146
  if (params === null || params === undefined || typeof params !== "object" || Array.isArray(params) || BufferUtils.isBuffer(params)) {
@@ -47565,8 +48165,7 @@ class AgentRuntime {
47565
48165
  try {
47566
48166
  const response = await model(this, modelParams);
47567
48167
  const elapsedTime = (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now()) - startTime;
47568
- this.logger.debug(`[useModel] ${modelKey} output (took ${Number(elapsedTime.toFixed(2)).toLocaleString()}ms):`, Array.isArray(response) ? `${JSON.stringify(response.slice(0, 5))}...${JSON.stringify(response.slice(-5))} (${response.length} items)` : JSON.stringify(response, safeReplacer(), 2).replace(/\\n/g, `
47569
- `));
48168
+ this.logger.trace({ src: "agent", agentId: this.agentId, model: modelKey, duration: Number(elapsedTime.toFixed(2)) }, "Model output");
47570
48169
  if (modelKey !== ModelType.TEXT_EMBEDDING && promptContent) {
47571
48170
  if (this.currentActionContext) {
47572
48171
  this.currentActionContext.prompts.push({
@@ -47681,36 +48280,33 @@ ${input}`;
47681
48280
  }
47682
48281
  await Promise.all(eventHandlers.map((handler) => handler(paramsWithRuntime)));
47683
48282
  } catch (error) {
47684
- this.logger.error(`Error during emitEvent for ${eventName} (handler execution): ${error}`);
48283
+ this.logger.error({ src: "agent", agentId: this.agentId, eventName, error: error instanceof Error ? error.message : String(error) }, "Event handler failed");
47685
48284
  }
47686
48285
  }
47687
48286
  }
47688
48287
  async ensureEmbeddingDimension() {
47689
- this.logger.debug(`[AgentRuntime][${this.character.name}] Starting ensureEmbeddingDimension`);
47690
48288
  if (!this.adapter) {
47691
- throw new Error(`[AgentRuntime][${this.character.name}] Database adapter not initialized before ensureEmbeddingDimension`);
48289
+ throw new Error("Database adapter not initialized before ensureEmbeddingDimension");
47692
48290
  }
47693
48291
  try {
47694
48292
  const model = this.getModel(ModelType.TEXT_EMBEDDING);
47695
48293
  if (!model) {
47696
- throw new Error(`[AgentRuntime][${this.character.name}] No TEXT_EMBEDDING model registered`);
48294
+ throw new Error("No TEXT_EMBEDDING model registered");
47697
48295
  }
47698
- this.logger.debug(`[AgentRuntime][${this.character.name}] Getting embedding dimensions`);
47699
48296
  const embedding = await this.useModel(ModelType.TEXT_EMBEDDING, null);
47700
48297
  if (!embedding || !embedding.length) {
47701
- throw new Error(`[AgentRuntime][${this.character.name}] Invalid embedding received`);
48298
+ throw new Error("Invalid embedding received");
47702
48299
  }
47703
- this.logger.debug(`[AgentRuntime][${this.character.name}] Setting embedding dimension: ${embedding.length}`);
47704
48300
  await this.adapter.ensureEmbeddingDimension(embedding.length);
47705
- this.logger.debug(`[AgentRuntime][${this.character.name}] Successfully set embedding dimension`);
48301
+ this.logger.debug({ src: "agent", agentId: this.agentId, dimension: embedding.length }, "Embedding dimension set");
47706
48302
  } catch (error) {
47707
- this.logger.debug(`[AgentRuntime][${this.character.name}] Error in ensureEmbeddingDimension: ${error}`);
48303
+ this.logger.error({ src: "agent", agentId: this.agentId, error: error instanceof Error ? error.message : String(error) }, "Embedding dimension setup failed");
47708
48304
  throw error;
47709
48305
  }
47710
48306
  }
47711
48307
  registerTaskWorker(taskHandler) {
47712
48308
  if (this.taskWorkers.has(taskHandler.name)) {
47713
- this.logger.warn(`Task definition ${taskHandler.name} already registered. Will be overwritten.`);
48309
+ this.logger.warn({ src: "agent", agentId: this.agentId, task: taskHandler.name }, "Task worker already registered, overwriting");
47714
48310
  }
47715
48311
  this.taskWorkers.set(taskHandler.name, taskHandler);
47716
48312
  }
@@ -47772,7 +48368,7 @@ ${input}`;
47772
48368
  if (!refreshedAgent) {
47773
48369
  throw new Error(`Failed to retrieve agent after update: ${agent.id}`);
47774
48370
  }
47775
- this.logger.debug(`Updated existing agent ${agent.id} on restart (merged ${Object.keys(existingAgent.settings || {}).length} DB settings with ${Object.keys(agent.settings || {}).length} character settings)`);
48371
+ this.logger.debug({ src: "agent", agentId: agent.id }, "Agent updated on restart");
47776
48372
  return refreshedAgent;
47777
48373
  }
47778
48374
  const newAgent = {
@@ -47783,7 +48379,7 @@ ${input}`;
47783
48379
  if (!created) {
47784
48380
  throw new Error(`Failed to create agent: ${agent.id}`);
47785
48381
  }
47786
- this.logger.debug(`Created new agent ${agent.id}`);
48382
+ this.logger.debug({ src: "agent", agentId: agent.id }, "Agent created");
47787
48383
  return newAgent;
47788
48384
  }
47789
48385
  async getEntityById(entityId) {
@@ -47841,7 +48437,7 @@ ${input}`;
47841
48437
  text: memoryText
47842
48438
  });
47843
48439
  } catch (error) {
47844
- this.logger.error("Failed to generate embedding:", error);
48440
+ this.logger.error({ src: "agent", agentId: this.agentId, error: error instanceof Error ? error.message : String(error) }, "Embedding generation failed");
47845
48441
  memory.embedding = await this.useModel(ModelType.TEXT_EMBEDDING, null);
47846
48442
  }
47847
48443
  return memory;
@@ -47855,7 +48451,6 @@ ${input}`;
47855
48451
  return;
47856
48452
  }
47857
48453
  if (!memory.content?.text) {
47858
- this.logger.debug("Skipping embedding generation for memory without text content");
47859
48454
  return;
47860
48455
  }
47861
48456
  await this.emitEvent("EMBEDDING_GENERATION_REQUESTED" /* EMBEDDING_GENERATION_REQUESTED */, {
@@ -47883,7 +48478,7 @@ ${input}`;
47883
48478
  });
47884
48479
  allMemories.push(...memories);
47885
48480
  } catch (error) {
47886
- this.logger.debug(`Failed to get memories from table ${tableName}: ${error}`);
48481
+ this.logger.debug({ src: "agent", agentId: this.agentId, tableName, error: error instanceof Error ? error.message : String(error) }, "Failed to get memories");
47887
48482
  }
47888
48483
  }
47889
48484
  return allMemories;
@@ -47935,16 +48530,15 @@ ${input}`;
47935
48530
  await this.adapter.deleteManyMemories(memoryIds);
47936
48531
  }
47937
48532
  async clearAllAgentMemories() {
47938
- this.logger.info(`Clearing all memories for agent ${this.character.name} (${this.agentId})`);
48533
+ this.logger.info({ src: "agent", agentId: this.agentId }, "Clearing all memories");
47939
48534
  const allMemories = await this.getAllMemories();
47940
48535
  const memoryIds = allMemories.map((memory) => memory.id).filter((id) => id !== undefined);
47941
48536
  if (memoryIds.length === 0) {
47942
- this.logger.info("No memories found to delete");
48537
+ this.logger.debug({ src: "agent", agentId: this.agentId }, "No memories to delete");
47943
48538
  return;
47944
48539
  }
47945
- this.logger.info(`Found ${memoryIds.length} memories to delete`);
47946
48540
  await this.adapter.deleteManyMemories(memoryIds);
47947
- this.logger.info(`Successfully cleared all ${memoryIds.length} memories for agent`);
48541
+ this.logger.info({ src: "agent", agentId: this.agentId, count: memoryIds.length }, "Memories cleared");
47948
48542
  }
47949
48543
  async deleteAllMemories(roomId, tableName) {
47950
48544
  await this.adapter.deleteAllMemories(roomId, tableName);
@@ -48117,29 +48711,29 @@ ${input}`;
48117
48711
  message: controlMessage,
48118
48712
  source: "agent"
48119
48713
  });
48120
- this.logger.debug(`Sent control message: ${action} to room ${roomId}`);
48714
+ this.logger.debug({ src: "agent", agentId: this.agentId, action, channelId: roomId }, "Control message sent");
48121
48715
  } catch (error) {
48122
- this.logger.error(`Error sending control message: ${error}`);
48716
+ this.logger.error({ src: "agent", agentId: this.agentId, error: error instanceof Error ? error.message : String(error) }, "Control message failed");
48123
48717
  }
48124
48718
  }
48125
48719
  registerSendHandler(source, handler) {
48126
48720
  if (this.sendHandlers.has(source)) {
48127
- this.logger.warn(`Send handler for source '${source}' already registered. Overwriting.`);
48721
+ this.logger.warn({ src: "agent", agentId: this.agentId, handlerSource: source }, "Send handler already registered, overwriting");
48128
48722
  }
48129
48723
  this.sendHandlers.set(source, handler);
48130
- this.logger.info(`Registered send handler for source: ${source}`);
48724
+ this.logger.debug({ src: "agent", agentId: this.agentId, handlerSource: source }, "Send handler registered");
48131
48725
  }
48132
48726
  async sendMessageToTarget(target, content) {
48133
48727
  const handler = this.sendHandlers.get(target.source);
48134
48728
  if (!handler) {
48135
48729
  const errorMsg = `No send handler registered for source: ${target.source}`;
48136
- this.logger.error(errorMsg);
48730
+ this.logger.error({ src: "agent", agentId: this.agentId, handlerSource: target.source }, "Send handler not found");
48137
48731
  throw new Error(errorMsg);
48138
48732
  }
48139
48733
  try {
48140
48734
  await handler(this, target, content);
48141
48735
  } catch (error) {
48142
- this.logger.error(`Error executing send handler for source ${target.source}:`, error);
48736
+ this.logger.error({ src: "agent", agentId: this.agentId, handlerSource: target.source, error: error instanceof Error ? error.message : String(error) }, "Send handler failed");
48143
48737
  throw error;
48144
48738
  }
48145
48739
  }
@@ -48150,7 +48744,7 @@ ${input}`;
48150
48744
  if (this.adapter && "runMigrations" in this.adapter) {
48151
48745
  await this.adapter.runMigrations(migrationsPaths);
48152
48746
  } else {
48153
- this.logger.warn("Database adapter does not support migrations.");
48747
+ this.logger.warn({ src: "agent", agentId: this.agentId }, "Database adapter does not support migrations");
48154
48748
  }
48155
48749
  }
48156
48750
  async isReady() {
@@ -48211,8 +48805,8 @@ function getCryptoModule() {
48211
48805
  return require_crypto_browserify();
48212
48806
  }
48213
48807
  function createHash(algorithm) {
48214
- const crypto = getCryptoModule();
48215
- const hash = crypto.createHash(algorithm);
48808
+ const crypto2 = getCryptoModule();
48809
+ const hash = crypto2.createHash(algorithm);
48216
48810
  return {
48217
48811
  update(data2) {
48218
48812
  hash.update(data2);
@@ -48227,15 +48821,15 @@ function createCipheriv(algorithm, key, iv) {
48227
48821
  if (algorithm !== "aes-256-cbc") {
48228
48822
  throw new Error(`Unsupported algorithm: ${algorithm}. Only 'aes-256-cbc' is currently supported.`);
48229
48823
  }
48230
- const crypto = getCryptoModule();
48231
- return crypto.createCipheriv(algorithm, key, iv);
48824
+ const crypto2 = getCryptoModule();
48825
+ return crypto2.createCipheriv(algorithm, key, iv);
48232
48826
  }
48233
48827
  function createDecipheriv(algorithm, key, iv) {
48234
48828
  if (algorithm !== "aes-256-cbc") {
48235
48829
  throw new Error(`Unsupported algorithm: ${algorithm}. Only 'aes-256-cbc' is currently supported.`);
48236
48830
  }
48237
- const crypto = getCryptoModule();
48238
- return crypto.createDecipheriv(algorithm, key, iv);
48831
+ const crypto2 = getCryptoModule();
48832
+ return crypto2.createDecipheriv(algorithm, key, iv);
48239
48833
  }
48240
48834
 
48241
48835
  // src/settings.ts
@@ -48267,7 +48861,7 @@ function getSalt() {
48267
48861
  }
48268
48862
  }
48269
48863
  if (currentEnvSalt === "secretsalt" && !saltErrorLogged) {
48270
- logger.warn("SECRET_SALT is not set or using default value");
48864
+ logger.warn({ src: "core:settings" }, "SECRET_SALT is not set or using default value");
48271
48865
  saltErrorLogged = true;
48272
48866
  }
48273
48867
  saltCache = {
@@ -48282,15 +48876,12 @@ function clearSaltCache() {
48282
48876
  }
48283
48877
  function encryptStringValue(value, salt) {
48284
48878
  if (value === undefined || value === null) {
48285
- logger.debug("Attempted to encrypt undefined or null value");
48286
48879
  return value;
48287
48880
  }
48288
48881
  if (typeof value === "boolean" || typeof value === "number") {
48289
- logger.debug("Value is a boolean or number, returning as is");
48290
48882
  return value;
48291
48883
  }
48292
48884
  if (typeof value !== "string") {
48293
- logger.debug(`Value is not a string (type: ${typeof value}), returning as is`);
48294
48885
  return value;
48295
48886
  }
48296
48887
  const parts = value.split(":");
@@ -48298,7 +48889,6 @@ function encryptStringValue(value, salt) {
48298
48889
  try {
48299
48890
  const possibleIv = BufferUtils.fromHex(parts[0]);
48300
48891
  if (possibleIv.length === 16) {
48301
- logger.debug("Value appears to be already encrypted, skipping re-encryption");
48302
48892
  return value;
48303
48893
  }
48304
48894
  } catch (e) {}
@@ -48319,7 +48909,6 @@ function decryptStringValue(value, salt) {
48319
48909
  return value;
48320
48910
  }
48321
48911
  if (typeof value !== "string") {
48322
- logger.debug(`Value is not a string (type: ${typeof value}), returning as is`);
48323
48912
  return value;
48324
48913
  }
48325
48914
  const parts = value.split(":");
@@ -48329,9 +48918,6 @@ function decryptStringValue(value, salt) {
48329
48918
  const iv = BufferUtils.fromHex(parts[0]);
48330
48919
  const encrypted = parts[1];
48331
48920
  if (iv.length !== 16) {
48332
- if (iv.length) {
48333
- logger.debug(`Invalid IV length (${iv.length}) - expected 16 bytes`);
48334
- }
48335
48921
  return value;
48336
48922
  }
48337
48923
  const key = createHash("sha256").update(salt).digest().slice(0, 32);
@@ -48340,7 +48926,7 @@ function decryptStringValue(value, salt) {
48340
48926
  decrypted += decipher.final("utf8");
48341
48927
  return decrypted;
48342
48928
  } catch (error) {
48343
- logger.error(`Error decrypting value: ${error}`);
48929
+ logger.error({ src: "core:settings", error }, "Decryption failed");
48344
48930
  return value;
48345
48931
  }
48346
48932
  }
@@ -48372,11 +48958,11 @@ function unsaltWorldSettings(worldSettings, salt) {
48372
48958
  }
48373
48959
  return unsaltedSettings;
48374
48960
  }
48375
- async function updateWorldSettings(runtime, serverId, worldSettings) {
48376
- const worldId = createUniqueUuid(runtime, serverId);
48961
+ async function updateWorldSettings(runtime, serverId2, worldSettings) {
48962
+ const worldId = createUniqueUuid(runtime, serverId2);
48377
48963
  const world = await runtime.getWorld(worldId);
48378
48964
  if (!world) {
48379
- logger.error(`No world found for server ${serverId}`);
48965
+ logger.error({ src: "core:settings", serverId: serverId2 }, "World not found");
48380
48966
  return false;
48381
48967
  }
48382
48968
  if (!world.metadata) {
@@ -48388,8 +48974,8 @@ async function updateWorldSettings(runtime, serverId, worldSettings) {
48388
48974
  await runtime.updateWorld(world);
48389
48975
  return true;
48390
48976
  }
48391
- async function getWorldSettings(runtime, serverId) {
48392
- const worldId = createUniqueUuid(runtime, serverId);
48977
+ async function getWorldSettings(runtime, serverId2) {
48978
+ const worldId = createUniqueUuid(runtime, serverId2);
48393
48979
  const world = await runtime.getWorld(worldId);
48394
48980
  if (!world || !world.metadata?.settings) {
48395
48981
  return null;
@@ -48400,7 +48986,7 @@ async function getWorldSettings(runtime, serverId) {
48400
48986
  }
48401
48987
  async function initializeOnboarding(runtime, world, config) {
48402
48988
  if (world.metadata?.settings) {
48403
- logger.info(`Onboarding state already exists for server ${world.messageServerId}`);
48989
+ logger.debug({ src: "core:settings", serverId: world.messageServerId }, "Onboarding state already exists");
48404
48990
  const saltedSettings = world.metadata.settings;
48405
48991
  const salt = getSalt();
48406
48992
  return unsaltWorldSettings(saltedSettings, salt);
@@ -48416,7 +49002,7 @@ async function initializeOnboarding(runtime, world, config) {
48416
49002
  }
48417
49003
  world.metadata.settings = worldSettings;
48418
49004
  await runtime.updateWorld(world);
48419
- logger.info(`Initialized settings config for server ${world.messageServerId}`);
49005
+ logger.info({ src: "core:settings", serverId: world.messageServerId }, "Settings config initialized");
48420
49006
  return worldSettings;
48421
49007
  }
48422
49008
  function encryptedCharacter(character) {
@@ -48533,30 +49119,30 @@ function isAutoInstallAllowed() {
48533
49119
  async function tryInstallPlugin(pluginName) {
48534
49120
  try {
48535
49121
  if (!isAutoInstallAllowed()) {
48536
- logger.debug(`Auto-install disabled or not allowed in this environment. Skipping install for ${pluginName}.`);
49122
+ logger.debug({ src: "core:plugin", pluginName }, "Auto-install disabled, skipping");
48537
49123
  return false;
48538
49124
  }
48539
49125
  if (attemptedInstalls.has(pluginName)) {
48540
- logger.debug(`Auto-install already attempted for ${pluginName}. Skipping.`);
49126
+ logger.debug({ src: "core:plugin", pluginName }, "Auto-install already attempted, skipping");
48541
49127
  return false;
48542
49128
  }
48543
49129
  attemptedInstalls.add(pluginName);
48544
49130
  if (typeof Bun === "undefined" || typeof Bun.spawn !== "function") {
48545
- logger.warn(`Bun runtime not available. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
49131
+ logger.warn({ src: "core:plugin", pluginName }, "Bun runtime not available, cannot auto-install");
48546
49132
  return false;
48547
49133
  }
48548
49134
  try {
48549
49135
  const check = Bun.spawn(["bun", "--version"], { stdout: "pipe", stderr: "pipe" });
48550
49136
  const code = await check.exited;
48551
49137
  if (code !== 0) {
48552
- logger.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
49138
+ logger.warn({ src: "core:plugin", pluginName }, "Bun not available on PATH, cannot auto-install");
48553
49139
  return false;
48554
49140
  }
48555
49141
  } catch {
48556
- logger.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
49142
+ logger.warn({ src: "core:plugin", pluginName }, "Bun not available on PATH, cannot auto-install");
48557
49143
  return false;
48558
49144
  }
48559
- logger.info(`Attempting to auto-install missing plugin: ${pluginName}`);
49145
+ logger.info({ src: "core:plugin", pluginName }, "Auto-installing missing plugin");
48560
49146
  const install = Bun.spawn(["bun", "add", pluginName], {
48561
49147
  cwd: process.cwd(),
48562
49148
  env: process.env,
@@ -48565,14 +49151,14 @@ async function tryInstallPlugin(pluginName) {
48565
49151
  });
48566
49152
  const exit = await install.exited;
48567
49153
  if (exit === 0) {
48568
- logger.info(`Successfully installed ${pluginName}. Retrying import...`);
49154
+ logger.info({ src: "core:plugin", pluginName }, "Plugin installed, retrying import");
48569
49155
  return true;
48570
49156
  }
48571
- logger.error(`bun add ${pluginName} failed with exit code ${exit}. Please install manually.`);
49157
+ logger.error({ src: "core:plugin", pluginName, exitCode: exit }, "Plugin installation failed");
48572
49158
  return false;
48573
49159
  } catch (e) {
48574
49160
  const message = e instanceof Error ? e.message : String(e);
48575
- logger.error(`Unexpected error during auto-install of ${pluginName}: ${message}`);
49161
+ logger.error({ src: "core:plugin", pluginName, error: message }, "Unexpected error during auto-install");
48576
49162
  return false;
48577
49163
  }
48578
49164
  }
@@ -48633,7 +49219,7 @@ async function loadAndPreparePlugin(pluginName) {
48633
49219
  try {
48634
49220
  pluginModule = await import(pluginName);
48635
49221
  } catch (error) {
48636
- logger.warn(`Failed to load plugin ${pluginName}: ${error}`);
49222
+ logger.warn({ src: "core:plugin", pluginName, error }, "Failed to load plugin");
48637
49223
  const attempted = await tryInstallPlugin(pluginName);
48638
49224
  if (!attempted) {
48639
49225
  return null;
@@ -48641,12 +49227,12 @@ async function loadAndPreparePlugin(pluginName) {
48641
49227
  try {
48642
49228
  pluginModule = await import(pluginName);
48643
49229
  } catch (secondError) {
48644
- logger.error(`Auto-install attempted for ${pluginName} but import still failed: ${secondError}`);
49230
+ logger.error({ src: "core:plugin", pluginName, error: secondError }, "Import failed after auto-install");
48645
49231
  return null;
48646
49232
  }
48647
49233
  }
48648
49234
  if (!pluginModule) {
48649
- logger.error(`Failed to load module for plugin ${pluginName}.`);
49235
+ logger.error({ src: "core:plugin", pluginName }, "Failed to load plugin module");
48650
49236
  return null;
48651
49237
  }
48652
49238
  const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match) => match[1].toUpperCase())}Plugin`;
@@ -48667,14 +49253,14 @@ async function loadAndPreparePlugin(pluginName) {
48667
49253
  return produced;
48668
49254
  }
48669
49255
  } catch (err) {
48670
- logger.debug(`Factory export threw for ${pluginName}: ${err}`);
49256
+ logger.debug({ src: "core:plugin", pluginName, error: err }, "Factory export threw");
48671
49257
  }
48672
49258
  }
48673
49259
  }
48674
- logger.warn(`Could not find a valid plugin export in ${pluginName}.`);
49260
+ logger.warn({ src: "core:plugin", pluginName }, "No valid plugin export found");
48675
49261
  return null;
48676
49262
  } catch (error) {
48677
- logger.error(`Error loading plugin ${pluginName}: ${error}`);
49263
+ logger.error({ src: "core:plugin", pluginName, error }, "Error loading plugin");
48678
49264
  return null;
48679
49265
  }
48680
49266
  }
@@ -48709,7 +49295,7 @@ function resolvePluginDependencies(availablePlugins, isTestMode = false) {
48709
49295
  const normalizedName = normalizePluginName(pluginName);
48710
49296
  const pluginByNormalized = lookupMap.get(normalizedName);
48711
49297
  if (!pluginByNormalized) {
48712
- logger.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
49298
+ logger.warn({ src: "core:plugin", pluginName }, "Plugin dependency not found, skipping");
48713
49299
  return;
48714
49300
  }
48715
49301
  return visit(pluginByNormalized.name);
@@ -48718,7 +49304,7 @@ function resolvePluginDependencies(availablePlugins, isTestMode = false) {
48718
49304
  if (visited.has(canonicalName))
48719
49305
  return;
48720
49306
  if (visiting.has(canonicalName)) {
48721
- logger.error(`Circular dependency detected involving plugin: ${canonicalName}`);
49307
+ logger.error({ src: "core:plugin", pluginName: canonicalName }, "Circular dependency detected");
48722
49308
  return;
48723
49309
  }
48724
49310
  visiting.add(canonicalName);
@@ -48746,7 +49332,7 @@ function resolvePluginDependencies(availablePlugins, isTestMode = false) {
48746
49332
  }
48747
49333
  return null;
48748
49334
  }).filter((p) => Boolean(p));
48749
- logger.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
49335
+ logger.debug({ src: "core:plugin", plugins: finalPlugins.map((p) => p.name) }, "Plugins resolved");
48750
49336
  return finalPlugins;
48751
49337
  }
48752
49338
  async function loadPlugin(nameOrPlugin) {
@@ -48755,7 +49341,7 @@ async function loadPlugin(nameOrPlugin) {
48755
49341
  }
48756
49342
  const validation = validatePlugin(nameOrPlugin);
48757
49343
  if (!validation.isValid) {
48758
- logger.error(`Invalid plugin provided: ${validation.errors.join(", ")}`);
49344
+ logger.error({ src: "core:plugin", errors: validation.errors }, "Invalid plugin provided");
48759
49345
  return null;
48760
49346
  }
48761
49347
  return nameOrPlugin;
@@ -48800,7 +49386,8 @@ async function resolvePlugins(plugins, isTestMode = false) {
48800
49386
  }
48801
49387
  const pluginObjects = plugins.filter((p) => typeof p !== "string");
48802
49388
  if (plugins.some((p) => typeof p === "string")) {
48803
- logger.warn("Browser environment: String plugin references are not supported. Only Plugin objects will be used. Skipped plugins: " + plugins.filter((p) => typeof p === "string").join(", "));
49389
+ const skippedPlugins = plugins.filter((p) => typeof p === "string");
49390
+ logger.warn({ src: "core:plugin", skippedPlugins }, "Browser environment: String plugin references not supported");
48804
49391
  }
48805
49392
  const pluginMap = new Map;
48806
49393
  for (const plugin of pluginObjects) {
@@ -49158,7 +49745,7 @@ async function getRecentInteractions(runtime, sourceEntityId, candidateEntities,
49158
49745
  async function findEntityByName(runtime, message, state) {
49159
49746
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
49160
49747
  if (!room) {
49161
- logger.warn("Room not found for entity search");
49748
+ logger.warn({ src: "core:entities", roomId: message.roomId }, "Room not found for entity search");
49162
49749
  return null;
49163
49750
  }
49164
49751
  const world = room.worldId ? await runtime.getWorld(room.worldId) : null;
@@ -49209,7 +49796,7 @@ async function findEntityByName(runtime, message, state) {
49209
49796
  });
49210
49797
  const resolution = parseKeyValueXml(result);
49211
49798
  if (!resolution) {
49212
- logger.warn("Failed to parse entity resolution result");
49799
+ logger.warn({ src: "core:entities" }, "Failed to parse entity resolution result");
49213
49800
  return null;
49214
49801
  }
49215
49802
  if (resolution.type === "EXACT_MATCH" && resolution.entityId) {
@@ -49480,5 +50067,5 @@ export {
49480
50067
  AgentRuntime
49481
50068
  };
49482
50069
 
49483
- //# debugId=A1412E5E5FDE737964756E2164756E21
50070
+ //# debugId=019277DAE9D708DD64756E2164756E21
49484
50071
  //# sourceMappingURL=index.node.js.map