@jarvis-agent/core 0.2.6 → 0.3.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/base.d.ts.map +1 -1
- package/dist/chat/tools/activate-skill-tool.d.ts +5 -3
- package/dist/chat/tools/activate-skill-tool.d.ts.map +1 -1
- package/dist/index.cjs +240 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +240 -99
- package/dist/index.esm.js.map +1 -1
- package/dist/prompt/agent.d.ts.map +1 -1
- package/dist/prompt/chat.d.ts.map +1 -1
- package/dist/tools/watch-trigger.d.ts +6 -0
- package/dist/tools/watch-trigger.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/agent/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/agent/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/agent/base.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAa,MAAM,SAAS,CAAC;AAShD,OAAO,EACL,IAAI,EAEJ,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAC;AAS1B,OAAO,WAAW,EAAE,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK5D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,UAAU,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,MAAM;IAOV,oBAAoB,CACzB,SAAS,CAAC,EAAE,2BAA2B,EAAE,GACxC,OAAO;IAIV,IAAI,IAAI,IAAI,MAAM,EAAE,GAAG,SAAS,CAE/B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED,IAAI,eAAe,uBAElB;IAED,IAAI,UAAU,IAAI,UAAU,EAAE,CAE7B;IAED,IAAI,SAAS,IAAI,UAAU,GAAG,SAAS,CAEtC;IAED,IAAI,YAAY,IAAI,YAAY,GAAG,SAAS,CAE3C;CACF"}
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
* POSITION: Chat dialogue tool enabling LLM to load domain-specific skills
|
|
5
5
|
*/
|
|
6
6
|
import { JSONSchema7 } from "@ai-sdk/provider";
|
|
7
|
-
import { DialogueTool, ToolResult } from "../../types";
|
|
7
|
+
import { DialogueTool, Tool, ToolResult } from "../../types";
|
|
8
8
|
export declare const TOOL_NAME = "activate_skill";
|
|
9
|
-
|
|
9
|
+
/** Works as both DialogueTool (Chat) and Tool (Agent) */
|
|
10
|
+
export default class ActivateSkillTool implements DialogueTool, Tool {
|
|
10
11
|
readonly name: string;
|
|
12
|
+
readonly noPlan: boolean;
|
|
11
13
|
/** Dynamic description with available skill list */
|
|
12
14
|
get description(): string;
|
|
13
15
|
/** Dynamic parameters with enum constraint */
|
|
14
16
|
get parameters(): JSONSchema7;
|
|
15
|
-
execute(args: Record<string, unknown
|
|
17
|
+
execute(args: Record<string, unknown>, ..._rest: unknown[]): Promise<ToolResult>;
|
|
16
18
|
}
|
|
17
19
|
export { ActivateSkillTool };
|
|
18
20
|
//# sourceMappingURL=activate-skill-tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activate-skill-tool.d.ts","sourceRoot":"","sources":["../../../src/chat/tools/activate-skill-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"activate-skill-tool.d.ts","sourceRoot":"","sources":["../../../src/chat/tools/activate-skill-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C,yDAAyD;AACzD,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,YAAY,EAAE,IAAI;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAa;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAQ;IAEhC,oDAAoD;IACpD,IAAI,WAAW,IAAI,MAAM,CAQxB;IAED,8CAA8C;IAC9C,IAAI,UAAU,IAAI,WAAW,CAgB5B;IAEK,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAkCvF;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -39704,6 +39704,24 @@ Output:
|
|
|
39704
39704
|
"changed": true,
|
|
39705
39705
|
"changeInfo": "New message received in the group chat. The message content is: 'Hello, how are you?'"
|
|
39706
39706
|
}`;
|
|
39707
|
+
const watch_text_system_prompt = `You are a page content analyzer. Given a page content and a condition description, determine if the condition is currently met on the page.
|
|
39708
|
+
Return ONLY a JSON object, no other text.
|
|
39709
|
+
- "changed": true means the condition IS met (e.g. the target button exists, the status has changed to the expected value)
|
|
39710
|
+
- "changed": false means the condition is NOT yet met
|
|
39711
|
+
|
|
39712
|
+
## Example
|
|
39713
|
+
Condition: Monitor for a "Retry" button appearing on the page
|
|
39714
|
+
### Condition not met
|
|
39715
|
+
Output:
|
|
39716
|
+
{
|
|
39717
|
+
"changed": false
|
|
39718
|
+
}
|
|
39719
|
+
### Condition met
|
|
39720
|
+
Output:
|
|
39721
|
+
{
|
|
39722
|
+
"changed": true,
|
|
39723
|
+
"changeInfo": "The 'Retry' button is present on the page at index 127-128"
|
|
39724
|
+
}`;
|
|
39707
39725
|
class WatchTriggerTool {
|
|
39708
39726
|
constructor() {
|
|
39709
39727
|
this.name = TOOL_NAME$a;
|
|
@@ -39768,12 +39786,34 @@ class WatchTriggerTool {
|
|
|
39768
39786
|
],
|
|
39769
39787
|
};
|
|
39770
39788
|
}
|
|
39789
|
+
const rlm = new RetryLanguageModel(agentContext.context.config.llms, agentContext.agent.Llms, agentContext.context.config.globalConfig?.streamFirstTimeout, agentContext.context.config.globalConfig?.streamTokenTimeout, agentContext);
|
|
39790
|
+
const useVision = this.isVisionModel(rlm);
|
|
39791
|
+
// Initial condition check (text-based, works with all models)
|
|
39792
|
+
const pageContent = await this.get_page_content(agentContext);
|
|
39793
|
+
const initialCheck = await this.is_condition_met(rlm, pageContent, task_description, agentContext);
|
|
39794
|
+
if (initialCheck.changed) {
|
|
39795
|
+
return {
|
|
39796
|
+
content: [
|
|
39797
|
+
{
|
|
39798
|
+
type: "text",
|
|
39799
|
+
text: initialCheck.changeInfo || "Condition already met on page.",
|
|
39800
|
+
},
|
|
39801
|
+
],
|
|
39802
|
+
};
|
|
39803
|
+
}
|
|
39804
|
+
// Enter monitoring loop
|
|
39771
39805
|
await this.init_eko_observer(agentContext);
|
|
39772
|
-
const image1 = await this.get_screenshot(agentContext);
|
|
39773
39806
|
const start = new Date().getTime();
|
|
39774
39807
|
const timeout = (args.timeout || 5) * 60000;
|
|
39775
39808
|
const frequency = Math.max(500, (args.frequency || 1) * 1000);
|
|
39776
|
-
|
|
39809
|
+
let image1;
|
|
39810
|
+
let content1;
|
|
39811
|
+
if (useVision) {
|
|
39812
|
+
image1 = await this.get_screenshot(agentContext);
|
|
39813
|
+
}
|
|
39814
|
+
else {
|
|
39815
|
+
content1 = pageContent;
|
|
39816
|
+
}
|
|
39777
39817
|
while (new Date().getTime() - start < timeout) {
|
|
39778
39818
|
await agentContext.context.checkAborted();
|
|
39779
39819
|
await new Promise((resolve) => setTimeout(resolve, frequency));
|
|
@@ -39782,17 +39822,32 @@ class WatchTriggerTool {
|
|
|
39782
39822
|
continue;
|
|
39783
39823
|
}
|
|
39784
39824
|
await this.init_eko_observer(agentContext);
|
|
39785
|
-
|
|
39786
|
-
|
|
39787
|
-
|
|
39788
|
-
|
|
39789
|
-
|
|
39790
|
-
|
|
39791
|
-
|
|
39792
|
-
text: changeResult.changeInfo || "DOM change detected.",
|
|
39793
|
-
|
|
39794
|
-
|
|
39795
|
-
}
|
|
39825
|
+
if (useVision) {
|
|
39826
|
+
// Vision model: compare screenshots
|
|
39827
|
+
const image2 = await this.get_screenshot(agentContext);
|
|
39828
|
+
const changeResult = await this.is_dom_change(agentContext, rlm, image1, image2, task_description);
|
|
39829
|
+
if (changeResult.changed) {
|
|
39830
|
+
return {
|
|
39831
|
+
content: [
|
|
39832
|
+
{ type: "text", text: changeResult.changeInfo || "DOM change detected." },
|
|
39833
|
+
],
|
|
39834
|
+
};
|
|
39835
|
+
}
|
|
39836
|
+
}
|
|
39837
|
+
else {
|
|
39838
|
+
// Text model: compare page content
|
|
39839
|
+
const content2 = await this.get_page_content(agentContext);
|
|
39840
|
+
if (content2 === content1)
|
|
39841
|
+
continue;
|
|
39842
|
+
const changeResult = await this.is_condition_met(rlm, content2, task_description, agentContext);
|
|
39843
|
+
content1 = content2;
|
|
39844
|
+
if (changeResult.changed) {
|
|
39845
|
+
return {
|
|
39846
|
+
content: [
|
|
39847
|
+
{ type: "text", text: changeResult.changeInfo || "Condition met." },
|
|
39848
|
+
],
|
|
39849
|
+
};
|
|
39850
|
+
}
|
|
39796
39851
|
}
|
|
39797
39852
|
}
|
|
39798
39853
|
return {
|
|
@@ -39804,6 +39859,65 @@ class WatchTriggerTool {
|
|
|
39804
39859
|
],
|
|
39805
39860
|
};
|
|
39806
39861
|
}
|
|
39862
|
+
/** Check if the primary LLM supports vision */
|
|
39863
|
+
isVisionModel(rlm) {
|
|
39864
|
+
const names = rlm.Names;
|
|
39865
|
+
const llms = rlm.Llms;
|
|
39866
|
+
if (!names || names.length === 0)
|
|
39867
|
+
return false;
|
|
39868
|
+
const config = llms[names[0]];
|
|
39869
|
+
if (!config)
|
|
39870
|
+
return false;
|
|
39871
|
+
const provider = String(config.provider || "").toLowerCase();
|
|
39872
|
+
const model = String(config.model || "").toLowerCase();
|
|
39873
|
+
if (provider === "deepseek" || model.includes("deepseek"))
|
|
39874
|
+
return false;
|
|
39875
|
+
if (provider === "anthropic")
|
|
39876
|
+
return true;
|
|
39877
|
+
if (provider === "google")
|
|
39878
|
+
return true;
|
|
39879
|
+
if (model.includes("gpt-4o") || model.includes("gpt-4-vision") || model.includes("gpt-4-turbo"))
|
|
39880
|
+
return true;
|
|
39881
|
+
if (model.includes("claude") || model.includes("gemini"))
|
|
39882
|
+
return true;
|
|
39883
|
+
return false;
|
|
39884
|
+
}
|
|
39885
|
+
/** Get page text content via extract_page_content */
|
|
39886
|
+
async get_page_content(agentContext) {
|
|
39887
|
+
const extract = agentContext.agent["extract_page_content"];
|
|
39888
|
+
if (!extract)
|
|
39889
|
+
return "";
|
|
39890
|
+
const result = await extract.call(agentContext.agent, agentContext);
|
|
39891
|
+
return result?.page_content || "";
|
|
39892
|
+
}
|
|
39893
|
+
/** Check if condition is met using text-based LLM analysis */
|
|
39894
|
+
async is_condition_met(rlm, pageContent, task_description, agentContext) {
|
|
39895
|
+
try {
|
|
39896
|
+
const request = {
|
|
39897
|
+
messages: [
|
|
39898
|
+
{ role: "system", content: watch_text_system_prompt },
|
|
39899
|
+
{
|
|
39900
|
+
role: "user",
|
|
39901
|
+
content: [
|
|
39902
|
+
{
|
|
39903
|
+
type: "text",
|
|
39904
|
+
text: `Condition: ${task_description}\n\nPage content:\n${pageContent.slice(0, 30000)}`,
|
|
39905
|
+
},
|
|
39906
|
+
],
|
|
39907
|
+
},
|
|
39908
|
+
],
|
|
39909
|
+
abortSignal: agentContext.context.controller.signal,
|
|
39910
|
+
};
|
|
39911
|
+
const result = await rlm.call(request);
|
|
39912
|
+
let resultText = result.text || "{}";
|
|
39913
|
+
resultText = resultText.substring(resultText.indexOf("{"), resultText.lastIndexOf("}") + 1);
|
|
39914
|
+
return JSON.parse(resultText);
|
|
39915
|
+
}
|
|
39916
|
+
catch (error) {
|
|
39917
|
+
Log.error("Error in is_condition_met:", error);
|
|
39918
|
+
}
|
|
39919
|
+
return { changed: false };
|
|
39920
|
+
}
|
|
39807
39921
|
async get_screenshot(agentContext) {
|
|
39808
39922
|
const screenshot = agentContext.agent["screenshot"];
|
|
39809
39923
|
const imageResult = (await screenshot.call(agentContext.agent, agentContext));
|
|
@@ -40177,10 +40291,77 @@ class McpTool {
|
|
|
40177
40291
|
}
|
|
40178
40292
|
}
|
|
40179
40293
|
|
|
40180
|
-
|
|
40181
|
-
|
|
40294
|
+
/**
|
|
40295
|
+
* INPUT: global.skillService for skill metadata and content
|
|
40296
|
+
* OUTPUT: Activated skill instructions + resource listing
|
|
40297
|
+
* POSITION: Chat dialogue tool enabling LLM to load domain-specific skills
|
|
40298
|
+
*/
|
|
40299
|
+
const TOOL_NAME$6 = "activate_skill";
|
|
40300
|
+
/** Works as both DialogueTool (Chat) and Tool (Agent) */
|
|
40301
|
+
class ActivateSkillTool {
|
|
40182
40302
|
constructor() {
|
|
40183
40303
|
this.name = TOOL_NAME$6;
|
|
40304
|
+
this.noPlan = true;
|
|
40305
|
+
}
|
|
40306
|
+
/** Dynamic description with available skill list */
|
|
40307
|
+
get description() {
|
|
40308
|
+
const skills = global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || [];
|
|
40309
|
+
if (skills.length === 0) {
|
|
40310
|
+
return "Activate a specialized skill. No skills currently available.";
|
|
40311
|
+
}
|
|
40312
|
+
const list = skills.map((s) => `- ${s.name}: ${s.description}`).join("\n");
|
|
40313
|
+
return `Activate a specialized skill that provides domain-specific instructions.\n\nAvailable skills:\n${list}`;
|
|
40314
|
+
}
|
|
40315
|
+
/** Dynamic parameters with enum constraint */
|
|
40316
|
+
get parameters() {
|
|
40317
|
+
const skillNames = (global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || []).map((s) => s.name);
|
|
40318
|
+
return {
|
|
40319
|
+
type: "object",
|
|
40320
|
+
properties: {
|
|
40321
|
+
name: {
|
|
40322
|
+
type: "string",
|
|
40323
|
+
...(skillNames.length > 0 ? { enum: skillNames } : {}),
|
|
40324
|
+
description: "Name of the skill to activate",
|
|
40325
|
+
},
|
|
40326
|
+
},
|
|
40327
|
+
required: ["name"],
|
|
40328
|
+
};
|
|
40329
|
+
}
|
|
40330
|
+
async execute(args, ..._rest) {
|
|
40331
|
+
const name = args.name;
|
|
40332
|
+
if (!global.skillService) {
|
|
40333
|
+
return {
|
|
40334
|
+
content: [{ type: "text", text: "Skill service not available" }],
|
|
40335
|
+
isError: true,
|
|
40336
|
+
};
|
|
40337
|
+
}
|
|
40338
|
+
const skill = await global.skillService.loadSkill(name);
|
|
40339
|
+
if (!skill) {
|
|
40340
|
+
return {
|
|
40341
|
+
content: [{ type: "text", text: `Skill "${name}" not found` }],
|
|
40342
|
+
isError: true,
|
|
40343
|
+
};
|
|
40344
|
+
}
|
|
40345
|
+
const output = [
|
|
40346
|
+
`<activated_skill name="${skill.metadata.name}">`,
|
|
40347
|
+
`<instructions>`,
|
|
40348
|
+
skill.instructions.trim(),
|
|
40349
|
+
`</instructions>`,
|
|
40350
|
+
];
|
|
40351
|
+
if (skill.resources.length > 0) {
|
|
40352
|
+
output.push(`<available_resources base="${skill.basePath}">`);
|
|
40353
|
+
skill.resources.forEach((r) => output.push(` <file>${r}</file>`));
|
|
40354
|
+
output.push(`</available_resources>`);
|
|
40355
|
+
}
|
|
40356
|
+
output.push(`</activated_skill>`);
|
|
40357
|
+
return { content: [{ type: "text", text: output.join("\n") }] };
|
|
40358
|
+
}
|
|
40359
|
+
}
|
|
40360
|
+
|
|
40361
|
+
const TOOL_NAME$5 = "task_result_check";
|
|
40362
|
+
class TaskResultCheckTool {
|
|
40363
|
+
constructor() {
|
|
40364
|
+
this.name = TOOL_NAME$5;
|
|
40184
40365
|
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.`;
|
|
40185
40366
|
this.parameters = {
|
|
40186
40367
|
type: "object",
|
|
@@ -40284,10 +40465,10 @@ async function doTaskResultCheck(agentContext, rlm, messages, tools) {
|
|
|
40284
40465
|
}
|
|
40285
40466
|
}
|
|
40286
40467
|
|
|
40287
|
-
const TOOL_NAME$
|
|
40468
|
+
const TOOL_NAME$4 = "todo_list_manager";
|
|
40288
40469
|
class TodoListManagerTool {
|
|
40289
40470
|
constructor() {
|
|
40290
|
-
this.name = TOOL_NAME$
|
|
40471
|
+
this.name = TOOL_NAME$4;
|
|
40291
40472
|
this.description =
|
|
40292
40473
|
"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.";
|
|
40293
40474
|
this.parameters = {
|
|
@@ -40440,6 +40621,14 @@ For repetitive tasks, when executing a forEach node, the \`${TOOL_NAME$b}\` tool
|
|
|
40440
40621
|
* watch node
|
|
40441
40622
|
monitor changes in webpage DOM elements, when executing to the watch node, require the use of the \`${TOOL_NAME$a}\` tool.
|
|
40442
40623
|
</if>
|
|
40624
|
+
<if ${TOOL_NAME$6}Tool>
|
|
40625
|
+
* SKILLS
|
|
40626
|
+
You can use the \`${TOOL_NAME$6}\` tool to load domain-specific skill instructions when they would help complete the current task.
|
|
40627
|
+
</if>
|
|
40628
|
+
<if skills>
|
|
40629
|
+
Available skills:
|
|
40630
|
+
{{skills}}
|
|
40631
|
+
</if>
|
|
40443
40632
|
|
|
40444
40633
|
<if mainTask>
|
|
40445
40634
|
Main task: {{mainTask}}
|
|
@@ -40492,6 +40681,14 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
40492
40681
|
for (let i = 0; i < tools.length; i++) {
|
|
40493
40682
|
toolVars[tools[i].name + "Tool"] = true;
|
|
40494
40683
|
}
|
|
40684
|
+
// Inject skill list when available
|
|
40685
|
+
let _skills = "";
|
|
40686
|
+
if (global.skillService) {
|
|
40687
|
+
const skills = global.skillService.getAllMetadata().filter((s) => s.enabled);
|
|
40688
|
+
if (skills.length > 0) {
|
|
40689
|
+
_skills = skills.map((s) => `- ${s.name}: ${s.description}`).join("\n");
|
|
40690
|
+
}
|
|
40691
|
+
}
|
|
40495
40692
|
let mainTask = "";
|
|
40496
40693
|
let preTaskResult = "";
|
|
40497
40694
|
if (context.chain.agents.length > 1) {
|
|
@@ -40504,6 +40701,7 @@ function getAgentSystemPrompt(agent, agentNode, context, tools, extSysPrompt) {
|
|
|
40504
40701
|
agent: agent.Name,
|
|
40505
40702
|
description: agent.Description,
|
|
40506
40703
|
extSysPrompt: extSysPrompt?.trim() || "",
|
|
40704
|
+
skills: _skills,
|
|
40507
40705
|
mainTask: mainTask,
|
|
40508
40706
|
preTaskResult: preTaskResult.trim(),
|
|
40509
40707
|
hasWatchNode: agentNode.xml.indexOf("</watch>") > -1,
|
|
@@ -40757,6 +40955,13 @@ class Agent {
|
|
|
40757
40955
|
callback?.onHumanHelp) {
|
|
40758
40956
|
tools.push(new HumanInteractTool());
|
|
40759
40957
|
}
|
|
40958
|
+
// Add skill tool when available
|
|
40959
|
+
if (global.skillService) {
|
|
40960
|
+
const skills = global.skillService.getAllMetadata().filter((s) => s.enabled);
|
|
40961
|
+
if (skills.length > 0) {
|
|
40962
|
+
tools.push(new ActivateSkillTool());
|
|
40963
|
+
}
|
|
40964
|
+
}
|
|
40760
40965
|
const toolNames = this.tools.map((tool) => tool.name);
|
|
40761
40966
|
return tools.filter((tool) => toolNames.indexOf(tool.name) == -1);
|
|
40762
40967
|
}
|
|
@@ -44279,7 +44484,7 @@ class ChatContext {
|
|
|
44279
44484
|
}
|
|
44280
44485
|
}
|
|
44281
44486
|
|
|
44282
|
-
const TOOL_NAME$
|
|
44487
|
+
const TOOL_NAME$3 = "webpageQa";
|
|
44283
44488
|
const WEBPAGE_QA_PROMPT = `
|
|
44284
44489
|
You are a helpful assistant that can answer questions based on the provided webpage context.
|
|
44285
44490
|
|
|
@@ -44300,7 +44505,7 @@ Answer user's question based on the webpage context, the answer should be in the
|
|
|
44300
44505
|
`;
|
|
44301
44506
|
class WebpageQaTool {
|
|
44302
44507
|
constructor(chatContext, params) {
|
|
44303
|
-
this.name = TOOL_NAME$
|
|
44508
|
+
this.name = TOOL_NAME$3;
|
|
44304
44509
|
this.params = params;
|
|
44305
44510
|
this.chatContext = chatContext;
|
|
44306
44511
|
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.`;
|
|
@@ -44416,10 +44621,10 @@ class WebpageQaTool {
|
|
|
44416
44621
|
}
|
|
44417
44622
|
}
|
|
44418
44623
|
|
|
44419
|
-
const TOOL_NAME$
|
|
44624
|
+
const TOOL_NAME$2 = "webSearch";
|
|
44420
44625
|
class WebSearchTool {
|
|
44421
44626
|
constructor(chatContext, params) {
|
|
44422
|
-
this.name = TOOL_NAME$
|
|
44627
|
+
this.name = TOOL_NAME$2;
|
|
44423
44628
|
this.params = params;
|
|
44424
44629
|
this.chatContext = chatContext;
|
|
44425
44630
|
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.`;
|
|
@@ -44489,12 +44694,12 @@ async function recursiveTextNode(node, callback) {
|
|
|
44489
44694
|
}
|
|
44490
44695
|
}
|
|
44491
44696
|
|
|
44492
|
-
const TOOL_NAME$
|
|
44697
|
+
const TOOL_NAME$1 = "deepAction";
|
|
44493
44698
|
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.";
|
|
44494
44699
|
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.";
|
|
44495
44700
|
class DeepActionTool {
|
|
44496
44701
|
constructor(chatContext, params) {
|
|
44497
|
-
this.name = TOOL_NAME$
|
|
44702
|
+
this.name = TOOL_NAME$1;
|
|
44498
44703
|
this.chatContext = chatContext;
|
|
44499
44704
|
const agents = this.chatContext.getConfig().agents || [];
|
|
44500
44705
|
const agentNames = agents.map((agent) => agent.Name).join(", ");
|
|
@@ -44651,10 +44856,10 @@ class DeepActionTool {
|
|
|
44651
44856
|
}
|
|
44652
44857
|
}
|
|
44653
44858
|
|
|
44654
|
-
const TOOL_NAME
|
|
44859
|
+
const TOOL_NAME = "taskVariableStorage";
|
|
44655
44860
|
class TaskVariableStorageTool {
|
|
44656
44861
|
constructor(chatContext, params) {
|
|
44657
|
-
this.name = TOOL_NAME
|
|
44862
|
+
this.name = TOOL_NAME;
|
|
44658
44863
|
this.params = params;
|
|
44659
44864
|
this.chatContext = chatContext;
|
|
44660
44865
|
this.description = `Used for storing, reading, and retrieving variable data, and maintaining input/output variables in task nodes.`;
|
|
@@ -44731,71 +44936,6 @@ class TaskVariableStorageTool {
|
|
|
44731
44936
|
}
|
|
44732
44937
|
}
|
|
44733
44938
|
|
|
44734
|
-
/**
|
|
44735
|
-
* INPUT: global.skillService for skill metadata and content
|
|
44736
|
-
* OUTPUT: Activated skill instructions + resource listing
|
|
44737
|
-
* POSITION: Chat dialogue tool enabling LLM to load domain-specific skills
|
|
44738
|
-
*/
|
|
44739
|
-
const TOOL_NAME = "activate_skill";
|
|
44740
|
-
class ActivateSkillTool {
|
|
44741
|
-
constructor() {
|
|
44742
|
-
this.name = TOOL_NAME;
|
|
44743
|
-
}
|
|
44744
|
-
/** Dynamic description with available skill list */
|
|
44745
|
-
get description() {
|
|
44746
|
-
const skills = global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || [];
|
|
44747
|
-
if (skills.length === 0) {
|
|
44748
|
-
return "Activate a specialized skill. No skills currently available.";
|
|
44749
|
-
}
|
|
44750
|
-
const list = skills.map((s) => `- ${s.name}: ${s.description}`).join("\n");
|
|
44751
|
-
return `Activate a specialized skill that provides domain-specific instructions.\n\nAvailable skills:\n${list}`;
|
|
44752
|
-
}
|
|
44753
|
-
/** Dynamic parameters with enum constraint */
|
|
44754
|
-
get parameters() {
|
|
44755
|
-
const skillNames = (global.skillService?.getAllMetadata()?.filter((s) => s.enabled) || []).map((s) => s.name);
|
|
44756
|
-
return {
|
|
44757
|
-
type: "object",
|
|
44758
|
-
properties: {
|
|
44759
|
-
name: {
|
|
44760
|
-
type: "string",
|
|
44761
|
-
...(skillNames.length > 0 ? { enum: skillNames } : {}),
|
|
44762
|
-
description: "Name of the skill to activate",
|
|
44763
|
-
},
|
|
44764
|
-
},
|
|
44765
|
-
required: ["name"],
|
|
44766
|
-
};
|
|
44767
|
-
}
|
|
44768
|
-
async execute(args) {
|
|
44769
|
-
const name = args.name;
|
|
44770
|
-
if (!global.skillService) {
|
|
44771
|
-
return {
|
|
44772
|
-
content: [{ type: "text", text: "Skill service not available" }],
|
|
44773
|
-
isError: true,
|
|
44774
|
-
};
|
|
44775
|
-
}
|
|
44776
|
-
const skill = await global.skillService.loadSkill(name);
|
|
44777
|
-
if (!skill) {
|
|
44778
|
-
return {
|
|
44779
|
-
content: [{ type: "text", text: `Skill "${name}" not found` }],
|
|
44780
|
-
isError: true,
|
|
44781
|
-
};
|
|
44782
|
-
}
|
|
44783
|
-
const output = [
|
|
44784
|
-
`<activated_skill name="${skill.metadata.name}">`,
|
|
44785
|
-
`<instructions>`,
|
|
44786
|
-
skill.instructions.trim(),
|
|
44787
|
-
`</instructions>`,
|
|
44788
|
-
];
|
|
44789
|
-
if (skill.resources.length > 0) {
|
|
44790
|
-
output.push(`<available_resources base="${skill.basePath}">`);
|
|
44791
|
-
skill.resources.forEach((r) => output.push(` <file>${r}</file>`));
|
|
44792
|
-
output.push(`</available_resources>`);
|
|
44793
|
-
}
|
|
44794
|
-
output.push(`</activated_skill>`);
|
|
44795
|
-
return { content: [{ type: "text", text: output.join("\n") }] };
|
|
44796
|
-
}
|
|
44797
|
-
}
|
|
44798
|
-
|
|
44799
44939
|
const CHAT_SYSTEM_TEMPLATE = `
|
|
44800
44940
|
You are {{name}}, it is an action-oriented assistant in the browser, a general-purpose intelligent agent running in the browser environment.
|
|
44801
44941
|
|
|
@@ -44806,26 +44946,27 @@ General Principles:
|
|
|
44806
44946
|
- 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.
|
|
44807
44947
|
|
|
44808
44948
|
For non-chat related tasks issued by users, the following tools need to be called to complete them:
|
|
44809
|
-
<if ${TOOL_NAME$
|
|
44810
|
-
- ${TOOL_NAME$
|
|
44811
|
-
</if>
|
|
44812
|
-
<if ${TOOL_NAME$4}Tool>
|
|
44813
|
-
- ${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.
|
|
44949
|
+
<if ${TOOL_NAME$1}Tool>
|
|
44950
|
+
- ${TOOL_NAME$1}: This tool is used to execute tasks, delegate to Javis AI assistant with full computer control.
|
|
44814
44951
|
</if>
|
|
44815
44952
|
<if ${TOOL_NAME$3}Tool>
|
|
44816
|
-
- ${TOOL_NAME$3}:
|
|
44953
|
+
- ${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.
|
|
44817
44954
|
</if>
|
|
44818
|
-
<if ${TOOL_NAME$
|
|
44819
|
-
- ${TOOL_NAME$
|
|
44955
|
+
<if ${TOOL_NAME$2}Tool>
|
|
44956
|
+
- ${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.
|
|
44820
44957
|
</if>
|
|
44821
44958
|
<if ${TOOL_NAME}Tool>
|
|
44822
|
-
- ${TOOL_NAME}:
|
|
44959
|
+
- ${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.
|
|
44960
|
+
</if>
|
|
44961
|
+
<if ${TOOL_NAME$6}Tool>
|
|
44962
|
+
- ${TOOL_NAME$6}: Activate a specialized skill for domain-specific tasks. Use when the user's request matches an available skill.
|
|
44823
44963
|
</if>
|
|
44824
44964
|
</tool_instructions>
|
|
44825
44965
|
|
|
44826
44966
|
<if skills>
|
|
44827
44967
|
## Available Skills
|
|
44828
44968
|
You have access to specialized skills. Use activate_skill when the user's request matches a skill.
|
|
44969
|
+
When you see <use_skill name="..." /> in user messages, you MUST call activate_skill with that skill name immediately before proceeding.
|
|
44829
44970
|
<available_skills>
|
|
44830
44971
|
{{skills}}
|
|
44831
44972
|
</available_skills>
|