@elizaos/core 1.6.2-alpha.1 → 1.6.2-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.browser.js +98 -87
- package/dist/browser/index.browser.js.map +24 -20
- package/dist/character.d.ts +25 -0
- package/dist/character.d.ts.map +1 -0
- package/dist/database.d.ts +1 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/elizaos.d.ts +2 -1
- package/dist/elizaos.d.ts.map +1 -1
- package/dist/index.node.d.ts +3 -0
- package/dist/index.node.d.ts.map +1 -1
- package/dist/node/index.node.js +701 -244
- package/dist/node/index.node.js.map +22 -22
- package/dist/plugin.d.ts +45 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/prompts.d.ts +2 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/schemas/character.d.ts +84 -3
- package/dist/schemas/character.d.ts.map +1 -1
- package/dist/secrets.d.ts +14 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/types/database.d.ts +1 -0
- package/dist/types/database.d.ts.map +1 -1
- package/dist/types/primitives.d.ts +18 -0
- package/dist/types/primitives.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/utils/environment.d.ts +10 -0
- package/dist/utils/environment.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/node/index.node.js
CHANGED
|
@@ -25,6 +25,7 @@ var __export = (target, all) => {
|
|
|
25
25
|
set: (newValue) => all[name] = () => newValue
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
28
29
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
29
30
|
|
|
30
31
|
// ../../node_modules/retry/lib/retry_operation.js
|
|
@@ -2291,6 +2292,9 @@ var require_parse_options = __commonJS((exports, module) => {
|
|
|
2291
2292
|
var require_identifiers = __commonJS((exports, module) => {
|
|
2292
2293
|
var numeric = /^[0-9]+$/;
|
|
2293
2294
|
var compareIdentifiers = (a, b) => {
|
|
2295
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
2296
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
2297
|
+
}
|
|
2294
2298
|
const anum = numeric.test(a);
|
|
2295
2299
|
const bnum = numeric.test(b);
|
|
2296
2300
|
if (anum && bnum) {
|
|
@@ -2393,7 +2397,25 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
2393
2397
|
if (!(other instanceof SemVer)) {
|
|
2394
2398
|
other = new SemVer(other, this.options);
|
|
2395
2399
|
}
|
|
2396
|
-
|
|
2400
|
+
if (this.major < other.major) {
|
|
2401
|
+
return -1;
|
|
2402
|
+
}
|
|
2403
|
+
if (this.major > other.major) {
|
|
2404
|
+
return 1;
|
|
2405
|
+
}
|
|
2406
|
+
if (this.minor < other.minor) {
|
|
2407
|
+
return -1;
|
|
2408
|
+
}
|
|
2409
|
+
if (this.minor > other.minor) {
|
|
2410
|
+
return 1;
|
|
2411
|
+
}
|
|
2412
|
+
if (this.patch < other.patch) {
|
|
2413
|
+
return -1;
|
|
2414
|
+
}
|
|
2415
|
+
if (this.patch > other.patch) {
|
|
2416
|
+
return 1;
|
|
2417
|
+
}
|
|
2418
|
+
return 0;
|
|
2397
2419
|
}
|
|
2398
2420
|
comparePre(other) {
|
|
2399
2421
|
if (!(other instanceof SemVer)) {
|
|
@@ -3070,6 +3092,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
3070
3092
|
return result;
|
|
3071
3093
|
};
|
|
3072
3094
|
var parseComparator = (comp, options) => {
|
|
3095
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
3073
3096
|
debug("comp", comp, options);
|
|
3074
3097
|
comp = replaceCarets(comp, options);
|
|
3075
3098
|
debug("caret", comp);
|
|
@@ -9811,6 +9834,220 @@ Length provided: ${this.length}. Number of dictionaries provided: ${this.diction
|
|
|
9811
9834
|
};
|
|
9812
9835
|
});
|
|
9813
9836
|
|
|
9837
|
+
// src/utils/environment.ts
|
|
9838
|
+
var exports_environment = {};
|
|
9839
|
+
__export(exports_environment, {
|
|
9840
|
+
setEnv: () => setEnv,
|
|
9841
|
+
loadEnvConfig: () => loadEnvConfig,
|
|
9842
|
+
initBrowserEnvironment: () => initBrowserEnvironment,
|
|
9843
|
+
hasEnv: () => hasEnv,
|
|
9844
|
+
getNumberEnv: () => getNumberEnv,
|
|
9845
|
+
getEnvironment: () => getEnvironment,
|
|
9846
|
+
getEnv: () => getEnv3,
|
|
9847
|
+
getBooleanEnv: () => getBooleanEnv,
|
|
9848
|
+
findEnvFile: () => findEnvFile,
|
|
9849
|
+
detectEnvironment: () => detectEnvironment,
|
|
9850
|
+
currentRuntime: () => currentRuntime,
|
|
9851
|
+
Environment: () => Environment
|
|
9852
|
+
});
|
|
9853
|
+
function detectEnvironment() {
|
|
9854
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
9855
|
+
return "node";
|
|
9856
|
+
}
|
|
9857
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined" && typeof globalThis.window.document !== "undefined") {
|
|
9858
|
+
return "browser";
|
|
9859
|
+
}
|
|
9860
|
+
return "unknown";
|
|
9861
|
+
}
|
|
9862
|
+
|
|
9863
|
+
class BrowserEnvironmentStore {
|
|
9864
|
+
store = {};
|
|
9865
|
+
constructor() {
|
|
9866
|
+
if (typeof globalThis !== "undefined" && globalThis.window && globalThis.window.ENV) {
|
|
9867
|
+
this.store = { ...globalThis.window.ENV };
|
|
9868
|
+
}
|
|
9869
|
+
if (typeof globalThis !== "undefined" && globalThis.__ENV__) {
|
|
9870
|
+
this.store = { ...this.store, ...globalThis.__ENV__ };
|
|
9871
|
+
}
|
|
9872
|
+
}
|
|
9873
|
+
get(key) {
|
|
9874
|
+
const value = this.store[key];
|
|
9875
|
+
return value !== undefined ? String(value) : undefined;
|
|
9876
|
+
}
|
|
9877
|
+
set(key, value) {
|
|
9878
|
+
this.store[key] = value;
|
|
9879
|
+
}
|
|
9880
|
+
has(key) {
|
|
9881
|
+
return key in this.store;
|
|
9882
|
+
}
|
|
9883
|
+
getAll() {
|
|
9884
|
+
return { ...this.store };
|
|
9885
|
+
}
|
|
9886
|
+
}
|
|
9887
|
+
|
|
9888
|
+
class Environment {
|
|
9889
|
+
runtime;
|
|
9890
|
+
browserStore;
|
|
9891
|
+
cache = new Map;
|
|
9892
|
+
constructor() {
|
|
9893
|
+
this.runtime = detectEnvironment();
|
|
9894
|
+
if (this.runtime === "browser") {
|
|
9895
|
+
this.browserStore = new BrowserEnvironmentStore;
|
|
9896
|
+
}
|
|
9897
|
+
}
|
|
9898
|
+
getRuntime() {
|
|
9899
|
+
return this.runtime;
|
|
9900
|
+
}
|
|
9901
|
+
isNode() {
|
|
9902
|
+
return this.runtime === "node";
|
|
9903
|
+
}
|
|
9904
|
+
isBrowser() {
|
|
9905
|
+
return this.runtime === "browser";
|
|
9906
|
+
}
|
|
9907
|
+
get(key, defaultValue) {
|
|
9908
|
+
if (this.cache.has(key)) {
|
|
9909
|
+
const cached = this.cache.get(key);
|
|
9910
|
+
return cached === undefined && defaultValue !== undefined ? defaultValue : cached;
|
|
9911
|
+
}
|
|
9912
|
+
let value;
|
|
9913
|
+
switch (this.runtime) {
|
|
9914
|
+
case "node":
|
|
9915
|
+
if (typeof process !== "undefined" && process.env) {
|
|
9916
|
+
value = process.env[key];
|
|
9917
|
+
}
|
|
9918
|
+
break;
|
|
9919
|
+
case "browser":
|
|
9920
|
+
if (this.browserStore) {
|
|
9921
|
+
value = this.browserStore.get(key);
|
|
9922
|
+
}
|
|
9923
|
+
break;
|
|
9924
|
+
default:
|
|
9925
|
+
value = undefined;
|
|
9926
|
+
}
|
|
9927
|
+
this.cache.set(key, value);
|
|
9928
|
+
return value === undefined && defaultValue !== undefined ? defaultValue : value;
|
|
9929
|
+
}
|
|
9930
|
+
set(key, value) {
|
|
9931
|
+
const stringValue = String(value);
|
|
9932
|
+
this.cache.delete(key);
|
|
9933
|
+
switch (this.runtime) {
|
|
9934
|
+
case "node":
|
|
9935
|
+
if (typeof process !== "undefined" && process.env) {
|
|
9936
|
+
process.env[key] = stringValue;
|
|
9937
|
+
}
|
|
9938
|
+
break;
|
|
9939
|
+
case "browser":
|
|
9940
|
+
if (this.browserStore) {
|
|
9941
|
+
this.browserStore.set(key, value);
|
|
9942
|
+
}
|
|
9943
|
+
break;
|
|
9944
|
+
}
|
|
9945
|
+
}
|
|
9946
|
+
has(key) {
|
|
9947
|
+
const value = this.get(key);
|
|
9948
|
+
return value !== undefined;
|
|
9949
|
+
}
|
|
9950
|
+
getAll() {
|
|
9951
|
+
switch (this.runtime) {
|
|
9952
|
+
case "node":
|
|
9953
|
+
if (typeof process !== "undefined" && process.env) {
|
|
9954
|
+
return { ...process.env };
|
|
9955
|
+
}
|
|
9956
|
+
break;
|
|
9957
|
+
case "browser":
|
|
9958
|
+
if (this.browserStore) {
|
|
9959
|
+
return this.browserStore.getAll();
|
|
9960
|
+
}
|
|
9961
|
+
break;
|
|
9962
|
+
}
|
|
9963
|
+
return {};
|
|
9964
|
+
}
|
|
9965
|
+
getBoolean(key, defaultValue = false) {
|
|
9966
|
+
const value = this.get(key);
|
|
9967
|
+
if (value === undefined) {
|
|
9968
|
+
return defaultValue;
|
|
9969
|
+
}
|
|
9970
|
+
return ["true", "1", "yes", "on"].includes(value.toLowerCase());
|
|
9971
|
+
}
|
|
9972
|
+
getNumber(key, defaultValue) {
|
|
9973
|
+
const value = this.get(key);
|
|
9974
|
+
if (value === undefined) {
|
|
9975
|
+
return defaultValue;
|
|
9976
|
+
}
|
|
9977
|
+
const parsed = Number(value);
|
|
9978
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
9979
|
+
}
|
|
9980
|
+
clearCache() {
|
|
9981
|
+
this.cache.clear();
|
|
9982
|
+
}
|
|
9983
|
+
}
|
|
9984
|
+
function getEnvironment() {
|
|
9985
|
+
if (!environmentInstance) {
|
|
9986
|
+
environmentInstance = new Environment;
|
|
9987
|
+
}
|
|
9988
|
+
return environmentInstance;
|
|
9989
|
+
}
|
|
9990
|
+
function getEnv3(key, defaultValue) {
|
|
9991
|
+
return getEnvironment().get(key, defaultValue);
|
|
9992
|
+
}
|
|
9993
|
+
function setEnv(key, value) {
|
|
9994
|
+
getEnvironment().set(key, value);
|
|
9995
|
+
}
|
|
9996
|
+
function hasEnv(key) {
|
|
9997
|
+
return getEnvironment().has(key);
|
|
9998
|
+
}
|
|
9999
|
+
function getBooleanEnv(key, defaultValue = false) {
|
|
10000
|
+
return getEnvironment().getBoolean(key, defaultValue);
|
|
10001
|
+
}
|
|
10002
|
+
function getNumberEnv(key, defaultValue) {
|
|
10003
|
+
return getEnvironment().getNumber(key, defaultValue);
|
|
10004
|
+
}
|
|
10005
|
+
function initBrowserEnvironment(config) {
|
|
10006
|
+
const env = getEnvironment();
|
|
10007
|
+
if (env.isBrowser()) {
|
|
10008
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
10009
|
+
if (value !== undefined) {
|
|
10010
|
+
env.set(key, value);
|
|
10011
|
+
}
|
|
10012
|
+
});
|
|
10013
|
+
}
|
|
10014
|
+
}
|
|
10015
|
+
function findEnvFile() {
|
|
10016
|
+
if (typeof process === "undefined" || !process.cwd) {
|
|
10017
|
+
return null;
|
|
10018
|
+
}
|
|
10019
|
+
const fs = __require("node:fs");
|
|
10020
|
+
const path = __require("node:path");
|
|
10021
|
+
const possiblePaths = [
|
|
10022
|
+
path.join(process.cwd(), ".env"),
|
|
10023
|
+
path.join(process.cwd(), ".env.local")
|
|
10024
|
+
];
|
|
10025
|
+
for (const envPath of possiblePaths) {
|
|
10026
|
+
if (fs.existsSync(envPath)) {
|
|
10027
|
+
return envPath;
|
|
10028
|
+
}
|
|
10029
|
+
}
|
|
10030
|
+
return null;
|
|
10031
|
+
}
|
|
10032
|
+
async function loadEnvConfig(envPath) {
|
|
10033
|
+
if (typeof process === "undefined" || !process.cwd) {
|
|
10034
|
+
return {};
|
|
10035
|
+
}
|
|
10036
|
+
const dotenv = __require("dotenv");
|
|
10037
|
+
const resolvedPath = envPath || findEnvFile();
|
|
10038
|
+
if (resolvedPath) {
|
|
10039
|
+
const result = dotenv.config({ path: resolvedPath });
|
|
10040
|
+
if (result.error) {
|
|
10041
|
+
throw result.error;
|
|
10042
|
+
}
|
|
10043
|
+
}
|
|
10044
|
+
return process.env;
|
|
10045
|
+
}
|
|
10046
|
+
var environmentInstance = null, currentRuntime;
|
|
10047
|
+
var init_environment = __esm(() => {
|
|
10048
|
+
currentRuntime = detectEnvironment();
|
|
10049
|
+
});
|
|
10050
|
+
|
|
9814
10051
|
// ../../node_modules/picocolors/picocolors.js
|
|
9815
10052
|
var require_picocolors = __commonJS((exports, module) => {
|
|
9816
10053
|
var p = process || {};
|
|
@@ -10499,24 +10736,6 @@ var require_get_proto = __commonJS((exports, module) => {
|
|
|
10499
10736
|
} : null;
|
|
10500
10737
|
});
|
|
10501
10738
|
|
|
10502
|
-
// ../../node_modules/async-function/index.js
|
|
10503
|
-
var require_async_function = __commonJS((exports, module) => {
|
|
10504
|
-
var cached = async function() {}.constructor;
|
|
10505
|
-
module.exports = () => cached;
|
|
10506
|
-
});
|
|
10507
|
-
|
|
10508
|
-
// ../../node_modules/generator-function/index.js
|
|
10509
|
-
var require_generator_function = __commonJS((exports, module) => {
|
|
10510
|
-
var cached = function* () {}.constructor;
|
|
10511
|
-
module.exports = () => cached;
|
|
10512
|
-
});
|
|
10513
|
-
|
|
10514
|
-
// ../../node_modules/async-generator-function/index.js
|
|
10515
|
-
var require_async_generator_function = __commonJS((exports, module) => {
|
|
10516
|
-
var cached = async function* () {}.constructor;
|
|
10517
|
-
module.exports = () => cached;
|
|
10518
|
-
});
|
|
10519
|
-
|
|
10520
10739
|
// ../../node_modules/hasown/index.js
|
|
10521
10740
|
var require_hasown = __commonJS((exports, module) => {
|
|
10522
10741
|
var call = Function.prototype.call;
|
|
@@ -10543,6 +10762,12 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
10543
10762
|
var pow = require_pow();
|
|
10544
10763
|
var round = require_round();
|
|
10545
10764
|
var sign = require_sign();
|
|
10765
|
+
var $Function = Function;
|
|
10766
|
+
var getEvalledConstructor = function(expressionSyntax) {
|
|
10767
|
+
try {
|
|
10768
|
+
return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")();
|
|
10769
|
+
} catch (e) {}
|
|
10770
|
+
};
|
|
10546
10771
|
var $gOPD = require_gopd();
|
|
10547
10772
|
var $defineProperty = require_es_define_property();
|
|
10548
10773
|
var throwTypeError = function() {
|
|
@@ -10597,7 +10822,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
10597
10822
|
"%Float32Array%": typeof Float32Array === "undefined" ? undefined3 : Float32Array,
|
|
10598
10823
|
"%Float64Array%": typeof Float64Array === "undefined" ? undefined3 : Float64Array,
|
|
10599
10824
|
"%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined3 : FinalizationRegistry,
|
|
10600
|
-
"%Function%": Function,
|
|
10825
|
+
"%Function%": $Function,
|
|
10601
10826
|
"%GeneratorFunction%": needsEval,
|
|
10602
10827
|
"%Int8Array%": typeof Int8Array === "undefined" ? undefined3 : Int8Array,
|
|
10603
10828
|
"%Int16Array%": typeof Int16Array === "undefined" ? undefined3 : Int16Array,
|
|
@@ -10660,17 +10885,14 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
10660
10885
|
}
|
|
10661
10886
|
}
|
|
10662
10887
|
var errorProto;
|
|
10663
|
-
var getAsyncFunction = require_async_function();
|
|
10664
|
-
var getGeneratorFunction = require_generator_function();
|
|
10665
|
-
var getAsyncGeneratorFunction = require_async_generator_function();
|
|
10666
10888
|
var doEval = function doEval(name) {
|
|
10667
10889
|
var value;
|
|
10668
10890
|
if (name === "%AsyncFunction%") {
|
|
10669
|
-
value =
|
|
10891
|
+
value = getEvalledConstructor("async function () {}");
|
|
10670
10892
|
} else if (name === "%GeneratorFunction%") {
|
|
10671
|
-
value =
|
|
10893
|
+
value = getEvalledConstructor("function* () {}");
|
|
10672
10894
|
} else if (name === "%AsyncGeneratorFunction%") {
|
|
10673
|
-
value =
|
|
10895
|
+
value = getEvalledConstructor("async function* () {}");
|
|
10674
10896
|
} else if (name === "%AsyncGenerator%") {
|
|
10675
10897
|
var fn = doEval("%AsyncGeneratorFunction%");
|
|
10676
10898
|
if (fn) {
|
|
@@ -25770,7 +25992,7 @@ var getDefaultProjectName = () => {
|
|
|
25770
25992
|
};
|
|
25771
25993
|
|
|
25772
25994
|
// ../../node_modules/langsmith/dist/index.js
|
|
25773
|
-
var __version__ = "0.3.
|
|
25995
|
+
var __version__ = "0.3.72";
|
|
25774
25996
|
|
|
25775
25997
|
// ../../node_modules/langsmith/dist/utils/env.js
|
|
25776
25998
|
var globalEnv;
|
|
@@ -39079,171 +39301,8 @@ var import_handlebars = __toESM(require_lib(), 1);
|
|
|
39079
39301
|
var import_unique_names_generator = __toESM(require_dist4(), 1);
|
|
39080
39302
|
import { z as z2 } from "zod";
|
|
39081
39303
|
|
|
39082
|
-
// src/
|
|
39083
|
-
|
|
39084
|
-
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
39085
|
-
return "node";
|
|
39086
|
-
}
|
|
39087
|
-
if (typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined" && typeof globalThis.window.document !== "undefined") {
|
|
39088
|
-
return "browser";
|
|
39089
|
-
}
|
|
39090
|
-
return "unknown";
|
|
39091
|
-
}
|
|
39092
|
-
|
|
39093
|
-
class BrowserEnvironmentStore {
|
|
39094
|
-
store = {};
|
|
39095
|
-
constructor() {
|
|
39096
|
-
if (typeof globalThis !== "undefined" && globalThis.window && globalThis.window.ENV) {
|
|
39097
|
-
this.store = { ...globalThis.window.ENV };
|
|
39098
|
-
}
|
|
39099
|
-
if (typeof globalThis !== "undefined" && globalThis.__ENV__) {
|
|
39100
|
-
this.store = { ...this.store, ...globalThis.__ENV__ };
|
|
39101
|
-
}
|
|
39102
|
-
}
|
|
39103
|
-
get(key) {
|
|
39104
|
-
const value = this.store[key];
|
|
39105
|
-
return value !== undefined ? String(value) : undefined;
|
|
39106
|
-
}
|
|
39107
|
-
set(key, value) {
|
|
39108
|
-
this.store[key] = value;
|
|
39109
|
-
}
|
|
39110
|
-
has(key) {
|
|
39111
|
-
return key in this.store;
|
|
39112
|
-
}
|
|
39113
|
-
getAll() {
|
|
39114
|
-
return { ...this.store };
|
|
39115
|
-
}
|
|
39116
|
-
}
|
|
39117
|
-
|
|
39118
|
-
class Environment {
|
|
39119
|
-
runtime;
|
|
39120
|
-
browserStore;
|
|
39121
|
-
cache = new Map;
|
|
39122
|
-
constructor() {
|
|
39123
|
-
this.runtime = detectEnvironment();
|
|
39124
|
-
if (this.runtime === "browser") {
|
|
39125
|
-
this.browserStore = new BrowserEnvironmentStore;
|
|
39126
|
-
}
|
|
39127
|
-
}
|
|
39128
|
-
getRuntime() {
|
|
39129
|
-
return this.runtime;
|
|
39130
|
-
}
|
|
39131
|
-
isNode() {
|
|
39132
|
-
return this.runtime === "node";
|
|
39133
|
-
}
|
|
39134
|
-
isBrowser() {
|
|
39135
|
-
return this.runtime === "browser";
|
|
39136
|
-
}
|
|
39137
|
-
get(key, defaultValue) {
|
|
39138
|
-
if (this.cache.has(key)) {
|
|
39139
|
-
const cached = this.cache.get(key);
|
|
39140
|
-
return cached === undefined && defaultValue !== undefined ? defaultValue : cached;
|
|
39141
|
-
}
|
|
39142
|
-
let value;
|
|
39143
|
-
switch (this.runtime) {
|
|
39144
|
-
case "node":
|
|
39145
|
-
if (typeof process !== "undefined" && process.env) {
|
|
39146
|
-
value = process.env[key];
|
|
39147
|
-
}
|
|
39148
|
-
break;
|
|
39149
|
-
case "browser":
|
|
39150
|
-
if (this.browserStore) {
|
|
39151
|
-
value = this.browserStore.get(key);
|
|
39152
|
-
}
|
|
39153
|
-
break;
|
|
39154
|
-
default:
|
|
39155
|
-
value = undefined;
|
|
39156
|
-
}
|
|
39157
|
-
this.cache.set(key, value);
|
|
39158
|
-
return value === undefined && defaultValue !== undefined ? defaultValue : value;
|
|
39159
|
-
}
|
|
39160
|
-
set(key, value) {
|
|
39161
|
-
const stringValue = String(value);
|
|
39162
|
-
this.cache.delete(key);
|
|
39163
|
-
switch (this.runtime) {
|
|
39164
|
-
case "node":
|
|
39165
|
-
if (typeof process !== "undefined" && process.env) {
|
|
39166
|
-
process.env[key] = stringValue;
|
|
39167
|
-
}
|
|
39168
|
-
break;
|
|
39169
|
-
case "browser":
|
|
39170
|
-
if (this.browserStore) {
|
|
39171
|
-
this.browserStore.set(key, value);
|
|
39172
|
-
}
|
|
39173
|
-
break;
|
|
39174
|
-
}
|
|
39175
|
-
}
|
|
39176
|
-
has(key) {
|
|
39177
|
-
const value = this.get(key);
|
|
39178
|
-
return value !== undefined;
|
|
39179
|
-
}
|
|
39180
|
-
getAll() {
|
|
39181
|
-
switch (this.runtime) {
|
|
39182
|
-
case "node":
|
|
39183
|
-
if (typeof process !== "undefined" && process.env) {
|
|
39184
|
-
return { ...process.env };
|
|
39185
|
-
}
|
|
39186
|
-
break;
|
|
39187
|
-
case "browser":
|
|
39188
|
-
if (this.browserStore) {
|
|
39189
|
-
return this.browserStore.getAll();
|
|
39190
|
-
}
|
|
39191
|
-
break;
|
|
39192
|
-
}
|
|
39193
|
-
return {};
|
|
39194
|
-
}
|
|
39195
|
-
getBoolean(key, defaultValue = false) {
|
|
39196
|
-
const value = this.get(key);
|
|
39197
|
-
if (value === undefined) {
|
|
39198
|
-
return defaultValue;
|
|
39199
|
-
}
|
|
39200
|
-
return ["true", "1", "yes", "on"].includes(value.toLowerCase());
|
|
39201
|
-
}
|
|
39202
|
-
getNumber(key, defaultValue) {
|
|
39203
|
-
const value = this.get(key);
|
|
39204
|
-
if (value === undefined) {
|
|
39205
|
-
return defaultValue;
|
|
39206
|
-
}
|
|
39207
|
-
const parsed = Number(value);
|
|
39208
|
-
return isNaN(parsed) ? defaultValue : parsed;
|
|
39209
|
-
}
|
|
39210
|
-
clearCache() {
|
|
39211
|
-
this.cache.clear();
|
|
39212
|
-
}
|
|
39213
|
-
}
|
|
39214
|
-
var environmentInstance = null;
|
|
39215
|
-
function getEnvironment() {
|
|
39216
|
-
if (!environmentInstance) {
|
|
39217
|
-
environmentInstance = new Environment;
|
|
39218
|
-
}
|
|
39219
|
-
return environmentInstance;
|
|
39220
|
-
}
|
|
39221
|
-
function getEnv3(key, defaultValue) {
|
|
39222
|
-
return getEnvironment().get(key, defaultValue);
|
|
39223
|
-
}
|
|
39224
|
-
function setEnv(key, value) {
|
|
39225
|
-
getEnvironment().set(key, value);
|
|
39226
|
-
}
|
|
39227
|
-
function hasEnv(key) {
|
|
39228
|
-
return getEnvironment().has(key);
|
|
39229
|
-
}
|
|
39230
|
-
function getBooleanEnv(key, defaultValue = false) {
|
|
39231
|
-
return getEnvironment().getBoolean(key, defaultValue);
|
|
39232
|
-
}
|
|
39233
|
-
function getNumberEnv(key, defaultValue) {
|
|
39234
|
-
return getEnvironment().getNumber(key, defaultValue);
|
|
39235
|
-
}
|
|
39236
|
-
function initBrowserEnvironment(config) {
|
|
39237
|
-
const env = getEnvironment();
|
|
39238
|
-
if (env.isBrowser()) {
|
|
39239
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
39240
|
-
if (value !== undefined) {
|
|
39241
|
-
env.set(key, value);
|
|
39242
|
-
}
|
|
39243
|
-
});
|
|
39244
|
-
}
|
|
39245
|
-
}
|
|
39246
|
-
var currentRuntime = detectEnvironment();
|
|
39304
|
+
// src/logger.ts
|
|
39305
|
+
init_environment();
|
|
39247
39306
|
// ../../node_modules/adze/dist/tools.js
|
|
39248
39307
|
class Tools {
|
|
39249
39308
|
globalStore;
|
|
@@ -41379,6 +41438,7 @@ var recentLogs = () => globalInMemoryDestination.recentLogs();
|
|
|
41379
41438
|
var logger_default = logger;
|
|
41380
41439
|
|
|
41381
41440
|
// src/utils.ts
|
|
41441
|
+
init_environment();
|
|
41382
41442
|
function upgradeDoubleToTriple(tpl) {
|
|
41383
41443
|
return tpl.replace(/(?<!{){{(?![{#\/!>])([\s\S]*?)}}/g, (_match, inner) => {
|
|
41384
41444
|
if (inner.trim() === "else")
|
|
@@ -41791,6 +41851,8 @@ function safeReplacer() {
|
|
|
41791
41851
|
function parseBooleanFromText2(value) {
|
|
41792
41852
|
if (!value)
|
|
41793
41853
|
return false;
|
|
41854
|
+
if (typeof value === "boolean")
|
|
41855
|
+
return value;
|
|
41794
41856
|
const affirmative = ["YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"];
|
|
41795
41857
|
const negative = ["NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"];
|
|
41796
41858
|
const normalizedText = value.trim().toUpperCase();
|
|
@@ -41990,63 +42052,72 @@ function getLocalServerUrl(path) {
|
|
|
41990
42052
|
}
|
|
41991
42053
|
// src/schemas/character.ts
|
|
41992
42054
|
import { z as z3 } from "zod";
|
|
41993
|
-
var uuidSchema2 = z3.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "Invalid UUID format");
|
|
42055
|
+
var uuidSchema2 = z3.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "Invalid UUID format").describe("Unique identifier for the character in UUID format");
|
|
42056
|
+
var mediaSchema = z3.object({
|
|
42057
|
+
id: z3.string().describe("Unique identifier for the media"),
|
|
42058
|
+
url: z3.string().describe("URL of the media file"),
|
|
42059
|
+
title: z3.string().optional().describe("Media title"),
|
|
42060
|
+
source: z3.string().optional().describe("Media source"),
|
|
42061
|
+
description: z3.string().optional().describe("Media description"),
|
|
42062
|
+
text: z3.string().optional().describe("Text content associated with the media"),
|
|
42063
|
+
contentType: z3.nativeEnum(ContentType).optional().describe("Type of media content")
|
|
42064
|
+
}).loose().describe("Media attachment with URL and metadata");
|
|
41994
42065
|
var contentSchema = z3.object({
|
|
41995
|
-
text: z3.string().optional(),
|
|
41996
|
-
thought: z3.string().optional(),
|
|
41997
|
-
actions: z3.array(z3.string()).optional(),
|
|
41998
|
-
providers: z3.array(z3.string()).optional(),
|
|
41999
|
-
source: z3.string().optional(),
|
|
42000
|
-
target: z3.string().optional(),
|
|
42001
|
-
url: z3.string().optional(),
|
|
42002
|
-
inReplyTo: uuidSchema2.optional(),
|
|
42003
|
-
attachments: z3.array(
|
|
42004
|
-
channelType: z3.
|
|
42005
|
-
}).
|
|
42066
|
+
text: z3.string().optional().describe("The main text content of the message"),
|
|
42067
|
+
thought: z3.string().optional().describe("Internal thought process or reasoning"),
|
|
42068
|
+
actions: z3.array(z3.string()).optional().describe("Actions to be taken in response"),
|
|
42069
|
+
providers: z3.array(z3.string()).optional().describe("Data providers to use (e.g., KNOWLEDGE)"),
|
|
42070
|
+
source: z3.string().optional().describe("Source of the content"),
|
|
42071
|
+
target: z3.string().optional().describe("Target of the content"),
|
|
42072
|
+
url: z3.string().optional().describe("Related URL"),
|
|
42073
|
+
inReplyTo: uuidSchema2.optional().describe("UUID of message this is replying to"),
|
|
42074
|
+
attachments: z3.array(mediaSchema).optional().describe("Array of media attachments (images, videos, documents, etc.)"),
|
|
42075
|
+
channelType: z3.enum(ChannelType).optional().describe("Type of channel this content is for")
|
|
42076
|
+
}).catchall(z3.unknown()).describe("Content structure for messages in conversation examples");
|
|
42006
42077
|
var messageExampleSchema = z3.object({
|
|
42007
|
-
name: z3.string(),
|
|
42078
|
+
name: z3.string().describe("Name of the speaker (can use {{name1}} placeholder for dynamic names)"),
|
|
42008
42079
|
content: contentSchema
|
|
42009
|
-
});
|
|
42080
|
+
}).describe("A single message in a conversation example");
|
|
42010
42081
|
var directoryItemSchema = z3.object({
|
|
42011
|
-
directory: z3.string(),
|
|
42012
|
-
shared: z3.boolean().optional()
|
|
42013
|
-
});
|
|
42082
|
+
directory: z3.string().describe("Path to a directory containing knowledge files"),
|
|
42083
|
+
shared: z3.boolean().optional().describe("Whether this knowledge is shared across characters")
|
|
42084
|
+
}).describe("Directory-based knowledge source");
|
|
42014
42085
|
var knowledgeItemSchema = z3.union([
|
|
42015
|
-
z3.string(),
|
|
42086
|
+
z3.string().describe("File path to a knowledge document"),
|
|
42016
42087
|
z3.object({
|
|
42017
|
-
path: z3.string(),
|
|
42018
|
-
shared: z3.boolean().optional()
|
|
42088
|
+
path: z3.string().describe("Path to a knowledge file"),
|
|
42089
|
+
shared: z3.boolean().optional().describe("Whether this knowledge is shared across characters")
|
|
42019
42090
|
}),
|
|
42020
42091
|
directoryItemSchema
|
|
42021
|
-
]);
|
|
42092
|
+
]).describe("Knowledge source - can be a file path, file object, or directory");
|
|
42022
42093
|
var templateTypeSchema = z3.union([
|
|
42023
|
-
z3.string(),
|
|
42094
|
+
z3.string().describe("Template string with placeholders"),
|
|
42024
42095
|
z3.function().optional()
|
|
42025
|
-
]);
|
|
42096
|
+
]).describe("Template for generating text - can be a string template or function");
|
|
42026
42097
|
var styleSchema = z3.object({
|
|
42027
|
-
all: z3.array(z3.string()).optional(),
|
|
42028
|
-
chat: z3.array(z3.string()).optional(),
|
|
42029
|
-
post: z3.array(z3.string()).optional()
|
|
42030
|
-
}).optional();
|
|
42031
|
-
var settingsSchema = z3.record(z3.string(), z3.union([z3.string(), z3.boolean(), z3.number(), z3.any()])).optional();
|
|
42032
|
-
var secretsSchema = z3.record(z3.string(), z3.union([z3.string(), z3.boolean(), z3.number()])).optional();
|
|
42098
|
+
all: z3.array(z3.string()).optional().describe("Style guidelines applied to all types of responses"),
|
|
42099
|
+
chat: z3.array(z3.string()).optional().describe("Style guidelines specific to chat/conversation responses"),
|
|
42100
|
+
post: z3.array(z3.string()).optional().describe("Style guidelines specific to social media posts")
|
|
42101
|
+
}).optional().describe("Style configuration defining how the character communicates across different contexts");
|
|
42102
|
+
var settingsSchema = z3.record(z3.string(), z3.union([z3.string(), z3.boolean(), z3.number(), z3.object({}).loose(), z3.array(z3.any())])).optional().describe("Character-specific settings like avatar URL, preferences, and configuration");
|
|
42103
|
+
var secretsSchema = z3.record(z3.string(), z3.union([z3.string(), z3.boolean(), z3.number()])).optional().describe("Secret values and API keys (should not be committed to version control)");
|
|
42033
42104
|
var characterSchema = z3.object({
|
|
42034
|
-
id: uuidSchema2.optional(),
|
|
42035
|
-
name: z3.string().min(1, "Character name is required"),
|
|
42036
|
-
username: z3.string().optional(),
|
|
42037
|
-
system: z3.string().optional(),
|
|
42038
|
-
templates: z3.record(z3.string(), templateTypeSchema).optional(),
|
|
42039
|
-
bio: z3.union([z3.string(), z3.array(z3.string())]),
|
|
42040
|
-
messageExamples: z3.array(z3.array(messageExampleSchema)).optional(),
|
|
42041
|
-
postExamples: z3.array(z3.string()).optional(),
|
|
42042
|
-
topics: z3.array(z3.string()).optional(),
|
|
42043
|
-
adjectives: z3.array(z3.string()).optional(),
|
|
42044
|
-
knowledge: z3.array(knowledgeItemSchema).optional(),
|
|
42045
|
-
plugins: z3.array(z3.string()).optional(),
|
|
42105
|
+
id: uuidSchema2.optional().describe("Unique identifier for the character"),
|
|
42106
|
+
name: z3.string().min(1, "Character name is required").describe('The name of the character (e.g., "Eliza")'),
|
|
42107
|
+
username: z3.string().optional().describe("Username for the character on various platforms"),
|
|
42108
|
+
system: z3.string().optional().describe("System prompt that defines the character's core behavior and response style"),
|
|
42109
|
+
templates: z3.record(z3.string(), templateTypeSchema).optional().describe("Custom templates for generating different types of content"),
|
|
42110
|
+
bio: z3.union([z3.string(), z3.array(z3.string())]).describe("Character biography - can be a single string or array of biographical points"),
|
|
42111
|
+
messageExamples: z3.array(z3.array(messageExampleSchema)).optional().describe("Example conversations showing how the character responds in different scenarios"),
|
|
42112
|
+
postExamples: z3.array(z3.string()).optional().describe("Example social media posts demonstrating the character's voice and topics"),
|
|
42113
|
+
topics: z3.array(z3.string()).optional().describe("Topics the character is knowledgeable about and engages with"),
|
|
42114
|
+
adjectives: z3.array(z3.string()).optional().describe("Adjectives that describe the character's personality and traits"),
|
|
42115
|
+
knowledge: z3.array(knowledgeItemSchema).optional().describe("Knowledge sources (files, directories) the character can reference"),
|
|
42116
|
+
plugins: z3.array(z3.string()).optional().describe('List of plugin package names to load (e.g., ["@elizaos/plugin-sql", "@elizaos/plugin-bootstrap"] - these are commonly required)'),
|
|
42046
42117
|
settings: settingsSchema,
|
|
42047
42118
|
secrets: secretsSchema,
|
|
42048
42119
|
style: styleSchema
|
|
42049
|
-
}).strict();
|
|
42120
|
+
}).strict().describe("Complete character definition including personality, behavior, and capabilities");
|
|
42050
42121
|
function validateCharacter(data2) {
|
|
42051
42122
|
const result = characterSchema.safeParse(data2);
|
|
42052
42123
|
if (result.success) {
|
|
@@ -42079,6 +42150,10 @@ function parseAndValidateCharacter(jsonString) {
|
|
|
42079
42150
|
function isValidCharacter(data2) {
|
|
42080
42151
|
return validateCharacter(data2).success;
|
|
42081
42152
|
}
|
|
42153
|
+
|
|
42154
|
+
// src/index.node.ts
|
|
42155
|
+
init_environment();
|
|
42156
|
+
|
|
42082
42157
|
// src/utils/buffer.ts
|
|
42083
42158
|
function hasNativeBuffer() {
|
|
42084
42159
|
return typeof Buffer !== "undefined" && typeof Buffer.from === "function";
|
|
@@ -42524,12 +42599,21 @@ var shouldRespondTemplate = `<task>Decide on behalf of {{agentName}} whether the
|
|
|
42524
42599
|
</providers>
|
|
42525
42600
|
|
|
42526
42601
|
<instructions>Decide if {{agentName}} should respond to or interact with the conversation.
|
|
42527
|
-
|
|
42528
|
-
|
|
42529
|
-
If {{agentName}}
|
|
42602
|
+
|
|
42603
|
+
IMPORTANT RULES FOR RESPONDING:
|
|
42604
|
+
- If YOUR name ({{agentName}}) is directly mentioned → RESPOND
|
|
42605
|
+
- If someone uses a DIFFERENT name (not {{agentName}}) → IGNORE (they're talking to someone else)
|
|
42606
|
+
- If you're actively participating in a conversation and the message continues that thread → RESPOND
|
|
42607
|
+
- If someone tells you to stop or be quiet → STOP
|
|
42608
|
+
- Otherwise → IGNORE
|
|
42609
|
+
|
|
42610
|
+
The key distinction is:
|
|
42611
|
+
- "Talking TO {{agentName}}" (your name mentioned, replies to you, continuing your conversation) → RESPOND
|
|
42612
|
+
- "Talking ABOUT {{agentName}}" or to someone else → IGNORE
|
|
42613
|
+
</instructions>
|
|
42530
42614
|
|
|
42531
42615
|
<output>
|
|
42532
|
-
Do NOT include any thinking, reasoning, or <think> sections in your response.
|
|
42616
|
+
Do NOT include any thinking, reasoning, or <think> sections in your response.
|
|
42533
42617
|
Go directly to the XML response format without any preamble or explanation.
|
|
42534
42618
|
|
|
42535
42619
|
Respond using XML format like this:
|
|
@@ -42701,12 +42785,12 @@ These are the actions or data provider calls that have already been used in this
|
|
|
42701
42785
|
|
|
42702
42786
|
<keys>
|
|
42703
42787
|
"thought" Clearly explain your reasoning for the selected providers and/or action, and how this step contributes to resolving the user's request.
|
|
42704
|
-
"action" Name of the action to execute after providers return (can be
|
|
42788
|
+
"action" Name of the action to execute after providers return (can be empty if no action is needed).
|
|
42705
42789
|
"providers" List of provider names to call in this step (can be empty if none are needed).
|
|
42706
42790
|
"isFinish" Set to true only if the task is fully complete.
|
|
42707
42791
|
</keys>
|
|
42708
42792
|
|
|
42709
|
-
⚠️ IMPORTANT: Do **not** mark the task as \`isFinish: true\` immediately after calling an action
|
|
42793
|
+
⚠️ IMPORTANT: Do **not** mark the task as \`isFinish: true\` immediately after calling an action. Wait for the action to complete before deciding the task is finished.
|
|
42710
42794
|
|
|
42711
42795
|
<output>
|
|
42712
42796
|
<response>
|
|
@@ -42842,6 +42926,9 @@ function v43(options, buf, offset) {
|
|
|
42842
42926
|
return _v4(options, buf, offset);
|
|
42843
42927
|
}
|
|
42844
42928
|
var v4_default = v43;
|
|
42929
|
+
// src/runtime.ts
|
|
42930
|
+
init_environment();
|
|
42931
|
+
|
|
42845
42932
|
// src/search.ts
|
|
42846
42933
|
var isV = (char) => {
|
|
42847
42934
|
switch (char) {
|
|
@@ -45560,6 +45647,7 @@ class AgentRuntime {
|
|
|
45560
45647
|
|
|
45561
45648
|
// src/settings.ts
|
|
45562
45649
|
var import_crypto_browserify = __toESM(require_crypto_browserify(), 1);
|
|
45650
|
+
init_environment();
|
|
45563
45651
|
function createSettingFromConfig(configSetting) {
|
|
45564
45652
|
return {
|
|
45565
45653
|
name: configSetting.name,
|
|
@@ -45836,20 +45924,324 @@ function defineService(definition) {
|
|
|
45836
45924
|
return createService(definition.serviceType).withDescription(definition.description).withStart(definition.start).withStop(definition.stop || (() => Promise.resolve())).build();
|
|
45837
45925
|
}
|
|
45838
45926
|
|
|
45927
|
+
// src/secrets.ts
|
|
45928
|
+
init_environment();
|
|
45929
|
+
function hasCharacterSecrets(character) {
|
|
45930
|
+
return Boolean(character?.settings?.secrets && Object.keys(character.settings.secrets).length > 0);
|
|
45931
|
+
}
|
|
45932
|
+
async function loadSecretsNodeImpl(character) {
|
|
45933
|
+
const fs = await import("node:fs");
|
|
45934
|
+
const dotenv = await import("dotenv");
|
|
45935
|
+
const { findEnvFile: findEnvFile2 } = await Promise.resolve().then(() => (init_environment(), exports_environment));
|
|
45936
|
+
if (hasCharacterSecrets(character)) {
|
|
45937
|
+
return false;
|
|
45938
|
+
}
|
|
45939
|
+
const envPath = findEnvFile2();
|
|
45940
|
+
if (!envPath)
|
|
45941
|
+
return false;
|
|
45942
|
+
try {
|
|
45943
|
+
const buf = fs.readFileSync(envPath);
|
|
45944
|
+
const envSecrets = dotenv.parse(buf);
|
|
45945
|
+
if (!character.settings) {
|
|
45946
|
+
character.settings = {};
|
|
45947
|
+
}
|
|
45948
|
+
character.settings.secrets = envSecrets;
|
|
45949
|
+
return true;
|
|
45950
|
+
} catch {
|
|
45951
|
+
return false;
|
|
45952
|
+
}
|
|
45953
|
+
}
|
|
45954
|
+
async function setDefaultSecretsFromEnv(character) {
|
|
45955
|
+
const env2 = detectEnvironment();
|
|
45956
|
+
if (env2 !== "node") {
|
|
45957
|
+
return false;
|
|
45958
|
+
}
|
|
45959
|
+
return loadSecretsNodeImpl(character);
|
|
45960
|
+
}
|
|
45961
|
+
|
|
45962
|
+
// src/plugin.ts
|
|
45963
|
+
init_environment();
|
|
45964
|
+
var attemptedInstalls = new Set;
|
|
45965
|
+
function isAutoInstallAllowed() {
|
|
45966
|
+
if (process.env.ELIZA_NO_AUTO_INSTALL === "true")
|
|
45967
|
+
return false;
|
|
45968
|
+
if (process.env.ELIZA_NO_PLUGIN_AUTO_INSTALL === "true")
|
|
45969
|
+
return false;
|
|
45970
|
+
if (process.env.CI === "true")
|
|
45971
|
+
return false;
|
|
45972
|
+
if (process.env.ELIZA_TEST_MODE === "true")
|
|
45973
|
+
return false;
|
|
45974
|
+
if (false)
|
|
45975
|
+
;
|
|
45976
|
+
return true;
|
|
45977
|
+
}
|
|
45978
|
+
async function tryInstallPlugin(pluginName) {
|
|
45979
|
+
try {
|
|
45980
|
+
if (!isAutoInstallAllowed()) {
|
|
45981
|
+
logger.debug(`Auto-install disabled or not allowed in this environment. Skipping install for ${pluginName}.`);
|
|
45982
|
+
return false;
|
|
45983
|
+
}
|
|
45984
|
+
if (attemptedInstalls.has(pluginName)) {
|
|
45985
|
+
logger.debug(`Auto-install already attempted for ${pluginName}. Skipping.`);
|
|
45986
|
+
return false;
|
|
45987
|
+
}
|
|
45988
|
+
attemptedInstalls.add(pluginName);
|
|
45989
|
+
if (typeof Bun === "undefined" || typeof Bun.spawn !== "function") {
|
|
45990
|
+
logger.warn(`Bun runtime not available. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
45991
|
+
return false;
|
|
45992
|
+
}
|
|
45993
|
+
try {
|
|
45994
|
+
const check = Bun.spawn(["bun", "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
45995
|
+
const code = await check.exited;
|
|
45996
|
+
if (code !== 0) {
|
|
45997
|
+
logger.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
45998
|
+
return false;
|
|
45999
|
+
}
|
|
46000
|
+
} catch {
|
|
46001
|
+
logger.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
46002
|
+
return false;
|
|
46003
|
+
}
|
|
46004
|
+
logger.info(`Attempting to auto-install missing plugin: ${pluginName}`);
|
|
46005
|
+
const install = Bun.spawn(["bun", "add", pluginName], {
|
|
46006
|
+
cwd: process.cwd(),
|
|
46007
|
+
env: process.env,
|
|
46008
|
+
stdout: "inherit",
|
|
46009
|
+
stderr: "inherit"
|
|
46010
|
+
});
|
|
46011
|
+
const exit = await install.exited;
|
|
46012
|
+
if (exit === 0) {
|
|
46013
|
+
logger.info(`Successfully installed ${pluginName}. Retrying import...`);
|
|
46014
|
+
return true;
|
|
46015
|
+
}
|
|
46016
|
+
logger.error(`bun add ${pluginName} failed with exit code ${exit}. Please install manually.`);
|
|
46017
|
+
return false;
|
|
46018
|
+
} catch (e) {
|
|
46019
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
46020
|
+
logger.error(`Unexpected error during auto-install of ${pluginName}: ${message}`);
|
|
46021
|
+
return false;
|
|
46022
|
+
}
|
|
46023
|
+
}
|
|
46024
|
+
function isValidPluginShape(obj) {
|
|
46025
|
+
if (!obj || typeof obj !== "object") {
|
|
46026
|
+
return false;
|
|
46027
|
+
}
|
|
46028
|
+
const plugin = obj;
|
|
46029
|
+
if (!plugin.name) {
|
|
46030
|
+
return false;
|
|
46031
|
+
}
|
|
46032
|
+
return !!(plugin.init || plugin.services || plugin.providers || plugin.actions || plugin.evaluators || plugin.description);
|
|
46033
|
+
}
|
|
46034
|
+
function validatePlugin(plugin) {
|
|
46035
|
+
const errors = [];
|
|
46036
|
+
if (!plugin) {
|
|
46037
|
+
errors.push("Plugin is null or undefined");
|
|
46038
|
+
return { isValid: false, errors };
|
|
46039
|
+
}
|
|
46040
|
+
const pluginObj = plugin;
|
|
46041
|
+
if (!pluginObj.name) {
|
|
46042
|
+
errors.push("Plugin must have a name");
|
|
46043
|
+
}
|
|
46044
|
+
if (pluginObj.actions) {
|
|
46045
|
+
if (!Array.isArray(pluginObj.actions)) {
|
|
46046
|
+
errors.push("Plugin actions must be an array");
|
|
46047
|
+
} else {
|
|
46048
|
+
const invalidActions = pluginObj.actions.filter((a) => typeof a !== "object" || !a);
|
|
46049
|
+
if (invalidActions.length > 0) {
|
|
46050
|
+
errors.push("Plugin actions must be an array of action objects");
|
|
46051
|
+
}
|
|
46052
|
+
}
|
|
46053
|
+
}
|
|
46054
|
+
if (pluginObj.services) {
|
|
46055
|
+
if (!Array.isArray(pluginObj.services)) {
|
|
46056
|
+
errors.push("Plugin services must be an array");
|
|
46057
|
+
} else {
|
|
46058
|
+
const invalidServices = pluginObj.services.filter((s) => typeof s !== "function" && (typeof s !== "object" || !s));
|
|
46059
|
+
if (invalidServices.length > 0) {
|
|
46060
|
+
errors.push("Plugin services must be an array of service classes or objects");
|
|
46061
|
+
}
|
|
46062
|
+
}
|
|
46063
|
+
}
|
|
46064
|
+
if (pluginObj.providers && !Array.isArray(pluginObj.providers)) {
|
|
46065
|
+
errors.push("Plugin providers must be an array");
|
|
46066
|
+
}
|
|
46067
|
+
if (pluginObj.evaluators && !Array.isArray(pluginObj.evaluators)) {
|
|
46068
|
+
errors.push("Plugin evaluators must be an array");
|
|
46069
|
+
}
|
|
46070
|
+
return {
|
|
46071
|
+
isValid: errors.length === 0,
|
|
46072
|
+
errors
|
|
46073
|
+
};
|
|
46074
|
+
}
|
|
46075
|
+
async function loadAndPreparePlugin(pluginName) {
|
|
46076
|
+
try {
|
|
46077
|
+
let pluginModule;
|
|
46078
|
+
try {
|
|
46079
|
+
pluginModule = await import(pluginName);
|
|
46080
|
+
} catch (error) {
|
|
46081
|
+
logger.warn(`Failed to load plugin ${pluginName}: ${error}`);
|
|
46082
|
+
const attempted = await tryInstallPlugin(pluginName);
|
|
46083
|
+
if (!attempted) {
|
|
46084
|
+
return null;
|
|
46085
|
+
}
|
|
46086
|
+
try {
|
|
46087
|
+
pluginModule = await import(pluginName);
|
|
46088
|
+
} catch (secondError) {
|
|
46089
|
+
logger.error(`Auto-install attempted for ${pluginName} but import still failed: ${secondError}`);
|
|
46090
|
+
return null;
|
|
46091
|
+
}
|
|
46092
|
+
}
|
|
46093
|
+
if (!pluginModule) {
|
|
46094
|
+
logger.error(`Failed to load module for plugin ${pluginName}.`);
|
|
46095
|
+
return null;
|
|
46096
|
+
}
|
|
46097
|
+
const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match) => match[1].toUpperCase())}Plugin`;
|
|
46098
|
+
const moduleObj = pluginModule;
|
|
46099
|
+
const exportsToCheck = [
|
|
46100
|
+
moduleObj[expectedFunctionName],
|
|
46101
|
+
moduleObj.default,
|
|
46102
|
+
...Object.values(moduleObj)
|
|
46103
|
+
];
|
|
46104
|
+
for (const potentialPlugin of exportsToCheck) {
|
|
46105
|
+
if (isValidPluginShape(potentialPlugin)) {
|
|
46106
|
+
return potentialPlugin;
|
|
46107
|
+
}
|
|
46108
|
+
if (typeof potentialPlugin === "function" && potentialPlugin.length === 0) {
|
|
46109
|
+
try {
|
|
46110
|
+
const produced = potentialPlugin();
|
|
46111
|
+
if (isValidPluginShape(produced)) {
|
|
46112
|
+
return produced;
|
|
46113
|
+
}
|
|
46114
|
+
} catch (err) {
|
|
46115
|
+
logger.debug(`Factory export threw for ${pluginName}: ${err}`);
|
|
46116
|
+
}
|
|
46117
|
+
}
|
|
46118
|
+
}
|
|
46119
|
+
logger.warn(`Could not find a valid plugin export in ${pluginName}.`);
|
|
46120
|
+
return null;
|
|
46121
|
+
} catch (error) {
|
|
46122
|
+
logger.error(`Error loading plugin ${pluginName}: ${error}`);
|
|
46123
|
+
return null;
|
|
46124
|
+
}
|
|
46125
|
+
}
|
|
46126
|
+
function resolvePluginDependencies(availablePlugins, isTestMode = false) {
|
|
46127
|
+
const resolutionOrder = [];
|
|
46128
|
+
const visited = new Set;
|
|
46129
|
+
const visiting = new Set;
|
|
46130
|
+
function visit(pluginName) {
|
|
46131
|
+
if (!availablePlugins.has(pluginName)) {
|
|
46132
|
+
logger.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
|
|
46133
|
+
return;
|
|
46134
|
+
}
|
|
46135
|
+
if (visited.has(pluginName))
|
|
46136
|
+
return;
|
|
46137
|
+
if (visiting.has(pluginName)) {
|
|
46138
|
+
logger.error(`Circular dependency detected involving plugin: ${pluginName}`);
|
|
46139
|
+
return;
|
|
46140
|
+
}
|
|
46141
|
+
visiting.add(pluginName);
|
|
46142
|
+
const plugin = availablePlugins.get(pluginName);
|
|
46143
|
+
if (plugin) {
|
|
46144
|
+
const deps = [...plugin.dependencies || []];
|
|
46145
|
+
if (isTestMode) {
|
|
46146
|
+
deps.push(...plugin.testDependencies || []);
|
|
46147
|
+
}
|
|
46148
|
+
for (const dep of deps) {
|
|
46149
|
+
visit(dep);
|
|
46150
|
+
}
|
|
46151
|
+
}
|
|
46152
|
+
visiting.delete(pluginName);
|
|
46153
|
+
visited.add(pluginName);
|
|
46154
|
+
resolutionOrder.push(pluginName);
|
|
46155
|
+
}
|
|
46156
|
+
for (const name of availablePlugins.keys()) {
|
|
46157
|
+
if (!visited.has(name)) {
|
|
46158
|
+
visit(name);
|
|
46159
|
+
}
|
|
46160
|
+
}
|
|
46161
|
+
const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => Boolean(p));
|
|
46162
|
+
logger.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
|
|
46163
|
+
return finalPlugins;
|
|
46164
|
+
}
|
|
46165
|
+
async function loadPlugin(nameOrPlugin) {
|
|
46166
|
+
if (typeof nameOrPlugin === "string") {
|
|
46167
|
+
return loadAndPreparePlugin(nameOrPlugin);
|
|
46168
|
+
}
|
|
46169
|
+
const validation = validatePlugin(nameOrPlugin);
|
|
46170
|
+
if (!validation.isValid) {
|
|
46171
|
+
logger.error(`Invalid plugin provided: ${validation.errors.join(", ")}`);
|
|
46172
|
+
return null;
|
|
46173
|
+
}
|
|
46174
|
+
return nameOrPlugin;
|
|
46175
|
+
}
|
|
46176
|
+
async function resolvePluginsImpl(plugins, isTestMode = false) {
|
|
46177
|
+
const pluginMap = new Map;
|
|
46178
|
+
const queue2 = [...plugins];
|
|
46179
|
+
while (queue2.length > 0) {
|
|
46180
|
+
const next = queue2.shift();
|
|
46181
|
+
const loaded = await loadPlugin(next);
|
|
46182
|
+
if (!loaded)
|
|
46183
|
+
continue;
|
|
46184
|
+
if (!pluginMap.has(loaded.name)) {
|
|
46185
|
+
pluginMap.set(loaded.name, loaded);
|
|
46186
|
+
for (const depName of loaded.dependencies ?? []) {
|
|
46187
|
+
if (!pluginMap.has(depName)) {
|
|
46188
|
+
queue2.push(depName);
|
|
46189
|
+
}
|
|
46190
|
+
}
|
|
46191
|
+
if (isTestMode) {
|
|
46192
|
+
for (const depName of loaded.testDependencies ?? []) {
|
|
46193
|
+
if (!pluginMap.has(depName)) {
|
|
46194
|
+
queue2.push(depName);
|
|
46195
|
+
}
|
|
46196
|
+
}
|
|
46197
|
+
}
|
|
46198
|
+
}
|
|
46199
|
+
}
|
|
46200
|
+
return resolvePluginDependencies(pluginMap, isTestMode);
|
|
46201
|
+
}
|
|
46202
|
+
async function resolvePlugins(plugins, isTestMode = false) {
|
|
46203
|
+
const env2 = detectEnvironment();
|
|
46204
|
+
if (env2 === "node") {
|
|
46205
|
+
return resolvePluginsImpl(plugins, isTestMode);
|
|
46206
|
+
}
|
|
46207
|
+
const pluginObjects = plugins.filter((p) => typeof p !== "string");
|
|
46208
|
+
if (plugins.some((p) => typeof p === "string")) {
|
|
46209
|
+
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(", "));
|
|
46210
|
+
}
|
|
46211
|
+
const pluginMap = new Map;
|
|
46212
|
+
for (const plugin of pluginObjects) {
|
|
46213
|
+
pluginMap.set(plugin.name, plugin);
|
|
46214
|
+
}
|
|
46215
|
+
return resolvePluginDependencies(pluginMap, isTestMode);
|
|
46216
|
+
}
|
|
46217
|
+
|
|
45839
46218
|
// src/elizaos.ts
|
|
45840
46219
|
class ElizaOS extends EventTarget {
|
|
45841
46220
|
runtimes = new Map;
|
|
45842
46221
|
editableMode = false;
|
|
45843
46222
|
async addAgents(agents) {
|
|
45844
46223
|
const promises = agents.map(async (agent) => {
|
|
46224
|
+
const character = agent.character;
|
|
46225
|
+
if (!hasCharacterSecrets(character)) {
|
|
46226
|
+
await setDefaultSecretsFromEnv(character);
|
|
46227
|
+
}
|
|
46228
|
+
const resolvedPlugins = agent.plugins ? await resolvePlugins(agent.plugins) : [];
|
|
45845
46229
|
const runtime = new AgentRuntime({
|
|
45846
|
-
character
|
|
45847
|
-
plugins:
|
|
46230
|
+
character,
|
|
46231
|
+
plugins: resolvedPlugins,
|
|
45848
46232
|
settings: agent.settings || {}
|
|
45849
46233
|
});
|
|
45850
46234
|
this.runtimes.set(runtime.agentId, runtime);
|
|
46235
|
+
const { settings, ...characterWithoutSecrets } = character;
|
|
46236
|
+
const { secrets, ...settingsWithoutSecrets } = settings || {};
|
|
45851
46237
|
this.dispatchEvent(new CustomEvent("agent:added", {
|
|
45852
|
-
detail: {
|
|
46238
|
+
detail: {
|
|
46239
|
+
agentId: runtime.agentId,
|
|
46240
|
+
character: {
|
|
46241
|
+
...characterWithoutSecrets,
|
|
46242
|
+
settings: settingsWithoutSecrets
|
|
46243
|
+
}
|
|
46244
|
+
}
|
|
45853
46245
|
}));
|
|
45854
46246
|
return runtime.agentId;
|
|
45855
46247
|
});
|
|
@@ -46257,6 +46649,47 @@ Data: ${JSON.stringify(entity.metadata)}
|
|
|
46257
46649
|
return entityStrings.join(`
|
|
46258
46650
|
`);
|
|
46259
46651
|
}
|
|
46652
|
+
// src/character.ts
|
|
46653
|
+
function parseCharacter(input) {
|
|
46654
|
+
if (typeof input === "string") {
|
|
46655
|
+
throw new Error(`Character path provided but must be loaded first: ${input}`);
|
|
46656
|
+
}
|
|
46657
|
+
if (typeof input === "object") {
|
|
46658
|
+
const validationResult = validateCharacter(input);
|
|
46659
|
+
if (!validationResult.success) {
|
|
46660
|
+
const errorDetails = validationResult.error?.issues ? validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ") : validationResult.error?.message || "Unknown validation error";
|
|
46661
|
+
throw new Error(`Character validation failed: ${errorDetails}`);
|
|
46662
|
+
}
|
|
46663
|
+
return validationResult.data;
|
|
46664
|
+
}
|
|
46665
|
+
throw new Error("Invalid character input format");
|
|
46666
|
+
}
|
|
46667
|
+
function validateCharacterConfig(character) {
|
|
46668
|
+
const validationResult = validateCharacter(character);
|
|
46669
|
+
if (validationResult.success) {
|
|
46670
|
+
return {
|
|
46671
|
+
isValid: true,
|
|
46672
|
+
errors: []
|
|
46673
|
+
};
|
|
46674
|
+
}
|
|
46675
|
+
const errors = validationResult.error?.issues ? validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`) : [validationResult.error?.message || "Unknown validation error"];
|
|
46676
|
+
return {
|
|
46677
|
+
isValid: false,
|
|
46678
|
+
errors
|
|
46679
|
+
};
|
|
46680
|
+
}
|
|
46681
|
+
function mergeCharacterDefaults(char) {
|
|
46682
|
+
const defaults = {
|
|
46683
|
+
settings: {},
|
|
46684
|
+
plugins: [],
|
|
46685
|
+
bio: []
|
|
46686
|
+
};
|
|
46687
|
+
return {
|
|
46688
|
+
...defaults,
|
|
46689
|
+
...char,
|
|
46690
|
+
name: char.name || "Unnamed Character"
|
|
46691
|
+
};
|
|
46692
|
+
}
|
|
46260
46693
|
|
|
46261
46694
|
// src/index.node.ts
|
|
46262
46695
|
var isBrowser4 = false;
|
|
@@ -46264,22 +46697,33 @@ var isNode3 = true;
|
|
|
46264
46697
|
export {
|
|
46265
46698
|
waitForServerReady,
|
|
46266
46699
|
validateUuid,
|
|
46700
|
+
validatePlugin,
|
|
46701
|
+
validateCharacterConfig,
|
|
46267
46702
|
validateCharacter,
|
|
46703
|
+
uuidSchema2 as uuidSchema,
|
|
46268
46704
|
updateWorldSettings,
|
|
46269
46705
|
unsaltWorldSettings,
|
|
46270
46706
|
unsaltSettingValue,
|
|
46707
|
+
tryInstallPlugin,
|
|
46271
46708
|
truncateToCompleteSentence,
|
|
46272
46709
|
trimTokens,
|
|
46273
46710
|
toString2 as toString,
|
|
46274
46711
|
toHex,
|
|
46712
|
+
templateTypeSchema,
|
|
46713
|
+
styleSchema,
|
|
46275
46714
|
stringToUuid,
|
|
46276
46715
|
splitChunks,
|
|
46277
46716
|
slice,
|
|
46278
46717
|
shouldRespondTemplate,
|
|
46718
|
+
settingsSchema,
|
|
46279
46719
|
setEnv,
|
|
46720
|
+
setDefaultSecretsFromEnv,
|
|
46721
|
+
secretsSchema,
|
|
46280
46722
|
saltWorldSettings,
|
|
46281
46723
|
saltSettingValue,
|
|
46282
46724
|
safeReplacer,
|
|
46725
|
+
resolvePlugins,
|
|
46726
|
+
resolvePluginDependencies,
|
|
46283
46727
|
resetPaths,
|
|
46284
46728
|
recentLogs,
|
|
46285
46729
|
randomBytes,
|
|
@@ -46288,13 +46732,22 @@ export {
|
|
|
46288
46732
|
pingServer,
|
|
46289
46733
|
parseKeyValueXml,
|
|
46290
46734
|
parseJSONObjectFromText,
|
|
46735
|
+
parseCharacter,
|
|
46291
46736
|
parseBooleanFromText2 as parseBooleanFromText,
|
|
46292
46737
|
parseAndValidateCharacter,
|
|
46293
46738
|
normalizeJsonString,
|
|
46294
46739
|
multiStepSummaryTemplate,
|
|
46295
46740
|
multiStepDecisionTemplate,
|
|
46296
46741
|
messageHandlerTemplate,
|
|
46742
|
+
messageExampleSchema,
|
|
46743
|
+
mergeCharacterDefaults,
|
|
46744
|
+
mediaSchema,
|
|
46297
46745
|
logger,
|
|
46746
|
+
loadPlugin,
|
|
46747
|
+
loadEnvConfig,
|
|
46748
|
+
loadAndPreparePlugin,
|
|
46749
|
+
knowledgeItemSchema,
|
|
46750
|
+
isValidPluginShape,
|
|
46298
46751
|
isValidCharacter,
|
|
46299
46752
|
isNode3 as isNode,
|
|
46300
46753
|
isMessageMetadata,
|
|
@@ -46310,6 +46763,7 @@ export {
|
|
|
46310
46763
|
initBrowserEnvironment,
|
|
46311
46764
|
imageDescriptionTemplate,
|
|
46312
46765
|
hasEnv,
|
|
46766
|
+
hasCharacterSecrets,
|
|
46313
46767
|
getWorldSettings,
|
|
46314
46768
|
getUserServerRole,
|
|
46315
46769
|
getUploadsChannelsDir,
|
|
@@ -46340,12 +46794,14 @@ export {
|
|
|
46340
46794
|
formatActions,
|
|
46341
46795
|
formatActionNames,
|
|
46342
46796
|
findWorldsForOwner,
|
|
46797
|
+
findEnvFile,
|
|
46343
46798
|
findEntityByName,
|
|
46344
46799
|
equals,
|
|
46345
46800
|
encryptedCharacter,
|
|
46346
46801
|
encryptStringValue,
|
|
46347
46802
|
encryptObjectValues,
|
|
46348
46803
|
elizaLogger,
|
|
46804
|
+
directoryItemSchema,
|
|
46349
46805
|
detectEnvironment,
|
|
46350
46806
|
defineService,
|
|
46351
46807
|
decryptedCharacter,
|
|
@@ -46360,6 +46816,7 @@ export {
|
|
|
46360
46816
|
createService,
|
|
46361
46817
|
createMessageMemory,
|
|
46362
46818
|
createLogger,
|
|
46819
|
+
contentSchema,
|
|
46363
46820
|
concat2 as concat,
|
|
46364
46821
|
composePromptFromState,
|
|
46365
46822
|
composePrompt,
|
|
@@ -46397,5 +46854,5 @@ export {
|
|
|
46397
46854
|
AgentRuntime
|
|
46398
46855
|
};
|
|
46399
46856
|
|
|
46400
|
-
//# debugId=
|
|
46857
|
+
//# debugId=E2D0C494EAA6822164756E2164756E21
|
|
46401
46858
|
//# sourceMappingURL=index.node.js.map
|