@elizaos/core 1.6.5-alpha.20 → 1.6.5-alpha.22
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 +90 -90
- package/dist/browser/index.browser.js.map +15 -15
- package/dist/elizaos.d.ts +31 -9
- package/dist/elizaos.d.ts.map +1 -1
- package/dist/node/index.node.js +393 -153
- package/dist/node/index.node.js.map +15 -15
- package/dist/types/elizaos.d.ts +3 -2
- package/dist/types/elizaos.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/node/index.node.js
CHANGED
|
@@ -26501,9 +26501,10 @@ function _mergeDicts(left = {}, right = {}) {
|
|
|
26501
26501
|
"name",
|
|
26502
26502
|
"output_version",
|
|
26503
26503
|
"model_provider"
|
|
26504
|
-
].includes(key))
|
|
26505
|
-
|
|
26506
|
-
|
|
26504
|
+
].includes(key)) {
|
|
26505
|
+
if (value)
|
|
26506
|
+
merged[key] = value;
|
|
26507
|
+
} else
|
|
26507
26508
|
merged[key] += value;
|
|
26508
26509
|
else if (typeof merged[key] === "object" && !Array.isArray(merged[key]))
|
|
26509
26510
|
merged[key] = _mergeDicts(merged[key], value);
|
|
@@ -26695,47 +26696,227 @@ function isToolMessageChunk(x) {
|
|
|
26695
26696
|
}
|
|
26696
26697
|
|
|
26697
26698
|
// ../../node_modules/@langchain/core/dist/utils/json.js
|
|
26698
|
-
function
|
|
26699
|
-
if (typeof s === "undefined")
|
|
26700
|
-
return null;
|
|
26699
|
+
function strictParsePartialJson(s) {
|
|
26701
26700
|
try {
|
|
26702
26701
|
return JSON.parse(s);
|
|
26703
26702
|
} catch {}
|
|
26704
|
-
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
let
|
|
26708
|
-
|
|
26709
|
-
|
|
26710
|
-
|
|
26711
|
-
|
|
26712
|
-
|
|
26713
|
-
|
|
26714
|
-
|
|
26715
|
-
|
|
26716
|
-
|
|
26717
|
-
|
|
26703
|
+
const buffer = s.trim();
|
|
26704
|
+
if (buffer.length === 0)
|
|
26705
|
+
throw new Error("Unexpected end of JSON input");
|
|
26706
|
+
let pos = 0;
|
|
26707
|
+
function skipWhitespace() {
|
|
26708
|
+
while (pos < buffer.length && /\s/.test(buffer[pos]))
|
|
26709
|
+
pos += 1;
|
|
26710
|
+
}
|
|
26711
|
+
function parseString() {
|
|
26712
|
+
if (buffer[pos] !== '"')
|
|
26713
|
+
throw new Error(`Expected '"' at position ${pos}, got '${buffer[pos]}'`);
|
|
26714
|
+
pos += 1;
|
|
26715
|
+
let result = "";
|
|
26716
|
+
let escaped = false;
|
|
26717
|
+
while (pos < buffer.length) {
|
|
26718
|
+
const char = buffer[pos];
|
|
26719
|
+
if (escaped) {
|
|
26720
|
+
if (char === "n")
|
|
26721
|
+
result += `
|
|
26722
|
+
`;
|
|
26723
|
+
else if (char === "t")
|
|
26724
|
+
result += "\t";
|
|
26725
|
+
else if (char === "r")
|
|
26726
|
+
result += "\r";
|
|
26727
|
+
else if (char === "\\")
|
|
26728
|
+
result += "\\";
|
|
26729
|
+
else if (char === '"')
|
|
26730
|
+
result += '"';
|
|
26731
|
+
else if (char === "b")
|
|
26732
|
+
result += "\b";
|
|
26733
|
+
else if (char === "f")
|
|
26734
|
+
result += "\f";
|
|
26735
|
+
else if (char === "/")
|
|
26736
|
+
result += "/";
|
|
26737
|
+
else if (char === "u") {
|
|
26738
|
+
const hex = buffer.substring(pos + 1, pos + 5);
|
|
26739
|
+
if (/^[0-9A-Fa-f]{0,4}$/.test(hex)) {
|
|
26740
|
+
if (hex.length === 4)
|
|
26741
|
+
result += String.fromCharCode(Number.parseInt(hex, 16));
|
|
26742
|
+
else
|
|
26743
|
+
result += `u${hex}`;
|
|
26744
|
+
pos += hex.length;
|
|
26745
|
+
} else
|
|
26746
|
+
throw new Error(`Invalid unicode escape sequence '\\u${hex}' at position ${pos}`);
|
|
26747
|
+
} else
|
|
26748
|
+
throw new Error(`Invalid escape sequence '\\${char}' at position ${pos}`);
|
|
26718
26749
|
escaped = false;
|
|
26719
|
-
|
|
26720
|
-
|
|
26721
|
-
|
|
26722
|
-
|
|
26723
|
-
|
|
26724
|
-
|
|
26725
|
-
|
|
26726
|
-
|
|
26727
|
-
|
|
26728
|
-
|
|
26729
|
-
|
|
26730
|
-
|
|
26731
|
-
new_s += char;
|
|
26750
|
+
} else if (char === "\\")
|
|
26751
|
+
escaped = true;
|
|
26752
|
+
else if (char === '"') {
|
|
26753
|
+
pos += 1;
|
|
26754
|
+
return result;
|
|
26755
|
+
} else
|
|
26756
|
+
result += char;
|
|
26757
|
+
pos += 1;
|
|
26758
|
+
}
|
|
26759
|
+
if (escaped)
|
|
26760
|
+
result += "\\";
|
|
26761
|
+
return result;
|
|
26732
26762
|
}
|
|
26733
|
-
|
|
26734
|
-
|
|
26735
|
-
|
|
26736
|
-
|
|
26763
|
+
function parseNumber() {
|
|
26764
|
+
const start = pos;
|
|
26765
|
+
let numStr = "";
|
|
26766
|
+
if (buffer[pos] === "-") {
|
|
26767
|
+
numStr += "-";
|
|
26768
|
+
pos += 1;
|
|
26769
|
+
}
|
|
26770
|
+
if (pos < buffer.length && buffer[pos] === "0") {
|
|
26771
|
+
numStr += "0";
|
|
26772
|
+
pos += 1;
|
|
26773
|
+
if (buffer[pos] >= "0" && buffer[pos] <= "9")
|
|
26774
|
+
throw new Error(`Invalid number at position ${start}`);
|
|
26775
|
+
}
|
|
26776
|
+
if (pos < buffer.length && buffer[pos] >= "1" && buffer[pos] <= "9")
|
|
26777
|
+
while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
|
|
26778
|
+
numStr += buffer[pos];
|
|
26779
|
+
pos += 1;
|
|
26780
|
+
}
|
|
26781
|
+
if (pos < buffer.length && buffer[pos] === ".") {
|
|
26782
|
+
numStr += ".";
|
|
26783
|
+
pos += 1;
|
|
26784
|
+
while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
|
|
26785
|
+
numStr += buffer[pos];
|
|
26786
|
+
pos += 1;
|
|
26787
|
+
}
|
|
26788
|
+
}
|
|
26789
|
+
if (pos < buffer.length && (buffer[pos] === "e" || buffer[pos] === "E")) {
|
|
26790
|
+
numStr += buffer[pos];
|
|
26791
|
+
pos += 1;
|
|
26792
|
+
if (pos < buffer.length && (buffer[pos] === "+" || buffer[pos] === "-")) {
|
|
26793
|
+
numStr += buffer[pos];
|
|
26794
|
+
pos += 1;
|
|
26795
|
+
}
|
|
26796
|
+
while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
|
|
26797
|
+
numStr += buffer[pos];
|
|
26798
|
+
pos += 1;
|
|
26799
|
+
}
|
|
26800
|
+
}
|
|
26801
|
+
if (numStr === "-")
|
|
26802
|
+
return -0;
|
|
26803
|
+
const num = Number.parseFloat(numStr);
|
|
26804
|
+
if (Number.isNaN(num)) {
|
|
26805
|
+
pos = start;
|
|
26806
|
+
throw new Error(`Invalid number '${numStr}' at position ${start}`);
|
|
26807
|
+
}
|
|
26808
|
+
return num;
|
|
26809
|
+
}
|
|
26810
|
+
function parseValue() {
|
|
26811
|
+
skipWhitespace();
|
|
26812
|
+
if (pos >= buffer.length)
|
|
26813
|
+
throw new Error(`Unexpected end of input at position ${pos}`);
|
|
26814
|
+
const char = buffer[pos];
|
|
26815
|
+
if (char === "{")
|
|
26816
|
+
return parseObject();
|
|
26817
|
+
if (char === "[")
|
|
26818
|
+
return parseArray();
|
|
26819
|
+
if (char === '"')
|
|
26820
|
+
return parseString();
|
|
26821
|
+
if ("null".startsWith(buffer.substring(pos, pos + 4))) {
|
|
26822
|
+
pos += Math.min(4, buffer.length - pos);
|
|
26823
|
+
return null;
|
|
26824
|
+
}
|
|
26825
|
+
if ("true".startsWith(buffer.substring(pos, pos + 4))) {
|
|
26826
|
+
pos += Math.min(4, buffer.length - pos);
|
|
26827
|
+
return true;
|
|
26828
|
+
}
|
|
26829
|
+
if ("false".startsWith(buffer.substring(pos, pos + 5))) {
|
|
26830
|
+
pos += Math.min(5, buffer.length - pos);
|
|
26831
|
+
return false;
|
|
26832
|
+
}
|
|
26833
|
+
if (char === "-" || char >= "0" && char <= "9")
|
|
26834
|
+
return parseNumber();
|
|
26835
|
+
throw new Error(`Unexpected character '${char}' at position ${pos}`);
|
|
26836
|
+
}
|
|
26837
|
+
function parseArray() {
|
|
26838
|
+
if (buffer[pos] !== "[")
|
|
26839
|
+
throw new Error(`Expected '[' at position ${pos}, got '${buffer[pos]}'`);
|
|
26840
|
+
const arr = [];
|
|
26841
|
+
pos += 1;
|
|
26842
|
+
skipWhitespace();
|
|
26843
|
+
if (pos >= buffer.length)
|
|
26844
|
+
return arr;
|
|
26845
|
+
if (buffer[pos] === "]") {
|
|
26846
|
+
pos += 1;
|
|
26847
|
+
return arr;
|
|
26848
|
+
}
|
|
26849
|
+
while (pos < buffer.length) {
|
|
26850
|
+
skipWhitespace();
|
|
26851
|
+
if (pos >= buffer.length)
|
|
26852
|
+
return arr;
|
|
26853
|
+
arr.push(parseValue());
|
|
26854
|
+
skipWhitespace();
|
|
26855
|
+
if (pos >= buffer.length)
|
|
26856
|
+
return arr;
|
|
26857
|
+
if (buffer[pos] === "]") {
|
|
26858
|
+
pos += 1;
|
|
26859
|
+
return arr;
|
|
26860
|
+
} else if (buffer[pos] === ",") {
|
|
26861
|
+
pos += 1;
|
|
26862
|
+
continue;
|
|
26863
|
+
}
|
|
26864
|
+
throw new Error(`Expected ',' or ']' at position ${pos}, got '${buffer[pos]}'`);
|
|
26865
|
+
}
|
|
26866
|
+
return arr;
|
|
26867
|
+
}
|
|
26868
|
+
function parseObject() {
|
|
26869
|
+
if (buffer[pos] !== "{")
|
|
26870
|
+
throw new Error(`Expected '{' at position ${pos}, got '${buffer[pos]}'`);
|
|
26871
|
+
const obj = {};
|
|
26872
|
+
pos += 1;
|
|
26873
|
+
skipWhitespace();
|
|
26874
|
+
if (pos >= buffer.length)
|
|
26875
|
+
return obj;
|
|
26876
|
+
if (buffer[pos] === "}") {
|
|
26877
|
+
pos += 1;
|
|
26878
|
+
return obj;
|
|
26879
|
+
}
|
|
26880
|
+
while (pos < buffer.length) {
|
|
26881
|
+
skipWhitespace();
|
|
26882
|
+
if (pos >= buffer.length)
|
|
26883
|
+
return obj;
|
|
26884
|
+
const key = parseString();
|
|
26885
|
+
skipWhitespace();
|
|
26886
|
+
if (pos >= buffer.length)
|
|
26887
|
+
return obj;
|
|
26888
|
+
if (buffer[pos] !== ":")
|
|
26889
|
+
throw new Error(`Expected ':' at position ${pos}, got '${buffer[pos]}'`);
|
|
26890
|
+
pos += 1;
|
|
26891
|
+
skipWhitespace();
|
|
26892
|
+
if (pos >= buffer.length)
|
|
26893
|
+
return obj;
|
|
26894
|
+
obj[key] = parseValue();
|
|
26895
|
+
skipWhitespace();
|
|
26896
|
+
if (pos >= buffer.length)
|
|
26897
|
+
return obj;
|
|
26898
|
+
if (buffer[pos] === "}") {
|
|
26899
|
+
pos += 1;
|
|
26900
|
+
return obj;
|
|
26901
|
+
} else if (buffer[pos] === ",") {
|
|
26902
|
+
pos += 1;
|
|
26903
|
+
continue;
|
|
26904
|
+
}
|
|
26905
|
+
throw new Error(`Expected ',' or '}' at position ${pos}, got '${buffer[pos]}'`);
|
|
26906
|
+
}
|
|
26907
|
+
return obj;
|
|
26908
|
+
}
|
|
26909
|
+
const value = parseValue();
|
|
26910
|
+
skipWhitespace();
|
|
26911
|
+
if (pos < buffer.length)
|
|
26912
|
+
throw new Error(`Unexpected character '${buffer[pos]}' at position ${pos}`);
|
|
26913
|
+
return value;
|
|
26914
|
+
}
|
|
26915
|
+
function parsePartialJson(s) {
|
|
26737
26916
|
try {
|
|
26738
|
-
|
|
26917
|
+
if (typeof s === "undefined")
|
|
26918
|
+
return null;
|
|
26919
|
+
return strictParsePartialJson(s);
|
|
26739
26920
|
} catch {
|
|
26740
26921
|
return null;
|
|
26741
26922
|
}
|
|
@@ -27208,59 +27389,12 @@ var AIMessageChunk = class extends BaseMessageChunk {
|
|
|
27208
27389
|
tool_call_chunks: [],
|
|
27209
27390
|
usage_metadata: fields.usage_metadata !== undefined ? fields.usage_metadata : undefined
|
|
27210
27391
|
};
|
|
27211
|
-
else
|
|
27212
|
-
const toolCallChunks = fields.tool_call_chunks ?? [];
|
|
27213
|
-
const groupedToolCallChunks = toolCallChunks.reduce((acc, chunk) => {
|
|
27214
|
-
const matchedChunkIndex = acc.findIndex(([match]) => {
|
|
27215
|
-
if ("id" in chunk && chunk.id && "index" in chunk && chunk.index !== undefined)
|
|
27216
|
-
return chunk.id === match.id && chunk.index === match.index;
|
|
27217
|
-
if ("id" in chunk && chunk.id)
|
|
27218
|
-
return chunk.id === match.id;
|
|
27219
|
-
if ("index" in chunk && chunk.index !== undefined)
|
|
27220
|
-
return chunk.index === match.index;
|
|
27221
|
-
return false;
|
|
27222
|
-
});
|
|
27223
|
-
if (matchedChunkIndex !== -1)
|
|
27224
|
-
acc[matchedChunkIndex].push(chunk);
|
|
27225
|
-
else
|
|
27226
|
-
acc.push([chunk]);
|
|
27227
|
-
return acc;
|
|
27228
|
-
}, []);
|
|
27229
|
-
const toolCalls = [];
|
|
27230
|
-
const invalidToolCalls = [];
|
|
27231
|
-
for (const chunks of groupedToolCallChunks) {
|
|
27232
|
-
let parsedArgs = null;
|
|
27233
|
-
const name = chunks[0]?.name ?? "";
|
|
27234
|
-
const joinedArgs = chunks.map((c) => c.args || "").join("");
|
|
27235
|
-
const argsStr = joinedArgs.length ? joinedArgs : "{}";
|
|
27236
|
-
const id = chunks[0]?.id;
|
|
27237
|
-
try {
|
|
27238
|
-
parsedArgs = parsePartialJson(argsStr);
|
|
27239
|
-
if (!id || parsedArgs === null || typeof parsedArgs !== "object" || Array.isArray(parsedArgs))
|
|
27240
|
-
throw new Error("Malformed tool call chunk args.");
|
|
27241
|
-
toolCalls.push({
|
|
27242
|
-
name,
|
|
27243
|
-
args: parsedArgs,
|
|
27244
|
-
id,
|
|
27245
|
-
type: "tool_call"
|
|
27246
|
-
});
|
|
27247
|
-
} catch {
|
|
27248
|
-
invalidToolCalls.push({
|
|
27249
|
-
name,
|
|
27250
|
-
args: argsStr,
|
|
27251
|
-
id,
|
|
27252
|
-
error: "Malformed args.",
|
|
27253
|
-
type: "invalid_tool_call"
|
|
27254
|
-
});
|
|
27255
|
-
}
|
|
27256
|
-
}
|
|
27392
|
+
else
|
|
27257
27393
|
initParams = {
|
|
27258
27394
|
...fields,
|
|
27259
|
-
|
|
27260
|
-
invalid_tool_calls: invalidToolCalls,
|
|
27395
|
+
...collapseToolCallChunks(fields.tool_call_chunks ?? []),
|
|
27261
27396
|
usage_metadata: fields.usage_metadata !== undefined ? fields.usage_metadata : undefined
|
|
27262
27397
|
};
|
|
27263
|
-
}
|
|
27264
27398
|
super(initParams);
|
|
27265
27399
|
this.tool_call_chunks = initParams.tool_call_chunks ?? this.tool_call_chunks;
|
|
27266
27400
|
this.tool_calls = initParams.tool_calls ?? this.tool_calls;
|
|
@@ -27359,6 +27493,57 @@ function getBufferString(messages, humanPrefix = "Human", aiPrefix = "AI") {
|
|
|
27359
27493
|
return string_messages.join(`
|
|
27360
27494
|
`);
|
|
27361
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
|
+
}
|
|
27362
27547
|
|
|
27363
27548
|
// ../../node_modules/@langchain/core/dist/utils/env.js
|
|
27364
27549
|
var env_exports = {};
|
|
@@ -35825,7 +36010,7 @@ var EventStreamCallbackHandler = class extends BaseTracer {
|
|
|
35825
36010
|
}
|
|
35826
36011
|
};
|
|
35827
36012
|
|
|
35828
|
-
// ../../node_modules/is-network-error/index.js
|
|
36013
|
+
// ../../node_modules/@langchain/core/dist/utils/is-network-error/index.js
|
|
35829
36014
|
var objectToString2 = Object.prototype.toString;
|
|
35830
36015
|
var isError2 = (value) => objectToString2.call(value) === "[object Error]";
|
|
35831
36016
|
var errorMessages2 = new Set([
|
|
@@ -35841,48 +36026,37 @@ var errorMessages2 = new Set([
|
|
|
35841
36026
|
]);
|
|
35842
36027
|
function isNetworkError2(error) {
|
|
35843
36028
|
const isValid = error && isError2(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
35844
|
-
if (!isValid)
|
|
36029
|
+
if (!isValid)
|
|
35845
36030
|
return false;
|
|
35846
|
-
}
|
|
35847
36031
|
const { message, stack } = error;
|
|
35848
|
-
if (message === "Load failed")
|
|
36032
|
+
if (message === "Load failed")
|
|
35849
36033
|
return stack === undefined || "__sentry_captured__" in error;
|
|
35850
|
-
|
|
35851
|
-
if (message.startsWith("error sending request for url")) {
|
|
36034
|
+
if (message.startsWith("error sending request for url"))
|
|
35852
36035
|
return true;
|
|
35853
|
-
}
|
|
35854
36036
|
return errorMessages2.has(message);
|
|
35855
36037
|
}
|
|
35856
36038
|
|
|
35857
|
-
// ../../node_modules/p-retry/index.js
|
|
36039
|
+
// ../../node_modules/@langchain/core/dist/utils/p-retry/index.js
|
|
35858
36040
|
function validateRetries2(retries) {
|
|
35859
36041
|
if (typeof retries === "number") {
|
|
35860
|
-
if (retries < 0)
|
|
36042
|
+
if (retries < 0)
|
|
35861
36043
|
throw new TypeError("Expected `retries` to be a non-negative number.");
|
|
35862
|
-
|
|
35863
|
-
if (Number.isNaN(retries)) {
|
|
36044
|
+
if (Number.isNaN(retries))
|
|
35864
36045
|
throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
|
|
35865
|
-
|
|
35866
|
-
} else if (retries !== undefined) {
|
|
36046
|
+
} else if (retries !== undefined)
|
|
35867
36047
|
throw new TypeError("Expected `retries` to be a number or Infinity.");
|
|
35868
|
-
}
|
|
35869
36048
|
}
|
|
35870
36049
|
function validateNumberOption2(name, value, { min = 0, allowInfinity = false } = {}) {
|
|
35871
|
-
if (value === undefined)
|
|
36050
|
+
if (value === undefined)
|
|
35872
36051
|
return;
|
|
35873
|
-
|
|
35874
|
-
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
36052
|
+
if (typeof value !== "number" || Number.isNaN(value))
|
|
35875
36053
|
throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
|
|
35876
|
-
|
|
35877
|
-
if (!allowInfinity && !Number.isFinite(value)) {
|
|
36054
|
+
if (!allowInfinity && !Number.isFinite(value))
|
|
35878
36055
|
throw new TypeError(`Expected \`${name}\` to be a finite number.`);
|
|
35879
|
-
|
|
35880
|
-
if (value < min) {
|
|
36056
|
+
if (value < min)
|
|
35881
36057
|
throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
|
|
35882
|
-
}
|
|
35883
36058
|
}
|
|
35884
|
-
|
|
35885
|
-
class AbortError2 extends Error {
|
|
36059
|
+
var AbortError2 = class extends Error {
|
|
35886
36060
|
constructor(message) {
|
|
35887
36061
|
super();
|
|
35888
36062
|
if (message instanceof Error) {
|
|
@@ -35895,7 +36069,7 @@ class AbortError2 extends Error {
|
|
|
35895
36069
|
this.name = "AbortError";
|
|
35896
36070
|
this.message = message;
|
|
35897
36071
|
}
|
|
35898
|
-
}
|
|
36072
|
+
};
|
|
35899
36073
|
function calculateDelay2(retriesConsumed, options) {
|
|
35900
36074
|
const attempt = Math.max(1, retriesConsumed + 1);
|
|
35901
36075
|
const random = options.randomize ? Math.random() + 1 : 1;
|
|
@@ -35904,16 +36078,14 @@ function calculateDelay2(retriesConsumed, options) {
|
|
|
35904
36078
|
return timeout;
|
|
35905
36079
|
}
|
|
35906
36080
|
function calculateRemainingTime2(start, max) {
|
|
35907
|
-
if (!Number.isFinite(max))
|
|
36081
|
+
if (!Number.isFinite(max))
|
|
35908
36082
|
return max;
|
|
35909
|
-
}
|
|
35910
36083
|
return max - (performance.now() - start);
|
|
35911
36084
|
}
|
|
35912
36085
|
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)
|
|
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)
|
|
35915
36088
|
throw normalizedError.originalError;
|
|
35916
|
-
}
|
|
35917
36089
|
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
|
35918
36090
|
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
|
35919
36091
|
const context = Object.freeze({
|
|
@@ -35923,31 +36095,27 @@ async function onAttemptFailure2({ error, attemptNumber, retriesConsumed, startT
|
|
|
35923
36095
|
retriesConsumed
|
|
35924
36096
|
});
|
|
35925
36097
|
await options.onFailedAttempt(context);
|
|
35926
|
-
if (calculateRemainingTime2(startTime, maxRetryTime) <= 0)
|
|
36098
|
+
if (calculateRemainingTime2(startTime, maxRetryTime) <= 0)
|
|
35927
36099
|
throw normalizedError;
|
|
35928
|
-
}
|
|
35929
36100
|
const consumeRetry = await options.shouldConsumeRetry(context);
|
|
35930
36101
|
const remainingTime = calculateRemainingTime2(startTime, maxRetryTime);
|
|
35931
|
-
if (remainingTime <= 0 || retriesLeft <= 0)
|
|
36102
|
+
if (remainingTime <= 0 || retriesLeft <= 0)
|
|
35932
36103
|
throw normalizedError;
|
|
35933
|
-
}
|
|
35934
36104
|
if (normalizedError instanceof TypeError && !isNetworkError2(normalizedError)) {
|
|
35935
|
-
if (consumeRetry)
|
|
36105
|
+
if (consumeRetry)
|
|
35936
36106
|
throw normalizedError;
|
|
35937
|
-
}
|
|
35938
36107
|
options.signal?.throwIfAborted();
|
|
35939
36108
|
return false;
|
|
35940
36109
|
}
|
|
35941
|
-
if (!await options.shouldRetry(context))
|
|
36110
|
+
if (!await options.shouldRetry(context))
|
|
35942
36111
|
throw normalizedError;
|
|
35943
|
-
}
|
|
35944
36112
|
if (!consumeRetry) {
|
|
35945
36113
|
options.signal?.throwIfAborted();
|
|
35946
36114
|
return false;
|
|
35947
36115
|
}
|
|
35948
36116
|
const delayTime = calculateDelay2(retriesConsumed, options);
|
|
35949
36117
|
const finalDelay = Math.min(delayTime, remainingTime);
|
|
35950
|
-
if (finalDelay > 0)
|
|
36118
|
+
if (finalDelay > 0)
|
|
35951
36119
|
await new Promise((resolve, reject) => {
|
|
35952
36120
|
const onAbort = () => {
|
|
35953
36121
|
clearTimeout(timeoutToken);
|
|
@@ -35958,21 +36126,18 @@ async function onAttemptFailure2({ error, attemptNumber, retriesConsumed, startT
|
|
|
35958
36126
|
options.signal?.removeEventListener("abort", onAbort);
|
|
35959
36127
|
resolve();
|
|
35960
36128
|
}, finalDelay);
|
|
35961
|
-
if (options.unref)
|
|
36129
|
+
if (options.unref)
|
|
35962
36130
|
timeoutToken.unref?.();
|
|
35963
|
-
}
|
|
35964
36131
|
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
35965
36132
|
});
|
|
35966
|
-
}
|
|
35967
36133
|
options.signal?.throwIfAborted();
|
|
35968
36134
|
return true;
|
|
35969
36135
|
}
|
|
35970
36136
|
async function pRetry2(input, options = {}) {
|
|
35971
36137
|
options = { ...options };
|
|
35972
36138
|
validateRetries2(options.retries);
|
|
35973
|
-
if (Object.hasOwn(options, "forever"))
|
|
36139
|
+
if (Object.hasOwn(options, "forever"))
|
|
35974
36140
|
throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
|
|
35975
|
-
}
|
|
35976
36141
|
options.retries ??= 10;
|
|
35977
36142
|
options.factor ??= 2;
|
|
35978
36143
|
options.minTimeout ??= 1000;
|
|
@@ -35982,13 +36147,24 @@ async function pRetry2(input, options = {}) {
|
|
|
35982
36147
|
options.onFailedAttempt ??= () => {};
|
|
35983
36148
|
options.shouldRetry ??= () => true;
|
|
35984
36149
|
options.shouldConsumeRetry ??= () => true;
|
|
35985
|
-
validateNumberOption2("factor", options.factor, {
|
|
35986
|
-
|
|
35987
|
-
|
|
35988
|
-
|
|
35989
|
-
|
|
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))
|
|
35990
36167
|
options.factor = 1;
|
|
35991
|
-
}
|
|
35992
36168
|
options.signal?.throwIfAborted();
|
|
35993
36169
|
let attemptNumber = 0;
|
|
35994
36170
|
let retriesConsumed = 0;
|
|
@@ -36007,9 +36183,8 @@ async function pRetry2(input, options = {}) {
|
|
|
36007
36183
|
retriesConsumed,
|
|
36008
36184
|
startTime,
|
|
36009
36185
|
options
|
|
36010
|
-
}))
|
|
36186
|
+
}))
|
|
36011
36187
|
retriesConsumed++;
|
|
36012
|
-
}
|
|
36013
36188
|
}
|
|
36014
36189
|
}
|
|
36015
36190
|
throw new Error("Retry attempts exhausted without throwing an error.");
|
|
@@ -36056,7 +36231,7 @@ var AsyncCaller2 = class {
|
|
|
36056
36231
|
const PQueue = "default" in import_p_queue3.default ? import_p_queue3.default.default : import_p_queue3.default;
|
|
36057
36232
|
this.queue = new PQueue({ concurrency: this.maxConcurrency });
|
|
36058
36233
|
}
|
|
36059
|
-
call(callable, ...args) {
|
|
36234
|
+
async call(callable, ...args) {
|
|
36060
36235
|
return this.queue.add(() => pRetry2(() => callable(...args).catch((error) => {
|
|
36061
36236
|
if (error instanceof Error)
|
|
36062
36237
|
throw error;
|
|
@@ -36161,6 +36336,10 @@ var _RootEventFilter = class {
|
|
|
36161
36336
|
return include;
|
|
36162
36337
|
}
|
|
36163
36338
|
};
|
|
36339
|
+
var toBase64Url = (str) => {
|
|
36340
|
+
const encoded = btoa(str);
|
|
36341
|
+
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
36342
|
+
};
|
|
36164
36343
|
|
|
36165
36344
|
// ../../node_modules/@langchain/core/dist/utils/types/zod.js
|
|
36166
36345
|
import { $ZodNever, $ZodOptional, $ZodUnknown, _never, _unknown, clone, globalRegistry, parse as parse3, parseAsync, util } from "zod/v4/core";
|
|
@@ -36236,6 +36415,20 @@ function isZodArrayV4(obj) {
|
|
|
36236
36415
|
return true;
|
|
36237
36416
|
return false;
|
|
36238
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
|
+
}
|
|
36239
36432
|
function interopZodObjectStrict(schema, recursive = false) {
|
|
36240
36433
|
if (isZodSchemaV3(schema))
|
|
36241
36434
|
return schema.strict();
|
|
@@ -36306,6 +36499,18 @@ function interopZodTransformInputSchemaImpl(schema, recursive, cache) {
|
|
|
36306
36499
|
...outputSchema._zod.def,
|
|
36307
36500
|
element: elementSchema
|
|
36308
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
|
+
});
|
|
36309
36514
|
}
|
|
36310
36515
|
}
|
|
36311
36516
|
const meta = globalRegistry.get(schema);
|
|
@@ -36414,7 +36619,7 @@ graph TD;
|
|
|
36414
36619
|
async function drawMermaidImage(mermaidSyntax, config) {
|
|
36415
36620
|
let backgroundColor = config?.backgroundColor ?? "white";
|
|
36416
36621
|
const imageType = config?.imageType ?? "png";
|
|
36417
|
-
const mermaidSyntaxEncoded =
|
|
36622
|
+
const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);
|
|
36418
36623
|
if (backgroundColor !== undefined) {
|
|
36419
36624
|
const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
|
|
36420
36625
|
if (!hexColorPattern.test(backgroundColor))
|
|
@@ -49660,17 +49865,26 @@ class ElizaOS extends EventTarget {
|
|
|
49660
49865
|
initFunctions = new Map;
|
|
49661
49866
|
editableMode = false;
|
|
49662
49867
|
async addAgents(agents, options) {
|
|
49868
|
+
const createdRuntimes = [];
|
|
49663
49869
|
const promises = agents.map(async (agent) => {
|
|
49664
49870
|
const character = agent.character;
|
|
49665
49871
|
await setDefaultSecretsFromEnv(character, { skipEnvMerge: options?.isTestMode });
|
|
49666
|
-
|
|
49872
|
+
let resolvedPlugins = agent.plugins ? await resolvePlugins(agent.plugins, options?.isTestMode || false) : [];
|
|
49873
|
+
if (agent.databaseAdapter) {
|
|
49874
|
+
resolvedPlugins = resolvedPlugins.filter((p) => p.name !== "@elizaos/plugin-sql");
|
|
49875
|
+
}
|
|
49667
49876
|
const runtime = new AgentRuntime({
|
|
49668
49877
|
character,
|
|
49669
49878
|
plugins: resolvedPlugins,
|
|
49670
49879
|
settings: agent.settings || {}
|
|
49671
49880
|
});
|
|
49881
|
+
if (agent.databaseAdapter) {
|
|
49882
|
+
runtime.registerDatabaseAdapter(agent.databaseAdapter);
|
|
49883
|
+
}
|
|
49672
49884
|
runtime.elizaOS = this;
|
|
49673
|
-
|
|
49885
|
+
if (!options?.ephemeral) {
|
|
49886
|
+
this.runtimes.set(runtime.agentId, runtime);
|
|
49887
|
+
}
|
|
49674
49888
|
if (typeof agent.init === "function") {
|
|
49675
49889
|
this.initFunctions.set(runtime.agentId, agent.init);
|
|
49676
49890
|
}
|
|
@@ -49682,15 +49896,33 @@ class ElizaOS extends EventTarget {
|
|
|
49682
49896
|
character: {
|
|
49683
49897
|
...characterWithoutSecrets,
|
|
49684
49898
|
settings: settingsWithoutSecrets
|
|
49685
|
-
}
|
|
49899
|
+
},
|
|
49900
|
+
ephemeral: options?.ephemeral
|
|
49686
49901
|
}
|
|
49687
49902
|
}));
|
|
49903
|
+
createdRuntimes.push(runtime);
|
|
49688
49904
|
return runtime.agentId;
|
|
49689
49905
|
});
|
|
49690
49906
|
const ids = await Promise.all(promises);
|
|
49907
|
+
if (options?.autoStart) {
|
|
49908
|
+
await Promise.all(createdRuntimes.map(async (runtime) => {
|
|
49909
|
+
await runtime.initialize({ skipMigrations: options?.skipMigrations });
|
|
49910
|
+
const initFn = this.initFunctions.get(runtime.agentId);
|
|
49911
|
+
if (initFn) {
|
|
49912
|
+
await initFn(runtime);
|
|
49913
|
+
this.initFunctions.delete(runtime.agentId);
|
|
49914
|
+
}
|
|
49915
|
+
this.dispatchEvent(new CustomEvent("agent:started", {
|
|
49916
|
+
detail: { agentId: runtime.agentId }
|
|
49917
|
+
}));
|
|
49918
|
+
}));
|
|
49919
|
+
}
|
|
49691
49920
|
this.dispatchEvent(new CustomEvent("agents:added", {
|
|
49692
|
-
detail: { agentIds: ids, count: ids.length }
|
|
49921
|
+
detail: { agentIds: ids, count: ids.length, ephemeral: options?.ephemeral }
|
|
49693
49922
|
}));
|
|
49923
|
+
if (options?.returnRuntimes) {
|
|
49924
|
+
return createdRuntimes;
|
|
49925
|
+
}
|
|
49694
49926
|
return ids;
|
|
49695
49927
|
}
|
|
49696
49928
|
registerAgent(runtime) {
|
|
@@ -49790,10 +50022,18 @@ class ElizaOS extends EventTarget {
|
|
|
49790
50022
|
getAgentByCharacterId(characterId) {
|
|
49791
50023
|
return this.getAgents().find((runtime) => runtime.character.id === characterId);
|
|
49792
50024
|
}
|
|
49793
|
-
async sendMessage(
|
|
49794
|
-
|
|
49795
|
-
|
|
49796
|
-
|
|
50025
|
+
async sendMessage(target, message, options) {
|
|
50026
|
+
let runtime;
|
|
50027
|
+
let agentId;
|
|
50028
|
+
if (typeof target === "string") {
|
|
50029
|
+
agentId = target;
|
|
50030
|
+
runtime = this.runtimes.get(agentId);
|
|
50031
|
+
if (!runtime) {
|
|
50032
|
+
throw new Error(`Agent ${agentId} not found in registry`);
|
|
50033
|
+
}
|
|
50034
|
+
} else {
|
|
50035
|
+
runtime = target;
|
|
50036
|
+
agentId = runtime.agentId;
|
|
49797
50037
|
}
|
|
49798
50038
|
if (!runtime.messageService) {
|
|
49799
50039
|
throw new Error("messageService is not initialized on runtime");
|
|
@@ -49854,13 +50094,13 @@ class ElizaOS extends EventTarget {
|
|
|
49854
50094
|
}));
|
|
49855
50095
|
return { messageId, userMessage };
|
|
49856
50096
|
} else {
|
|
49857
|
-
const
|
|
50097
|
+
const processing = await handleMessageWithEntityContext(() => runtime.messageService.handleMessage(runtime, userMessage, undefined, processingOptions));
|
|
49858
50098
|
if (options?.onComplete)
|
|
49859
50099
|
await options.onComplete();
|
|
49860
50100
|
this.dispatchEvent(new CustomEvent("message:sent", {
|
|
49861
|
-
detail: { agentId, messageId, mode: "sync",
|
|
50101
|
+
detail: { agentId, messageId, mode: "sync", processing }
|
|
49862
50102
|
}));
|
|
49863
|
-
return { messageId, userMessage,
|
|
50103
|
+
return { messageId, userMessage, processing };
|
|
49864
50104
|
}
|
|
49865
50105
|
}
|
|
49866
50106
|
async sendMessages(messages) {
|
|
@@ -50325,5 +50565,5 @@ export {
|
|
|
50325
50565
|
AgentRuntime
|
|
50326
50566
|
};
|
|
50327
50567
|
|
|
50328
|
-
//# debugId=
|
|
50568
|
+
//# debugId=C89E737E05095B6864756E2164756E21
|
|
50329
50569
|
//# sourceMappingURL=index.node.js.map
|