@jarvis-agent/core 0.1.9 → 0.2.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/index.cjs +187 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +187 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ 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
13
|
export { ChatAgent, ChatContext, AgentWrapTool, WebSearchTool, WebpageQaTool, DeepActionTool, TaskVariableStorageTool, } from "./chat";
|
|
14
|
-
export { Agent, type AgentParams, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, } from "./agent";
|
|
14
|
+
export { Agent, type AgentParams, BaseFileAgent, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, } from "./agent";
|
|
15
15
|
export { ForeachTaskTool, WatchTriggerTool, HumanInteractTool, TaskNodeStatusTool, VariableStorageTool, } from "./tools";
|
|
16
16
|
export type { ChatService, BrowserService } from "./service";
|
|
17
17
|
export { sub, uuidv4, toFile, toImage, fixJson, mergeTools, call_timeout, compressImageData, convertToolSchema, } from "./common/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,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,MAAM,M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AAK,WAAW,EAChB,aAAa,EACb,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
|
@@ -42342,7 +42342,7 @@ function mark_screenshot_highlight_elements(screenshot, area_map, client_rect) {
|
|
|
42342
42342
|
});
|
|
42343
42343
|
}
|
|
42344
42344
|
|
|
42345
|
-
const AGENT_NAME = "Browser";
|
|
42345
|
+
const AGENT_NAME$1 = "Browser";
|
|
42346
42346
|
class BaseBrowserAgent extends Agent {
|
|
42347
42347
|
async go_back(agentContext) {
|
|
42348
42348
|
try {
|
|
@@ -43227,7 +43227,7 @@ class BaseBrowserLabelsAgent extends BaseBrowserAgent {
|
|
|
43227
43227
|
}
|
|
43228
43228
|
const initTools = [];
|
|
43229
43229
|
super({
|
|
43230
|
-
name: AGENT_NAME,
|
|
43230
|
+
name: AGENT_NAME$1,
|
|
43231
43231
|
description: description,
|
|
43232
43232
|
tools: initTools,
|
|
43233
43233
|
llms: llms,
|
|
@@ -43994,7 +43994,7 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
43994
43994
|
- YOU CAN DO ANYTHING ON THE BROWSER - including clicking on elements, filling forms, submitting data, etc.`;
|
|
43995
43995
|
const initTools = [];
|
|
43996
43996
|
super({
|
|
43997
|
-
name: AGENT_NAME,
|
|
43997
|
+
name: AGENT_NAME$1,
|
|
43998
43998
|
description: description,
|
|
43999
43999
|
tools: initTools,
|
|
44000
44000
|
llms: llms,
|
|
@@ -44282,6 +44282,189 @@ class BaseBrowserScreenAgent extends BaseBrowserAgent {
|
|
|
44282
44282
|
}
|
|
44283
44283
|
}
|
|
44284
44284
|
|
|
44285
|
+
const AGENT_NAME = "File";
|
|
44286
|
+
class BaseFileAgent extends Agent {
|
|
44287
|
+
constructor(work_path, llms, ext_tools, mcpClients, planDescription) {
|
|
44288
|
+
const initTools = [];
|
|
44289
|
+
const prompt = work_path
|
|
44290
|
+
? `Your working directory is: ${work_path}
|
|
44291
|
+
- When viewing file lists and outputting file paths, always include the working directory
|
|
44292
|
+
- When outputting files, there is no need to verify if the working path exists; the working path will be automatically created when writing files
|
|
44293
|
+
- Output file names must be in English
|
|
44294
|
+
- IMPORTANT: In your final summary, describe ONLY what was accomplished. NEVER include file paths, file names, or file locations. Do not verify or mention file existence
|
|
44295
|
+
- For data-related content, combine with visualization tools for display
|
|
44296
|
+
- For visualizations, generate charts first before page generation to minimize repetitive work`
|
|
44297
|
+
: "";
|
|
44298
|
+
super({
|
|
44299
|
+
name: AGENT_NAME,
|
|
44300
|
+
description: `You are a file agent, handling file-related tasks such as creating, finding, reading, modifying files, etc.${prompt}`,
|
|
44301
|
+
tools: initTools,
|
|
44302
|
+
llms: llms,
|
|
44303
|
+
mcpClients: Array.isArray(mcpClients) ? mcpClients : (mcpClients ? [mcpClients] : []),
|
|
44304
|
+
planDescription: planDescription ||
|
|
44305
|
+
`File operation agent, handles file-related tasks such as creating, finding, reading, modifying files, etc. Only supports text file output
|
|
44306
|
+
- Output file names must be in English
|
|
44307
|
+
- When users request poster or summary file output, only output txt or html files, no need to verify existence or accessibility at the end
|
|
44308
|
+
- For data-related content, combine with visualization tools for display
|
|
44309
|
+
- For visualizations, generate charts first before page generation to minimize repetitive work`,
|
|
44310
|
+
});
|
|
44311
|
+
let builtTools = this.buildInitTools();
|
|
44312
|
+
if (ext_tools && ext_tools.length > 0) {
|
|
44313
|
+
builtTools = mergeTools(builtTools, ext_tools);
|
|
44314
|
+
}
|
|
44315
|
+
builtTools.forEach((tool) => initTools.push(tool));
|
|
44316
|
+
}
|
|
44317
|
+
async do_file_read(agentContext, path, write_variable) {
|
|
44318
|
+
let file_context = await this.file_read(agentContext, path);
|
|
44319
|
+
if (file_context && file_context.length > config$1.fileTextMaxLength) {
|
|
44320
|
+
file_context = sub(file_context, config$1.fileTextMaxLength, true);
|
|
44321
|
+
}
|
|
44322
|
+
if (write_variable) {
|
|
44323
|
+
agentContext.context.variables.set(write_variable, file_context);
|
|
44324
|
+
}
|
|
44325
|
+
return {
|
|
44326
|
+
file_context: file_context,
|
|
44327
|
+
write_variable: write_variable,
|
|
44328
|
+
};
|
|
44329
|
+
}
|
|
44330
|
+
async do_file_write(agentContext, path, append, content, from_variable) {
|
|
44331
|
+
if (content == null && from_variable == null) {
|
|
44332
|
+
throw new Error(`content and from_variable cannot be both empty, cannot write to file ${path}`);
|
|
44333
|
+
}
|
|
44334
|
+
if (from_variable) {
|
|
44335
|
+
let variable_value = agentContext.context.variables.get(from_variable) || "";
|
|
44336
|
+
if (variable_value) {
|
|
44337
|
+
content = variable_value;
|
|
44338
|
+
}
|
|
44339
|
+
if (!content) {
|
|
44340
|
+
throw new Error(`Variable ${from_variable} is empty, cannot write to file ${path}`);
|
|
44341
|
+
}
|
|
44342
|
+
}
|
|
44343
|
+
if (!content) {
|
|
44344
|
+
throw new Error(`content is empty, cannot write to file ${path}`);
|
|
44345
|
+
}
|
|
44346
|
+
return await this.file_write(agentContext, path, content || "", append);
|
|
44347
|
+
}
|
|
44348
|
+
buildInitTools() {
|
|
44349
|
+
return [
|
|
44350
|
+
{
|
|
44351
|
+
name: "file_list",
|
|
44352
|
+
description: "Getting a list of files in a specified directory.",
|
|
44353
|
+
parameters: {
|
|
44354
|
+
type: "object",
|
|
44355
|
+
properties: {
|
|
44356
|
+
path: {
|
|
44357
|
+
type: "string",
|
|
44358
|
+
description: "File directory path",
|
|
44359
|
+
},
|
|
44360
|
+
},
|
|
44361
|
+
required: ["path"],
|
|
44362
|
+
},
|
|
44363
|
+
execute: async (args, agentContext) => {
|
|
44364
|
+
return await this.callInnerTool(() => this.file_list(agentContext, args.path));
|
|
44365
|
+
},
|
|
44366
|
+
},
|
|
44367
|
+
{
|
|
44368
|
+
name: "file_read",
|
|
44369
|
+
description: "Read file content. Use to read files or check file content.",
|
|
44370
|
+
parameters: {
|
|
44371
|
+
type: "object",
|
|
44372
|
+
properties: {
|
|
44373
|
+
path: {
|
|
44374
|
+
type: "string",
|
|
44375
|
+
description: "File path",
|
|
44376
|
+
},
|
|
44377
|
+
write_variable: {
|
|
44378
|
+
type: "string",
|
|
44379
|
+
description: "Variable name, the content after reading is simultaneously written to the variable, facilitating direct loading from the variable in subsequent operations.",
|
|
44380
|
+
},
|
|
44381
|
+
},
|
|
44382
|
+
required: ["path"],
|
|
44383
|
+
},
|
|
44384
|
+
execute: async (args, agentContext) => {
|
|
44385
|
+
return await this.callInnerTool(() => this.do_file_read(agentContext, args.path, args.write_variable));
|
|
44386
|
+
},
|
|
44387
|
+
},
|
|
44388
|
+
{
|
|
44389
|
+
name: "file_write",
|
|
44390
|
+
description: "Overwrite or append content to a file. Use for creating new files, appending content, or modifying existing files, only supports txt/md/json/csv or other text formats.",
|
|
44391
|
+
parameters: {
|
|
44392
|
+
type: "object",
|
|
44393
|
+
properties: {
|
|
44394
|
+
path: {
|
|
44395
|
+
type: "string",
|
|
44396
|
+
description: "File path",
|
|
44397
|
+
},
|
|
44398
|
+
append: {
|
|
44399
|
+
type: "boolean",
|
|
44400
|
+
description: "(Optional) Whether to use append mode",
|
|
44401
|
+
default: false,
|
|
44402
|
+
},
|
|
44403
|
+
content: {
|
|
44404
|
+
type: "string",
|
|
44405
|
+
description: "Text content, write content directly to the file.",
|
|
44406
|
+
},
|
|
44407
|
+
from_variable: {
|
|
44408
|
+
type: "string",
|
|
44409
|
+
description: "Variable name, read content from the variable and write it.",
|
|
44410
|
+
},
|
|
44411
|
+
},
|
|
44412
|
+
required: ["path"],
|
|
44413
|
+
},
|
|
44414
|
+
execute: async (args, agentContext) => {
|
|
44415
|
+
return await this.callInnerTool(() => this.do_file_write(agentContext, args.path, (args.append || false), args.content, args.from_variable));
|
|
44416
|
+
},
|
|
44417
|
+
},
|
|
44418
|
+
{
|
|
44419
|
+
name: "file_str_replace",
|
|
44420
|
+
description: "Replace specified string in a file. Use for updating specific content in files.",
|
|
44421
|
+
parameters: {
|
|
44422
|
+
type: "object",
|
|
44423
|
+
properties: {
|
|
44424
|
+
path: {
|
|
44425
|
+
type: "string",
|
|
44426
|
+
description: "File path",
|
|
44427
|
+
},
|
|
44428
|
+
old_str: {
|
|
44429
|
+
type: "string",
|
|
44430
|
+
description: "Original string to be replaced",
|
|
44431
|
+
},
|
|
44432
|
+
new_str: {
|
|
44433
|
+
type: "string",
|
|
44434
|
+
description: "New string to replace with",
|
|
44435
|
+
},
|
|
44436
|
+
},
|
|
44437
|
+
required: ["path", "old_str", "new_str"],
|
|
44438
|
+
},
|
|
44439
|
+
execute: async (args, agentContext) => {
|
|
44440
|
+
return await this.callInnerTool(() => this.file_str_replace(agentContext, args.path, args.old_str, args.new_str));
|
|
44441
|
+
},
|
|
44442
|
+
},
|
|
44443
|
+
{
|
|
44444
|
+
name: "file_find_by_name",
|
|
44445
|
+
description: "Find files by name pattern in specified directory. Use for locating files with specific naming patterns.",
|
|
44446
|
+
parameters: {
|
|
44447
|
+
type: "object",
|
|
44448
|
+
properties: {
|
|
44449
|
+
path: {
|
|
44450
|
+
type: "string",
|
|
44451
|
+
description: "Absolute path of directory to search",
|
|
44452
|
+
},
|
|
44453
|
+
glob: {
|
|
44454
|
+
type: "string",
|
|
44455
|
+
description: "Filename pattern using glob syntax wildcards, Example: **/*.txt",
|
|
44456
|
+
},
|
|
44457
|
+
},
|
|
44458
|
+
required: ["path", "glob"],
|
|
44459
|
+
},
|
|
44460
|
+
execute: async (args, agentContext) => {
|
|
44461
|
+
return await this.callInnerTool(() => this.file_find_by_name(agentContext, args.path, args.glob));
|
|
44462
|
+
},
|
|
44463
|
+
},
|
|
44464
|
+
];
|
|
44465
|
+
}
|
|
44466
|
+
}
|
|
44467
|
+
|
|
44285
44468
|
class EkoMemory {
|
|
44286
44469
|
constructor(systemPrompt, messages = [], memoryConfig = config$1.memoryConfig) {
|
|
44287
44470
|
this.messages = messages;
|
|
@@ -46021,5 +46204,5 @@ class AgentWrapTool {
|
|
|
46021
46204
|
}
|
|
46022
46205
|
}
|
|
46023
46206
|
|
|
46024
|
-
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 };
|
|
46207
|
+
export { Agent, AgentChain, AgentContext, AgentWrapTool, BaseBrowserAgent, BaseBrowserLabelsAgent, BaseBrowserScreenAgent, BaseFileAgent, 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 };
|
|
46025
46208
|
//# sourceMappingURL=index.esm.js.map
|