@eko-ai/eko 4.1.0 → 4.1.2
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/chat/chat-agent.d.ts +0 -1
- package/dist/chat/chat-agent.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 +52 -22
- 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 +50 -23
- package/dist/index.esm.js.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/dist/types/agent.types.d.ts +4 -0
- package/dist/types/agent.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/package.json +1 -1
|
@@ -8,7 +8,6 @@ export declare class ChatAgent {
|
|
|
8
8
|
protected maxReactLoopNum: number;
|
|
9
9
|
constructor(config: EkoDialogueConfig, chatId?: string, memory?: EkoMemory, tools?: DialogueTool[]);
|
|
10
10
|
chat(params: DialogueParams): Promise<string>;
|
|
11
|
-
private doChat;
|
|
12
11
|
initMessages(): Promise<void>;
|
|
13
12
|
protected buildSystemPrompt(params: DialogueParams, chatTools: DialogueTool[]): Promise<void>;
|
|
14
13
|
protected addUserMessage(messageId: string, user: EkoMessageUserPart[]): Promise<EkoMessage>;
|
|
@@ -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,CA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E,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"}
|
|
@@ -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"}
|
package/dist/index.cjs
CHANGED
|
@@ -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,
|
|
@@ -37132,15 +37133,15 @@ async function doCompressAgentMessages(agentContext, messages, tools) {
|
|
|
37132
37133
|
content: toolResult.content.filter((s) => s.type == "text"),
|
|
37133
37134
|
});
|
|
37134
37135
|
}
|
|
37135
|
-
function compressLargeContextMessages(messages) {
|
|
37136
|
+
function compressLargeContextMessages(messages, largeTextLength = config$1.largeTextLength) {
|
|
37136
37137
|
for (let r = 2; r < messages.length; r++) {
|
|
37137
37138
|
const message = messages[r];
|
|
37138
37139
|
if (message.role == "assistant") {
|
|
37139
37140
|
message.content = message.content.map((c) => {
|
|
37140
|
-
if (c.type == "text" && c.text.length >
|
|
37141
|
+
if (c.type == "text" && c.text.length > largeTextLength) {
|
|
37141
37142
|
return {
|
|
37142
37143
|
...c,
|
|
37143
|
-
text: sub(c.text,
|
|
37144
|
+
text: sub(c.text, largeTextLength, true),
|
|
37144
37145
|
};
|
|
37145
37146
|
}
|
|
37146
37147
|
return c;
|
|
@@ -37148,10 +37149,10 @@ function compressLargeContextMessages(messages) {
|
|
|
37148
37149
|
}
|
|
37149
37150
|
else if (message.role == "user") {
|
|
37150
37151
|
message.content = message.content.map((c) => {
|
|
37151
|
-
if (c.type == "text" && c.text.length >
|
|
37152
|
+
if (c.type == "text" && c.text.length > largeTextLength) {
|
|
37152
37153
|
return {
|
|
37153
37154
|
...c,
|
|
37154
|
-
text: sub(c.text,
|
|
37155
|
+
text: sub(c.text, largeTextLength, true),
|
|
37155
37156
|
};
|
|
37156
37157
|
}
|
|
37157
37158
|
return c;
|
|
@@ -37162,18 +37163,18 @@ function compressLargeContextMessages(messages) {
|
|
|
37162
37163
|
if (c.type == "tool-result" && c.output) {
|
|
37163
37164
|
const output = c.output;
|
|
37164
37165
|
if ((output.type == "text" || output.type == "error-text") &&
|
|
37165
|
-
output.value.length >
|
|
37166
|
+
output.value.length > largeTextLength) {
|
|
37166
37167
|
return {
|
|
37167
37168
|
...c,
|
|
37168
37169
|
output: {
|
|
37169
37170
|
...output,
|
|
37170
|
-
value: sub(output.value,
|
|
37171
|
+
value: sub(output.value, largeTextLength, true),
|
|
37171
37172
|
},
|
|
37172
37173
|
};
|
|
37173
37174
|
}
|
|
37174
37175
|
else if ((output.type == "json" || output.type == "error-json") &&
|
|
37175
|
-
JSON.stringify(output.value).length >
|
|
37176
|
-
const json_str = sub(JSON.stringify(output.value),
|
|
37176
|
+
JSON.stringify(output.value).length > largeTextLength) {
|
|
37177
|
+
const json_str = sub(JSON.stringify(output.value), largeTextLength, false);
|
|
37177
37178
|
const json_obj = fixJson(json_str);
|
|
37178
37179
|
if (JSON.stringify(json_obj).length < 10) {
|
|
37179
37180
|
return {
|
|
@@ -37199,8 +37200,8 @@ function compressLargeContextMessages(messages) {
|
|
|
37199
37200
|
for (let i = 0; i < output.value.length; i++) {
|
|
37200
37201
|
const content = output.value[i];
|
|
37201
37202
|
if (content.type == "text" &&
|
|
37202
|
-
content.text.length >
|
|
37203
|
-
content.text = sub(content.text,
|
|
37203
|
+
content.text.length > largeTextLength) {
|
|
37204
|
+
content.text = sub(content.text, largeTextLength, true);
|
|
37204
37205
|
}
|
|
37205
37206
|
}
|
|
37206
37207
|
}
|
|
@@ -37210,7 +37211,7 @@ function compressLargeContextMessages(messages) {
|
|
|
37210
37211
|
}
|
|
37211
37212
|
}
|
|
37212
37213
|
}
|
|
37213
|
-
function handleLargeContextMessages(messages) {
|
|
37214
|
+
function handleLargeContextMessages(messages, largeTextLength = config$1.largeTextLength) {
|
|
37214
37215
|
let imageNum = 0;
|
|
37215
37216
|
let fileNum = 0;
|
|
37216
37217
|
let maxNum = config$1.maxDialogueImgFileNum;
|
|
@@ -37266,7 +37267,7 @@ function handleLargeContextMessages(messages) {
|
|
|
37266
37267
|
for (let r = 0; r < toolContent.value.length; r++) {
|
|
37267
37268
|
let _content = toolContent.value[r];
|
|
37268
37269
|
if (_content.type == "text" &&
|
|
37269
|
-
_content.text?.length >
|
|
37270
|
+
_content.text?.length > largeTextLength) {
|
|
37270
37271
|
if (!longTextTools[toolResult.toolName]) {
|
|
37271
37272
|
longTextTools[toolResult.toolName] = 1;
|
|
37272
37273
|
break;
|
|
@@ -37276,7 +37277,7 @@ function handleLargeContextMessages(messages) {
|
|
|
37276
37277
|
}
|
|
37277
37278
|
_content = {
|
|
37278
37279
|
type: "text",
|
|
37279
|
-
text: sub(_content.text,
|
|
37280
|
+
text: sub(_content.text, largeTextLength, true),
|
|
37280
37281
|
};
|
|
37281
37282
|
toolContent.value[r] = _content;
|
|
37282
37283
|
}
|
|
@@ -37754,7 +37755,13 @@ class RetryLanguageModel {
|
|
|
37754
37755
|
if (!providerOptions) {
|
|
37755
37756
|
options.providerOptions = defaultLLMProviderOptions();
|
|
37756
37757
|
if (llmConfig.options && Object.keys(llmConfig.options).length > 0) {
|
|
37757
|
-
|
|
37758
|
+
// Filter out keys that start with 'stream_'
|
|
37759
|
+
options.providerOptions[llm.provider] = Object.entries(llmConfig.options).reduce((acc, [key, value]) => {
|
|
37760
|
+
if (!key.startsWith("stream_")) {
|
|
37761
|
+
acc[key] = value;
|
|
37762
|
+
}
|
|
37763
|
+
return acc;
|
|
37764
|
+
}, {});
|
|
37758
37765
|
}
|
|
37759
37766
|
}
|
|
37760
37767
|
let _options = options;
|
|
@@ -44298,10 +44305,10 @@ class DeepActionTool {
|
|
|
44298
44305
|
const taskDescription = args.taskDescription;
|
|
44299
44306
|
const tabIds = args.tabIds;
|
|
44300
44307
|
const dependentVariables = args.dependentVariables;
|
|
44301
|
-
const
|
|
44308
|
+
const chatConfig = this.chatContext.getConfig();
|
|
44302
44309
|
const globalVariables = this.chatContext.getGlobalVariables();
|
|
44303
44310
|
const eko = new Eko({
|
|
44304
|
-
...
|
|
44311
|
+
...chatConfig,
|
|
44305
44312
|
callback: this.params.callback?.taskCallback,
|
|
44306
44313
|
}, chatId);
|
|
44307
44314
|
this.chatContext.addEko(messageId, eko);
|
|
@@ -44317,7 +44324,7 @@ class DeepActionTool {
|
|
|
44317
44324
|
}
|
|
44318
44325
|
const attachments = this.params.user
|
|
44319
44326
|
.filter((part) => part.type === "file")
|
|
44320
|
-
.filter((part) => part.data && part.data.length <
|
|
44327
|
+
.filter((part) => part.data && part.data.length < 1000)
|
|
44321
44328
|
.map((part) => {
|
|
44322
44329
|
return {
|
|
44323
44330
|
file_name: part.filename,
|
|
@@ -44337,7 +44344,30 @@ class DeepActionTool {
|
|
|
44337
44344
|
datetime: this.params.datetime || new Date().toLocaleString(),
|
|
44338
44345
|
});
|
|
44339
44346
|
const context = eko.getTask(messageId);
|
|
44340
|
-
|
|
44347
|
+
Log.info("==> workflow", workflow);
|
|
44348
|
+
if (config$1.workflowConfirm && this.params.callback?.taskCallback) {
|
|
44349
|
+
const result = await new Promise((resolve) => {
|
|
44350
|
+
this.params.callback.taskCallback?.onMessage({
|
|
44351
|
+
streamType: "agent",
|
|
44352
|
+
chatId: context.chatId,
|
|
44353
|
+
taskId: context.taskId,
|
|
44354
|
+
agentName: "",
|
|
44355
|
+
type: "workflow_confirm",
|
|
44356
|
+
workflow: workflow,
|
|
44357
|
+
resolve,
|
|
44358
|
+
});
|
|
44359
|
+
});
|
|
44360
|
+
if (result == "cancel") {
|
|
44361
|
+
return {
|
|
44362
|
+
content: [
|
|
44363
|
+
{
|
|
44364
|
+
type: "text",
|
|
44365
|
+
text: "User has canceled the execution.",
|
|
44366
|
+
},
|
|
44367
|
+
],
|
|
44368
|
+
};
|
|
44369
|
+
}
|
|
44370
|
+
}
|
|
44341
44371
|
const result = await eko.execute(messageId);
|
|
44342
44372
|
const variableNames = [];
|
|
44343
44373
|
if (context.variables && context.variables.size > 0) {
|
|
@@ -44550,9 +44580,6 @@ class ChatAgent {
|
|
|
44550
44580
|
global.chatMap.set(chatId, this.chatContext);
|
|
44551
44581
|
}
|
|
44552
44582
|
async chat(params) {
|
|
44553
|
-
return this.doChat(params, false);
|
|
44554
|
-
}
|
|
44555
|
-
async doChat(params, segmentedExecution) {
|
|
44556
44583
|
const runStartTime = Date.now();
|
|
44557
44584
|
let reactLoopNum = 0;
|
|
44558
44585
|
let errorInfo = null;
|
|
@@ -44964,11 +44991,14 @@ exports.callLLM = callLLM;
|
|
|
44964
44991
|
exports.callWithReAct = callWithReAct;
|
|
44965
44992
|
exports.call_timeout = call_timeout;
|
|
44966
44993
|
exports.compressImageData = compressImageData;
|
|
44994
|
+
exports.compressLargeContextMessages = compressLargeContextMessages;
|
|
44967
44995
|
exports.config = config$1;
|
|
44968
44996
|
exports.convertToolSchema = convertToolSchema;
|
|
44969
44997
|
exports.default = Eko;
|
|
44970
44998
|
exports.extract_page_content = extract_page_content;
|
|
44999
|
+
exports.fixJson = fixJson;
|
|
44971
45000
|
exports.global = global;
|
|
45001
|
+
exports.handleLargeContextMessages = handleLargeContextMessages;
|
|
44972
45002
|
exports.mergeTools = mergeTools;
|
|
44973
45003
|
exports.parseWorkflow = parseWorkflow;
|
|
44974
45004
|
exports.resetWorkflowXml = resetWorkflowXml;
|