@eko-ai/eko 4.0.9 → 4.1.0
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/agent/eko.d.ts.map +1 -1
- package/dist/chat/chat-agent.d.ts +2 -1
- package/dist/chat/chat-agent.d.ts.map +1 -1
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/{index.cjs.js → index.cjs} +180 -14
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +169 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/service/chat-service.d.ts +2 -2
- package/dist/service/chat-service.d.ts.map +1 -1
- package/dist/service/workflow-logs-service.d.ts +8 -0
- package/dist/service/workflow-logs-service.d.ts.map +1 -0
- package/dist/service/workflow-service.d.ts +4 -0
- package/dist/service/workflow-service.d.ts.map +1 -0
- package/dist/types/chat.types.d.ts +2 -1
- package/dist/types/chat.types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +14 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/service.types.d.ts +1 -1
- package/dist/types/service.types.d.ts.map +1 -1
- package/dist/types/workflow-logs.types.d.ts +42 -0
- package/dist/types/workflow-logs.types.d.ts.map +1 -0
- package/package.json +7 -6
- package/dist/index.cjs.js.map +0 -1
- package/dist/prompt/prompt_template.d.ts +0 -30
- package/dist/prompt/prompt_template.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,14 +10,14 @@ import TaskContext, { AgentContext } from "./agent/agent-context";
|
|
|
10
10
|
import { RetryLanguageModel, callLLM, callWithReAct } from "./llm";
|
|
11
11
|
export default Eko;
|
|
12
12
|
export { Eko, EkoMemory, Log, config, global, Chain, Planner, AgentChain, TaskContext, AgentContext, SimpleSseMcpClient, SimpleHttpMcpClient, RetryLanguageModel, TaskContext as Context, callLLM, callWithReAct, };
|
|
13
|
-
export { ChatAgent, ChatContext, WebSearchTool, WebpageQaTool, DeepActionTool, TaskVariableStorageTool, } from "./chat";
|
|
13
|
+
export { ChatAgent, ChatContext, AgentWrapTool, WebSearchTool, WebpageQaTool, DeepActionTool, TaskVariableStorageTool, } from "./chat";
|
|
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 { type LLMs, type LLMRequest, type HumanCallback, type Workflow, type EkoConfig, type WorkflowNode, type WorkflowAgent, type AgentStreamMessage, type AgentStreamCallback, type AgentStreamCallback as StreamCallback, type AgentStreamMessage as StreamCallbackMessage, } from "./types";
|
|
18
17
|
export { sub, uuidv4, toFile, toImage, mergeTools, call_timeout, compressImageData, convertToolSchema, } from "./common/utils";
|
|
19
18
|
export { parseWorkflow, resetWorkflowXml, buildSimpleAgentWorkflow, } from "./common/xml";
|
|
20
19
|
export { buildAgentTree } from "./common/tree";
|
|
21
20
|
export { PromptTemplate } from "./prompt/prompt-template";
|
|
22
21
|
export { extract_page_content } from "./agent/browser/utils";
|
|
22
|
+
export * from "./types";
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
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,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MA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,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,cAAc,SAAS,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -43182,7 +43182,7 @@ class EkoMemory {
|
|
|
43182
43182
|
this.memoryConfig = memoryConfig;
|
|
43183
43183
|
}
|
|
43184
43184
|
genMessageId() {
|
|
43185
|
-
return uuidv4();
|
|
43185
|
+
return "msg-" + uuidv4();
|
|
43186
43186
|
}
|
|
43187
43187
|
async import(data) {
|
|
43188
43188
|
this.messages = [...data.messages];
|
|
@@ -44507,7 +44507,8 @@ function getTabsInfo(tabs) {
|
|
|
44507
44507
|
}
|
|
44508
44508
|
|
|
44509
44509
|
class ChatAgent {
|
|
44510
|
-
constructor(config, chatId = uuidv4(), memory, tools) {
|
|
44510
|
+
constructor(config, chatId = "chat-" + uuidv4(), memory, tools) {
|
|
44511
|
+
this.maxReactLoopNum = 15;
|
|
44511
44512
|
this.tools = tools ?? [];
|
|
44512
44513
|
this.memory = memory ?? new EkoMemory();
|
|
44513
44514
|
this.chatContext = new ChatContext(chatId, config);
|
|
@@ -44534,7 +44535,7 @@ class ChatAgent {
|
|
|
44534
44535
|
await this.addUserMessage(params.messageId, params.user);
|
|
44535
44536
|
const config = this.chatContext.getConfig();
|
|
44536
44537
|
const rlm = new RetryLanguageModel(config.llms, config.chatLlms);
|
|
44537
|
-
for (; reactLoopNum <
|
|
44538
|
+
for (; reactLoopNum < this.maxReactLoopNum; reactLoopNum++) {
|
|
44538
44539
|
const messages = this.memory.buildMessages();
|
|
44539
44540
|
const results = await callChatLLM(this.chatContext.getChatId(), params.messageId, rlm, messages, convertTools(chatTools), undefined, params.callback, params.signal);
|
|
44540
44541
|
const finalResult = await this.handleCallResult(params.messageId, chatTools, results, params.callback);
|
|
@@ -44729,5 +44730,169 @@ class ChatAgent {
|
|
|
44729
44730
|
}
|
|
44730
44731
|
}
|
|
44731
44732
|
|
|
44732
|
-
|
|
44733
|
+
class AgentWrapTool {
|
|
44734
|
+
constructor(chatContext, params, agent, extra) {
|
|
44735
|
+
this.agent = agent;
|
|
44736
|
+
this.params = params;
|
|
44737
|
+
this.chatContext = chatContext;
|
|
44738
|
+
this.name =
|
|
44739
|
+
extra?.name ||
|
|
44740
|
+
agent.Name.substring(0, 1).toLowerCase() + agent.Name.substring(1);
|
|
44741
|
+
this.description =
|
|
44742
|
+
extra?.description ||
|
|
44743
|
+
agent.PlanDescription ||
|
|
44744
|
+
sub(agent.Description, 600, true, false);
|
|
44745
|
+
this.parameters = extra?.parameters || {
|
|
44746
|
+
type: "object",
|
|
44747
|
+
properties: {
|
|
44748
|
+
language: {
|
|
44749
|
+
type: "string",
|
|
44750
|
+
description: "User language used, eg: English",
|
|
44751
|
+
},
|
|
44752
|
+
taskDescription: {
|
|
44753
|
+
type: "string",
|
|
44754
|
+
description: "Task description, please do not omit any information from the user's instructions, and use the same language as the user's question.",
|
|
44755
|
+
},
|
|
44756
|
+
tabIds: {
|
|
44757
|
+
type: "array",
|
|
44758
|
+
description: "Browser Tab IDs associated with this task, When user says 'left side' or 'current', it means current active tab",
|
|
44759
|
+
items: { type: "integer" },
|
|
44760
|
+
},
|
|
44761
|
+
dependentVariables: {
|
|
44762
|
+
type: "array",
|
|
44763
|
+
description: "The current task relies on variable data from prerequisite execution outputs. Provide the name of the dependent variable.",
|
|
44764
|
+
items: {
|
|
44765
|
+
type: "string",
|
|
44766
|
+
},
|
|
44767
|
+
},
|
|
44768
|
+
},
|
|
44769
|
+
required: ["language", "taskDescription"],
|
|
44770
|
+
};
|
|
44771
|
+
}
|
|
44772
|
+
async execute(args, toolCall, messageId) {
|
|
44773
|
+
const chatId = this.chatContext.getChatId();
|
|
44774
|
+
const language = args.language;
|
|
44775
|
+
const taskDescription = args.taskDescription;
|
|
44776
|
+
const tabIds = args.tabIds;
|
|
44777
|
+
const dependentVariables = args.dependentVariables;
|
|
44778
|
+
const globalVariables = this.chatContext.getGlobalVariables();
|
|
44779
|
+
const attachments = this.params.user
|
|
44780
|
+
.filter((part) => part.type === "file")
|
|
44781
|
+
.filter((part) => part.data && part.data.length < 500)
|
|
44782
|
+
.map((part) => {
|
|
44783
|
+
return {
|
|
44784
|
+
file_name: part.filename,
|
|
44785
|
+
file_path: part.filePath,
|
|
44786
|
+
file_url: part.data,
|
|
44787
|
+
};
|
|
44788
|
+
});
|
|
44789
|
+
const taskWebsite = await this.getTaskWebsite(tabIds);
|
|
44790
|
+
const config = this.chatContext.getConfig();
|
|
44791
|
+
const contextParams = {
|
|
44792
|
+
...(this.params.extra || {}),
|
|
44793
|
+
...globalVariables,
|
|
44794
|
+
tabIds: tabIds,
|
|
44795
|
+
language: language,
|
|
44796
|
+
attachments: attachments,
|
|
44797
|
+
taskWebsite: taskWebsite,
|
|
44798
|
+
dependentVariables: dependentVariables,
|
|
44799
|
+
datetime: this.params.datetime || new Date().toLocaleString(),
|
|
44800
|
+
};
|
|
44801
|
+
const agents = [this.agent];
|
|
44802
|
+
const chain = new Chain(taskDescription);
|
|
44803
|
+
const taskId = messageId;
|
|
44804
|
+
const context = new TaskContext(chatId, taskId, {
|
|
44805
|
+
...config,
|
|
44806
|
+
callback: this.params.callback?.taskCallback,
|
|
44807
|
+
}, agents, chain);
|
|
44808
|
+
if (contextParams) {
|
|
44809
|
+
Object.keys(contextParams).forEach((key) => context.variables.set(key, contextParams[key]));
|
|
44810
|
+
}
|
|
44811
|
+
context.workflow = buildSimpleAgentWorkflow({
|
|
44812
|
+
taskId,
|
|
44813
|
+
name: "Task",
|
|
44814
|
+
agentName: this.agent.Name,
|
|
44815
|
+
task: taskDescription,
|
|
44816
|
+
});
|
|
44817
|
+
try {
|
|
44818
|
+
global.taskMap.set(taskId, context);
|
|
44819
|
+
const agentNode = context.workflow.agents[0];
|
|
44820
|
+
const resultText = await this.runAgent(context, this.agent, {
|
|
44821
|
+
type: "normal",
|
|
44822
|
+
agent: agentNode,
|
|
44823
|
+
}, new AgentChain(agentNode));
|
|
44824
|
+
return {
|
|
44825
|
+
content: [
|
|
44826
|
+
{
|
|
44827
|
+
type: "text",
|
|
44828
|
+
text: resultText || "",
|
|
44829
|
+
},
|
|
44830
|
+
],
|
|
44831
|
+
};
|
|
44832
|
+
}
|
|
44833
|
+
finally {
|
|
44834
|
+
global.taskMap.delete(taskId);
|
|
44835
|
+
}
|
|
44836
|
+
}
|
|
44837
|
+
async runAgent(context, agent, agentNode, agentChain) {
|
|
44838
|
+
const callback = this.params.callback?.taskCallback;
|
|
44839
|
+
try {
|
|
44840
|
+
agentNode.agent.status = "running";
|
|
44841
|
+
callback &&
|
|
44842
|
+
(await callback.onMessage({
|
|
44843
|
+
streamType: "agent",
|
|
44844
|
+
chatId: context.chatId,
|
|
44845
|
+
taskId: context.taskId,
|
|
44846
|
+
agentName: agentNode.agent.name,
|
|
44847
|
+
nodeId: agentNode.agent.id,
|
|
44848
|
+
type: "agent_start",
|
|
44849
|
+
agentNode: agentNode.agent,
|
|
44850
|
+
}, agent.AgentContext));
|
|
44851
|
+
agentNode.result = await agent.run(context, agentChain);
|
|
44852
|
+
agentNode.agent.status = "done";
|
|
44853
|
+
callback &&
|
|
44854
|
+
(await callback.onMessage({
|
|
44855
|
+
streamType: "agent",
|
|
44856
|
+
chatId: context.chatId,
|
|
44857
|
+
taskId: context.taskId,
|
|
44858
|
+
agentName: agentNode.agent.name,
|
|
44859
|
+
nodeId: agentNode.agent.id,
|
|
44860
|
+
type: "agent_result",
|
|
44861
|
+
agentNode: agentNode.agent,
|
|
44862
|
+
result: agentNode.result,
|
|
44863
|
+
}, agent.AgentContext));
|
|
44864
|
+
return agentNode.result;
|
|
44865
|
+
}
|
|
44866
|
+
catch (e) {
|
|
44867
|
+
agentNode.agent.status = "error";
|
|
44868
|
+
callback &&
|
|
44869
|
+
(await callback.onMessage({
|
|
44870
|
+
streamType: "agent",
|
|
44871
|
+
chatId: context.chatId,
|
|
44872
|
+
taskId: context.taskId,
|
|
44873
|
+
agentName: agentNode.agent.name,
|
|
44874
|
+
nodeId: agentNode.agent.id,
|
|
44875
|
+
type: "agent_result",
|
|
44876
|
+
agentNode: agentNode.agent,
|
|
44877
|
+
error: e,
|
|
44878
|
+
}, agent.AgentContext));
|
|
44879
|
+
throw e;
|
|
44880
|
+
}
|
|
44881
|
+
}
|
|
44882
|
+
async getTaskWebsite(tabIds) {
|
|
44883
|
+
if (!global.browserService) {
|
|
44884
|
+
return [];
|
|
44885
|
+
}
|
|
44886
|
+
const tabs = await global.browserService.loadTabs(this.chatContext.getChatId(), tabIds);
|
|
44887
|
+
return tabs.map((tab) => {
|
|
44888
|
+
return {
|
|
44889
|
+
tabId: tab.tabId,
|
|
44890
|
+
title: tab.title,
|
|
44891
|
+
url: sub(tab.url, 300),
|
|
44892
|
+
};
|
|
44893
|
+
});
|
|
44894
|
+
}
|
|
44895
|
+
}
|
|
44896
|
+
|
|
44897
|
+
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 };
|
|
44733
44898
|
//# sourceMappingURL=index.esm.js.map
|