dhalsim 2.3.1 → 2.4.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 +53 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +53 -36
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -16594,25 +16594,7 @@ ${states.join("\n\n")}
|
|
|
16594
16594
|
};
|
|
16595
16595
|
|
|
16596
16596
|
// src/subagents/prompts.ts
|
|
16597
|
-
var
|
|
16598
|
-
- ReportResult: **REQUIRED** - Call this to return your findings when task is complete
|
|
16599
|
-
- Navigate: Go to a URL
|
|
16600
|
-
- Click: Click an element (auto-waits for element to be actionable)
|
|
16601
|
-
- Fill: Fill a form input
|
|
16602
|
-
- FillForm: Fill multiple fields and submit
|
|
16603
|
-
- Select: Select dropdown option
|
|
16604
|
-
- Check: Toggle checkboxes
|
|
16605
|
-
- GetFullPageContent: Read page text content
|
|
16606
|
-
- Screenshot: Capture the page (use when you need to show visual results)
|
|
16607
|
-
- DismissOverlays: Auto-dismiss cookie banners
|
|
16608
|
-
- Scroll: Scroll the page
|
|
16609
|
-
- WaitForElement: Wait for an element to appear
|
|
16610
|
-
- Wait: General wait
|
|
16611
|
-
- RequestUserAssistance: Ask user for help with CAPTCHAs, 2FA codes, or other human-only challenges`;
|
|
16612
|
-
var GADGET_LIST_WITHOUT_USER_ASSISTANCE = `## Available Gadgets
|
|
16613
|
-
- ReportResult: **REQUIRED** - Call this to return your findings when task is complete
|
|
16614
|
-
- Navigate: Go to a URL
|
|
16615
|
-
- Click: Click an element (auto-waits for element to be actionable)
|
|
16597
|
+
var GADGETS_CORE = `- Click: Click an element (auto-waits for element to be actionable)
|
|
16616
16598
|
- Fill: Fill a form input
|
|
16617
16599
|
- FillForm: Fill multiple fields and submit
|
|
16618
16600
|
- Select: Select dropdown option
|
|
@@ -16623,8 +16605,44 @@ var GADGET_LIST_WITHOUT_USER_ASSISTANCE = `## Available Gadgets
|
|
|
16623
16605
|
- Scroll: Scroll the page
|
|
16624
16606
|
- WaitForElement: Wait for an element to appear
|
|
16625
16607
|
- Wait: General wait`;
|
|
16608
|
+
function buildGadgetList(options) {
|
|
16609
|
+
const lines = ["## Available Gadgets", "- ReportResult: **REQUIRED** - Call this to return your findings when task is complete"];
|
|
16610
|
+
if (options.includeNavigation) {
|
|
16611
|
+
lines.push("- Navigate: Go to a URL");
|
|
16612
|
+
}
|
|
16613
|
+
lines.push(GADGETS_CORE);
|
|
16614
|
+
if (options.includeUserAssistance) {
|
|
16615
|
+
lines.push("- RequestUserAssistance: Ask user for help with CAPTCHAs, 2FA codes, or other human-only challenges");
|
|
16616
|
+
}
|
|
16617
|
+
return lines.join("\n");
|
|
16618
|
+
}
|
|
16626
16619
|
function createDhalsimSystemPrompt(options) {
|
|
16627
|
-
const
|
|
16620
|
+
const includeNavigation = !options.disableNavigation;
|
|
16621
|
+
const gadgetList = buildGadgetList({
|
|
16622
|
+
includeNavigation,
|
|
16623
|
+
includeUserAssistance: options.includeUserAssistance
|
|
16624
|
+
});
|
|
16625
|
+
const criticalRules = includeNavigation ? `## CRITICAL Rules
|
|
16626
|
+
1. You have ONE page (p1) already open. Use Navigate to go to URLs.
|
|
16627
|
+
2. ONLY use selectors exactly as shown in <CurrentBrowserState>
|
|
16628
|
+
3. NEVER guess selectors - use GetFullPageContent if you need more info
|
|
16629
|
+
4. Focus on completing the task efficiently - avoid unnecessary actions
|
|
16630
|
+
5. If a selector matches multiple elements, you'll get an error with a "suggestions" array containing valid selectors. USE ONE OF THESE SUGGESTIONS DIRECTLY - don't guess or modify them.
|
|
16631
|
+
6. For batch extraction: GetFullPageContent returns ALL matches when a selector matches multiple elements (as "texts" array). Use this instead of querying each element separately.` : `## CRITICAL Rules
|
|
16632
|
+
1. You have ONE page (p1) open at the target URL. You cannot navigate to other URLs.
|
|
16633
|
+
2. ONLY use selectors exactly as shown in <CurrentBrowserState>
|
|
16634
|
+
3. NEVER guess selectors - use GetFullPageContent if you need more info
|
|
16635
|
+
4. Focus on completing the task efficiently - avoid unnecessary actions
|
|
16636
|
+
5. If a selector matches multiple elements, you'll get an error with a "suggestions" array containing valid selectors. USE ONE OF THESE SUGGESTIONS DIRECTLY - don't guess or modify them.
|
|
16637
|
+
6. For batch extraction: GetFullPageContent returns ALL matches when a selector matches multiple elements (as "texts" array). Use this instead of querying each element separately.`;
|
|
16638
|
+
const efficientPattern = includeNavigation ? `## Efficient Pattern
|
|
16639
|
+
On first call: Navigate and DismissOverlays are ALREADY done. Take action immediately.
|
|
16640
|
+
After any Navigate call: DismissOverlays, then interact with elements.
|
|
16641
|
+
|
|
16642
|
+
If an action doesn't produce expected results, use GetFullPageContent to diagnose before retrying.` : `## Efficient Pattern
|
|
16643
|
+
On first call: DismissOverlays is ALREADY done. Take action immediately.
|
|
16644
|
+
|
|
16645
|
+
If an action doesn't produce expected results, use GetFullPageContent to diagnose before retrying.`;
|
|
16628
16646
|
return `You are a browser automation agent focused on completing a specific web task.
|
|
16629
16647
|
|
|
16630
16648
|
## Browser State (<CurrentBrowserState>)
|
|
@@ -16638,19 +16656,9 @@ This is your source of truth for what's on screen. It contains:
|
|
|
16638
16656
|
- CHECKBOXES: Checkbox/radio inputs
|
|
16639
16657
|
- MENUITEMS: Dropdown options (only visible when dropdown is open)
|
|
16640
16658
|
|
|
16641
|
-
|
|
16642
|
-
1. You have ONE page (p1) already open. Use Navigate to go to URLs.
|
|
16643
|
-
2. ONLY use selectors exactly as shown in <CurrentBrowserState>
|
|
16644
|
-
3. NEVER guess selectors - use GetFullPageContent if you need more info
|
|
16645
|
-
4. Focus on completing the task efficiently - avoid unnecessary actions
|
|
16646
|
-
5. If a selector matches multiple elements, you'll get an error with a "suggestions" array containing valid selectors. USE ONE OF THESE SUGGESTIONS DIRECTLY - don't guess or modify them.
|
|
16647
|
-
6. For batch extraction: GetFullPageContent returns ALL matches when a selector matches multiple elements (as "texts" array). Use this instead of querying each element separately.
|
|
16659
|
+
${criticalRules}
|
|
16648
16660
|
|
|
16649
|
-
|
|
16650
|
-
On first call: Navigate and DismissOverlays are ALREADY done. Take action immediately.
|
|
16651
|
-
After any Navigate call: DismissOverlays, then interact with elements.
|
|
16652
|
-
|
|
16653
|
-
If an action doesn't produce expected results, use GetFullPageContent to diagnose before retrying.
|
|
16661
|
+
${efficientPattern}
|
|
16654
16662
|
|
|
16655
16663
|
## Dropdown/Toggle Behavior
|
|
16656
16664
|
Dropdowns are TOGGLES - clicking the same trigger twice will close it!
|
|
@@ -16719,7 +16727,8 @@ Use this for web research, data extraction, form filling, or any web-based task.
|
|
|
16719
16727
|
headless: import_llmist15.z.boolean().optional().describe("Run browser in headless mode (default: true, configurable via CLI)"),
|
|
16720
16728
|
timeoutMs: import_llmist15.z.number().optional().describe("Overall timeout in ms (default: 300000 = 5 min, 0 = disabled, configurable via CLI)"),
|
|
16721
16729
|
disableCache: import_llmist15.z.boolean().optional().describe("Disable browser cache for lower memory usage (default: false, configurable via CLI)"),
|
|
16722
|
-
navigationTimeoutMs: import_llmist15.z.number().optional().describe("Navigation timeout in ms (default: 60000, configurable via CLI)")
|
|
16730
|
+
navigationTimeoutMs: import_llmist15.z.number().optional().describe("Navigation timeout in ms (default: 60000, configurable via CLI)"),
|
|
16731
|
+
disableNavigation: import_llmist15.z.boolean().optional().describe("Disable Navigate gadget to restrict agent to the initial URL (default: false, configurable via CLI)")
|
|
16723
16732
|
}),
|
|
16724
16733
|
timeoutMs: 3e5
|
|
16725
16734
|
// 5 minutes - web browsing can take time
|
|
@@ -16727,12 +16736,14 @@ Use this for web research, data extraction, form filling, or any web-based task.
|
|
|
16727
16736
|
customSessionManager;
|
|
16728
16737
|
customSystemPrompt;
|
|
16729
16738
|
userAssistanceEnabled;
|
|
16739
|
+
navigationDisabled;
|
|
16730
16740
|
customUserAssistanceCallback;
|
|
16731
16741
|
constructor(options) {
|
|
16732
16742
|
super();
|
|
16733
16743
|
this.customSessionManager = options?.sessionManager;
|
|
16734
16744
|
this.customSystemPrompt = options?.systemPrompt;
|
|
16735
16745
|
this.userAssistanceEnabled = options?.userAssistance;
|
|
16746
|
+
this.navigationDisabled = options?.disableNavigation;
|
|
16736
16747
|
this.customUserAssistanceCallback = options?.onUserAssistance;
|
|
16737
16748
|
if (options?.timeoutMs !== void 0) {
|
|
16738
16749
|
this.timeoutMs = options.timeoutMs === 0 ? void 0 : options.timeoutMs;
|
|
@@ -16763,8 +16774,13 @@ Use this for web research, data extraction, form filling, or any web-based task.
|
|
|
16763
16774
|
subagentKey: "navigationTimeoutMs",
|
|
16764
16775
|
defaultValue: 6e4
|
|
16765
16776
|
});
|
|
16777
|
+
const disableNavigation = (0, import_llmist15.resolveValue)(ctx, "BrowseWeb", {
|
|
16778
|
+
runtime: params.disableNavigation,
|
|
16779
|
+
subagentKey: "disableNavigation",
|
|
16780
|
+
defaultValue: this.navigationDisabled ?? false
|
|
16781
|
+
});
|
|
16766
16782
|
const userAssistanceEnabled = this.userAssistanceEnabled ?? (this.customUserAssistanceCallback !== void 0 || ctx?.requestHumanInput !== void 0);
|
|
16767
|
-
logger13?.debug(`[BrowseWeb] User assistance enabled=${userAssistanceEnabled}`);
|
|
16783
|
+
logger13?.debug(`[BrowseWeb] User assistance enabled=${userAssistanceEnabled}, disableNavigation=${disableNavigation}`);
|
|
16768
16784
|
const collectedMedia = [];
|
|
16769
16785
|
const manager = this.customSessionManager ?? new BrowserSessionManager(logger13);
|
|
16770
16786
|
const isOwnedManager = !this.customSessionManager;
|
|
@@ -16810,7 +16826,8 @@ Use this for web research, data extraction, form filling, or any web-based task.
|
|
|
16810
16826
|
const gadgets = [
|
|
16811
16827
|
reportResult,
|
|
16812
16828
|
// First so it's prominent in the list
|
|
16813
|
-
|
|
16829
|
+
// Conditionally include Navigate (excluded when disableNavigation is true)
|
|
16830
|
+
...disableNavigation ? [] : [new Navigate(manager)],
|
|
16814
16831
|
new Click(manager),
|
|
16815
16832
|
new Fill(manager),
|
|
16816
16833
|
new FillForm(manager),
|
|
@@ -16827,7 +16844,7 @@ Use this for web research, data extraction, form filling, or any web-based task.
|
|
|
16827
16844
|
];
|
|
16828
16845
|
const { AgentBuilder, LLMist } = (0, import_llmist15.getHostExports)(ctx);
|
|
16829
16846
|
const client = new LLMist();
|
|
16830
|
-
const systemPrompt = this.customSystemPrompt ?? createDhalsimSystemPrompt({ includeUserAssistance: userAssistanceEnabled });
|
|
16847
|
+
const systemPrompt = this.customSystemPrompt ?? createDhalsimSystemPrompt({ includeUserAssistance: userAssistanceEnabled, disableNavigation });
|
|
16831
16848
|
const builder = new AgentBuilder(client).withModel(model).withSystem(systemPrompt).withMaxIterations(maxIterations).withGadgets(...gadgets).withTrailingMessage((trailingCtx) => [
|
|
16832
16849
|
pageStateScanner.getCachedState(),
|
|
16833
16850
|
"",
|