@eko-ai/eko 4.1.1 → 4.1.3
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/index.cjs +46 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +44 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/llm/react.d.ts.map +1 -1
- package/dist/llm/rlm.d.ts.map +1 -1
- package/dist/memory/index.d.ts +2 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -14,8 +14,9 @@ export { ChatAgent, ChatContext, AgentWrapTool, WebSearchTool, WebpageQaTool, De
|
|
|
14
14
|
export { Agent, type AgentParams, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, } from "./agent";
|
|
15
15
|
export { ForeachTaskTool, WatchTriggerTool, HumanInteractTool, TaskNodeStatusTool, VariableStorageTool, } from "./tools";
|
|
16
16
|
export type { ChatService, BrowserService } from "./service";
|
|
17
|
-
export { sub, uuidv4, toFile, toImage, mergeTools, call_timeout, compressImageData, convertToolSchema, } from "./common/utils";
|
|
17
|
+
export { sub, uuidv4, toFile, toImage, fixJson, mergeTools, call_timeout, compressImageData, convertToolSchema, } from "./common/utils";
|
|
18
18
|
export { parseWorkflow, resetWorkflowXml, buildSimpleAgentWorkflow, } from "./common/xml";
|
|
19
|
+
export { handleLargeContextMessages, compressLargeContextMessages, } from "./memory";
|
|
19
20
|
export { buildAgentTree } from "./common/tree";
|
|
20
21
|
export { PromptTemplate } from "./prompt/prompt-template";
|
|
21
22
|
export { extract_page_content } from "./agent/browser/utils";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OA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,EACL,KAAK,WAAW,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EACL,GAAG,EACH,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,cAAc,SAAS,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -29778,7 +29778,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
29778
29778
|
}
|
|
29779
29779
|
|
|
29780
29780
|
// src/version.ts
|
|
29781
|
-
var VERSION$1 = "1.5.
|
|
29781
|
+
var VERSION$1 = "1.5.4";
|
|
29782
29782
|
|
|
29783
29783
|
// src/provider.ts
|
|
29784
29784
|
function createOpenRouter(options = {}) {
|
|
@@ -37098,15 +37098,15 @@ async function doCompressAgentMessages(agentContext, messages, tools) {
|
|
|
37098
37098
|
content: toolResult.content.filter((s) => s.type == "text"),
|
|
37099
37099
|
});
|
|
37100
37100
|
}
|
|
37101
|
-
function compressLargeContextMessages(messages) {
|
|
37101
|
+
function compressLargeContextMessages(messages, largeTextLength = config$1.largeTextLength) {
|
|
37102
37102
|
for (let r = 2; r < messages.length; r++) {
|
|
37103
37103
|
const message = messages[r];
|
|
37104
37104
|
if (message.role == "assistant") {
|
|
37105
37105
|
message.content = message.content.map((c) => {
|
|
37106
|
-
if (c.type == "text" && c.text.length >
|
|
37106
|
+
if (c.type == "text" && c.text.length > largeTextLength) {
|
|
37107
37107
|
return {
|
|
37108
37108
|
...c,
|
|
37109
|
-
text: sub(c.text,
|
|
37109
|
+
text: sub(c.text, largeTextLength, true),
|
|
37110
37110
|
};
|
|
37111
37111
|
}
|
|
37112
37112
|
return c;
|
|
@@ -37114,10 +37114,10 @@ function compressLargeContextMessages(messages) {
|
|
|
37114
37114
|
}
|
|
37115
37115
|
else if (message.role == "user") {
|
|
37116
37116
|
message.content = message.content.map((c) => {
|
|
37117
|
-
if (c.type == "text" && c.text.length >
|
|
37117
|
+
if (c.type == "text" && c.text.length > largeTextLength) {
|
|
37118
37118
|
return {
|
|
37119
37119
|
...c,
|
|
37120
|
-
text: sub(c.text,
|
|
37120
|
+
text: sub(c.text, largeTextLength, true),
|
|
37121
37121
|
};
|
|
37122
37122
|
}
|
|
37123
37123
|
return c;
|
|
@@ -37128,18 +37128,18 @@ function compressLargeContextMessages(messages) {
|
|
|
37128
37128
|
if (c.type == "tool-result" && c.output) {
|
|
37129
37129
|
const output = c.output;
|
|
37130
37130
|
if ((output.type == "text" || output.type == "error-text") &&
|
|
37131
|
-
output.value.length >
|
|
37131
|
+
output.value.length > largeTextLength) {
|
|
37132
37132
|
return {
|
|
37133
37133
|
...c,
|
|
37134
37134
|
output: {
|
|
37135
37135
|
...output,
|
|
37136
|
-
value: sub(output.value,
|
|
37136
|
+
value: sub(output.value, largeTextLength, true),
|
|
37137
37137
|
},
|
|
37138
37138
|
};
|
|
37139
37139
|
}
|
|
37140
37140
|
else if ((output.type == "json" || output.type == "error-json") &&
|
|
37141
|
-
JSON.stringify(output.value).length >
|
|
37142
|
-
const json_str = sub(JSON.stringify(output.value),
|
|
37141
|
+
JSON.stringify(output.value).length > largeTextLength) {
|
|
37142
|
+
const json_str = sub(JSON.stringify(output.value), largeTextLength, false);
|
|
37143
37143
|
const json_obj = fixJson(json_str);
|
|
37144
37144
|
if (JSON.stringify(json_obj).length < 10) {
|
|
37145
37145
|
return {
|
|
@@ -37165,8 +37165,8 @@ function compressLargeContextMessages(messages) {
|
|
|
37165
37165
|
for (let i = 0; i < output.value.length; i++) {
|
|
37166
37166
|
const content = output.value[i];
|
|
37167
37167
|
if (content.type == "text" &&
|
|
37168
|
-
content.text.length >
|
|
37169
|
-
content.text = sub(content.text,
|
|
37168
|
+
content.text.length > largeTextLength) {
|
|
37169
|
+
content.text = sub(content.text, largeTextLength, true);
|
|
37170
37170
|
}
|
|
37171
37171
|
}
|
|
37172
37172
|
}
|
|
@@ -37176,7 +37176,7 @@ function compressLargeContextMessages(messages) {
|
|
|
37176
37176
|
}
|
|
37177
37177
|
}
|
|
37178
37178
|
}
|
|
37179
|
-
function handleLargeContextMessages(messages) {
|
|
37179
|
+
function handleLargeContextMessages(messages, largeTextLength = config$1.largeTextLength) {
|
|
37180
37180
|
let imageNum = 0;
|
|
37181
37181
|
let fileNum = 0;
|
|
37182
37182
|
let maxNum = config$1.maxDialogueImgFileNum;
|
|
@@ -37232,7 +37232,7 @@ function handleLargeContextMessages(messages) {
|
|
|
37232
37232
|
for (let r = 0; r < toolContent.value.length; r++) {
|
|
37233
37233
|
let _content = toolContent.value[r];
|
|
37234
37234
|
if (_content.type == "text" &&
|
|
37235
|
-
_content.text?.length >
|
|
37235
|
+
_content.text?.length > largeTextLength) {
|
|
37236
37236
|
if (!longTextTools[toolResult.toolName]) {
|
|
37237
37237
|
longTextTools[toolResult.toolName] = 1;
|
|
37238
37238
|
break;
|
|
@@ -37242,7 +37242,7 @@ function handleLargeContextMessages(messages) {
|
|
|
37242
37242
|
}
|
|
37243
37243
|
_content = {
|
|
37244
37244
|
type: "text",
|
|
37245
|
-
text: sub(_content.text,
|
|
37245
|
+
text: sub(_content.text, largeTextLength, true),
|
|
37246
37246
|
};
|
|
37247
37247
|
toolContent.value[r] = _content;
|
|
37248
37248
|
}
|
|
@@ -37672,7 +37672,7 @@ class RetryLanguageModel {
|
|
|
37672
37672
|
this.llms = llms;
|
|
37673
37673
|
this.names = names || [];
|
|
37674
37674
|
context && this.setContext(context);
|
|
37675
|
-
this.stream_first_timeout = stream_first_timeout ||
|
|
37675
|
+
this.stream_first_timeout = stream_first_timeout || 45000;
|
|
37676
37676
|
this.stream_token_timeout = stream_token_timeout || 180000;
|
|
37677
37677
|
if (this.names.indexOf("default") == -1) {
|
|
37678
37678
|
this.names.push("default");
|
|
@@ -37720,7 +37720,13 @@ class RetryLanguageModel {
|
|
|
37720
37720
|
if (!providerOptions) {
|
|
37721
37721
|
options.providerOptions = defaultLLMProviderOptions();
|
|
37722
37722
|
if (llmConfig.options && Object.keys(llmConfig.options).length > 0) {
|
|
37723
|
-
|
|
37723
|
+
// Filter out keys that start with 'stream_'
|
|
37724
|
+
options.providerOptions[llm.provider] = Object.entries(llmConfig.options).reduce((acc, [key, value]) => {
|
|
37725
|
+
if (!key.startsWith("stream_")) {
|
|
37726
|
+
acc[key] = value;
|
|
37727
|
+
}
|
|
37728
|
+
return acc;
|
|
37729
|
+
}, {});
|
|
37724
37730
|
}
|
|
37725
37731
|
}
|
|
37726
37732
|
let _options = options;
|
|
@@ -37833,12 +37839,11 @@ class RetryLanguageModel {
|
|
|
37833
37839
|
}
|
|
37834
37840
|
lastError = e;
|
|
37835
37841
|
if (Log.isEnableInfo()) {
|
|
37836
|
-
Log.info(`LLM stream request, name: ${name} => `, {
|
|
37837
|
-
tools: _options.tools,
|
|
37842
|
+
Log.info(`LLM stream request, name: ${name} => `, e, {
|
|
37838
37843
|
messages: _options.prompt,
|
|
37844
|
+
tools: _options.tools,
|
|
37839
37845
|
});
|
|
37840
37846
|
}
|
|
37841
|
-
Log.error(`LLM error, name: ${name} => `, e);
|
|
37842
37847
|
}
|
|
37843
37848
|
}
|
|
37844
37849
|
return Promise.reject(lastError ? lastError : new Error("No LLM available"));
|
|
@@ -38342,14 +38347,28 @@ async function callLLM(rlm, request, streamCallback, errorHandler, finishHandler
|
|
|
38342
38347
|
}
|
|
38343
38348
|
}
|
|
38344
38349
|
catch (e) {
|
|
38345
|
-
if (
|
|
38346
|
-
await sleep(200 * (retryNum + 1) * (retryNum + 1));
|
|
38350
|
+
if (e instanceof Error && e.name === "AbortError") {
|
|
38347
38351
|
if (errorHandler) {
|
|
38348
38352
|
await errorHandler(request, e, retryNum);
|
|
38349
38353
|
}
|
|
38350
|
-
|
|
38354
|
+
Log.warn("callLLM abort error: ", e);
|
|
38355
|
+
return streamText
|
|
38356
|
+
? [
|
|
38357
|
+
{ type: "text", text: streamText },
|
|
38358
|
+
...toolParts,
|
|
38359
|
+
]
|
|
38360
|
+
: toolParts;
|
|
38361
|
+
}
|
|
38362
|
+
else {
|
|
38363
|
+
if (retryNum < config$1.maxRetryNum) {
|
|
38364
|
+
await sleep(200 * (retryNum + 1) * (retryNum + 1));
|
|
38365
|
+
if (errorHandler) {
|
|
38366
|
+
await errorHandler(request, e, retryNum);
|
|
38367
|
+
}
|
|
38368
|
+
return callLLM(rlm, request, streamCallback, errorHandler, finishHandler, ++retryNum);
|
|
38369
|
+
}
|
|
38370
|
+
throw e;
|
|
38351
38371
|
}
|
|
38352
|
-
throw e;
|
|
38353
38372
|
}
|
|
38354
38373
|
finally {
|
|
38355
38374
|
reader && reader.releaseLock();
|
|
@@ -44915,5 +44934,5 @@ class AgentWrapTool {
|
|
|
44915
44934
|
}
|
|
44916
44935
|
}
|
|
44917
44936
|
|
|
44918
|
-
export { Agent, AgentChain, AgentContext, AgentWrapTool, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, Chain, ChatAgent, ChatContext, TaskContext as Context, DeepActionTool, Eko, EkoMemory, ForeachTaskTool, GlobalPromptKey, HumanInteractTool, Log, Planner, PromptTemplate, RetryLanguageModel, SimpleHttpMcpClient, SimpleSseMcpClient, TaskContext, TaskNodeStatusTool, TaskVariableStorageTool, VariableStorageTool, WatchTriggerTool, WebSearchTool, WebpageQaTool, buildAgentTree, buildSimpleAgentWorkflow, callLLM, callWithReAct, call_timeout, compressImageData, config$1 as config, convertToolSchema, Eko as default, extract_page_content, global, mergeTools, parseWorkflow, resetWorkflowXml, sub, toFile, toImage, uuidv4 };
|
|
44937
|
+
export { Agent, AgentChain, AgentContext, AgentWrapTool, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, Chain, ChatAgent, ChatContext, TaskContext as Context, DeepActionTool, Eko, EkoMemory, ForeachTaskTool, GlobalPromptKey, HumanInteractTool, Log, Planner, PromptTemplate, RetryLanguageModel, SimpleHttpMcpClient, SimpleSseMcpClient, TaskContext, TaskNodeStatusTool, TaskVariableStorageTool, VariableStorageTool, WatchTriggerTool, WebSearchTool, WebpageQaTool, buildAgentTree, buildSimpleAgentWorkflow, callLLM, callWithReAct, call_timeout, compressImageData, compressLargeContextMessages, config$1 as config, convertToolSchema, Eko as default, extract_page_content, fixJson, global, handleLargeContextMessages, mergeTools, parseWorkflow, resetWorkflowXml, sub, toFile, toImage, uuidv4 };
|
|
44919
44938
|
//# sourceMappingURL=index.esm.js.map
|