@elizaos/core 1.6.5-alpha.20 → 1.6.5-alpha.21

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.
@@ -16,6 +16,16 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  return to;
17
17
  };
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
19
29
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
30
 
21
31
  // ../../node_modules/decamelize/index.js
@@ -3865,6 +3875,212 @@ var require_ansi_styles = __commonJS((exports, module) => {
3865
3875
  });
3866
3876
  });
3867
3877
 
3878
+ // ../../node_modules/is-network-error/index.js
3879
+ function isNetworkError2(error) {
3880
+ const isValid = error && isError2(error) && error.name === "TypeError" && typeof error.message === "string";
3881
+ if (!isValid) {
3882
+ return false;
3883
+ }
3884
+ const { message, stack } = error;
3885
+ if (message === "Load failed") {
3886
+ return stack === undefined || "__sentry_captured__" in error;
3887
+ }
3888
+ if (message.startsWith("error sending request for url")) {
3889
+ return true;
3890
+ }
3891
+ return errorMessages2.has(message);
3892
+ }
3893
+ var objectToString2, isError2 = (value) => objectToString2.call(value) === "[object Error]", errorMessages2;
3894
+ var init_is_network_error = __esm(() => {
3895
+ objectToString2 = Object.prototype.toString;
3896
+ errorMessages2 = new Set([
3897
+ "network error",
3898
+ "Failed to fetch",
3899
+ "NetworkError when attempting to fetch resource.",
3900
+ "The Internet connection appears to be offline.",
3901
+ "Network request failed",
3902
+ "fetch failed",
3903
+ "terminated",
3904
+ " A network error occurred.",
3905
+ "Network connection lost"
3906
+ ]);
3907
+ });
3908
+
3909
+ // ../../node_modules/p-retry/index.js
3910
+ var exports_p_retry = {};
3911
+ __export(exports_p_retry, {
3912
+ makeRetriable: () => makeRetriable,
3913
+ default: () => pRetry2,
3914
+ AbortError: () => AbortError2
3915
+ });
3916
+ function validateRetries2(retries) {
3917
+ if (typeof retries === "number") {
3918
+ if (retries < 0) {
3919
+ throw new TypeError("Expected `retries` to be a non-negative number.");
3920
+ }
3921
+ if (Number.isNaN(retries)) {
3922
+ throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
3923
+ }
3924
+ } else if (retries !== undefined) {
3925
+ throw new TypeError("Expected `retries` to be a number or Infinity.");
3926
+ }
3927
+ }
3928
+ function validateNumberOption2(name, value, { min = 0, allowInfinity = false } = {}) {
3929
+ if (value === undefined) {
3930
+ return;
3931
+ }
3932
+ if (typeof value !== "number" || Number.isNaN(value)) {
3933
+ throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
3934
+ }
3935
+ if (!allowInfinity && !Number.isFinite(value)) {
3936
+ throw new TypeError(`Expected \`${name}\` to be a finite number.`);
3937
+ }
3938
+ if (value < min) {
3939
+ throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
3940
+ }
3941
+ }
3942
+ function calculateDelay2(retriesConsumed, options) {
3943
+ const attempt = Math.max(1, retriesConsumed + 1);
3944
+ const random = options.randomize ? Math.random() + 1 : 1;
3945
+ let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
3946
+ timeout = Math.min(timeout, options.maxTimeout);
3947
+ return timeout;
3948
+ }
3949
+ function calculateRemainingTime2(start, max) {
3950
+ if (!Number.isFinite(max)) {
3951
+ return max;
3952
+ }
3953
+ return max - (performance.now() - start);
3954
+ }
3955
+ async function onAttemptFailure2({ error, attemptNumber, retriesConsumed, startTime, options }) {
3956
+ const normalizedError = error instanceof Error ? error : new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
3957
+ if (normalizedError instanceof AbortError2) {
3958
+ throw normalizedError.originalError;
3959
+ }
3960
+ const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
3961
+ const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
3962
+ const context = Object.freeze({
3963
+ error: normalizedError,
3964
+ attemptNumber,
3965
+ retriesLeft,
3966
+ retriesConsumed
3967
+ });
3968
+ await options.onFailedAttempt(context);
3969
+ if (calculateRemainingTime2(startTime, maxRetryTime) <= 0) {
3970
+ throw normalizedError;
3971
+ }
3972
+ const consumeRetry = await options.shouldConsumeRetry(context);
3973
+ const remainingTime = calculateRemainingTime2(startTime, maxRetryTime);
3974
+ if (remainingTime <= 0 || retriesLeft <= 0) {
3975
+ throw normalizedError;
3976
+ }
3977
+ if (normalizedError instanceof TypeError && !isNetworkError2(normalizedError)) {
3978
+ if (consumeRetry) {
3979
+ throw normalizedError;
3980
+ }
3981
+ options.signal?.throwIfAborted();
3982
+ return false;
3983
+ }
3984
+ if (!await options.shouldRetry(context)) {
3985
+ throw normalizedError;
3986
+ }
3987
+ if (!consumeRetry) {
3988
+ options.signal?.throwIfAborted();
3989
+ return false;
3990
+ }
3991
+ const delayTime = calculateDelay2(retriesConsumed, options);
3992
+ const finalDelay = Math.min(delayTime, remainingTime);
3993
+ if (finalDelay > 0) {
3994
+ await new Promise((resolve, reject) => {
3995
+ const onAbort = () => {
3996
+ clearTimeout(timeoutToken);
3997
+ options.signal?.removeEventListener("abort", onAbort);
3998
+ reject(options.signal.reason);
3999
+ };
4000
+ const timeoutToken = setTimeout(() => {
4001
+ options.signal?.removeEventListener("abort", onAbort);
4002
+ resolve();
4003
+ }, finalDelay);
4004
+ if (options.unref) {
4005
+ timeoutToken.unref?.();
4006
+ }
4007
+ options.signal?.addEventListener("abort", onAbort, { once: true });
4008
+ });
4009
+ }
4010
+ options.signal?.throwIfAborted();
4011
+ return true;
4012
+ }
4013
+ async function pRetry2(input, options = {}) {
4014
+ options = { ...options };
4015
+ validateRetries2(options.retries);
4016
+ if (Object.hasOwn(options, "forever")) {
4017
+ throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
4018
+ }
4019
+ options.retries ??= 10;
4020
+ options.factor ??= 2;
4021
+ options.minTimeout ??= 1000;
4022
+ options.maxTimeout ??= Number.POSITIVE_INFINITY;
4023
+ options.maxRetryTime ??= Number.POSITIVE_INFINITY;
4024
+ options.randomize ??= false;
4025
+ options.onFailedAttempt ??= () => {};
4026
+ options.shouldRetry ??= () => true;
4027
+ options.shouldConsumeRetry ??= () => true;
4028
+ validateNumberOption2("factor", options.factor, { min: 0, allowInfinity: false });
4029
+ validateNumberOption2("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
4030
+ validateNumberOption2("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
4031
+ validateNumberOption2("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true });
4032
+ if (!(options.factor > 0)) {
4033
+ options.factor = 1;
4034
+ }
4035
+ options.signal?.throwIfAborted();
4036
+ let attemptNumber = 0;
4037
+ let retriesConsumed = 0;
4038
+ const startTime = performance.now();
4039
+ while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
4040
+ attemptNumber++;
4041
+ try {
4042
+ options.signal?.throwIfAborted();
4043
+ const result = await input(attemptNumber);
4044
+ options.signal?.throwIfAborted();
4045
+ return result;
4046
+ } catch (error) {
4047
+ if (await onAttemptFailure2({
4048
+ error,
4049
+ attemptNumber,
4050
+ retriesConsumed,
4051
+ startTime,
4052
+ options
4053
+ })) {
4054
+ retriesConsumed++;
4055
+ }
4056
+ }
4057
+ }
4058
+ throw new Error("Retry attempts exhausted without throwing an error.");
4059
+ }
4060
+ function makeRetriable(function_, options) {
4061
+ return function(...arguments_) {
4062
+ return pRetry2(() => function_.apply(this, arguments_), options);
4063
+ };
4064
+ }
4065
+ var AbortError2;
4066
+ var init_p_retry = __esm(() => {
4067
+ init_is_network_error();
4068
+ AbortError2 = class AbortError2 extends Error {
4069
+ constructor(message) {
4070
+ super();
4071
+ if (message instanceof Error) {
4072
+ this.originalError = message;
4073
+ ({ message } = message);
4074
+ } else {
4075
+ this.originalError = new Error(message);
4076
+ this.originalError.stack = this.stack;
4077
+ }
4078
+ this.name = "AbortError";
4079
+ this.message = message;
4080
+ }
4081
+ };
4082
+ });
4083
+
3868
4084
  // ../../node_modules/base64-js/index.js
3869
4085
  var require_base64_js = __commonJS((exports) => {
3870
4086
  exports.byteLength = byteLength;
@@ -25417,7 +25633,7 @@ var SOCKET_MESSAGE_TYPE;
25417
25633
  })(SOCKET_MESSAGE_TYPE ||= {});
25418
25634
  // ../../node_modules/@langchain/core/dist/_virtual/rolldown_runtime.js
25419
25635
  var __defProp2 = Object.defineProperty;
25420
- var __export = (target, all) => {
25636
+ var __export2 = (target, all) => {
25421
25637
  for (var name in all)
25422
25638
  __defProp2(target, name, {
25423
25639
  get: all[name],
@@ -25453,7 +25669,7 @@ function mapKeys(fields, mapper, map) {
25453
25669
 
25454
25670
  // ../../node_modules/@langchain/core/dist/load/serializable.js
25455
25671
  var serializable_exports = {};
25456
- __export(serializable_exports, {
25672
+ __export2(serializable_exports, {
25457
25673
  Serializable: () => Serializable,
25458
25674
  get_lc_unique_name: () => get_lc_unique_name
25459
25675
  });
@@ -26580,7 +26796,7 @@ var BaseMessageChunk = class BaseMessageChunk2 extends BaseMessage {
26580
26796
 
26581
26797
  // ../../node_modules/@langchain/core/dist/messages/tool.js
26582
26798
  var tool_exports = {};
26583
- __export(tool_exports, {
26799
+ __export2(tool_exports, {
26584
26800
  ToolMessage: () => ToolMessage,
26585
26801
  ToolMessageChunk: () => ToolMessageChunk,
26586
26802
  defaultToolCallParser: () => defaultToolCallParser,
@@ -26695,47 +26911,227 @@ function isToolMessageChunk(x) {
26695
26911
  }
26696
26912
 
26697
26913
  // ../../node_modules/@langchain/core/dist/utils/json.js
26698
- function parsePartialJson(s) {
26699
- if (typeof s === "undefined")
26700
- return null;
26914
+ function strictParsePartialJson(s) {
26701
26915
  try {
26702
26916
  return JSON.parse(s);
26703
26917
  } catch {}
26704
- let new_s = "";
26705
- const stack = [];
26706
- let isInsideString = false;
26707
- let escaped = false;
26708
- for (let char of s) {
26709
- if (isInsideString)
26710
- if (char === '"' && !escaped)
26711
- isInsideString = false;
26712
- else if (char === `
26713
- ` && !escaped)
26714
- char = "\\n";
26715
- else if (char === "\\")
26716
- escaped = !escaped;
26717
- else
26918
+ const buffer = s.trim();
26919
+ if (buffer.length === 0)
26920
+ throw new Error("Unexpected end of JSON input");
26921
+ let pos = 0;
26922
+ function skipWhitespace() {
26923
+ while (pos < buffer.length && /\s/.test(buffer[pos]))
26924
+ pos += 1;
26925
+ }
26926
+ function parseString() {
26927
+ if (buffer[pos] !== '"')
26928
+ throw new Error(`Expected '"' at position ${pos}, got '${buffer[pos]}'`);
26929
+ pos += 1;
26930
+ let result = "";
26931
+ let escaped = false;
26932
+ while (pos < buffer.length) {
26933
+ const char = buffer[pos];
26934
+ if (escaped) {
26935
+ if (char === "n")
26936
+ result += `
26937
+ `;
26938
+ else if (char === "t")
26939
+ result += "\t";
26940
+ else if (char === "r")
26941
+ result += "\r";
26942
+ else if (char === "\\")
26943
+ result += "\\";
26944
+ else if (char === '"')
26945
+ result += '"';
26946
+ else if (char === "b")
26947
+ result += "\b";
26948
+ else if (char === "f")
26949
+ result += "\f";
26950
+ else if (char === "/")
26951
+ result += "/";
26952
+ else if (char === "u") {
26953
+ const hex = buffer.substring(pos + 1, pos + 5);
26954
+ if (/^[0-9A-Fa-f]{0,4}$/.test(hex)) {
26955
+ if (hex.length === 4)
26956
+ result += String.fromCharCode(Number.parseInt(hex, 16));
26957
+ else
26958
+ result += `u${hex}`;
26959
+ pos += hex.length;
26960
+ } else
26961
+ throw new Error(`Invalid unicode escape sequence '\\u${hex}' at position ${pos}`);
26962
+ } else
26963
+ throw new Error(`Invalid escape sequence '\\${char}' at position ${pos}`);
26718
26964
  escaped = false;
26719
- else if (char === '"') {
26720
- isInsideString = true;
26721
- escaped = false;
26722
- } else if (char === "{")
26723
- stack.push("}");
26724
- else if (char === "[")
26725
- stack.push("]");
26726
- else if (char === "}" || char === "]")
26727
- if (stack && stack[stack.length - 1] === char)
26728
- stack.pop();
26729
- else
26730
- return null;
26731
- new_s += char;
26965
+ } else if (char === "\\")
26966
+ escaped = true;
26967
+ else if (char === '"') {
26968
+ pos += 1;
26969
+ return result;
26970
+ } else
26971
+ result += char;
26972
+ pos += 1;
26973
+ }
26974
+ if (escaped)
26975
+ result += "\\";
26976
+ return result;
26977
+ }
26978
+ function parseNumber() {
26979
+ const start = pos;
26980
+ let numStr = "";
26981
+ if (buffer[pos] === "-") {
26982
+ numStr += "-";
26983
+ pos += 1;
26984
+ }
26985
+ if (pos < buffer.length && buffer[pos] === "0") {
26986
+ numStr += "0";
26987
+ pos += 1;
26988
+ if (buffer[pos] >= "0" && buffer[pos] <= "9")
26989
+ throw new Error(`Invalid number at position ${start}`);
26990
+ }
26991
+ if (pos < buffer.length && buffer[pos] >= "1" && buffer[pos] <= "9")
26992
+ while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
26993
+ numStr += buffer[pos];
26994
+ pos += 1;
26995
+ }
26996
+ if (pos < buffer.length && buffer[pos] === ".") {
26997
+ numStr += ".";
26998
+ pos += 1;
26999
+ while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
27000
+ numStr += buffer[pos];
27001
+ pos += 1;
27002
+ }
27003
+ }
27004
+ if (pos < buffer.length && (buffer[pos] === "e" || buffer[pos] === "E")) {
27005
+ numStr += buffer[pos];
27006
+ pos += 1;
27007
+ if (pos < buffer.length && (buffer[pos] === "+" || buffer[pos] === "-")) {
27008
+ numStr += buffer[pos];
27009
+ pos += 1;
27010
+ }
27011
+ while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
27012
+ numStr += buffer[pos];
27013
+ pos += 1;
27014
+ }
27015
+ }
27016
+ if (numStr === "-")
27017
+ return -0;
27018
+ const num = Number.parseFloat(numStr);
27019
+ if (Number.isNaN(num)) {
27020
+ pos = start;
27021
+ throw new Error(`Invalid number '${numStr}' at position ${start}`);
27022
+ }
27023
+ return num;
27024
+ }
27025
+ function parseValue() {
27026
+ skipWhitespace();
27027
+ if (pos >= buffer.length)
27028
+ throw new Error(`Unexpected end of input at position ${pos}`);
27029
+ const char = buffer[pos];
27030
+ if (char === "{")
27031
+ return parseObject();
27032
+ if (char === "[")
27033
+ return parseArray();
27034
+ if (char === '"')
27035
+ return parseString();
27036
+ if ("null".startsWith(buffer.substring(pos, pos + 4))) {
27037
+ pos += Math.min(4, buffer.length - pos);
27038
+ return null;
27039
+ }
27040
+ if ("true".startsWith(buffer.substring(pos, pos + 4))) {
27041
+ pos += Math.min(4, buffer.length - pos);
27042
+ return true;
27043
+ }
27044
+ if ("false".startsWith(buffer.substring(pos, pos + 5))) {
27045
+ pos += Math.min(5, buffer.length - pos);
27046
+ return false;
27047
+ }
27048
+ if (char === "-" || char >= "0" && char <= "9")
27049
+ return parseNumber();
27050
+ throw new Error(`Unexpected character '${char}' at position ${pos}`);
27051
+ }
27052
+ function parseArray() {
27053
+ if (buffer[pos] !== "[")
27054
+ throw new Error(`Expected '[' at position ${pos}, got '${buffer[pos]}'`);
27055
+ const arr = [];
27056
+ pos += 1;
27057
+ skipWhitespace();
27058
+ if (pos >= buffer.length)
27059
+ return arr;
27060
+ if (buffer[pos] === "]") {
27061
+ pos += 1;
27062
+ return arr;
27063
+ }
27064
+ while (pos < buffer.length) {
27065
+ skipWhitespace();
27066
+ if (pos >= buffer.length)
27067
+ return arr;
27068
+ arr.push(parseValue());
27069
+ skipWhitespace();
27070
+ if (pos >= buffer.length)
27071
+ return arr;
27072
+ if (buffer[pos] === "]") {
27073
+ pos += 1;
27074
+ return arr;
27075
+ } else if (buffer[pos] === ",") {
27076
+ pos += 1;
27077
+ continue;
27078
+ }
27079
+ throw new Error(`Expected ',' or ']' at position ${pos}, got '${buffer[pos]}'`);
27080
+ }
27081
+ return arr;
27082
+ }
27083
+ function parseObject() {
27084
+ if (buffer[pos] !== "{")
27085
+ throw new Error(`Expected '{' at position ${pos}, got '${buffer[pos]}'`);
27086
+ const obj = {};
27087
+ pos += 1;
27088
+ skipWhitespace();
27089
+ if (pos >= buffer.length)
27090
+ return obj;
27091
+ if (buffer[pos] === "}") {
27092
+ pos += 1;
27093
+ return obj;
27094
+ }
27095
+ while (pos < buffer.length) {
27096
+ skipWhitespace();
27097
+ if (pos >= buffer.length)
27098
+ return obj;
27099
+ const key = parseString();
27100
+ skipWhitespace();
27101
+ if (pos >= buffer.length)
27102
+ return obj;
27103
+ if (buffer[pos] !== ":")
27104
+ throw new Error(`Expected ':' at position ${pos}, got '${buffer[pos]}'`);
27105
+ pos += 1;
27106
+ skipWhitespace();
27107
+ if (pos >= buffer.length)
27108
+ return obj;
27109
+ obj[key] = parseValue();
27110
+ skipWhitespace();
27111
+ if (pos >= buffer.length)
27112
+ return obj;
27113
+ if (buffer[pos] === "}") {
27114
+ pos += 1;
27115
+ return obj;
27116
+ } else if (buffer[pos] === ",") {
27117
+ pos += 1;
27118
+ continue;
27119
+ }
27120
+ throw new Error(`Expected ',' or '}' at position ${pos}, got '${buffer[pos]}'`);
27121
+ }
27122
+ return obj;
26732
27123
  }
26733
- if (isInsideString)
26734
- new_s += '"';
26735
- for (let i = stack.length - 1;i >= 0; i -= 1)
26736
- new_s += stack[i];
27124
+ const value = parseValue();
27125
+ skipWhitespace();
27126
+ if (pos < buffer.length)
27127
+ throw new Error(`Unexpected character '${buffer[pos]}' at position ${pos}`);
27128
+ return value;
27129
+ }
27130
+ function parsePartialJson(s) {
26737
27131
  try {
26738
- return JSON.parse(new_s);
27132
+ if (typeof s === "undefined")
27133
+ return null;
27134
+ return strictParsePartialJson(s);
26739
27135
  } catch {
26740
27136
  return null;
26741
27137
  }
@@ -27231,7 +27627,7 @@ var AIMessageChunk = class extends BaseMessageChunk {
27231
27627
  for (const chunks of groupedToolCallChunks) {
27232
27628
  let parsedArgs = null;
27233
27629
  const name = chunks[0]?.name ?? "";
27234
- const joinedArgs = chunks.map((c) => c.args || "").join("");
27630
+ const joinedArgs = chunks.map((c) => c.args || "").join("").trim();
27235
27631
  const argsStr = joinedArgs.length ? joinedArgs : "{}";
27236
27632
  const id = chunks[0]?.id;
27237
27633
  try {
@@ -27362,7 +27758,7 @@ function getBufferString(messages, humanPrefix = "Human", aiPrefix = "AI") {
27362
27758
 
27363
27759
  // ../../node_modules/@langchain/core/dist/utils/env.js
27364
27760
  var env_exports = {};
27365
- __export(env_exports, {
27761
+ __export2(env_exports, {
27366
27762
  getEnv: () => getEnv,
27367
27763
  getEnvironmentVariable: () => getEnvironmentVariable,
27368
27764
  getRuntimeEnvironment: () => getRuntimeEnvironment,
@@ -27436,7 +27832,7 @@ var parse = import_dist.default.parse;
27436
27832
 
27437
27833
  // ../../node_modules/@langchain/core/dist/callbacks/base.js
27438
27834
  var base_exports = {};
27439
- __export(base_exports, {
27835
+ __export2(base_exports, {
27440
27836
  BaseCallbackHandler: () => BaseCallbackHandler,
27441
27837
  callbackHandlerPrefersStreaming: () => callbackHandlerPrefersStreaming,
27442
27838
  isBaseCallbackHandler: () => isBaseCallbackHandler
@@ -32993,7 +33389,7 @@ function _checkEndpointEnvUnset(parsed) {
32993
33389
  }
32994
33390
  // ../../node_modules/@langchain/core/dist/tracers/base.js
32995
33391
  var base_exports2 = {};
32996
- __export(base_exports2, {
33392
+ __export2(base_exports2, {
32997
33393
  BaseTracer: () => BaseTracer,
32998
33394
  isBaseTracer: () => isBaseTracer
32999
33395
  });
@@ -33431,7 +33827,7 @@ ${error.stack}` : "");
33431
33827
  // ../../node_modules/@langchain/core/dist/tracers/console.js
33432
33828
  var import_ansi_styles = __toESM(require_ansi_styles(), 1);
33433
33829
  var console_exports = {};
33434
- __export(console_exports, { ConsoleCallbackHandler: () => ConsoleCallbackHandler });
33830
+ __export2(console_exports, { ConsoleCallbackHandler: () => ConsoleCallbackHandler });
33435
33831
  function wrap(style, text) {
33436
33832
  return `${style.open}${text}${style.close}`;
33437
33833
  }
@@ -33587,7 +33983,7 @@ function isTraceableFunction(x) {
33587
33983
  }
33588
33984
  // ../../node_modules/@langchain/core/dist/tracers/tracer_langchain.js
33589
33985
  var tracer_langchain_exports = {};
33590
- __export(tracer_langchain_exports, { LangChainTracer: () => LangChainTracer });
33986
+ __export2(tracer_langchain_exports, { LangChainTracer: () => LangChainTracer });
33591
33987
  var LangChainTracer = class LangChainTracer2 extends BaseTracer {
33592
33988
  name = "langchain_tracer";
33593
33989
  projectName;
@@ -33708,7 +34104,7 @@ async function awaitAllCallbacks() {
33708
34104
 
33709
34105
  // ../../node_modules/@langchain/core/dist/callbacks/promises.js
33710
34106
  var promises_exports = {};
33711
- __export(promises_exports, {
34107
+ __export2(promises_exports, {
33712
34108
  awaitAllCallbacks: () => awaitAllCallbacks,
33713
34109
  consumeCallback: () => consumeCallback
33714
34110
  });
@@ -33739,7 +34135,7 @@ var _getConfigureHooks = () => getContextVariable(LC_CONFIGURE_HOOKS_KEY) || [];
33739
34135
 
33740
34136
  // ../../node_modules/@langchain/core/dist/callbacks/manager.js
33741
34137
  var manager_exports = {};
33742
- __export(manager_exports, {
34138
+ __export2(manager_exports, {
33743
34139
  BaseCallbackManager: () => BaseCallbackManager,
33744
34140
  BaseRunManager: () => BaseRunManager,
33745
34141
  CallbackManager: () => CallbackManager,
@@ -34331,7 +34727,7 @@ var AsyncLocalStorageProviderSingleton2 = new AsyncLocalStorageProvider2;
34331
34727
 
34332
34728
  // ../../node_modules/@langchain/core/dist/singletons/index.js
34333
34729
  var singletons_exports = {};
34334
- __export(singletons_exports, {
34730
+ __export2(singletons_exports, {
34335
34731
  AsyncLocalStorageProviderSingleton: () => AsyncLocalStorageProviderSingleton2,
34336
34732
  MockAsyncLocalStorage: () => MockAsyncLocalStorage2,
34337
34733
  _CONTEXT_VARIABLES_KEY: () => _CONTEXT_VARIABLES_KEY
@@ -34525,7 +34921,7 @@ function getAbortSignalError(signal) {
34525
34921
 
34526
34922
  // ../../node_modules/@langchain/core/dist/utils/stream.js
34527
34923
  var stream_exports = {};
34528
- __export(stream_exports, {
34924
+ __export2(stream_exports, {
34529
34925
  AsyncGeneratorWithSetup: () => AsyncGeneratorWithSetup,
34530
34926
  IterableReadableStream: () => IterableReadableStream,
34531
34927
  atee: () => atee,
@@ -34822,7 +35218,7 @@ var PatchError = class extends Error {
34822
35218
 
34823
35219
  // ../../node_modules/@langchain/core/dist/utils/fast-json-patch/src/core.js
34824
35220
  var core_exports = {};
34825
- __export(core_exports, {
35221
+ __export2(core_exports, {
34826
35222
  JsonPatchError: () => JsonPatchError,
34827
35223
  _areEquals: () => _areEquals,
34828
35224
  applyOperation: () => applyOperation,
@@ -35150,7 +35546,7 @@ var fast_json_patch_default = {
35150
35546
 
35151
35547
  // ../../node_modules/@langchain/core/dist/tracers/log_stream.js
35152
35548
  var log_stream_exports = {};
35153
- __export(log_stream_exports, {
35549
+ __export2(log_stream_exports, {
35154
35550
  LogStreamCallbackHandler: () => LogStreamCallbackHandler,
35155
35551
  RunLog: () => RunLog,
35156
35552
  RunLogPatch: () => RunLogPatch,
@@ -35407,7 +35803,7 @@ var LogStreamCallbackHandler = class extends BaseTracer {
35407
35803
 
35408
35804
  // ../../node_modules/@langchain/core/dist/outputs.js
35409
35805
  var outputs_exports = {};
35410
- __export(outputs_exports, {
35806
+ __export2(outputs_exports, {
35411
35807
  ChatGenerationChunk: () => ChatGenerationChunk,
35412
35808
  GenerationChunk: () => GenerationChunk,
35413
35809
  RUN_KEY: () => RUN_KEY
@@ -35825,200 +36221,16 @@ var EventStreamCallbackHandler = class extends BaseTracer {
35825
36221
  }
35826
36222
  };
35827
36223
 
35828
- // ../../node_modules/is-network-error/index.js
35829
- var objectToString2 = Object.prototype.toString;
35830
- var isError2 = (value) => objectToString2.call(value) === "[object Error]";
35831
- var errorMessages2 = new Set([
35832
- "network error",
35833
- "Failed to fetch",
35834
- "NetworkError when attempting to fetch resource.",
35835
- "The Internet connection appears to be offline.",
35836
- "Network request failed",
35837
- "fetch failed",
35838
- "terminated",
35839
- " A network error occurred.",
35840
- "Network connection lost"
35841
- ]);
35842
- function isNetworkError2(error) {
35843
- const isValid = error && isError2(error) && error.name === "TypeError" && typeof error.message === "string";
35844
- if (!isValid) {
35845
- return false;
35846
- }
35847
- const { message, stack } = error;
35848
- if (message === "Load failed") {
35849
- return stack === undefined || "__sentry_captured__" in error;
35850
- }
35851
- if (message.startsWith("error sending request for url")) {
35852
- return true;
35853
- }
35854
- return errorMessages2.has(message);
35855
- }
35856
-
35857
- // ../../node_modules/p-retry/index.js
35858
- function validateRetries2(retries) {
35859
- if (typeof retries === "number") {
35860
- if (retries < 0) {
35861
- throw new TypeError("Expected `retries` to be a non-negative number.");
35862
- }
35863
- if (Number.isNaN(retries)) {
35864
- throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
35865
- }
35866
- } else if (retries !== undefined) {
35867
- throw new TypeError("Expected `retries` to be a number or Infinity.");
35868
- }
35869
- }
35870
- function validateNumberOption2(name, value, { min = 0, allowInfinity = false } = {}) {
35871
- if (value === undefined) {
35872
- return;
35873
- }
35874
- if (typeof value !== "number" || Number.isNaN(value)) {
35875
- throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
35876
- }
35877
- if (!allowInfinity && !Number.isFinite(value)) {
35878
- throw new TypeError(`Expected \`${name}\` to be a finite number.`);
35879
- }
35880
- if (value < min) {
35881
- throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
35882
- }
35883
- }
35884
-
35885
- class AbortError2 extends Error {
35886
- constructor(message) {
35887
- super();
35888
- if (message instanceof Error) {
35889
- this.originalError = message;
35890
- ({ message } = message);
35891
- } else {
35892
- this.originalError = new Error(message);
35893
- this.originalError.stack = this.stack;
35894
- }
35895
- this.name = "AbortError";
35896
- this.message = message;
35897
- }
35898
- }
35899
- function calculateDelay2(retriesConsumed, options) {
35900
- const attempt = Math.max(1, retriesConsumed + 1);
35901
- const random = options.randomize ? Math.random() + 1 : 1;
35902
- let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
35903
- timeout = Math.min(timeout, options.maxTimeout);
35904
- return timeout;
35905
- }
35906
- function calculateRemainingTime2(start, max) {
35907
- if (!Number.isFinite(max)) {
35908
- return max;
35909
- }
35910
- return max - (performance.now() - start);
35911
- }
35912
- async function onAttemptFailure2({ error, attemptNumber, retriesConsumed, startTime, options }) {
35913
- const normalizedError = error instanceof Error ? error : new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
35914
- if (normalizedError instanceof AbortError2) {
35915
- throw normalizedError.originalError;
35916
- }
35917
- const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
35918
- const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
35919
- const context = Object.freeze({
35920
- error: normalizedError,
35921
- attemptNumber,
35922
- retriesLeft,
35923
- retriesConsumed
35924
- });
35925
- await options.onFailedAttempt(context);
35926
- if (calculateRemainingTime2(startTime, maxRetryTime) <= 0) {
35927
- throw normalizedError;
35928
- }
35929
- const consumeRetry = await options.shouldConsumeRetry(context);
35930
- const remainingTime = calculateRemainingTime2(startTime, maxRetryTime);
35931
- if (remainingTime <= 0 || retriesLeft <= 0) {
35932
- throw normalizedError;
35933
- }
35934
- if (normalizedError instanceof TypeError && !isNetworkError2(normalizedError)) {
35935
- if (consumeRetry) {
35936
- throw normalizedError;
35937
- }
35938
- options.signal?.throwIfAborted();
35939
- return false;
35940
- }
35941
- if (!await options.shouldRetry(context)) {
35942
- throw normalizedError;
35943
- }
35944
- if (!consumeRetry) {
35945
- options.signal?.throwIfAborted();
35946
- return false;
35947
- }
35948
- const delayTime = calculateDelay2(retriesConsumed, options);
35949
- const finalDelay = Math.min(delayTime, remainingTime);
35950
- if (finalDelay > 0) {
35951
- await new Promise((resolve, reject) => {
35952
- const onAbort = () => {
35953
- clearTimeout(timeoutToken);
35954
- options.signal?.removeEventListener("abort", onAbort);
35955
- reject(options.signal.reason);
35956
- };
35957
- const timeoutToken = setTimeout(() => {
35958
- options.signal?.removeEventListener("abort", onAbort);
35959
- resolve();
35960
- }, finalDelay);
35961
- if (options.unref) {
35962
- timeoutToken.unref?.();
35963
- }
35964
- options.signal?.addEventListener("abort", onAbort, { once: true });
35965
- });
35966
- }
35967
- options.signal?.throwIfAborted();
35968
- return true;
35969
- }
35970
- async function pRetry2(input, options = {}) {
35971
- options = { ...options };
35972
- validateRetries2(options.retries);
35973
- if (Object.hasOwn(options, "forever")) {
35974
- throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
35975
- }
35976
- options.retries ??= 10;
35977
- options.factor ??= 2;
35978
- options.minTimeout ??= 1000;
35979
- options.maxTimeout ??= Number.POSITIVE_INFINITY;
35980
- options.maxRetryTime ??= Number.POSITIVE_INFINITY;
35981
- options.randomize ??= false;
35982
- options.onFailedAttempt ??= () => {};
35983
- options.shouldRetry ??= () => true;
35984
- options.shouldConsumeRetry ??= () => true;
35985
- validateNumberOption2("factor", options.factor, { min: 0, allowInfinity: false });
35986
- validateNumberOption2("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
35987
- validateNumberOption2("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
35988
- validateNumberOption2("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true });
35989
- if (!(options.factor > 0)) {
35990
- options.factor = 1;
35991
- }
35992
- options.signal?.throwIfAborted();
35993
- let attemptNumber = 0;
35994
- let retriesConsumed = 0;
35995
- const startTime = performance.now();
35996
- while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
35997
- attemptNumber++;
35998
- try {
35999
- options.signal?.throwIfAborted();
36000
- const result = await input(attemptNumber);
36001
- options.signal?.throwIfAborted();
36002
- return result;
36003
- } catch (error) {
36004
- if (await onAttemptFailure2({
36005
- error,
36006
- attemptNumber,
36007
- retriesConsumed,
36008
- startTime,
36009
- options
36010
- })) {
36011
- retriesConsumed++;
36012
- }
36013
- }
36014
- }
36015
- throw new Error("Retry attempts exhausted without throwing an error.");
36016
- }
36017
-
36018
36224
  // ../../node_modules/@langchain/core/dist/utils/async_caller.js
36019
36225
  var import_p_queue3 = __toESM(require_dist3(), 1);
36020
36226
  var async_caller_exports = {};
36021
- __export(async_caller_exports, { AsyncCaller: () => AsyncCaller2 });
36227
+ __export2(async_caller_exports, { AsyncCaller: () => AsyncCaller2 });
36228
+ var pRetryModule = null;
36229
+ async function getPRetry() {
36230
+ if (!pRetryModule)
36231
+ pRetryModule = await Promise.resolve().then(() => (init_p_retry(), exports_p_retry));
36232
+ return pRetryModule.default;
36233
+ }
36022
36234
  var STATUS_NO_RETRY = [
36023
36235
  400,
36024
36236
  401,
@@ -36056,8 +36268,9 @@ var AsyncCaller2 = class {
36056
36268
  const PQueue = "default" in import_p_queue3.default ? import_p_queue3.default.default : import_p_queue3.default;
36057
36269
  this.queue = new PQueue({ concurrency: this.maxConcurrency });
36058
36270
  }
36059
- call(callable, ...args) {
36060
- return this.queue.add(() => pRetry2(() => callable(...args).catch((error) => {
36271
+ async call(callable, ...args) {
36272
+ const pRetry3 = await getPRetry();
36273
+ return this.queue.add(() => pRetry3(() => callable(...args).catch((error) => {
36061
36274
  if (error instanceof Error)
36062
36275
  throw error;
36063
36276
  else
@@ -38715,7 +38928,7 @@ class Validator {
38715
38928
 
38716
38929
  // ../../node_modules/@langchain/core/dist/utils/json_schema.js
38717
38930
  var json_schema_exports = {};
38718
- __export(json_schema_exports, {
38931
+ __export2(json_schema_exports, {
38719
38932
  Validator: () => Validator,
38720
38933
  deepCompareStrict: () => deepCompareStrict,
38721
38934
  toJsonSchema: () => toJsonSchema,
@@ -38768,7 +38981,7 @@ function validatesOnlyStrings(schema) {
38768
38981
 
38769
38982
  // ../../node_modules/@langchain/core/dist/runnables/graph.js
38770
38983
  var graph_exports = {};
38771
- __export(graph_exports, { Graph: () => Graph });
38984
+ __export2(graph_exports, { Graph: () => Graph });
38772
38985
  function nodeDataStr(id, data) {
38773
38986
  if (id !== undefined && !validate(id))
38774
38987
  return id;
@@ -39021,6 +39234,7 @@ async function* consumeAsyncIterableInContext(context, iter) {
39021
39234
  }
39022
39235
 
39023
39236
  // ../../node_modules/@langchain/core/dist/runnables/base.js
39237
+ init_p_retry();
39024
39238
  import { z } from "zod/v3";
39025
39239
  function _coerceToDict2(value, defaultKey) {
39026
39240
  return value && !Array.isArray(value) && !(value instanceof Date) && typeof value === "object" ? value : { [defaultKey]: value };
@@ -40394,7 +40608,7 @@ var MappingDocumentTransformer = class extends BaseDocumentTransformer {
40394
40608
 
40395
40609
  // ../../node_modules/@langchain/core/dist/documents/index.js
40396
40610
  var documents_exports = {};
40397
- __export(documents_exports, {
40611
+ __export2(documents_exports, {
40398
40612
  BaseDocumentTransformer: () => BaseDocumentTransformer,
40399
40613
  Document: () => Document,
40400
40614
  MappingDocumentTransformer: () => MappingDocumentTransformer
@@ -40661,7 +40875,7 @@ function getEncodingNameForModel(model) {
40661
40875
  }
40662
40876
  // ../../node_modules/@langchain/core/dist/utils/tiktoken.js
40663
40877
  var tiktoken_exports = {};
40664
- __export(tiktoken_exports, {
40878
+ __export2(tiktoken_exports, {
40665
40879
  encodingForModel: () => encodingForModel,
40666
40880
  getEncoding: () => getEncoding
40667
40881
  });
@@ -49660,17 +49874,26 @@ class ElizaOS extends EventTarget {
49660
49874
  initFunctions = new Map;
49661
49875
  editableMode = false;
49662
49876
  async addAgents(agents, options) {
49877
+ const createdRuntimes = [];
49663
49878
  const promises = agents.map(async (agent) => {
49664
49879
  const character = agent.character;
49665
49880
  await setDefaultSecretsFromEnv(character, { skipEnvMerge: options?.isTestMode });
49666
- const resolvedPlugins = agent.plugins ? await resolvePlugins(agent.plugins, options?.isTestMode || false) : [];
49881
+ let resolvedPlugins = agent.plugins ? await resolvePlugins(agent.plugins, options?.isTestMode || false) : [];
49882
+ if (agent.databaseAdapter) {
49883
+ resolvedPlugins = resolvedPlugins.filter((p) => p.name !== "@elizaos/plugin-sql");
49884
+ }
49667
49885
  const runtime = new AgentRuntime({
49668
49886
  character,
49669
49887
  plugins: resolvedPlugins,
49670
49888
  settings: agent.settings || {}
49671
49889
  });
49890
+ if (agent.databaseAdapter) {
49891
+ runtime.registerDatabaseAdapter(agent.databaseAdapter);
49892
+ }
49672
49893
  runtime.elizaOS = this;
49673
- this.runtimes.set(runtime.agentId, runtime);
49894
+ if (!options?.ephemeral) {
49895
+ this.runtimes.set(runtime.agentId, runtime);
49896
+ }
49674
49897
  if (typeof agent.init === "function") {
49675
49898
  this.initFunctions.set(runtime.agentId, agent.init);
49676
49899
  }
@@ -49682,15 +49905,33 @@ class ElizaOS extends EventTarget {
49682
49905
  character: {
49683
49906
  ...characterWithoutSecrets,
49684
49907
  settings: settingsWithoutSecrets
49685
- }
49908
+ },
49909
+ ephemeral: options?.ephemeral
49686
49910
  }
49687
49911
  }));
49912
+ createdRuntimes.push(runtime);
49688
49913
  return runtime.agentId;
49689
49914
  });
49690
49915
  const ids = await Promise.all(promises);
49916
+ if (options?.autoStart) {
49917
+ await Promise.all(createdRuntimes.map(async (runtime) => {
49918
+ await runtime.initialize({ skipMigrations: options?.skipMigrations });
49919
+ const initFn = this.initFunctions.get(runtime.agentId);
49920
+ if (initFn) {
49921
+ await initFn(runtime);
49922
+ this.initFunctions.delete(runtime.agentId);
49923
+ }
49924
+ this.dispatchEvent(new CustomEvent("agent:started", {
49925
+ detail: { agentId: runtime.agentId }
49926
+ }));
49927
+ }));
49928
+ }
49691
49929
  this.dispatchEvent(new CustomEvent("agents:added", {
49692
- detail: { agentIds: ids, count: ids.length }
49930
+ detail: { agentIds: ids, count: ids.length, ephemeral: options?.ephemeral }
49693
49931
  }));
49932
+ if (options?.returnRuntimes) {
49933
+ return createdRuntimes;
49934
+ }
49694
49935
  return ids;
49695
49936
  }
49696
49937
  registerAgent(runtime) {
@@ -49790,10 +50031,18 @@ class ElizaOS extends EventTarget {
49790
50031
  getAgentByCharacterId(characterId) {
49791
50032
  return this.getAgents().find((runtime) => runtime.character.id === characterId);
49792
50033
  }
49793
- async sendMessage(agentId, message, options) {
49794
- const runtime = this.runtimes.get(agentId);
49795
- if (!runtime) {
49796
- throw new Error(`Agent ${agentId} not found`);
50034
+ async sendMessage(target, message, options) {
50035
+ let runtime;
50036
+ let agentId;
50037
+ if (typeof target === "string") {
50038
+ agentId = target;
50039
+ runtime = this.runtimes.get(agentId);
50040
+ if (!runtime) {
50041
+ throw new Error(`Agent ${agentId} not found in registry`);
50042
+ }
50043
+ } else {
50044
+ runtime = target;
50045
+ agentId = runtime.agentId;
49797
50046
  }
49798
50047
  if (!runtime.messageService) {
49799
50048
  throw new Error("messageService is not initialized on runtime");
@@ -49854,13 +50103,13 @@ class ElizaOS extends EventTarget {
49854
50103
  }));
49855
50104
  return { messageId, userMessage };
49856
50105
  } else {
49857
- const result = await handleMessageWithEntityContext(() => runtime.messageService.handleMessage(runtime, userMessage, undefined, processingOptions));
50106
+ const processing = await handleMessageWithEntityContext(() => runtime.messageService.handleMessage(runtime, userMessage, undefined, processingOptions));
49858
50107
  if (options?.onComplete)
49859
50108
  await options.onComplete();
49860
50109
  this.dispatchEvent(new CustomEvent("message:sent", {
49861
- detail: { agentId, messageId, mode: "sync", result }
50110
+ detail: { agentId, messageId, mode: "sync", processing }
49862
50111
  }));
49863
- return { messageId, userMessage, result };
50112
+ return { messageId, userMessage, processing };
49864
50113
  }
49865
50114
  }
49866
50115
  async sendMessages(messages) {
@@ -50325,5 +50574,5 @@ export {
50325
50574
  AgentRuntime
50326
50575
  };
50327
50576
 
50328
- //# debugId=1AE99B04D756580C64756E2164756E21
50577
+ //# debugId=DEC41F0963B99DD564756E2164756E21
50329
50578
  //# sourceMappingURL=index.node.js.map