@jarvis-agent/core 0.2.6 → 0.3.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.esm.js CHANGED
@@ -40142,10 +40142,77 @@ class McpTool {
40142
40142
  }
40143
40143
  }
40144
40144
 
40145
- const TOOL_NAME$6 = "task_result_check";
40146
- class TaskResultCheckTool {
40145
+ /**
40146
+ * INPUT: global.skillService for skill metadata and content
40147
+ * OUTPUT: Activated skill instructions + resource listing
40148
+ * POSITION: Chat dialogue tool enabling LLM to load domain-specific skills
40149
+ */
40150
+ const TOOL_NAME$6 = "activate_skill";
40151
+ /** Works as both DialogueTool (Chat) and Tool (Agent) */
40152
+ class ActivateSkillTool {
40147
40153
  constructor() {
40148
40154
  this.name = TOOL_NAME$6;
40155
+ this.noPlan = true;
40156
+ }
40157
+ /** Dynamic description with available skill list */
40158
+ get description() {
40159
+ const skills = global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || [];
40160
+ if (skills.length === 0) {
40161
+ return "Activate a specialized skill. No skills currently available.";
40162
+ }
40163
+ const list = skills.map((s) => `- ${s.name}: ${s.description}`).join("\n");
40164
+ return `Activate a specialized skill that provides domain-specific instructions.\n\nAvailable skills:\n${list}`;
40165
+ }
40166
+ /** Dynamic parameters with enum constraint */
40167
+ get parameters() {
40168
+ const skillNames = (global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || []).map((s) => s.name);
40169
+ return {
40170
+ type: "object",
40171
+ properties: {
40172
+ name: {
40173
+ type: "string",
40174
+ ...(skillNames.length > 0 ? { enum: skillNames } : {}),
40175
+ description: "Name of the skill to activate",
40176
+ },
40177
+ },
40178
+ required: ["name"],
40179
+ };
40180
+ }
40181
+ async execute(args) {
40182
+ const name = args.name;
40183
+ if (!global.skillService) {
40184
+ return {
40185
+ content: [{ type: "text", text: "Skill service not available" }],
40186
+ isError: true,
40187
+ };
40188
+ }
40189
+ const skill = await global.skillService.loadSkill(name);
40190
+ if (!skill) {
40191
+ return {
40192
+ content: [{ type: "text", text: `Skill "${name}" not found` }],
40193
+ isError: true,
40194
+ };
40195
+ }
40196
+ const output = [
40197
+ `<activated_skill name="${skill.metadata.name}">`,
40198
+ `<instructions>`,
40199
+ skill.instructions.trim(),
40200
+ `</instructions>`,
40201
+ ];
40202
+ if (skill.resources.length > 0) {
40203
+ output.push(`<available_resources base="${skill.basePath}">`);
40204
+ skill.resources.forEach((r) => output.push(` <file>${r}</file>`));
40205
+ output.push(`</available_resources>`);
40206
+ }
40207
+ output.push(`</activated_skill>`);
40208
+ return { content: [{ type: "text", text: output.join("\n") }] };
40209
+ }
40210
+ }
40211
+
40212
+ const TOOL_NAME$5 = "task_result_check";
40213
+ class TaskResultCheckTool {
40214
+ constructor() {
40215
+ this.name = TOOL_NAME$5;
40149
40216
  this.description = `Check the current task execution process and results, evaluate the overall completion status of the current task, and whether the output variables in the nodes are stored.`;
40150
40217
  this.parameters = {
40151
40218
  type: "object",
@@ -40249,10 +40316,10 @@ async function doTaskResultCheck(agentContext, rlm, messages, tools) {
40249
40316
  }
40250
40317
  }
40251
40318
 
40252
- const TOOL_NAME$5 = "todo_list_manager";
40319
+ const TOOL_NAME$4 = "todo_list_manager";
40253
40320
  class TodoListManagerTool {
40254
40321
  constructor() {
40255
- this.name = TOOL_NAME$5;
40322
+ this.name = TOOL_NAME$4;
40256
40323
  this.description =
40257
40324
  "Current task to-do list management, used for managing the to-do list of current tasks. During task execution, the to-do list needs to be updated according to the task execution status: completed, pending. It also detects whether tasks are being executed in repetitive loops during the execution process.";
40258
40325
  this.parameters = {
@@ -40405,6 +40472,14 @@ For repetitive tasks, when executing a forEach node, the \`${TOOL_NAME$b}\` tool
40405
40472
  * watch node
40406
40473
  monitor changes in webpage DOM elements, when executing to the watch node, require the use of the \`${TOOL_NAME$a}\` tool.
40407
40474
  </if>
40475
+ <if ${TOOL_NAME$6}Tool>
40476
+ * SKILLS
40477
+ You can use the \`${TOOL_NAME$6}\` tool to load domain-specific skill instructions when they would help complete the current task.
40478
+ <if skills>
40479
+ Available skills:
40480
+ {{skills}}
40481
+ </if>
40482
+ </if>
40408
40483
 
40409
40484
  <if mainTask>
40410
40485
  Main task: {{mainTask}}
@@ -40457,6 +40532,14 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
40457
40532
  for (let i = 0; i < tools.length; i++) {
40458
40533
  toolVars[tools[i].name + "Tool"] = true;
40459
40534
  }
40535
+ // Inject skill list when available
40536
+ let _skills = "";
40537
+ if (global.skillService) {
40538
+ const skills = global.skillService.getAllMetadata().filter((s) => s.enabled);
40539
+ if (skills.length > 0) {
40540
+ _skills = skills.map((s) => `- ${s.name}: ${s.description}`).join("\n");
40541
+ }
40542
+ }
40460
40543
  let mainTask = "";
40461
40544
  let preTaskResult = "";
40462
40545
  if (context.chain.agents.length > 1) {
@@ -40469,6 +40552,7 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
40469
40552
  agent: agent.Name,
40470
40553
  description: agent.Description,
40471
40554
  extSysPrompt: extSysPrompt?.trim() || "",
40555
+ skills: _skills,
40472
40556
  mainTask: mainTask,
40473
40557
  preTaskResult: preTaskResult.trim(),
40474
40558
  hasWatchNode: agentNode.xml.indexOf("</watch>") > -1,
@@ -40722,6 +40806,13 @@ class Agent {
40722
40806
  callback?.onHumanHelp) {
40723
40807
  tools.push(new HumanInteractTool());
40724
40808
  }
40809
+ // Add skill tool when available
40810
+ if (global.skillService) {
40811
+ const skills = global.skillService.getAllMetadata().filter((s) => s.enabled);
40812
+ if (skills.length > 0) {
40813
+ tools.push(new ActivateSkillTool());
40814
+ }
40815
+ }
40725
40816
  const toolNames = this.tools.map((tool) => tool.name);
40726
40817
  return tools.filter((tool) => toolNames.indexOf(tool.name) == -1);
40727
40818
  }
@@ -44244,7 +44335,7 @@ class ChatContext {
44244
44335
  }
44245
44336
  }
44246
44337
 
44247
- const TOOL_NAME$4 = "webpageQa";
44338
+ const TOOL_NAME$3 = "webpageQa";
44248
44339
  const WEBPAGE_QA_PROMPT = `
44249
44340
  You are a helpful assistant that can answer questions based on the provided webpage context.
44250
44341
 
@@ -44265,7 +44356,7 @@ Answer user's question based on the webpage context, the answer should be in the
44265
44356
  `;
44266
44357
  class WebpageQaTool {
44267
44358
  constructor(chatContext, params) {
44268
- this.name = TOOL_NAME$4;
44359
+ this.name = TOOL_NAME$3;
44269
44360
  this.params = params;
44270
44361
  this.chatContext = chatContext;
44271
44362
  this.description = `This tool is designed only for handling simple web-related tasks, including summarizing webpage content, extracting data from web pages, translating webpage content, and converting webpage information into more easily understandable forms. It does not interact with or operate web pages. For more complex browser tasks, please use deepAction.It does not perform operations on the webpage itself, but only involves reading the page content. Users do not need to provide the web page content, as the tool can automatically extract the content of the web page based on the tabId to respond.`;
@@ -44381,10 +44472,10 @@ class WebpageQaTool {
44381
44472
  }
44382
44473
  }
44383
44474
 
44384
- const TOOL_NAME$3 = "webSearch";
44475
+ const TOOL_NAME$2 = "webSearch";
44385
44476
  class WebSearchTool {
44386
44477
  constructor(chatContext, params) {
44387
- this.name = TOOL_NAME$3;
44478
+ this.name = TOOL_NAME$2;
44388
44479
  this.params = params;
44389
44480
  this.chatContext = chatContext;
44390
44481
  this.description = `Search the web for information using search engine API. This tool can perform web searches to find current information, news, articles, and other web content related to the query. It returns search results with titles, descriptions, URLs, and other relevant metadata, use this tool when users need the latest data/information and have NOT specified a particular platform or website, use the search tool.`;
@@ -44454,12 +44545,12 @@ async function recursiveTextNode(node, callback) {
44454
44545
  }
44455
44546
  }
44456
44547
 
44457
- const TOOL_NAME$2 = "deepAction";
44548
+ const TOOL_NAME$1 = "deepAction";
44458
44549
  const deep_action_description = "Delegate tasks to a Javis AI assistant for completion. This assistant can understand natural language instructions and has full control over both networked computers, browser agent, and multiple specialized agents ({agentNames}). The assistant can autonomously decide to use various software tools, browse the internet to query information, write code, and perform direct operations to complete tasks. He can deliver various digitized outputs (text reports, tables, images, music, videos, websites, deepSearch, programs, etc.) and handle design/analysis tasks. and execute operational tasks (such as batch following bloggers of specific topics on certain websites). For operational tasks, the focus is on completing the process actions rather than delivering final outputs, and the assistant can complete these types of tasks well. It should also be noted that users may actively mention deepsearch, which is also one of the capabilities of this tool. If users mention it, please explicitly tell the assistant to use deepsearch. Supports parallel execution of multiple tasks.";
44459
44550
  const deep_action_param_task_description = "Task description, please output the user's original instructions without omitting any information from the user's instructions, and use the same language as the user's question.";
44460
44551
  class DeepActionTool {
44461
44552
  constructor(chatContext, params) {
44462
- this.name = TOOL_NAME$2;
44553
+ this.name = TOOL_NAME$1;
44463
44554
  this.chatContext = chatContext;
44464
44555
  const agents = this.chatContext.getConfig().agents || [];
44465
44556
  const agentNames = agents.map((agent) => agent.Name).join(", ");
@@ -44616,10 +44707,10 @@ class DeepActionTool {
44616
44707
  }
44617
44708
  }
44618
44709
 
44619
- const TOOL_NAME$1 = "taskVariableStorage";
44710
+ const TOOL_NAME = "taskVariableStorage";
44620
44711
  class TaskVariableStorageTool {
44621
44712
  constructor(chatContext, params) {
44622
- this.name = TOOL_NAME$1;
44713
+ this.name = TOOL_NAME;
44623
44714
  this.params = params;
44624
44715
  this.chatContext = chatContext;
44625
44716
  this.description = `Used for storing, reading, and retrieving variable data, and maintaining input/output variables in task nodes.`;
@@ -44696,71 +44787,6 @@ class TaskVariableStorageTool {
44696
44787
  }
44697
44788
  }
44698
44789
 
44699
- /**
44700
- * INPUT: global.skillService for skill metadata and content
44701
- * OUTPUT: Activated skill instructions + resource listing
44702
- * POSITION: Chat dialogue tool enabling LLM to load domain-specific skills
44703
- */
44704
- const TOOL_NAME = "activate_skill";
44705
- class ActivateSkillTool {
44706
- constructor() {
44707
- this.name = TOOL_NAME;
44708
- }
44709
- /** Dynamic description with available skill list */
44710
- get description() {
44711
- const skills = global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || [];
44712
- if (skills.length === 0) {
44713
- return "Activate a specialized skill. No skills currently available.";
44714
- }
44715
- const list = skills.map((s) => `- ${s.name}: ${s.description}`).join("\n");
44716
- return `Activate a specialized skill that provides domain-specific instructions.\n\nAvailable skills:\n${list}`;
44717
- }
44718
- /** Dynamic parameters with enum constraint */
44719
- get parameters() {
44720
- const skillNames = (global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || []).map((s) => s.name);
44721
- return {
44722
- type: "object",
44723
- properties: {
44724
- name: {
44725
- type: "string",
44726
- ...(skillNames.length > 0 ? { enum: skillNames } : {}),
44727
- description: "Name of the skill to activate",
44728
- },
44729
- },
44730
- required: ["name"],
44731
- };
44732
- }
44733
- async execute(args) {
44734
- const name = args.name;
44735
- if (!global.skillService) {
44736
- return {
44737
- content: [{ type: "text", text: "Skill service not available" }],
44738
- isError: true,
44739
- };
44740
- }
44741
- const skill = await global.skillService.loadSkill(name);
44742
- if (!skill) {
44743
- return {
44744
- content: [{ type: "text", text: `Skill "${name}" not found` }],
44745
- isError: true,
44746
- };
44747
- }
44748
- const output = [
44749
- `<activated_skill name="${skill.metadata.name}">`,
44750
- `<instructions>`,
44751
- skill.instructions.trim(),
44752
- `</instructions>`,
44753
- ];
44754
- if (skill.resources.length > 0) {
44755
- output.push(`<available_resources base="${skill.basePath}">`);
44756
- skill.resources.forEach((r) => output.push(` <file>${r}</file>`));
44757
- output.push(`</available_resources>`);
44758
- }
44759
- output.push(`</activated_skill>`);
44760
- return { content: [{ type: "text", text: output.join("\n") }] };
44761
- }
44762
- }
44763
-
44764
44790
  const CHAT_SYSTEM_TEMPLATE = `
44765
44791
  You are {{name}}, it is an action-oriented assistant in the browser, a general-purpose intelligent agent running in the browser environment.
44766
44792
 
@@ -44771,26 +44797,27 @@ General Principles:
44771
44797
  - Users may switch topics multiple times during ongoing conversations. When calling tools, assistant must focus ONLY on the current user question and ignore previous conversation topics unless they are directly related to the current request. Each question should be treated as independent unless explicitly building on previous context.
44772
44798
 
44773
44799
  For non-chat related tasks issued by users, the following tools need to be called to complete them:
44774
- <if ${TOOL_NAME$2}Tool>
44775
- - ${TOOL_NAME$2}: This tool is used to execute tasks, delegate to Javis AI assistant with full computer control.
44776
- </if>
44777
- <if ${TOOL_NAME$4}Tool>
44778
- - ${TOOL_NAME$4}: When a user's query involves finding content in a webpage within a browser tab, extracting webpage content, summarizing webpage content, translating webpage content, read PDF page content, or converting webpage content into a more understandable format, this tool should be used. If the task requires performing actions based on webpage content, deepAction should be used. only needs to provide the required invocation parameters according to the tool's needs; users do not need to manually provide the content of the browser tab.
44800
+ <if ${TOOL_NAME$1}Tool>
44801
+ - ${TOOL_NAME$1}: This tool is used to execute tasks, delegate to Javis AI assistant with full computer control.
44779
44802
  </if>
44780
44803
  <if ${TOOL_NAME$3}Tool>
44781
- - ${TOOL_NAME$3}: Search the web for information using search engine API. This tool can perform web searches to find current information, news, articles, and other web content related to the query. It returns search results with titles, descriptions, URLs, and other relevant metadata. Use this tool when you need to find current information from the internet that may not be available in your training data.
44804
+ - ${TOOL_NAME$3}: When a user's query involves finding content in a webpage within a browser tab, extracting webpage content, summarizing webpage content, translating webpage content, read PDF page content, or converting webpage content into a more understandable format, this tool should be used. If the task requires performing actions based on webpage content, deepAction should be used. only needs to provide the required invocation parameters according to the tool's needs; users do not need to manually provide the content of the browser tab.
44782
44805
  </if>
44783
- <if ${TOOL_NAME$1}Tool>
44784
- - ${TOOL_NAME$1}: This tool is used to read output variables from task nodes and write input variables to task nodes, mainly used to retrieve variable results after task execution is completed.
44806
+ <if ${TOOL_NAME$2}Tool>
44807
+ - ${TOOL_NAME$2}: Search the web for information using search engine API. This tool can perform web searches to find current information, news, articles, and other web content related to the query. It returns search results with titles, descriptions, URLs, and other relevant metadata. Use this tool when you need to find current information from the internet that may not be available in your training data.
44785
44808
  </if>
44786
44809
  <if ${TOOL_NAME}Tool>
44787
- - ${TOOL_NAME}: Activate a specialized skill for domain-specific tasks. Use when the user's request matches an available skill.
44810
+ - ${TOOL_NAME}: This tool is used to read output variables from task nodes and write input variables to task nodes, mainly used to retrieve variable results after task execution is completed.
44811
+ </if>
44812
+ <if ${TOOL_NAME$6}Tool>
44813
+ - ${TOOL_NAME$6}: Activate a specialized skill for domain-specific tasks. Use when the user's request matches an available skill.
44788
44814
  </if>
44789
44815
  </tool_instructions>
44790
44816
 
44791
44817
  <if skills>
44792
44818
  ## Available Skills
44793
44819
  You have access to specialized skills. Use activate_skill when the user's request matches a skill.
44820
+ When you see <use_skill name="..." /> in user messages, you MUST call activate_skill with that skill name immediately before proceeding.
44794
44821
  <available_skills>
44795
44822
  {{skills}}
44796
44823
  </available_skills>