@eko-ai/eko 2.0.8 → 2.0.9
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/base.d.ts +2 -1
- package/dist/agent/base.d.ts.map +1 -1
- package/dist/agent/file.d.ts +16 -4
- package/dist/agent/file.d.ts.map +1 -1
- package/dist/agent/shell.d.ts.map +1 -1
- package/dist/core/plan.d.ts.map +1 -1
- package/dist/index.cjs.js +79 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +78 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/prompt/agent.d.ts.map +1 -1
- package/dist/prompt/plan.d.ts +2 -2
- package/dist/prompt/plan.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mcp.types.d.ts +2 -2
- package/dist/types/mcp.types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { Eko, Log, config, Context, AgentContext, Chain, AgentChain, SimpleSseMc
|
|
|
10
10
|
export { Agent, type AgentParams, BaseChatAgent, BaseFileAgent, BaseShellAgent, BaseTimerAgent, BaseComputerAgent, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, } from "./agent";
|
|
11
11
|
export { HumanInteractTool, TaskNodeStatusTool, VariableStorageTool, ForeachTaskTool, WatchTriggerTool, } from "./tools";
|
|
12
12
|
export { type LLMs, type LLMRequest, type StreamCallback, type HumanCallback, type EkoConfig, type Workflow, type WorkflowAgent, type WorkflowNode, type StreamCallbackMessage, } from "./types";
|
|
13
|
-
export { mergeTools, toImage, convertToolSchema } from "./common/utils";
|
|
13
|
+
export { mergeTools, toImage, convertToolSchema, uuidv4, call_timeout, } from "./common/utils";
|
|
14
14
|
//# 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,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEvD,eAAe,GAAG,CAAC;AAEnB,OAAO,EACL,GAAG,EACH,GAAG,EACH,MAAM,EACN,OAAO,EACP,YAAY,EACZ,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,kBAAkB,GACnB,CAAC;AAEF,OAAO,EACL,KAAK,EACL,KAAK,WAAW,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,
|
|
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,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEvD,eAAe,GAAG,CAAC;AAEnB,OAAO,EACL,GAAG,EACH,GAAG,EACH,MAAM,EACN,OAAO,EACP,YAAY,EACZ,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,kBAAkB,GACnB,CAAC;AAEF,OAAO,EACL,KAAK,EACL,KAAK,WAAW,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const config = {
|
|
2
|
-
name: "
|
|
2
|
+
name: "Eko",
|
|
3
3
|
platform: "mac",
|
|
4
4
|
maxReactNum: 200,
|
|
5
5
|
maxTokens: 16000,
|
|
@@ -18108,12 +18108,14 @@ UTC datetime: {datetime}
|
|
|
18108
18108
|
<mainTask>main task</mainTask>
|
|
18109
18109
|
<!-- The tasks that the current agent needs to complete, the current agent only needs to complete the currentTask -->
|
|
18110
18110
|
<currentTask>specific task</currentTask>
|
|
18111
|
-
<!-- Complete the corresponding step nodes of the task -->
|
|
18111
|
+
<!-- Complete the corresponding step nodes of the task, Only for reference -->
|
|
18112
18112
|
<nodes>
|
|
18113
18113
|
<!-- node supports input/output variables to pass dependencies -->
|
|
18114
18114
|
<node input="variable name" output="variable name" status="todo / done">task step node</node>{nodePrompt}
|
|
18115
18115
|
</nodes>
|
|
18116
18116
|
</root>
|
|
18117
|
+
|
|
18118
|
+
The output language should follow the language corresponding to the user's task.
|
|
18117
18119
|
`;
|
|
18118
18120
|
const HUMAN_PROMPT = `
|
|
18119
18121
|
* HUMAN INTERACT
|
|
@@ -18255,7 +18257,7 @@ class Agent {
|
|
|
18255
18257
|
if (mcpClient) {
|
|
18256
18258
|
let controlMcp = await this.controlMcpTools(agentContext, messages, loopNum);
|
|
18257
18259
|
if (controlMcp.mcpTools) {
|
|
18258
|
-
let mcpTools = await this.listTools(
|
|
18260
|
+
let mcpTools = await this.listTools(context, mcpClient, agentNode, controlMcp.mcpParams);
|
|
18259
18261
|
let usedTools = extractUsedTool(messages, agentTools);
|
|
18260
18262
|
let _agentTools = mergeTools(tools, usedTools);
|
|
18261
18263
|
agentTools = mergeTools(_agentTools, mcpTools);
|
|
@@ -18374,24 +18376,33 @@ class Agent {
|
|
|
18374
18376
|
async extSysPrompt(agentContext, tools) {
|
|
18375
18377
|
return "";
|
|
18376
18378
|
}
|
|
18377
|
-
async listTools(
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18382
|
-
|
|
18383
|
-
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
let
|
|
18392
|
-
|
|
18379
|
+
async listTools(context, mcpClient, agentNode, mcpParams) {
|
|
18380
|
+
try {
|
|
18381
|
+
if (!mcpClient.isConnected()) {
|
|
18382
|
+
await mcpClient.connect();
|
|
18383
|
+
}
|
|
18384
|
+
let list = await mcpClient.listTools({
|
|
18385
|
+
taskId: context.taskId,
|
|
18386
|
+
nodeId: agentNode?.id,
|
|
18387
|
+
environment: config.platform,
|
|
18388
|
+
agent_name: agentNode?.name || this.name,
|
|
18389
|
+
params: {},
|
|
18390
|
+
prompt: agentNode?.task || context.chain.taskPrompt,
|
|
18391
|
+
...(mcpParams || {}),
|
|
18392
|
+
});
|
|
18393
|
+
let mcpTools = [];
|
|
18394
|
+
for (let i = 0; i < list.length; i++) {
|
|
18395
|
+
let toolSchema = list[i];
|
|
18396
|
+
let execute = this.toolExecuter(mcpClient, toolSchema.name);
|
|
18397
|
+
let toolWrapper = new ToolWrapper(toolSchema, execute);
|
|
18398
|
+
mcpTools.push(new McpTool(toolWrapper));
|
|
18399
|
+
}
|
|
18400
|
+
return mcpTools;
|
|
18401
|
+
}
|
|
18402
|
+
catch (e) {
|
|
18403
|
+
Log.error("Mcp listTools error", e);
|
|
18404
|
+
return [];
|
|
18393
18405
|
}
|
|
18394
|
-
return mcpTools;
|
|
18395
18406
|
}
|
|
18396
18407
|
async controlMcpTools(agentContext, messages, loopNum) {
|
|
18397
18408
|
return {
|
|
@@ -18502,6 +18513,15 @@ class Agent {
|
|
|
18502
18513
|
],
|
|
18503
18514
|
};
|
|
18504
18515
|
}
|
|
18516
|
+
async loadTools(context) {
|
|
18517
|
+
if (this.mcpClient) {
|
|
18518
|
+
let mcpTools = await this.listTools(context, this.mcpClient);
|
|
18519
|
+
if (mcpTools && mcpTools.length > 0) {
|
|
18520
|
+
return mergeTools(this.tools, mcpTools);
|
|
18521
|
+
}
|
|
18522
|
+
}
|
|
18523
|
+
return this.tools;
|
|
18524
|
+
}
|
|
18505
18525
|
get Name() {
|
|
18506
18526
|
return this.name;
|
|
18507
18527
|
}
|
|
@@ -18518,7 +18538,7 @@ class Agent {
|
|
|
18518
18538
|
return this.mcpClient;
|
|
18519
18539
|
}
|
|
18520
18540
|
}
|
|
18521
|
-
async function callLLM(agentContext, rlm, messages, tools, noCompress, toolChoice) {
|
|
18541
|
+
async function callLLM(agentContext, rlm, messages, tools, noCompress, toolChoice, retry) {
|
|
18522
18542
|
if (messages.length >= config.compressThreshold && !noCompress) {
|
|
18523
18543
|
await compressAgentMessages(agentContext, rlm, messages, tools);
|
|
18524
18544
|
}
|
|
@@ -18667,6 +18687,10 @@ async function callLLM(agentContext, rlm, messages, tools, noCompress, toolChoic
|
|
|
18667
18687
|
finishReason: chunk.finishReason,
|
|
18668
18688
|
usage: chunk.usage,
|
|
18669
18689
|
});
|
|
18690
|
+
if (chunk.finishReason === "length" && messages.length >= 10 && !noCompress && !retry) {
|
|
18691
|
+
await compressAgentMessages(agentContext, rlm, messages, tools);
|
|
18692
|
+
return callLLM(agentContext, rlm, messages, tools, noCompress, toolChoice, true);
|
|
18693
|
+
}
|
|
18670
18694
|
break;
|
|
18671
18695
|
}
|
|
18672
18696
|
}
|
|
@@ -18864,19 +18888,24 @@ User Platform: {platform}
|
|
|
18864
18888
|
Task Website: {task_website}
|
|
18865
18889
|
Task Description: {taskPrompt}
|
|
18866
18890
|
`;
|
|
18867
|
-
function getPlanSystemPrompt(
|
|
18868
|
-
let agents_prompt =
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18891
|
+
async function getPlanSystemPrompt(context) {
|
|
18892
|
+
let agents_prompt = "";
|
|
18893
|
+
let agents = context.agents;
|
|
18894
|
+
for (let i = 0; i < agents.length; i++) {
|
|
18895
|
+
let agent = agents[i];
|
|
18896
|
+
let tools = await agent.loadTools(context);
|
|
18897
|
+
agents_prompt +=
|
|
18898
|
+
`<agent name="${agent.Name}">\n` +
|
|
18899
|
+
`Description: ${agent.PlanDescription || agent.Description}\n` +
|
|
18900
|
+
"Tools:\n" +
|
|
18901
|
+
tools
|
|
18902
|
+
.filter((tool) => !tool.noPlan)
|
|
18903
|
+
.map((tool) => ` - ${tool.name}: ${tool.planDescription || tool.description || ""}`)
|
|
18904
|
+
.join("\n") +
|
|
18905
|
+
"\n</agent>\n\n";
|
|
18906
|
+
}
|
|
18878
18907
|
let example_prompt = "";
|
|
18879
|
-
let hasChatAgent = agents.filter((a) => a.Name == AGENT_NAME$4).length > 0;
|
|
18908
|
+
let hasChatAgent = context.agents.filter((a) => a.Name == AGENT_NAME$4).length > 0;
|
|
18880
18909
|
const example_list = hasChatAgent
|
|
18881
18910
|
? [PLAN_CHAT_EXAMPLE, ...PLAN_EXAMPLE_LIST]
|
|
18882
18911
|
: [...PLAN_EXAMPLE_LIST];
|
|
@@ -18884,7 +18913,7 @@ function getPlanSystemPrompt(agents) {
|
|
|
18884
18913
|
example_prompt += `## Example ${i + 1}\n${example_list[i]}\n\n`;
|
|
18885
18914
|
}
|
|
18886
18915
|
return PLAN_SYSTEM_TEMPLATE.replace("{name}", config.name)
|
|
18887
|
-
.replace("{agents}", agents_prompt)
|
|
18916
|
+
.replace("{agents}", agents_prompt.trim())
|
|
18888
18917
|
.replace("{datetime}", new Date().toISOString())
|
|
18889
18918
|
.replace("{example_prompt}", example_prompt)
|
|
18890
18919
|
.trim();
|
|
@@ -18934,7 +18963,10 @@ class Planner {
|
|
|
18934
18963
|
}
|
|
18935
18964
|
else {
|
|
18936
18965
|
messages = [
|
|
18937
|
-
{
|
|
18966
|
+
{
|
|
18967
|
+
role: "system",
|
|
18968
|
+
content: await getPlanSystemPrompt(this.context),
|
|
18969
|
+
},
|
|
18938
18970
|
{
|
|
18939
18971
|
role: "user",
|
|
18940
18972
|
content: [
|
|
@@ -19365,7 +19397,9 @@ const AGENT_NAME$3 = "File";
|
|
|
19365
19397
|
class BaseFileAgent extends Agent {
|
|
19366
19398
|
constructor(work_path, llms, ext_tools, mcpClient, planDescription) {
|
|
19367
19399
|
const _tools_ = [];
|
|
19368
|
-
const prompt = work_path
|
|
19400
|
+
const prompt = work_path
|
|
19401
|
+
? `Your default working path is: ${work_path}`
|
|
19402
|
+
: "";
|
|
19369
19403
|
super({
|
|
19370
19404
|
name: AGENT_NAME$3,
|
|
19371
19405
|
description: `You are a file agent, handling file-related tasks such as creating, finding, reading, modifying files, etc.${prompt}`,
|
|
@@ -19499,7 +19533,10 @@ class BaseShellAgent extends Agent {
|
|
|
19499
19533
|
const _tools_ = [];
|
|
19500
19534
|
super({
|
|
19501
19535
|
name: AGENT_NAME$2,
|
|
19502
|
-
description:
|
|
19536
|
+
description: `Run commands in a bash shell,
|
|
19537
|
+
* You must first call create_session to create a new session when using it for the first time.
|
|
19538
|
+
* Please execute delete commands with caution, and never perform dangerous operations like \`rm -rf /\`.
|
|
19539
|
+
* Please avoid commands that may produce a very large amount of output.`,
|
|
19503
19540
|
tools: _tools_,
|
|
19504
19541
|
llms: llms,
|
|
19505
19542
|
mcpClient: mcpClient,
|
|
@@ -19589,7 +19626,7 @@ This is a computer GUI interface, observe the execution through screenshots, and
|
|
|
19589
19626
|
tools: _tools_,
|
|
19590
19627
|
llms: llms,
|
|
19591
19628
|
mcpClient: mcpClient,
|
|
19592
|
-
planDescription: "Computer operation agent, interact with the computer using the mouse and keyboard
|
|
19629
|
+
planDescription: "Computer operation agent, interact with the computer using the mouse and keyboard."
|
|
19593
19630
|
});
|
|
19594
19631
|
if (!keyboardKeys) {
|
|
19595
19632
|
if (config.platform == "windows") {
|
|
@@ -20864,7 +20901,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
20864
20901
|
},
|
|
20865
20902
|
{
|
|
20866
20903
|
name: "get_select_options",
|
|
20867
|
-
description: "Get all options from a native dropdown element",
|
|
20904
|
+
description: "Get all options from a native dropdown element (<select>).",
|
|
20868
20905
|
parameters: {
|
|
20869
20906
|
type: "object",
|
|
20870
20907
|
properties: {
|
|
@@ -20881,7 +20918,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
20881
20918
|
},
|
|
20882
20919
|
{
|
|
20883
20920
|
name: "select_option",
|
|
20884
|
-
description: "Select the native dropdown option",
|
|
20921
|
+
description: "Select the native dropdown option, Use this after get_select_options and when you need to select an option from a dropdown.",
|
|
20885
20922
|
parameters: {
|
|
20886
20923
|
type: "object",
|
|
20887
20924
|
properties: {
|
|
@@ -21420,5 +21457,5 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
21420
21457
|
}
|
|
21421
21458
|
}
|
|
21422
21459
|
|
|
21423
|
-
export { Agent, AgentChain, AgentContext, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, BaseChatAgent, BaseComputerAgent, BaseFileAgent, BaseShellAgent, BaseTimerAgent, Chain, Context, Eko, ForeachTaskTool, HumanInteractTool, Log, RetryLanguageModel, SimpleSseMcpClient, TaskNodeStatusTool, VariableStorageTool, WatchTriggerTool, config, convertToolSchema, Eko as default, mergeTools, toImage };
|
|
21460
|
+
export { Agent, AgentChain, AgentContext, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, BaseChatAgent, BaseComputerAgent, BaseFileAgent, BaseShellAgent, BaseTimerAgent, Chain, Context, Eko, ForeachTaskTool, HumanInteractTool, Log, RetryLanguageModel, SimpleSseMcpClient, TaskNodeStatusTool, VariableStorageTool, WatchTriggerTool, call_timeout, config, convertToolSchema, Eko as default, mergeTools, toImage, uuidv4 };
|
|
21424
21461
|
//# sourceMappingURL=index.esm.js.map
|