@eko-ai/eko 4.0.9 → 4.1.1
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 -2
- 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/chat/tools/deep-action.d.ts.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/{index.cjs.js → index.cjs} +208 -21
- 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 +197 -11
- 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/agent.types.d.ts +4 -0
- package/dist/types/agent.types.d.ts.map +1 -1
- package/dist/types/chat.types.d.ts +2 -1
- package/dist/types/chat.types.d.ts.map +1 -1
- package/dist/types/config.types.d.ts +1 -0
- package/dist/types/config.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/agent/eko.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eko.d.ts","sourceRoot":"","sources":["../../src/agent/eko.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eko.d.ts","sourceRoot":"","sources":["../../src/agent/eko.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAI9B,qBAAa,GAAG;IACd,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;gBAEhB,MAAM,EAAE,SAAS,EAAE,MAAM,GAAE,MAAiB;IAK3C,QAAQ,CACnB,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAiB,EACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,QAAQ,CAAC;IA8BP,MAAM,CACjB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,QAAQ,CAAC;IAcP,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA+B3C,GAAG,CACd,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAiB,EACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAClC,OAAO,CAAC,SAAS,CAAC;IAKR,WAAW,CACtB,QAAQ,EAAE,QAAQ,EAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAClC,OAAO,CAAC,WAAW,CAAC;YA0BT,aAAa;cAiHX,QAAQ,CACtB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,eAAe,EAC1B,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,MAAM,CAAC;IAqDX,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAIhD,YAAY,IAAI,MAAM,EAAE;IAIxB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IASnC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAYnD,SAAS,CACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,gBAAgB,CAAC,EAAE,OAAO,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO;IAWH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAQlE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;YAKrB,YAAY;CAa3B"}
|
|
@@ -5,12 +5,12 @@ export declare class ChatAgent {
|
|
|
5
5
|
protected memory: EkoMemory;
|
|
6
6
|
protected tools: DialogueTool[];
|
|
7
7
|
protected chatContext: ChatContext;
|
|
8
|
+
protected maxReactLoopNum: number;
|
|
8
9
|
constructor(config: EkoDialogueConfig, chatId?: string, memory?: EkoMemory, tools?: DialogueTool[]);
|
|
9
10
|
chat(params: DialogueParams): Promise<string>;
|
|
10
|
-
private doChat;
|
|
11
11
|
initMessages(): Promise<void>;
|
|
12
12
|
protected buildSystemPrompt(params: DialogueParams, chatTools: DialogueTool[]): Promise<void>;
|
|
13
|
-
protected addUserMessage(messageId: string, user:
|
|
13
|
+
protected addUserMessage(messageId: string, user: EkoMessageUserPart[]): Promise<EkoMessage>;
|
|
14
14
|
protected addMessages(messages: EkoMessage[], storage?: boolean): Promise<void>;
|
|
15
15
|
protected buildInnerTools(params: DialogueParams): DialogueTool[];
|
|
16
16
|
getMemory(): EkoMemory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-agent.d.ts","sourceRoot":"","sources":["../../src/chat/chat-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAE5B,MAAM,UAAU,CAAC;AASlB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAS7C,qBAAa,SAAS;IACpB,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;IAC5B,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC;IAChC,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-agent.d.ts","sourceRoot":"","sources":["../../src/chat/chat-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAE5B,MAAM,UAAU,CAAC;AASlB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAS7C,qBAAa,SAAS;IACpB,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;IAC5B,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC;IAChC,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACnC,SAAS,CAAC,eAAe,EAAE,MAAM,CAAM;gBAGrC,MAAM,EAAE,iBAAiB,EACzB,MAAM,GAAE,MAA2B,EACnC,MAAM,CAAC,EAAE,SAAS,EAClB,KAAK,CAAC,EAAE,YAAY,EAAE;IAQX,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAsE7C,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;cAe1B,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,YAAY,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC;cAsCA,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,kBAAkB,EAAE,GACzB,OAAO,CAAC,UAAU,CAAC;cAWN,WAAW,CACzB,QAAQ,EAAE,UAAU,EAAE,EACtB,OAAO,GAAE,OAAc,GACtB,OAAO,CAAC,IAAI,CAAC;IAUhB,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY,EAAE;IAc1D,SAAS,IAAI,SAAS;IAItB,QAAQ,IAAI,YAAY,EAAE;IAI1B,cAAc,IAAI,WAAW;cAIpB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,YAAY,EAAE,EACzB,OAAO,EAAE,KAAK,CAAC,uBAAuB,GAAG,2BAA2B,CAAC,EACrE,kBAAkB,CAAC,EAAE,kBAAkB,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAyE1B"}
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { ChatAgent } from "./chat-agent";
|
|
|
2
2
|
import { ChatContext } from "./chat-context";
|
|
3
3
|
import { WebSearchTool } from "./tools/web-search";
|
|
4
4
|
import { WebpageQaTool } from "./tools/webpage-qa";
|
|
5
|
+
import AgentWrapTool from "./tools/agent-wrap-tool";
|
|
5
6
|
import { DeepActionTool } from "./tools/deep-action";
|
|
6
7
|
import { TaskVariableStorageTool } from "./tools/variable-storage";
|
|
7
|
-
export { ChatAgent, ChatContext, WebSearchTool, WebpageQaTool, DeepActionTool, TaskVariableStorageTool, };
|
|
8
|
+
export { ChatAgent, ChatContext, AgentWrapTool, WebSearchTool, WebpageQaTool, DeepActionTool, TaskVariableStorageTool, };
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/chat/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,uBAAuB,GACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,uBAAuB,GACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-action.d.ts","sourceRoot":"","sources":["../../../src/chat/tools/deep-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EAEd,2BAA2B,EAC5B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"deep-action.d.ts","sourceRoot":"","sources":["../../../src/chat/tools/deep-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EAEd,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,eAAO,MAAM,SAAS,eAAe,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,YAAY;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAa;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IAEjC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,MAAM,CAAiB;gBAEnB,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc;IA0CtD,OAAO,CACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,QAAQ,EAAE,2BAA2B,EACrC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,UAAU,CAAC;YAgHR,cAAc;CAgB7B;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,MAAM,EAAE,MAyBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -12,6 +12,7 @@ const config$1 = {
|
|
|
12
12
|
maxOutputTokens: 16000,
|
|
13
13
|
maxRetryNum: 3,
|
|
14
14
|
agentParallel: false,
|
|
15
|
+
workflowConfirm: false,
|
|
15
16
|
compressThreshold: 80,
|
|
16
17
|
compressTokensThreshold: 80000,
|
|
17
18
|
largeTextLength: 8000,
|
|
@@ -38420,7 +38421,7 @@ const global = {
|
|
|
38420
38421
|
prompts: new Map(),
|
|
38421
38422
|
};
|
|
38422
38423
|
|
|
38423
|
-
|
|
38424
|
+
exports.GlobalPromptKey = void 0;
|
|
38424
38425
|
(function (GlobalPromptKey) {
|
|
38425
38426
|
GlobalPromptKey["planner_system"] = "planner_system";
|
|
38426
38427
|
GlobalPromptKey["planner_example"] = "planner_example";
|
|
@@ -38430,7 +38431,7 @@ var GlobalPromptKey;
|
|
|
38430
38431
|
GlobalPromptKey["webpage_qa_prompt"] = "webpage_qa_prompt";
|
|
38431
38432
|
GlobalPromptKey["deep_action_description"] = "deep_action_description";
|
|
38432
38433
|
GlobalPromptKey["deep_action_param_task_description"] = "deep_action_param_task_description";
|
|
38433
|
-
})(GlobalPromptKey || (GlobalPromptKey = {}));
|
|
38434
|
+
})(exports.GlobalPromptKey || (exports.GlobalPromptKey = {}));
|
|
38434
38435
|
|
|
38435
38436
|
class PromptTemplate {
|
|
38436
38437
|
/**
|
|
@@ -38750,8 +38751,8 @@ Attachments:
|
|
|
38750
38751
|
`;
|
|
38751
38752
|
async function getPlanSystemPrompt(context) {
|
|
38752
38753
|
const agents_prompt = await buildAgentsPrompt(context.agents, context);
|
|
38753
|
-
const planSysPrompt = global.prompts.get(GlobalPromptKey.planner_system) || PLAN_SYSTEM_TEMPLATE;
|
|
38754
|
-
const planExamplePrompt = global.prompts.get(GlobalPromptKey.planner_example) || EXAMPLE_TEMPLATE;
|
|
38754
|
+
const planSysPrompt = global.prompts.get(exports.GlobalPromptKey.planner_system) || PLAN_SYSTEM_TEMPLATE;
|
|
38755
|
+
const planExamplePrompt = global.prompts.get(exports.GlobalPromptKey.planner_example) || EXAMPLE_TEMPLATE;
|
|
38755
38756
|
return PromptTemplate.render(planSysPrompt, {
|
|
38756
38757
|
name: config$1.name,
|
|
38757
38758
|
agents: agents_prompt.trim(),
|
|
@@ -38759,7 +38760,7 @@ async function getPlanSystemPrompt(context) {
|
|
|
38759
38760
|
}).trim();
|
|
38760
38761
|
}
|
|
38761
38762
|
function getPlanUserPrompt(context, taskPrompt) {
|
|
38762
|
-
const planUserPrompt = global.prompts.get(GlobalPromptKey.planner_user) || PLAN_USER_TEMPLATE;
|
|
38763
|
+
const planUserPrompt = global.prompts.get(exports.GlobalPromptKey.planner_user) || PLAN_USER_TEMPLATE;
|
|
38763
38764
|
return PromptTemplate.render(planUserPrompt, {
|
|
38764
38765
|
taskPrompt: taskPrompt,
|
|
38765
38766
|
platform: config$1.platform,
|
|
@@ -40392,7 +40393,7 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
40392
40393
|
mainTask = context.chain.taskPrompt.trim();
|
|
40393
40394
|
preTaskResult = buildPreTaskResult(context);
|
|
40394
40395
|
}
|
|
40395
|
-
const agentSysPrompt = global.prompts.get(GlobalPromptKey.agent_system) || AGENT_SYSTEM_TEMPLATE;
|
|
40396
|
+
const agentSysPrompt = global.prompts.get(exports.GlobalPromptKey.agent_system) || AGENT_SYSTEM_TEMPLATE;
|
|
40396
40397
|
return PromptTemplate.render(agentSysPrompt, {
|
|
40397
40398
|
name: config$1.name,
|
|
40398
40399
|
agent: agent.Name,
|
|
@@ -43217,7 +43218,7 @@ class EkoMemory {
|
|
|
43217
43218
|
this.memoryConfig = memoryConfig;
|
|
43218
43219
|
}
|
|
43219
43220
|
genMessageId() {
|
|
43220
|
-
return uuidv4();
|
|
43221
|
+
return "msg-" + uuidv4();
|
|
43221
43222
|
}
|
|
43222
43223
|
async import(data) {
|
|
43223
43224
|
this.messages = [...data.messages];
|
|
@@ -44097,7 +44098,7 @@ class WebpageQaTool {
|
|
|
44097
44098
|
const tabs = await global.browserService.extractPageContents(this.chatContext.getChatId(), tabIds);
|
|
44098
44099
|
const chatConfig = this.chatContext.getConfig();
|
|
44099
44100
|
const rlm = new RetryLanguageModel(chatConfig.llms, chatConfig.chatLlms);
|
|
44100
|
-
const prompt = PromptTemplate.render(global.prompts.get(GlobalPromptKey.webpage_qa_prompt) ||
|
|
44101
|
+
const prompt = PromptTemplate.render(global.prompts.get(exports.GlobalPromptKey.webpage_qa_prompt) ||
|
|
44101
44102
|
WEBPAGE_QA_PROMPT, {
|
|
44102
44103
|
language: language,
|
|
44103
44104
|
userPrompt: this.params.user
|
|
@@ -44259,9 +44260,9 @@ class DeepActionTool {
|
|
|
44259
44260
|
this.chatContext = chatContext;
|
|
44260
44261
|
const agents = this.chatContext.getConfig().agents || [];
|
|
44261
44262
|
const agentNames = agents.map((agent) => agent.Name).join(", ");
|
|
44262
|
-
const description = global.prompts.get(GlobalPromptKey.deep_action_description) ||
|
|
44263
|
+
const description = global.prompts.get(exports.GlobalPromptKey.deep_action_description) ||
|
|
44263
44264
|
deep_action_description;
|
|
44264
|
-
const paramTaskDescription = global.prompts.get(GlobalPromptKey.deep_action_param_task_description) ||
|
|
44265
|
+
const paramTaskDescription = global.prompts.get(exports.GlobalPromptKey.deep_action_param_task_description) ||
|
|
44265
44266
|
deep_action_param_task_description;
|
|
44266
44267
|
this.description = description.replace("{agentNames}", agentNames).trim();
|
|
44267
44268
|
this.parameters = {
|
|
@@ -44298,10 +44299,10 @@ class DeepActionTool {
|
|
|
44298
44299
|
const taskDescription = args.taskDescription;
|
|
44299
44300
|
const tabIds = args.tabIds;
|
|
44300
44301
|
const dependentVariables = args.dependentVariables;
|
|
44301
|
-
const
|
|
44302
|
+
const chatConfig = this.chatContext.getConfig();
|
|
44302
44303
|
const globalVariables = this.chatContext.getGlobalVariables();
|
|
44303
44304
|
const eko = new Eko({
|
|
44304
|
-
...
|
|
44305
|
+
...chatConfig,
|
|
44305
44306
|
callback: this.params.callback?.taskCallback,
|
|
44306
44307
|
}, chatId);
|
|
44307
44308
|
this.chatContext.addEko(messageId, eko);
|
|
@@ -44317,7 +44318,7 @@ class DeepActionTool {
|
|
|
44317
44318
|
}
|
|
44318
44319
|
const attachments = this.params.user
|
|
44319
44320
|
.filter((part) => part.type === "file")
|
|
44320
|
-
.filter((part) => part.data && part.data.length <
|
|
44321
|
+
.filter((part) => part.data && part.data.length < 1000)
|
|
44321
44322
|
.map((part) => {
|
|
44322
44323
|
return {
|
|
44323
44324
|
file_name: part.filename,
|
|
@@ -44337,7 +44338,30 @@ class DeepActionTool {
|
|
|
44337
44338
|
datetime: this.params.datetime || new Date().toLocaleString(),
|
|
44338
44339
|
});
|
|
44339
44340
|
const context = eko.getTask(messageId);
|
|
44340
|
-
|
|
44341
|
+
Log.info("==> workflow", workflow);
|
|
44342
|
+
if (config$1.workflowConfirm && this.params.callback?.taskCallback) {
|
|
44343
|
+
const result = await new Promise((resolve) => {
|
|
44344
|
+
this.params.callback.taskCallback?.onMessage({
|
|
44345
|
+
streamType: "agent",
|
|
44346
|
+
chatId: context.chatId,
|
|
44347
|
+
taskId: context.taskId,
|
|
44348
|
+
agentName: "",
|
|
44349
|
+
type: "workflow_confirm",
|
|
44350
|
+
workflow: workflow,
|
|
44351
|
+
resolve,
|
|
44352
|
+
});
|
|
44353
|
+
});
|
|
44354
|
+
if (result == "cancel") {
|
|
44355
|
+
return {
|
|
44356
|
+
content: [
|
|
44357
|
+
{
|
|
44358
|
+
type: "text",
|
|
44359
|
+
text: "User has canceled the execution.",
|
|
44360
|
+
},
|
|
44361
|
+
],
|
|
44362
|
+
};
|
|
44363
|
+
}
|
|
44364
|
+
}
|
|
44341
44365
|
const result = await eko.execute(messageId);
|
|
44342
44366
|
const variableNames = [];
|
|
44343
44367
|
if (context.variables && context.variables.size > 0) {
|
|
@@ -44513,7 +44537,7 @@ Current datetime: {{datetime}}
|
|
|
44513
44537
|
The output language should match the user's conversation language.
|
|
44514
44538
|
`;
|
|
44515
44539
|
function getChatSystemPrompt(tools, datetime, memory, tabs) {
|
|
44516
|
-
const systemPrompt = global.prompts.get(GlobalPromptKey.chat_system) || CHAT_SYSTEM_TEMPLATE;
|
|
44540
|
+
const systemPrompt = global.prompts.get(exports.GlobalPromptKey.chat_system) || CHAT_SYSTEM_TEMPLATE;
|
|
44517
44541
|
const toolVars = {};
|
|
44518
44542
|
for (let i = 0; i < tools.length; i++) {
|
|
44519
44543
|
toolVars[tools[i].name + "Tool"] = true;
|
|
@@ -44542,16 +44566,14 @@ function getTabsInfo(tabs) {
|
|
|
44542
44566
|
}
|
|
44543
44567
|
|
|
44544
44568
|
class ChatAgent {
|
|
44545
|
-
constructor(config, chatId = uuidv4(), memory, tools) {
|
|
44569
|
+
constructor(config, chatId = "chat-" + uuidv4(), memory, tools) {
|
|
44570
|
+
this.maxReactLoopNum = 15;
|
|
44546
44571
|
this.tools = tools ?? [];
|
|
44547
44572
|
this.memory = memory ?? new EkoMemory();
|
|
44548
44573
|
this.chatContext = new ChatContext(chatId, config);
|
|
44549
44574
|
global.chatMap.set(chatId, this.chatContext);
|
|
44550
44575
|
}
|
|
44551
44576
|
async chat(params) {
|
|
44552
|
-
return this.doChat(params, false);
|
|
44553
|
-
}
|
|
44554
|
-
async doChat(params, segmentedExecution) {
|
|
44555
44577
|
const runStartTime = Date.now();
|
|
44556
44578
|
let reactLoopNum = 0;
|
|
44557
44579
|
let errorInfo = null;
|
|
@@ -44569,7 +44591,7 @@ class ChatAgent {
|
|
|
44569
44591
|
await this.addUserMessage(params.messageId, params.user);
|
|
44570
44592
|
const config = this.chatContext.getConfig();
|
|
44571
44593
|
const rlm = new RetryLanguageModel(config.llms, config.chatLlms);
|
|
44572
|
-
for (; reactLoopNum <
|
|
44594
|
+
for (; reactLoopNum < this.maxReactLoopNum; reactLoopNum++) {
|
|
44573
44595
|
const messages = this.memory.buildMessages();
|
|
44574
44596
|
const results = await callChatLLM(this.chatContext.getChatId(), params.messageId, rlm, messages, convertTools(chatTools), undefined, params.callback, params.signal);
|
|
44575
44597
|
const finalResult = await this.handleCallResult(params.messageId, chatTools, results, params.callback);
|
|
@@ -44764,9 +44786,174 @@ class ChatAgent {
|
|
|
44764
44786
|
}
|
|
44765
44787
|
}
|
|
44766
44788
|
|
|
44789
|
+
class AgentWrapTool {
|
|
44790
|
+
constructor(chatContext, params, agent, extra) {
|
|
44791
|
+
this.agent = agent;
|
|
44792
|
+
this.params = params;
|
|
44793
|
+
this.chatContext = chatContext;
|
|
44794
|
+
this.name =
|
|
44795
|
+
extra?.name ||
|
|
44796
|
+
agent.Name.substring(0, 1).toLowerCase() + agent.Name.substring(1);
|
|
44797
|
+
this.description =
|
|
44798
|
+
extra?.description ||
|
|
44799
|
+
agent.PlanDescription ||
|
|
44800
|
+
sub(agent.Description, 600, true, false);
|
|
44801
|
+
this.parameters = extra?.parameters || {
|
|
44802
|
+
type: "object",
|
|
44803
|
+
properties: {
|
|
44804
|
+
language: {
|
|
44805
|
+
type: "string",
|
|
44806
|
+
description: "User language used, eg: English",
|
|
44807
|
+
},
|
|
44808
|
+
taskDescription: {
|
|
44809
|
+
type: "string",
|
|
44810
|
+
description: "Task description, please do not omit any information from the user's instructions, and use the same language as the user's question.",
|
|
44811
|
+
},
|
|
44812
|
+
tabIds: {
|
|
44813
|
+
type: "array",
|
|
44814
|
+
description: "Browser Tab IDs associated with this task, When user says 'left side' or 'current', it means current active tab",
|
|
44815
|
+
items: { type: "integer" },
|
|
44816
|
+
},
|
|
44817
|
+
dependentVariables: {
|
|
44818
|
+
type: "array",
|
|
44819
|
+
description: "The current task relies on variable data from prerequisite execution outputs. Provide the name of the dependent variable.",
|
|
44820
|
+
items: {
|
|
44821
|
+
type: "string",
|
|
44822
|
+
},
|
|
44823
|
+
},
|
|
44824
|
+
},
|
|
44825
|
+
required: ["language", "taskDescription"],
|
|
44826
|
+
};
|
|
44827
|
+
}
|
|
44828
|
+
async execute(args, toolCall, messageId) {
|
|
44829
|
+
const chatId = this.chatContext.getChatId();
|
|
44830
|
+
const language = args.language;
|
|
44831
|
+
const taskDescription = args.taskDescription;
|
|
44832
|
+
const tabIds = args.tabIds;
|
|
44833
|
+
const dependentVariables = args.dependentVariables;
|
|
44834
|
+
const globalVariables = this.chatContext.getGlobalVariables();
|
|
44835
|
+
const attachments = this.params.user
|
|
44836
|
+
.filter((part) => part.type === "file")
|
|
44837
|
+
.filter((part) => part.data && part.data.length < 500)
|
|
44838
|
+
.map((part) => {
|
|
44839
|
+
return {
|
|
44840
|
+
file_name: part.filename,
|
|
44841
|
+
file_path: part.filePath,
|
|
44842
|
+
file_url: part.data,
|
|
44843
|
+
};
|
|
44844
|
+
});
|
|
44845
|
+
const taskWebsite = await this.getTaskWebsite(tabIds);
|
|
44846
|
+
const config = this.chatContext.getConfig();
|
|
44847
|
+
const contextParams = {
|
|
44848
|
+
...(this.params.extra || {}),
|
|
44849
|
+
...globalVariables,
|
|
44850
|
+
tabIds: tabIds,
|
|
44851
|
+
language: language,
|
|
44852
|
+
attachments: attachments,
|
|
44853
|
+
taskWebsite: taskWebsite,
|
|
44854
|
+
dependentVariables: dependentVariables,
|
|
44855
|
+
datetime: this.params.datetime || new Date().toLocaleString(),
|
|
44856
|
+
};
|
|
44857
|
+
const agents = [this.agent];
|
|
44858
|
+
const chain = new Chain(taskDescription);
|
|
44859
|
+
const taskId = messageId;
|
|
44860
|
+
const context = new TaskContext(chatId, taskId, {
|
|
44861
|
+
...config,
|
|
44862
|
+
callback: this.params.callback?.taskCallback,
|
|
44863
|
+
}, agents, chain);
|
|
44864
|
+
if (contextParams) {
|
|
44865
|
+
Object.keys(contextParams).forEach((key) => context.variables.set(key, contextParams[key]));
|
|
44866
|
+
}
|
|
44867
|
+
context.workflow = buildSimpleAgentWorkflow({
|
|
44868
|
+
taskId,
|
|
44869
|
+
name: "Task",
|
|
44870
|
+
agentName: this.agent.Name,
|
|
44871
|
+
task: taskDescription,
|
|
44872
|
+
});
|
|
44873
|
+
try {
|
|
44874
|
+
global.taskMap.set(taskId, context);
|
|
44875
|
+
const agentNode = context.workflow.agents[0];
|
|
44876
|
+
const resultText = await this.runAgent(context, this.agent, {
|
|
44877
|
+
type: "normal",
|
|
44878
|
+
agent: agentNode,
|
|
44879
|
+
}, new AgentChain(agentNode));
|
|
44880
|
+
return {
|
|
44881
|
+
content: [
|
|
44882
|
+
{
|
|
44883
|
+
type: "text",
|
|
44884
|
+
text: resultText || "",
|
|
44885
|
+
},
|
|
44886
|
+
],
|
|
44887
|
+
};
|
|
44888
|
+
}
|
|
44889
|
+
finally {
|
|
44890
|
+
global.taskMap.delete(taskId);
|
|
44891
|
+
}
|
|
44892
|
+
}
|
|
44893
|
+
async runAgent(context, agent, agentNode, agentChain) {
|
|
44894
|
+
const callback = this.params.callback?.taskCallback;
|
|
44895
|
+
try {
|
|
44896
|
+
agentNode.agent.status = "running";
|
|
44897
|
+
callback &&
|
|
44898
|
+
(await callback.onMessage({
|
|
44899
|
+
streamType: "agent",
|
|
44900
|
+
chatId: context.chatId,
|
|
44901
|
+
taskId: context.taskId,
|
|
44902
|
+
agentName: agentNode.agent.name,
|
|
44903
|
+
nodeId: agentNode.agent.id,
|
|
44904
|
+
type: "agent_start",
|
|
44905
|
+
agentNode: agentNode.agent,
|
|
44906
|
+
}, agent.AgentContext));
|
|
44907
|
+
agentNode.result = await agent.run(context, agentChain);
|
|
44908
|
+
agentNode.agent.status = "done";
|
|
44909
|
+
callback &&
|
|
44910
|
+
(await callback.onMessage({
|
|
44911
|
+
streamType: "agent",
|
|
44912
|
+
chatId: context.chatId,
|
|
44913
|
+
taskId: context.taskId,
|
|
44914
|
+
agentName: agentNode.agent.name,
|
|
44915
|
+
nodeId: agentNode.agent.id,
|
|
44916
|
+
type: "agent_result",
|
|
44917
|
+
agentNode: agentNode.agent,
|
|
44918
|
+
result: agentNode.result,
|
|
44919
|
+
}, agent.AgentContext));
|
|
44920
|
+
return agentNode.result;
|
|
44921
|
+
}
|
|
44922
|
+
catch (e) {
|
|
44923
|
+
agentNode.agent.status = "error";
|
|
44924
|
+
callback &&
|
|
44925
|
+
(await callback.onMessage({
|
|
44926
|
+
streamType: "agent",
|
|
44927
|
+
chatId: context.chatId,
|
|
44928
|
+
taskId: context.taskId,
|
|
44929
|
+
agentName: agentNode.agent.name,
|
|
44930
|
+
nodeId: agentNode.agent.id,
|
|
44931
|
+
type: "agent_result",
|
|
44932
|
+
agentNode: agentNode.agent,
|
|
44933
|
+
error: e,
|
|
44934
|
+
}, agent.AgentContext));
|
|
44935
|
+
throw e;
|
|
44936
|
+
}
|
|
44937
|
+
}
|
|
44938
|
+
async getTaskWebsite(tabIds) {
|
|
44939
|
+
if (!global.browserService) {
|
|
44940
|
+
return [];
|
|
44941
|
+
}
|
|
44942
|
+
const tabs = await global.browserService.loadTabs(this.chatContext.getChatId(), tabIds);
|
|
44943
|
+
return tabs.map((tab) => {
|
|
44944
|
+
return {
|
|
44945
|
+
tabId: tab.tabId,
|
|
44946
|
+
title: tab.title,
|
|
44947
|
+
url: sub(tab.url, 300),
|
|
44948
|
+
};
|
|
44949
|
+
});
|
|
44950
|
+
}
|
|
44951
|
+
}
|
|
44952
|
+
|
|
44767
44953
|
exports.Agent = Agent;
|
|
44768
44954
|
exports.AgentChain = AgentChain;
|
|
44769
44955
|
exports.AgentContext = AgentContext;
|
|
44956
|
+
exports.AgentWrapTool = AgentWrapTool;
|
|
44770
44957
|
exports.BaseBrowserAgent = BaseBrowserAgent;
|
|
44771
44958
|
exports.BaseBrowserLabelsAgent = BaseBrowserLabelsAgent;
|
|
44772
44959
|
exports.BaseBrowserScreenAgent = BaseBrowserScreenAgent;
|
|
@@ -44810,4 +44997,4 @@ exports.sub = sub;
|
|
|
44810
44997
|
exports.toFile = toFile;
|
|
44811
44998
|
exports.toImage = toImage;
|
|
44812
44999
|
exports.uuidv4 = uuidv4;
|
|
44813
|
-
//# sourceMappingURL=index.cjs.
|
|
45000
|
+
//# sourceMappingURL=index.cjs.map
|