@elizaos/core 1.6.5-alpha.21 → 1.6.5-alpha.23
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 +136 -135
- package/dist/browser/index.browser.js.map +43 -40
- package/dist/elizaos.d.ts.map +1 -1
- package/dist/entities.d.ts.map +1 -1
- package/dist/node/index.node.js +434 -325
- package/dist/node/index.node.js.map +25 -25
- package/dist/plugin.d.ts.map +1 -1
- package/dist/roles.d.ts.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/secrets.d.ts.map +1 -1
- package/dist/services/default-message-service.d.ts.map +1 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/types/service.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +13 -13
package/dist/node/index.node.js
CHANGED
|
@@ -16,16 +16,6 @@ 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);
|
|
29
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
20
|
|
|
31
21
|
// ../../node_modules/decamelize/index.js
|
|
@@ -3875,212 +3865,6 @@ var require_ansi_styles = __commonJS((exports, module) => {
|
|
|
3875
3865
|
});
|
|
3876
3866
|
});
|
|
3877
3867
|
|
|
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
|
-
|
|
4084
3868
|
// ../../node_modules/base64-js/index.js
|
|
4085
3869
|
var require_base64_js = __commonJS((exports) => {
|
|
4086
3870
|
exports.byteLength = byteLength;
|
|
@@ -25633,7 +25417,7 @@ var SOCKET_MESSAGE_TYPE;
|
|
|
25633
25417
|
})(SOCKET_MESSAGE_TYPE ||= {});
|
|
25634
25418
|
// ../../node_modules/@langchain/core/dist/_virtual/rolldown_runtime.js
|
|
25635
25419
|
var __defProp2 = Object.defineProperty;
|
|
25636
|
-
var
|
|
25420
|
+
var __export = (target, all) => {
|
|
25637
25421
|
for (var name in all)
|
|
25638
25422
|
__defProp2(target, name, {
|
|
25639
25423
|
get: all[name],
|
|
@@ -25669,7 +25453,7 @@ function mapKeys(fields, mapper, map) {
|
|
|
25669
25453
|
|
|
25670
25454
|
// ../../node_modules/@langchain/core/dist/load/serializable.js
|
|
25671
25455
|
var serializable_exports = {};
|
|
25672
|
-
|
|
25456
|
+
__export(serializable_exports, {
|
|
25673
25457
|
Serializable: () => Serializable,
|
|
25674
25458
|
get_lc_unique_name: () => get_lc_unique_name
|
|
25675
25459
|
});
|
|
@@ -26717,9 +26501,10 @@ function _mergeDicts(left = {}, right = {}) {
|
|
|
26717
26501
|
"name",
|
|
26718
26502
|
"output_version",
|
|
26719
26503
|
"model_provider"
|
|
26720
|
-
].includes(key))
|
|
26721
|
-
|
|
26722
|
-
|
|
26504
|
+
].includes(key)) {
|
|
26505
|
+
if (value)
|
|
26506
|
+
merged[key] = value;
|
|
26507
|
+
} else
|
|
26723
26508
|
merged[key] += value;
|
|
26724
26509
|
else if (typeof merged[key] === "object" && !Array.isArray(merged[key]))
|
|
26725
26510
|
merged[key] = _mergeDicts(merged[key], value);
|
|
@@ -26796,7 +26581,7 @@ var BaseMessageChunk = class BaseMessageChunk2 extends BaseMessage {
|
|
|
26796
26581
|
|
|
26797
26582
|
// ../../node_modules/@langchain/core/dist/messages/tool.js
|
|
26798
26583
|
var tool_exports = {};
|
|
26799
|
-
|
|
26584
|
+
__export(tool_exports, {
|
|
26800
26585
|
ToolMessage: () => ToolMessage,
|
|
26801
26586
|
ToolMessageChunk: () => ToolMessageChunk,
|
|
26802
26587
|
defaultToolCallParser: () => defaultToolCallParser,
|
|
@@ -27604,59 +27389,12 @@ var AIMessageChunk = class extends BaseMessageChunk {
|
|
|
27604
27389
|
tool_call_chunks: [],
|
|
27605
27390
|
usage_metadata: fields.usage_metadata !== undefined ? fields.usage_metadata : undefined
|
|
27606
27391
|
};
|
|
27607
|
-
else
|
|
27608
|
-
const toolCallChunks = fields.tool_call_chunks ?? [];
|
|
27609
|
-
const groupedToolCallChunks = toolCallChunks.reduce((acc, chunk) => {
|
|
27610
|
-
const matchedChunkIndex = acc.findIndex(([match]) => {
|
|
27611
|
-
if ("id" in chunk && chunk.id && "index" in chunk && chunk.index !== undefined)
|
|
27612
|
-
return chunk.id === match.id && chunk.index === match.index;
|
|
27613
|
-
if ("id" in chunk && chunk.id)
|
|
27614
|
-
return chunk.id === match.id;
|
|
27615
|
-
if ("index" in chunk && chunk.index !== undefined)
|
|
27616
|
-
return chunk.index === match.index;
|
|
27617
|
-
return false;
|
|
27618
|
-
});
|
|
27619
|
-
if (matchedChunkIndex !== -1)
|
|
27620
|
-
acc[matchedChunkIndex].push(chunk);
|
|
27621
|
-
else
|
|
27622
|
-
acc.push([chunk]);
|
|
27623
|
-
return acc;
|
|
27624
|
-
}, []);
|
|
27625
|
-
const toolCalls = [];
|
|
27626
|
-
const invalidToolCalls = [];
|
|
27627
|
-
for (const chunks of groupedToolCallChunks) {
|
|
27628
|
-
let parsedArgs = null;
|
|
27629
|
-
const name = chunks[0]?.name ?? "";
|
|
27630
|
-
const joinedArgs = chunks.map((c) => c.args || "").join("").trim();
|
|
27631
|
-
const argsStr = joinedArgs.length ? joinedArgs : "{}";
|
|
27632
|
-
const id = chunks[0]?.id;
|
|
27633
|
-
try {
|
|
27634
|
-
parsedArgs = parsePartialJson(argsStr);
|
|
27635
|
-
if (!id || parsedArgs === null || typeof parsedArgs !== "object" || Array.isArray(parsedArgs))
|
|
27636
|
-
throw new Error("Malformed tool call chunk args.");
|
|
27637
|
-
toolCalls.push({
|
|
27638
|
-
name,
|
|
27639
|
-
args: parsedArgs,
|
|
27640
|
-
id,
|
|
27641
|
-
type: "tool_call"
|
|
27642
|
-
});
|
|
27643
|
-
} catch {
|
|
27644
|
-
invalidToolCalls.push({
|
|
27645
|
-
name,
|
|
27646
|
-
args: argsStr,
|
|
27647
|
-
id,
|
|
27648
|
-
error: "Malformed args.",
|
|
27649
|
-
type: "invalid_tool_call"
|
|
27650
|
-
});
|
|
27651
|
-
}
|
|
27652
|
-
}
|
|
27392
|
+
else
|
|
27653
27393
|
initParams = {
|
|
27654
27394
|
...fields,
|
|
27655
|
-
|
|
27656
|
-
invalid_tool_calls: invalidToolCalls,
|
|
27395
|
+
...collapseToolCallChunks(fields.tool_call_chunks ?? []),
|
|
27657
27396
|
usage_metadata: fields.usage_metadata !== undefined ? fields.usage_metadata : undefined
|
|
27658
27397
|
};
|
|
27659
|
-
}
|
|
27660
27398
|
super(initParams);
|
|
27661
27399
|
this.tool_call_chunks = initParams.tool_call_chunks ?? this.tool_call_chunks;
|
|
27662
27400
|
this.tool_calls = initParams.tool_calls ?? this.tool_calls;
|
|
@@ -27755,10 +27493,61 @@ function getBufferString(messages, humanPrefix = "Human", aiPrefix = "AI") {
|
|
|
27755
27493
|
return string_messages.join(`
|
|
27756
27494
|
`);
|
|
27757
27495
|
}
|
|
27496
|
+
function collapseToolCallChunks(chunks) {
|
|
27497
|
+
const groupedToolCallChunks = chunks.reduce((acc, chunk) => {
|
|
27498
|
+
const matchedChunkIndex = acc.findIndex(([match]) => {
|
|
27499
|
+
if ("id" in chunk && chunk.id && "index" in chunk && chunk.index !== undefined)
|
|
27500
|
+
return chunk.id === match.id && chunk.index === match.index;
|
|
27501
|
+
if ("id" in chunk && chunk.id)
|
|
27502
|
+
return chunk.id === match.id;
|
|
27503
|
+
if ("index" in chunk && chunk.index !== undefined)
|
|
27504
|
+
return chunk.index === match.index;
|
|
27505
|
+
return false;
|
|
27506
|
+
});
|
|
27507
|
+
if (matchedChunkIndex !== -1)
|
|
27508
|
+
acc[matchedChunkIndex].push(chunk);
|
|
27509
|
+
else
|
|
27510
|
+
acc.push([chunk]);
|
|
27511
|
+
return acc;
|
|
27512
|
+
}, []);
|
|
27513
|
+
const toolCalls = [];
|
|
27514
|
+
const invalidToolCalls = [];
|
|
27515
|
+
for (const chunks$1 of groupedToolCallChunks) {
|
|
27516
|
+
let parsedArgs = null;
|
|
27517
|
+
const name = chunks$1[0]?.name ?? "";
|
|
27518
|
+
const joinedArgs = chunks$1.map((c) => c.args || "").join("").trim();
|
|
27519
|
+
const argsStr = joinedArgs.length ? joinedArgs : "{}";
|
|
27520
|
+
const id = chunks$1[0]?.id;
|
|
27521
|
+
try {
|
|
27522
|
+
parsedArgs = parsePartialJson(argsStr);
|
|
27523
|
+
if (!id || parsedArgs === null || typeof parsedArgs !== "object" || Array.isArray(parsedArgs))
|
|
27524
|
+
throw new Error("Malformed tool call chunk args.");
|
|
27525
|
+
toolCalls.push({
|
|
27526
|
+
name,
|
|
27527
|
+
args: parsedArgs,
|
|
27528
|
+
id,
|
|
27529
|
+
type: "tool_call"
|
|
27530
|
+
});
|
|
27531
|
+
} catch {
|
|
27532
|
+
invalidToolCalls.push({
|
|
27533
|
+
name,
|
|
27534
|
+
args: argsStr,
|
|
27535
|
+
id,
|
|
27536
|
+
error: "Malformed args.",
|
|
27537
|
+
type: "invalid_tool_call"
|
|
27538
|
+
});
|
|
27539
|
+
}
|
|
27540
|
+
}
|
|
27541
|
+
return {
|
|
27542
|
+
tool_call_chunks: chunks,
|
|
27543
|
+
tool_calls: toolCalls,
|
|
27544
|
+
invalid_tool_calls: invalidToolCalls
|
|
27545
|
+
};
|
|
27546
|
+
}
|
|
27758
27547
|
|
|
27759
27548
|
// ../../node_modules/@langchain/core/dist/utils/env.js
|
|
27760
27549
|
var env_exports = {};
|
|
27761
|
-
|
|
27550
|
+
__export(env_exports, {
|
|
27762
27551
|
getEnv: () => getEnv,
|
|
27763
27552
|
getEnvironmentVariable: () => getEnvironmentVariable,
|
|
27764
27553
|
getRuntimeEnvironment: () => getRuntimeEnvironment,
|
|
@@ -27832,7 +27621,7 @@ var parse = import_dist.default.parse;
|
|
|
27832
27621
|
|
|
27833
27622
|
// ../../node_modules/@langchain/core/dist/callbacks/base.js
|
|
27834
27623
|
var base_exports = {};
|
|
27835
|
-
|
|
27624
|
+
__export(base_exports, {
|
|
27836
27625
|
BaseCallbackHandler: () => BaseCallbackHandler,
|
|
27837
27626
|
callbackHandlerPrefersStreaming: () => callbackHandlerPrefersStreaming,
|
|
27838
27627
|
isBaseCallbackHandler: () => isBaseCallbackHandler
|
|
@@ -33389,7 +33178,7 @@ function _checkEndpointEnvUnset(parsed) {
|
|
|
33389
33178
|
}
|
|
33390
33179
|
// ../../node_modules/@langchain/core/dist/tracers/base.js
|
|
33391
33180
|
var base_exports2 = {};
|
|
33392
|
-
|
|
33181
|
+
__export(base_exports2, {
|
|
33393
33182
|
BaseTracer: () => BaseTracer,
|
|
33394
33183
|
isBaseTracer: () => isBaseTracer
|
|
33395
33184
|
});
|
|
@@ -33827,7 +33616,7 @@ ${error.stack}` : "");
|
|
|
33827
33616
|
// ../../node_modules/@langchain/core/dist/tracers/console.js
|
|
33828
33617
|
var import_ansi_styles = __toESM(require_ansi_styles(), 1);
|
|
33829
33618
|
var console_exports = {};
|
|
33830
|
-
|
|
33619
|
+
__export(console_exports, { ConsoleCallbackHandler: () => ConsoleCallbackHandler });
|
|
33831
33620
|
function wrap(style, text) {
|
|
33832
33621
|
return `${style.open}${text}${style.close}`;
|
|
33833
33622
|
}
|
|
@@ -33983,7 +33772,7 @@ function isTraceableFunction(x) {
|
|
|
33983
33772
|
}
|
|
33984
33773
|
// ../../node_modules/@langchain/core/dist/tracers/tracer_langchain.js
|
|
33985
33774
|
var tracer_langchain_exports = {};
|
|
33986
|
-
|
|
33775
|
+
__export(tracer_langchain_exports, { LangChainTracer: () => LangChainTracer });
|
|
33987
33776
|
var LangChainTracer = class LangChainTracer2 extends BaseTracer {
|
|
33988
33777
|
name = "langchain_tracer";
|
|
33989
33778
|
projectName;
|
|
@@ -34104,7 +33893,7 @@ async function awaitAllCallbacks() {
|
|
|
34104
33893
|
|
|
34105
33894
|
// ../../node_modules/@langchain/core/dist/callbacks/promises.js
|
|
34106
33895
|
var promises_exports = {};
|
|
34107
|
-
|
|
33896
|
+
__export(promises_exports, {
|
|
34108
33897
|
awaitAllCallbacks: () => awaitAllCallbacks,
|
|
34109
33898
|
consumeCallback: () => consumeCallback
|
|
34110
33899
|
});
|
|
@@ -34135,7 +33924,7 @@ var _getConfigureHooks = () => getContextVariable(LC_CONFIGURE_HOOKS_KEY) || [];
|
|
|
34135
33924
|
|
|
34136
33925
|
// ../../node_modules/@langchain/core/dist/callbacks/manager.js
|
|
34137
33926
|
var manager_exports = {};
|
|
34138
|
-
|
|
33927
|
+
__export(manager_exports, {
|
|
34139
33928
|
BaseCallbackManager: () => BaseCallbackManager,
|
|
34140
33929
|
BaseRunManager: () => BaseRunManager,
|
|
34141
33930
|
CallbackManager: () => CallbackManager,
|
|
@@ -34727,7 +34516,7 @@ var AsyncLocalStorageProviderSingleton2 = new AsyncLocalStorageProvider2;
|
|
|
34727
34516
|
|
|
34728
34517
|
// ../../node_modules/@langchain/core/dist/singletons/index.js
|
|
34729
34518
|
var singletons_exports = {};
|
|
34730
|
-
|
|
34519
|
+
__export(singletons_exports, {
|
|
34731
34520
|
AsyncLocalStorageProviderSingleton: () => AsyncLocalStorageProviderSingleton2,
|
|
34732
34521
|
MockAsyncLocalStorage: () => MockAsyncLocalStorage2,
|
|
34733
34522
|
_CONTEXT_VARIABLES_KEY: () => _CONTEXT_VARIABLES_KEY
|
|
@@ -34921,7 +34710,7 @@ function getAbortSignalError(signal) {
|
|
|
34921
34710
|
|
|
34922
34711
|
// ../../node_modules/@langchain/core/dist/utils/stream.js
|
|
34923
34712
|
var stream_exports = {};
|
|
34924
|
-
|
|
34713
|
+
__export(stream_exports, {
|
|
34925
34714
|
AsyncGeneratorWithSetup: () => AsyncGeneratorWithSetup,
|
|
34926
34715
|
IterableReadableStream: () => IterableReadableStream,
|
|
34927
34716
|
atee: () => atee,
|
|
@@ -35218,7 +35007,7 @@ var PatchError = class extends Error {
|
|
|
35218
35007
|
|
|
35219
35008
|
// ../../node_modules/@langchain/core/dist/utils/fast-json-patch/src/core.js
|
|
35220
35009
|
var core_exports = {};
|
|
35221
|
-
|
|
35010
|
+
__export(core_exports, {
|
|
35222
35011
|
JsonPatchError: () => JsonPatchError,
|
|
35223
35012
|
_areEquals: () => _areEquals,
|
|
35224
35013
|
applyOperation: () => applyOperation,
|
|
@@ -35546,7 +35335,7 @@ var fast_json_patch_default = {
|
|
|
35546
35335
|
|
|
35547
35336
|
// ../../node_modules/@langchain/core/dist/tracers/log_stream.js
|
|
35548
35337
|
var log_stream_exports = {};
|
|
35549
|
-
|
|
35338
|
+
__export(log_stream_exports, {
|
|
35550
35339
|
LogStreamCallbackHandler: () => LogStreamCallbackHandler,
|
|
35551
35340
|
RunLog: () => RunLog,
|
|
35552
35341
|
RunLogPatch: () => RunLogPatch,
|
|
@@ -35803,7 +35592,7 @@ var LogStreamCallbackHandler = class extends BaseTracer {
|
|
|
35803
35592
|
|
|
35804
35593
|
// ../../node_modules/@langchain/core/dist/outputs.js
|
|
35805
35594
|
var outputs_exports = {};
|
|
35806
|
-
|
|
35595
|
+
__export(outputs_exports, {
|
|
35807
35596
|
ChatGenerationChunk: () => ChatGenerationChunk,
|
|
35808
35597
|
GenerationChunk: () => GenerationChunk,
|
|
35809
35598
|
RUN_KEY: () => RUN_KEY
|
|
@@ -36221,16 +36010,190 @@ var EventStreamCallbackHandler = class extends BaseTracer {
|
|
|
36221
36010
|
}
|
|
36222
36011
|
};
|
|
36223
36012
|
|
|
36013
|
+
// ../../node_modules/@langchain/core/dist/utils/is-network-error/index.js
|
|
36014
|
+
var objectToString2 = Object.prototype.toString;
|
|
36015
|
+
var isError2 = (value) => objectToString2.call(value) === "[object Error]";
|
|
36016
|
+
var errorMessages2 = new Set([
|
|
36017
|
+
"network error",
|
|
36018
|
+
"Failed to fetch",
|
|
36019
|
+
"NetworkError when attempting to fetch resource.",
|
|
36020
|
+
"The Internet connection appears to be offline.",
|
|
36021
|
+
"Network request failed",
|
|
36022
|
+
"fetch failed",
|
|
36023
|
+
"terminated",
|
|
36024
|
+
" A network error occurred.",
|
|
36025
|
+
"Network connection lost"
|
|
36026
|
+
]);
|
|
36027
|
+
function isNetworkError2(error) {
|
|
36028
|
+
const isValid = error && isError2(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
36029
|
+
if (!isValid)
|
|
36030
|
+
return false;
|
|
36031
|
+
const { message, stack } = error;
|
|
36032
|
+
if (message === "Load failed")
|
|
36033
|
+
return stack === undefined || "__sentry_captured__" in error;
|
|
36034
|
+
if (message.startsWith("error sending request for url"))
|
|
36035
|
+
return true;
|
|
36036
|
+
return errorMessages2.has(message);
|
|
36037
|
+
}
|
|
36038
|
+
|
|
36039
|
+
// ../../node_modules/@langchain/core/dist/utils/p-retry/index.js
|
|
36040
|
+
function validateRetries2(retries) {
|
|
36041
|
+
if (typeof retries === "number") {
|
|
36042
|
+
if (retries < 0)
|
|
36043
|
+
throw new TypeError("Expected `retries` to be a non-negative number.");
|
|
36044
|
+
if (Number.isNaN(retries))
|
|
36045
|
+
throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
|
|
36046
|
+
} else if (retries !== undefined)
|
|
36047
|
+
throw new TypeError("Expected `retries` to be a number or Infinity.");
|
|
36048
|
+
}
|
|
36049
|
+
function validateNumberOption2(name, value, { min = 0, allowInfinity = false } = {}) {
|
|
36050
|
+
if (value === undefined)
|
|
36051
|
+
return;
|
|
36052
|
+
if (typeof value !== "number" || Number.isNaN(value))
|
|
36053
|
+
throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
|
|
36054
|
+
if (!allowInfinity && !Number.isFinite(value))
|
|
36055
|
+
throw new TypeError(`Expected \`${name}\` to be a finite number.`);
|
|
36056
|
+
if (value < min)
|
|
36057
|
+
throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
|
|
36058
|
+
}
|
|
36059
|
+
var AbortError2 = class extends Error {
|
|
36060
|
+
constructor(message) {
|
|
36061
|
+
super();
|
|
36062
|
+
if (message instanceof Error) {
|
|
36063
|
+
this.originalError = message;
|
|
36064
|
+
({ message } = message);
|
|
36065
|
+
} else {
|
|
36066
|
+
this.originalError = new Error(message);
|
|
36067
|
+
this.originalError.stack = this.stack;
|
|
36068
|
+
}
|
|
36069
|
+
this.name = "AbortError";
|
|
36070
|
+
this.message = message;
|
|
36071
|
+
}
|
|
36072
|
+
};
|
|
36073
|
+
function calculateDelay2(retriesConsumed, options) {
|
|
36074
|
+
const attempt = Math.max(1, retriesConsumed + 1);
|
|
36075
|
+
const random = options.randomize ? Math.random() + 1 : 1;
|
|
36076
|
+
let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
|
|
36077
|
+
timeout = Math.min(timeout, options.maxTimeout);
|
|
36078
|
+
return timeout;
|
|
36079
|
+
}
|
|
36080
|
+
function calculateRemainingTime2(start, max) {
|
|
36081
|
+
if (!Number.isFinite(max))
|
|
36082
|
+
return max;
|
|
36083
|
+
return max - (performance.now() - start);
|
|
36084
|
+
}
|
|
36085
|
+
async function onAttemptFailure2({ error, attemptNumber, retriesConsumed, startTime, options }) {
|
|
36086
|
+
const normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
36087
|
+
if (normalizedError instanceof AbortError2)
|
|
36088
|
+
throw normalizedError.originalError;
|
|
36089
|
+
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
|
36090
|
+
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
|
36091
|
+
const context = Object.freeze({
|
|
36092
|
+
error: normalizedError,
|
|
36093
|
+
attemptNumber,
|
|
36094
|
+
retriesLeft,
|
|
36095
|
+
retriesConsumed
|
|
36096
|
+
});
|
|
36097
|
+
await options.onFailedAttempt(context);
|
|
36098
|
+
if (calculateRemainingTime2(startTime, maxRetryTime) <= 0)
|
|
36099
|
+
throw normalizedError;
|
|
36100
|
+
const consumeRetry = await options.shouldConsumeRetry(context);
|
|
36101
|
+
const remainingTime = calculateRemainingTime2(startTime, maxRetryTime);
|
|
36102
|
+
if (remainingTime <= 0 || retriesLeft <= 0)
|
|
36103
|
+
throw normalizedError;
|
|
36104
|
+
if (normalizedError instanceof TypeError && !isNetworkError2(normalizedError)) {
|
|
36105
|
+
if (consumeRetry)
|
|
36106
|
+
throw normalizedError;
|
|
36107
|
+
options.signal?.throwIfAborted();
|
|
36108
|
+
return false;
|
|
36109
|
+
}
|
|
36110
|
+
if (!await options.shouldRetry(context))
|
|
36111
|
+
throw normalizedError;
|
|
36112
|
+
if (!consumeRetry) {
|
|
36113
|
+
options.signal?.throwIfAborted();
|
|
36114
|
+
return false;
|
|
36115
|
+
}
|
|
36116
|
+
const delayTime = calculateDelay2(retriesConsumed, options);
|
|
36117
|
+
const finalDelay = Math.min(delayTime, remainingTime);
|
|
36118
|
+
if (finalDelay > 0)
|
|
36119
|
+
await new Promise((resolve, reject) => {
|
|
36120
|
+
const onAbort = () => {
|
|
36121
|
+
clearTimeout(timeoutToken);
|
|
36122
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
36123
|
+
reject(options.signal.reason);
|
|
36124
|
+
};
|
|
36125
|
+
const timeoutToken = setTimeout(() => {
|
|
36126
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
36127
|
+
resolve();
|
|
36128
|
+
}, finalDelay);
|
|
36129
|
+
if (options.unref)
|
|
36130
|
+
timeoutToken.unref?.();
|
|
36131
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
36132
|
+
});
|
|
36133
|
+
options.signal?.throwIfAborted();
|
|
36134
|
+
return true;
|
|
36135
|
+
}
|
|
36136
|
+
async function pRetry2(input, options = {}) {
|
|
36137
|
+
options = { ...options };
|
|
36138
|
+
validateRetries2(options.retries);
|
|
36139
|
+
if (Object.hasOwn(options, "forever"))
|
|
36140
|
+
throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
|
|
36141
|
+
options.retries ??= 10;
|
|
36142
|
+
options.factor ??= 2;
|
|
36143
|
+
options.minTimeout ??= 1000;
|
|
36144
|
+
options.maxTimeout ??= Number.POSITIVE_INFINITY;
|
|
36145
|
+
options.maxRetryTime ??= Number.POSITIVE_INFINITY;
|
|
36146
|
+
options.randomize ??= false;
|
|
36147
|
+
options.onFailedAttempt ??= () => {};
|
|
36148
|
+
options.shouldRetry ??= () => true;
|
|
36149
|
+
options.shouldConsumeRetry ??= () => true;
|
|
36150
|
+
validateNumberOption2("factor", options.factor, {
|
|
36151
|
+
min: 0,
|
|
36152
|
+
allowInfinity: false
|
|
36153
|
+
});
|
|
36154
|
+
validateNumberOption2("minTimeout", options.minTimeout, {
|
|
36155
|
+
min: 0,
|
|
36156
|
+
allowInfinity: false
|
|
36157
|
+
});
|
|
36158
|
+
validateNumberOption2("maxTimeout", options.maxTimeout, {
|
|
36159
|
+
min: 0,
|
|
36160
|
+
allowInfinity: true
|
|
36161
|
+
});
|
|
36162
|
+
validateNumberOption2("maxRetryTime", options.maxRetryTime, {
|
|
36163
|
+
min: 0,
|
|
36164
|
+
allowInfinity: true
|
|
36165
|
+
});
|
|
36166
|
+
if (!(options.factor > 0))
|
|
36167
|
+
options.factor = 1;
|
|
36168
|
+
options.signal?.throwIfAborted();
|
|
36169
|
+
let attemptNumber = 0;
|
|
36170
|
+
let retriesConsumed = 0;
|
|
36171
|
+
const startTime = performance.now();
|
|
36172
|
+
while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
|
|
36173
|
+
attemptNumber++;
|
|
36174
|
+
try {
|
|
36175
|
+
options.signal?.throwIfAborted();
|
|
36176
|
+
const result = await input(attemptNumber);
|
|
36177
|
+
options.signal?.throwIfAborted();
|
|
36178
|
+
return result;
|
|
36179
|
+
} catch (error) {
|
|
36180
|
+
if (await onAttemptFailure2({
|
|
36181
|
+
error,
|
|
36182
|
+
attemptNumber,
|
|
36183
|
+
retriesConsumed,
|
|
36184
|
+
startTime,
|
|
36185
|
+
options
|
|
36186
|
+
}))
|
|
36187
|
+
retriesConsumed++;
|
|
36188
|
+
}
|
|
36189
|
+
}
|
|
36190
|
+
throw new Error("Retry attempts exhausted without throwing an error.");
|
|
36191
|
+
}
|
|
36192
|
+
|
|
36224
36193
|
// ../../node_modules/@langchain/core/dist/utils/async_caller.js
|
|
36225
36194
|
var import_p_queue3 = __toESM(require_dist3(), 1);
|
|
36226
36195
|
var async_caller_exports = {};
|
|
36227
|
-
|
|
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
|
-
}
|
|
36196
|
+
__export(async_caller_exports, { AsyncCaller: () => AsyncCaller2 });
|
|
36234
36197
|
var STATUS_NO_RETRY = [
|
|
36235
36198
|
400,
|
|
36236
36199
|
401,
|
|
@@ -36269,8 +36232,7 @@ var AsyncCaller2 = class {
|
|
|
36269
36232
|
this.queue = new PQueue({ concurrency: this.maxConcurrency });
|
|
36270
36233
|
}
|
|
36271
36234
|
async call(callable, ...args) {
|
|
36272
|
-
|
|
36273
|
-
return this.queue.add(() => pRetry3(() => callable(...args).catch((error) => {
|
|
36235
|
+
return this.queue.add(() => pRetry2(() => callable(...args).catch((error) => {
|
|
36274
36236
|
if (error instanceof Error)
|
|
36275
36237
|
throw error;
|
|
36276
36238
|
else
|
|
@@ -36374,6 +36336,10 @@ var _RootEventFilter = class {
|
|
|
36374
36336
|
return include;
|
|
36375
36337
|
}
|
|
36376
36338
|
};
|
|
36339
|
+
var toBase64Url = (str) => {
|
|
36340
|
+
const encoded = btoa(str);
|
|
36341
|
+
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
36342
|
+
};
|
|
36377
36343
|
|
|
36378
36344
|
// ../../node_modules/@langchain/core/dist/utils/types/zod.js
|
|
36379
36345
|
import { $ZodNever, $ZodOptional, $ZodUnknown, _never, _unknown, clone, globalRegistry, parse as parse3, parseAsync, util } from "zod/v4/core";
|
|
@@ -36449,6 +36415,20 @@ function isZodArrayV4(obj) {
|
|
|
36449
36415
|
return true;
|
|
36450
36416
|
return false;
|
|
36451
36417
|
}
|
|
36418
|
+
function isZodOptionalV4(obj) {
|
|
36419
|
+
if (!isZodSchemaV4(obj))
|
|
36420
|
+
return false;
|
|
36421
|
+
if (typeof obj === "object" && obj !== null && "_zod" in obj && typeof obj._zod === "object" && obj._zod !== null && "def" in obj._zod && typeof obj._zod.def === "object" && obj._zod.def !== null && "type" in obj._zod.def && obj._zod.def.type === "optional")
|
|
36422
|
+
return true;
|
|
36423
|
+
return false;
|
|
36424
|
+
}
|
|
36425
|
+
function isZodNullableV4(obj) {
|
|
36426
|
+
if (!isZodSchemaV4(obj))
|
|
36427
|
+
return false;
|
|
36428
|
+
if (typeof obj === "object" && obj !== null && "_zod" in obj && typeof obj._zod === "object" && obj._zod !== null && "def" in obj._zod && typeof obj._zod.def === "object" && obj._zod.def !== null && "type" in obj._zod.def && obj._zod.def.type === "nullable")
|
|
36429
|
+
return true;
|
|
36430
|
+
return false;
|
|
36431
|
+
}
|
|
36452
36432
|
function interopZodObjectStrict(schema, recursive = false) {
|
|
36453
36433
|
if (isZodSchemaV3(schema))
|
|
36454
36434
|
return schema.strict();
|
|
@@ -36519,6 +36499,18 @@ function interopZodTransformInputSchemaImpl(schema, recursive, cache) {
|
|
|
36519
36499
|
...outputSchema._zod.def,
|
|
36520
36500
|
element: elementSchema
|
|
36521
36501
|
});
|
|
36502
|
+
} else if (isZodOptionalV4(outputSchema)) {
|
|
36503
|
+
const innerSchema = interopZodTransformInputSchemaImpl(outputSchema._zod.def.innerType, recursive, cache);
|
|
36504
|
+
outputSchema = clone(outputSchema, {
|
|
36505
|
+
...outputSchema._zod.def,
|
|
36506
|
+
innerType: innerSchema
|
|
36507
|
+
});
|
|
36508
|
+
} else if (isZodNullableV4(outputSchema)) {
|
|
36509
|
+
const innerSchema = interopZodTransformInputSchemaImpl(outputSchema._zod.def.innerType, recursive, cache);
|
|
36510
|
+
outputSchema = clone(outputSchema, {
|
|
36511
|
+
...outputSchema._zod.def,
|
|
36512
|
+
innerType: innerSchema
|
|
36513
|
+
});
|
|
36522
36514
|
}
|
|
36523
36515
|
}
|
|
36524
36516
|
const meta = globalRegistry.get(schema);
|
|
@@ -36627,7 +36619,7 @@ graph TD;
|
|
|
36627
36619
|
async function drawMermaidImage(mermaidSyntax, config) {
|
|
36628
36620
|
let backgroundColor = config?.backgroundColor ?? "white";
|
|
36629
36621
|
const imageType = config?.imageType ?? "png";
|
|
36630
|
-
const mermaidSyntaxEncoded =
|
|
36622
|
+
const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);
|
|
36631
36623
|
if (backgroundColor !== undefined) {
|
|
36632
36624
|
const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
|
|
36633
36625
|
if (!hexColorPattern.test(backgroundColor))
|
|
@@ -38928,7 +38920,7 @@ class Validator {
|
|
|
38928
38920
|
|
|
38929
38921
|
// ../../node_modules/@langchain/core/dist/utils/json_schema.js
|
|
38930
38922
|
var json_schema_exports = {};
|
|
38931
|
-
|
|
38923
|
+
__export(json_schema_exports, {
|
|
38932
38924
|
Validator: () => Validator,
|
|
38933
38925
|
deepCompareStrict: () => deepCompareStrict,
|
|
38934
38926
|
toJsonSchema: () => toJsonSchema,
|
|
@@ -38981,7 +38973,7 @@ function validatesOnlyStrings(schema) {
|
|
|
38981
38973
|
|
|
38982
38974
|
// ../../node_modules/@langchain/core/dist/runnables/graph.js
|
|
38983
38975
|
var graph_exports = {};
|
|
38984
|
-
|
|
38976
|
+
__export(graph_exports, { Graph: () => Graph });
|
|
38985
38977
|
function nodeDataStr(id, data) {
|
|
38986
38978
|
if (id !== undefined && !validate(id))
|
|
38987
38979
|
return id;
|
|
@@ -39234,7 +39226,6 @@ async function* consumeAsyncIterableInContext(context, iter) {
|
|
|
39234
39226
|
}
|
|
39235
39227
|
|
|
39236
39228
|
// ../../node_modules/@langchain/core/dist/runnables/base.js
|
|
39237
|
-
init_p_retry();
|
|
39238
39229
|
import { z } from "zod/v3";
|
|
39239
39230
|
function _coerceToDict2(value, defaultKey) {
|
|
39240
39231
|
return value && !Array.isArray(value) && !(value instanceof Date) && typeof value === "object" ? value : { [defaultKey]: value };
|
|
@@ -40608,7 +40599,7 @@ var MappingDocumentTransformer = class extends BaseDocumentTransformer {
|
|
|
40608
40599
|
|
|
40609
40600
|
// ../../node_modules/@langchain/core/dist/documents/index.js
|
|
40610
40601
|
var documents_exports = {};
|
|
40611
|
-
|
|
40602
|
+
__export(documents_exports, {
|
|
40612
40603
|
BaseDocumentTransformer: () => BaseDocumentTransformer,
|
|
40613
40604
|
Document: () => Document,
|
|
40614
40605
|
MappingDocumentTransformer: () => MappingDocumentTransformer
|
|
@@ -40875,7 +40866,7 @@ function getEncodingNameForModel(model) {
|
|
|
40875
40866
|
}
|
|
40876
40867
|
// ../../node_modules/@langchain/core/dist/utils/tiktoken.js
|
|
40877
40868
|
var tiktoken_exports = {};
|
|
40878
|
-
|
|
40869
|
+
__export(tiktoken_exports, {
|
|
40879
40870
|
encodingForModel: () => encodingForModel,
|
|
40880
40871
|
getEncoding: () => getEncoding
|
|
40881
40872
|
});
|
|
@@ -45607,7 +45598,12 @@ class DefaultMessageService {
|
|
|
45607
45598
|
let timeoutId = undefined;
|
|
45608
45599
|
const responseId = v4_default();
|
|
45609
45600
|
try {
|
|
45610
|
-
runtime.logger.info({
|
|
45601
|
+
runtime.logger.info({
|
|
45602
|
+
src: "service:message",
|
|
45603
|
+
agentId: runtime.agentId,
|
|
45604
|
+
entityId: message.entityId,
|
|
45605
|
+
roomId: message.roomId
|
|
45606
|
+
}, "Message received");
|
|
45611
45607
|
if (!latestResponseIds.has(runtime.agentId)) {
|
|
45612
45608
|
latestResponseIds.set(runtime.agentId, new Map);
|
|
45613
45609
|
}
|
|
@@ -45676,7 +45672,10 @@ class DefaultMessageService {
|
|
|
45676
45672
|
mode: "none"
|
|
45677
45673
|
};
|
|
45678
45674
|
}
|
|
45679
|
-
runtime.logger.debug({
|
|
45675
|
+
runtime.logger.debug({
|
|
45676
|
+
src: "service:message",
|
|
45677
|
+
messagePreview: truncateToCompleteSentence(message.content.text || "", 50)
|
|
45678
|
+
}, "Processing message");
|
|
45680
45679
|
runtime.logger.debug({ src: "service:message" }, "Saving message to memory");
|
|
45681
45680
|
let memoryToQueue;
|
|
45682
45681
|
if (message.id) {
|
|
@@ -45732,14 +45731,22 @@ class DefaultMessageService {
|
|
|
45732
45731
|
runtime.logger.debug({ src: "service:message", responseDecision }, "Response decision");
|
|
45733
45732
|
let shouldRespondToMessage = true;
|
|
45734
45733
|
if (responseDecision.skipEvaluation) {
|
|
45735
|
-
runtime.logger.debug({
|
|
45734
|
+
runtime.logger.debug({
|
|
45735
|
+
src: "service:message",
|
|
45736
|
+
agentName: runtime.character.name,
|
|
45737
|
+
reason: responseDecision.reason
|
|
45738
|
+
}, "Skipping LLM evaluation");
|
|
45736
45739
|
shouldRespondToMessage = responseDecision.shouldRespond;
|
|
45737
45740
|
} else {
|
|
45738
45741
|
const shouldRespondPrompt = composePromptFromState({
|
|
45739
45742
|
state,
|
|
45740
45743
|
template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
|
|
45741
45744
|
});
|
|
45742
|
-
runtime.logger.debug({
|
|
45745
|
+
runtime.logger.debug({
|
|
45746
|
+
src: "service:message",
|
|
45747
|
+
agentName: runtime.character.name,
|
|
45748
|
+
reason: responseDecision.reason
|
|
45749
|
+
}, "Using LLM evaluation");
|
|
45743
45750
|
const response = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
45744
45751
|
prompt: shouldRespondPrompt
|
|
45745
45752
|
});
|
|
@@ -46009,7 +46016,10 @@ class DefaultMessageService {
|
|
|
46009
46016
|
processedAttachment.description = parsedXml.description || "";
|
|
46010
46017
|
processedAttachment.title = parsedXml.title || "Image";
|
|
46011
46018
|
processedAttachment.text = parsedXml.text || parsedXml.description || "";
|
|
46012
|
-
runtime.logger.debug({
|
|
46019
|
+
runtime.logger.debug({
|
|
46020
|
+
src: "service:message",
|
|
46021
|
+
descriptionPreview: processedAttachment.description?.substring(0, 100)
|
|
46022
|
+
}, "Generated image description");
|
|
46013
46023
|
} else {
|
|
46014
46024
|
const responseStr = response;
|
|
46015
46025
|
const titleMatch = responseStr.match(/<title>([^<]+)<\/title>/);
|
|
@@ -46019,7 +46029,10 @@ class DefaultMessageService {
|
|
|
46019
46029
|
processedAttachment.title = titleMatch?.[1] || "Image";
|
|
46020
46030
|
processedAttachment.description = descMatch?.[1] || "";
|
|
46021
46031
|
processedAttachment.text = textMatch?.[1] || descMatch?.[1] || "";
|
|
46022
|
-
runtime.logger.debug({
|
|
46032
|
+
runtime.logger.debug({
|
|
46033
|
+
src: "service:message",
|
|
46034
|
+
descriptionPreview: processedAttachment.description?.substring(0, 100)
|
|
46035
|
+
}, "Used fallback XML parsing for description");
|
|
46023
46036
|
} else {
|
|
46024
46037
|
runtime.logger.warn({ src: "service:message" }, "Failed to parse XML response for image description");
|
|
46025
46038
|
}
|
|
@@ -46028,7 +46041,10 @@ class DefaultMessageService {
|
|
|
46028
46041
|
processedAttachment.description = response.description;
|
|
46029
46042
|
processedAttachment.title = response.title || "Image";
|
|
46030
46043
|
processedAttachment.text = response.description;
|
|
46031
|
-
runtime.logger.debug({
|
|
46044
|
+
runtime.logger.debug({
|
|
46045
|
+
src: "service:message",
|
|
46046
|
+
descriptionPreview: processedAttachment.description?.substring(0, 100)
|
|
46047
|
+
}, "Generated image description");
|
|
46032
46048
|
} else {
|
|
46033
46049
|
runtime.logger.warn({ src: "service:message" }, "Unexpected response format for image description");
|
|
46034
46050
|
}
|
|
@@ -46132,7 +46148,11 @@ class DefaultMessageService {
|
|
|
46132
46148
|
let iterationCount = 0;
|
|
46133
46149
|
while (iterationCount < opts.maxMultiStepIterations) {
|
|
46134
46150
|
iterationCount++;
|
|
46135
|
-
runtime.logger.debug({
|
|
46151
|
+
runtime.logger.debug({
|
|
46152
|
+
src: "service:message",
|
|
46153
|
+
iteration: iterationCount,
|
|
46154
|
+
maxIterations: opts.maxMultiStepIterations
|
|
46155
|
+
}, "Starting multi-step iteration");
|
|
46136
46156
|
accumulatedState = await runtime.composeState(message, [
|
|
46137
46157
|
"RECENT_MESSAGES",
|
|
46138
46158
|
"ACTION_STATE"
|
|
@@ -46302,7 +46322,12 @@ class DefaultMessageService {
|
|
|
46302
46322
|
runtime.logger.error({ src: "service:message", agentId: runtime.agentId }, "Cannot delete memory: message ID is missing");
|
|
46303
46323
|
return;
|
|
46304
46324
|
}
|
|
46305
|
-
runtime.logger.info({
|
|
46325
|
+
runtime.logger.info({
|
|
46326
|
+
src: "service:message",
|
|
46327
|
+
agentId: runtime.agentId,
|
|
46328
|
+
messageId: message.id,
|
|
46329
|
+
roomId: message.roomId
|
|
46330
|
+
}, "Deleting memory");
|
|
46306
46331
|
await runtime.deleteMemory(message.id);
|
|
46307
46332
|
runtime.logger.debug({ src: "service:message", messageId: message.id }, "Successfully deleted memory");
|
|
46308
46333
|
} catch (error) {
|
|
@@ -46329,7 +46354,13 @@ class DefaultMessageService {
|
|
|
46329
46354
|
}
|
|
46330
46355
|
}
|
|
46331
46356
|
}
|
|
46332
|
-
runtime.logger.info({
|
|
46357
|
+
runtime.logger.info({
|
|
46358
|
+
src: "service:message",
|
|
46359
|
+
agentId: runtime.agentId,
|
|
46360
|
+
channelId,
|
|
46361
|
+
deletedCount,
|
|
46362
|
+
totalCount: memories.length
|
|
46363
|
+
}, "Cleared message memories from channel");
|
|
46333
46364
|
} catch (error) {
|
|
46334
46365
|
runtime.logger.error({ src: "service:message", agentId: runtime.agentId, error }, "Error in clearChannel");
|
|
46335
46366
|
throw error;
|
|
@@ -47340,7 +47371,13 @@ class AgentRuntime {
|
|
|
47340
47371
|
}
|
|
47341
47372
|
this.serviceRegistrationStatus.set(serviceType, "pending");
|
|
47342
47373
|
this.registerService(service).catch((error) => {
|
|
47343
|
-
this.logger.error({
|
|
47374
|
+
this.logger.error({
|
|
47375
|
+
src: "agent",
|
|
47376
|
+
agentId: this.agentId,
|
|
47377
|
+
plugin: plugin.name,
|
|
47378
|
+
serviceType,
|
|
47379
|
+
error: error instanceof Error ? error.message : String(error)
|
|
47380
|
+
}, "Service registration failed");
|
|
47344
47381
|
const handler = this.servicePromiseHandlers.get(serviceType);
|
|
47345
47382
|
if (handler) {
|
|
47346
47383
|
const serviceError = new Error(`Service ${serviceType} from plugin ${plugin.name} failed to register: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -47510,7 +47547,11 @@ class AgentRuntime {
|
|
|
47510
47547
|
});
|
|
47511
47548
|
this.logger.debug({ src: "agent", agentId: this.agentId }, "Plugin migrations completed");
|
|
47512
47549
|
} catch (error) {
|
|
47513
|
-
this.logger.error({
|
|
47550
|
+
this.logger.error({
|
|
47551
|
+
src: "agent",
|
|
47552
|
+
agentId: this.agentId,
|
|
47553
|
+
error: error instanceof Error ? error.message : String(error)
|
|
47554
|
+
}, "Plugin migrations failed");
|
|
47514
47555
|
throw error;
|
|
47515
47556
|
}
|
|
47516
47557
|
}
|
|
@@ -47618,7 +47659,11 @@ class AgentRuntime {
|
|
|
47618
47659
|
const actions = response.content.actions;
|
|
47619
47660
|
const actionResults = [];
|
|
47620
47661
|
let accumulatedState = state;
|
|
47621
|
-
this.logger.trace({
|
|
47662
|
+
this.logger.trace({
|
|
47663
|
+
src: "agent",
|
|
47664
|
+
agentId: this.agentId,
|
|
47665
|
+
actions: this.actions.map((a) => normalizeAction(a.name))
|
|
47666
|
+
}, "Available actions");
|
|
47622
47667
|
for (const responseAction of actions) {
|
|
47623
47668
|
if (actionPlan) {
|
|
47624
47669
|
actionPlan = this.updateActionPlan(actionPlan, { currentStep: actionIndex + 1 });
|
|
@@ -47818,7 +47863,12 @@ class AgentRuntime {
|
|
|
47818
47863
|
}
|
|
47819
47864
|
});
|
|
47820
47865
|
} catch (error) {
|
|
47821
|
-
this.logger.error({
|
|
47866
|
+
this.logger.error({
|
|
47867
|
+
src: "agent",
|
|
47868
|
+
agentId: this.agentId,
|
|
47869
|
+
action: action.name,
|
|
47870
|
+
error: error instanceof Error ? error.message : String(error)
|
|
47871
|
+
}, "Failed to emit ACTION_COMPLETED event");
|
|
47822
47872
|
}
|
|
47823
47873
|
if (callback) {
|
|
47824
47874
|
for (const content of storedCallbackData) {
|
|
@@ -47966,7 +48016,12 @@ class AgentRuntime {
|
|
|
47966
48016
|
}
|
|
47967
48017
|
return null;
|
|
47968
48018
|
} catch (error) {
|
|
47969
|
-
this.logger.error({
|
|
48019
|
+
this.logger.error({
|
|
48020
|
+
src: "agent",
|
|
48021
|
+
agentId: this.agentId,
|
|
48022
|
+
evaluator: evaluator.name,
|
|
48023
|
+
error: error instanceof Error ? error.message : String(error)
|
|
48024
|
+
}, "Evaluator validation failed");
|
|
47970
48025
|
return null;
|
|
47971
48026
|
}
|
|
47972
48027
|
});
|
|
@@ -47993,12 +48048,23 @@ class AgentRuntime {
|
|
|
47993
48048
|
});
|
|
47994
48049
|
}
|
|
47995
48050
|
} catch (error) {
|
|
47996
|
-
this.logger.error({
|
|
48051
|
+
this.logger.error({
|
|
48052
|
+
src: "agent",
|
|
48053
|
+
agentId: this.agentId,
|
|
48054
|
+
evaluator: evaluator.name,
|
|
48055
|
+
error: error instanceof Error ? error.message : String(error)
|
|
48056
|
+
}, "Evaluator execution failed");
|
|
47997
48057
|
}
|
|
47998
48058
|
}));
|
|
47999
48059
|
return evaluators;
|
|
48000
48060
|
} catch (error) {
|
|
48001
|
-
this.logger.error({
|
|
48061
|
+
this.logger.error({
|
|
48062
|
+
src: "agent",
|
|
48063
|
+
agentId: this.agentId,
|
|
48064
|
+
messageId: message.id,
|
|
48065
|
+
channelId: message.roomId,
|
|
48066
|
+
error: error instanceof Error ? error.message : String(error)
|
|
48067
|
+
}, "Evaluate method failed");
|
|
48002
48068
|
return [];
|
|
48003
48069
|
}
|
|
48004
48070
|
}
|
|
@@ -48068,7 +48134,12 @@ class AgentRuntime {
|
|
|
48068
48134
|
const entityIdsInFirstRoomFiltered = entityIdsInFirstRoom.filter(Boolean);
|
|
48069
48135
|
const missingIdsInRoom = entityIds.filter((id) => !entityIdsInFirstRoomFiltered.includes(id));
|
|
48070
48136
|
if (missingIdsInRoom.length) {
|
|
48071
|
-
this.logger.debug({
|
|
48137
|
+
this.logger.debug({
|
|
48138
|
+
src: "agent",
|
|
48139
|
+
agentId: this.agentId,
|
|
48140
|
+
count: missingIdsInRoom.length,
|
|
48141
|
+
channelId: firstRoom.id
|
|
48142
|
+
}, "Adding missing participants");
|
|
48072
48143
|
const batches = chunkArray(missingIdsInRoom, 5000);
|
|
48073
48144
|
for (const batch of batches) {
|
|
48074
48145
|
await this.addParticipantsRoom(batch, firstRoom.id);
|
|
@@ -48171,7 +48242,13 @@ class AgentRuntime {
|
|
|
48171
48242
|
await this.ensureParticipantInRoom(this.agentId, roomId);
|
|
48172
48243
|
this.logger.debug({ src: "agent", agentId: this.agentId, entityId, channelId: roomId }, "Entity connected");
|
|
48173
48244
|
} catch (error) {
|
|
48174
|
-
this.logger.error({
|
|
48245
|
+
this.logger.error({
|
|
48246
|
+
src: "agent",
|
|
48247
|
+
agentId: this.agentId,
|
|
48248
|
+
entityId,
|
|
48249
|
+
channelId: roomId,
|
|
48250
|
+
error: error instanceof Error ? error.message : String(error)
|
|
48251
|
+
}, "Connection setup failed");
|
|
48175
48252
|
throw error;
|
|
48176
48253
|
}
|
|
48177
48254
|
}
|
|
@@ -48637,7 +48714,12 @@ class AgentRuntime {
|
|
|
48637
48714
|
try {
|
|
48638
48715
|
const response = await model(this, modelParams);
|
|
48639
48716
|
const elapsedTime = (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now()) - startTime;
|
|
48640
|
-
this.logger.trace({
|
|
48717
|
+
this.logger.trace({
|
|
48718
|
+
src: "agent",
|
|
48719
|
+
agentId: this.agentId,
|
|
48720
|
+
model: modelKey,
|
|
48721
|
+
duration: Number(elapsedTime.toFixed(2))
|
|
48722
|
+
}, "Model output");
|
|
48641
48723
|
if (modelKey !== ModelType.TEXT_EMBEDDING && promptContent) {
|
|
48642
48724
|
if (this.currentActionContext) {
|
|
48643
48725
|
this.currentActionContext.prompts.push({
|
|
@@ -48752,7 +48834,12 @@ ${input}`;
|
|
|
48752
48834
|
}
|
|
48753
48835
|
await Promise.all(eventHandlers.map((handler) => handler(paramsWithRuntime)));
|
|
48754
48836
|
} catch (error) {
|
|
48755
|
-
this.logger.error({
|
|
48837
|
+
this.logger.error({
|
|
48838
|
+
src: "agent",
|
|
48839
|
+
agentId: this.agentId,
|
|
48840
|
+
eventName,
|
|
48841
|
+
error: error instanceof Error ? error.message : String(error)
|
|
48842
|
+
}, "Event handler failed");
|
|
48756
48843
|
}
|
|
48757
48844
|
}
|
|
48758
48845
|
}
|
|
@@ -48772,7 +48859,11 @@ ${input}`;
|
|
|
48772
48859
|
await this.adapter.ensureEmbeddingDimension(embedding.length);
|
|
48773
48860
|
this.logger.debug({ src: "agent", agentId: this.agentId, dimension: embedding.length }, "Embedding dimension set");
|
|
48774
48861
|
} catch (error) {
|
|
48775
|
-
this.logger.error({
|
|
48862
|
+
this.logger.error({
|
|
48863
|
+
src: "agent",
|
|
48864
|
+
agentId: this.agentId,
|
|
48865
|
+
error: error instanceof Error ? error.message : String(error)
|
|
48866
|
+
}, "Embedding dimension setup failed");
|
|
48776
48867
|
throw error;
|
|
48777
48868
|
}
|
|
48778
48869
|
}
|
|
@@ -48909,7 +49000,11 @@ ${input}`;
|
|
|
48909
49000
|
text: memoryText
|
|
48910
49001
|
});
|
|
48911
49002
|
} catch (error) {
|
|
48912
|
-
this.logger.error({
|
|
49003
|
+
this.logger.error({
|
|
49004
|
+
src: "agent",
|
|
49005
|
+
agentId: this.agentId,
|
|
49006
|
+
error: error instanceof Error ? error.message : String(error)
|
|
49007
|
+
}, "Embedding generation failed");
|
|
48913
49008
|
memory.embedding = await this.useModel(ModelType.TEXT_EMBEDDING, null);
|
|
48914
49009
|
}
|
|
48915
49010
|
return memory;
|
|
@@ -48950,7 +49045,12 @@ ${input}`;
|
|
|
48950
49045
|
});
|
|
48951
49046
|
allMemories.push(...memories);
|
|
48952
49047
|
} catch (error) {
|
|
48953
|
-
this.logger.debug({
|
|
49048
|
+
this.logger.debug({
|
|
49049
|
+
src: "agent",
|
|
49050
|
+
agentId: this.agentId,
|
|
49051
|
+
tableName,
|
|
49052
|
+
error: error instanceof Error ? error.message : String(error)
|
|
49053
|
+
}, "Failed to get memories");
|
|
48954
49054
|
}
|
|
48955
49055
|
}
|
|
48956
49056
|
return allMemories;
|
|
@@ -49185,7 +49285,11 @@ ${input}`;
|
|
|
49185
49285
|
});
|
|
49186
49286
|
this.logger.debug({ src: "agent", agentId: this.agentId, action, channelId: roomId }, "Control message sent");
|
|
49187
49287
|
} catch (error) {
|
|
49188
|
-
this.logger.error({
|
|
49288
|
+
this.logger.error({
|
|
49289
|
+
src: "agent",
|
|
49290
|
+
agentId: this.agentId,
|
|
49291
|
+
error: error instanceof Error ? error.message : String(error)
|
|
49292
|
+
}, "Control message failed");
|
|
49189
49293
|
}
|
|
49190
49294
|
}
|
|
49191
49295
|
registerSendHandler(source, handler) {
|
|
@@ -49205,7 +49309,12 @@ ${input}`;
|
|
|
49205
49309
|
try {
|
|
49206
49310
|
await handler(this, target, content);
|
|
49207
49311
|
} catch (error) {
|
|
49208
|
-
this.logger.error({
|
|
49312
|
+
this.logger.error({
|
|
49313
|
+
src: "agent",
|
|
49314
|
+
agentId: this.agentId,
|
|
49315
|
+
handlerSource: target.source,
|
|
49316
|
+
error: error instanceof Error ? error.message : String(error)
|
|
49317
|
+
}, "Send handler failed");
|
|
49209
49318
|
throw error;
|
|
49210
49319
|
}
|
|
49211
49320
|
}
|
|
@@ -50574,5 +50683,5 @@ export {
|
|
|
50574
50683
|
AgentRuntime
|
|
50575
50684
|
};
|
|
50576
50685
|
|
|
50577
|
-
//# debugId=
|
|
50686
|
+
//# debugId=C468BC8B5AE0993F64756E2164756E21
|
|
50578
50687
|
//# sourceMappingURL=index.node.js.map
|