dhalsim 0.1.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +137 -0
  3. package/dhalsim-icon.png +0 -0
  4. package/dist/config/cmp-selectors.d.ts +9 -0
  5. package/dist/factory.d.ts +110 -0
  6. package/dist/gadgets/click.d.ts +57 -0
  7. package/dist/gadgets/content.d.ts +89 -0
  8. package/dist/gadgets/content.test.d.ts +1 -0
  9. package/dist/gadgets/form.d.ts +199 -0
  10. package/dist/gadgets/index.d.ts +12 -0
  11. package/dist/gadgets/interaction.test.d.ts +1 -0
  12. package/dist/gadgets/keyboard.d.ts +40 -0
  13. package/dist/gadgets/navigation.d.ts +143 -0
  14. package/dist/gadgets/navigation.test.d.ts +1 -0
  15. package/dist/gadgets/overlays.d.ts +42 -0
  16. package/dist/gadgets/page.d.ts +106 -0
  17. package/dist/gadgets/page.test.d.ts +1 -0
  18. package/dist/gadgets/script.d.ts +40 -0
  19. package/dist/gadgets/script.test.d.ts +1 -0
  20. package/dist/gadgets/scroll.d.ts +90 -0
  21. package/dist/gadgets/selection.d.ts +93 -0
  22. package/dist/gadgets/selector-validator.d.ts +29 -0
  23. package/dist/gadgets/selector-validator.test.d.ts +1 -0
  24. package/dist/gadgets/user-input.d.ts +46 -0
  25. package/dist/gadgets/wait.d.ts +85 -0
  26. package/dist/gadgets/wait.test.d.ts +1 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/index.js +22722 -0
  29. package/dist/session/index.d.ts +4 -0
  30. package/dist/session/manager.d.ts +59 -0
  31. package/dist/session/manager.test.d.ts +1 -0
  32. package/dist/session/test-manager.d.ts +33 -0
  33. package/dist/session/types.d.ts +41 -0
  34. package/dist/state/index.d.ts +1 -0
  35. package/dist/state/page-state.d.ts +99 -0
  36. package/dist/state/page-state.test.d.ts +1 -0
  37. package/dist/stealth.d.ts +15 -0
  38. package/dist/subagents/dhalsim.d.ts +112 -0
  39. package/dist/subagents/dhalsim.test.d.ts +1 -0
  40. package/dist/subagents/index.d.ts +3 -0
  41. package/dist/subagents/prompts.d.ts +9 -0
  42. package/dist/utils/constants.d.ts +20 -0
  43. package/dist/utils/element-checks.d.ts +17 -0
  44. package/dist/utils/errors.d.ts +12 -0
  45. package/dist/utils/index.d.ts +6 -0
  46. package/package.json +88 -0
@@ -0,0 +1,4 @@
1
+ export type { CloseBrowserResult, ClosePageResult, NewPageResult, StartBrowserOptions, StartBrowserResult, } from "./manager";
2
+ export { BrowserSessionManager, getSessionManager, resetSessionManager } from "./manager";
3
+ export { TestBrowserSessionManager } from "./test-manager";
4
+ export type { BrowserEntry, BrowserInfo, IBrowserSessionManager, PageEntry, PageInfo } from "./types";
@@ -0,0 +1,59 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { BrowserInfo, PageInfo } from "./types";
3
+ type Logger = {
4
+ debug: (...args: unknown[]) => void;
5
+ };
6
+ export interface ProxyOptions {
7
+ server: string;
8
+ username?: string;
9
+ password?: string;
10
+ }
11
+ export interface StartBrowserOptions {
12
+ headless?: boolean;
13
+ url?: string;
14
+ /** Proxy server configuration */
15
+ proxy?: ProxyOptions;
16
+ /** Auto-detect timezone/locale from proxy IP */
17
+ geoip?: boolean;
18
+ }
19
+ export interface StartBrowserResult {
20
+ browserId: string;
21
+ pageId: string;
22
+ url: string;
23
+ }
24
+ export interface NewPageResult {
25
+ pageId: string;
26
+ browserId: string;
27
+ url: string;
28
+ title: string;
29
+ }
30
+ export interface CloseBrowserResult {
31
+ success: true;
32
+ closedPages: string[];
33
+ }
34
+ export interface ClosePageResult {
35
+ success: true;
36
+ }
37
+ export declare class BrowserSessionManager {
38
+ private browsers;
39
+ private pages;
40
+ private browserCounter;
41
+ private pageCounter;
42
+ private logger;
43
+ constructor(logger?: Logger);
44
+ private nextBrowserId;
45
+ private nextPageId;
46
+ startBrowser(options?: StartBrowserOptions): Promise<StartBrowserResult>;
47
+ closeBrowser(browserId: string): Promise<CloseBrowserResult>;
48
+ listBrowsers(): BrowserInfo[];
49
+ newPage(browserId: string, url?: string): Promise<NewPageResult>;
50
+ closePage(pageId: string): Promise<ClosePageResult>;
51
+ listPages(browserId?: string): PageInfo[];
52
+ getPage(pageId: string): Page | undefined;
53
+ requirePage(pageId: string): Page;
54
+ getBrowserIdForPage(pageId: string): string | undefined;
55
+ closeAll(): Promise<void>;
56
+ }
57
+ export declare function getSessionManager(): BrowserSessionManager;
58
+ export declare function resetSessionManager(): void;
59
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Test-only browser session manager using vanilla playwright-core.
3
+ * This bypasses camoufox-js to avoid better-sqlite3 compatibility issues with Bun.
4
+ */
5
+ import { type Page } from "playwright-core";
6
+ import type { BrowserInfo, PageInfo } from "./types";
7
+ import type { StartBrowserOptions, StartBrowserResult, NewPageResult, CloseBrowserResult, ClosePageResult } from "./manager";
8
+ /**
9
+ * Browser session manager for tests using vanilla playwright-core (chromium).
10
+ * API-compatible with BrowserSessionManager.
11
+ */
12
+ export declare class TestBrowserSessionManager {
13
+ private browsers;
14
+ private pages;
15
+ private browserCounter;
16
+ private pageCounter;
17
+ private nextBrowserId;
18
+ private nextPageId;
19
+ startBrowser(options?: StartBrowserOptions): Promise<StartBrowserResult>;
20
+ closeBrowser(browserId: string): Promise<CloseBrowserResult>;
21
+ listBrowsers(): BrowserInfo[];
22
+ newPage(browserId: string, url?: string): Promise<NewPageResult>;
23
+ closePage(pageId: string): Promise<ClosePageResult>;
24
+ listPages(browserId?: string): PageInfo[];
25
+ getPage(pageId: string): Page | undefined;
26
+ requirePage(pageId: string): Page;
27
+ getBrowserIdForPage(pageId: string): string | undefined;
28
+ /**
29
+ * Reset a page to clean state with HTML content or blank.
30
+ */
31
+ resetPage(pageId: string, html?: string): Promise<void>;
32
+ closeAll(): Promise<void>;
33
+ }
@@ -0,0 +1,41 @@
1
+ import type { Browser, BrowserContext, Page } from "playwright-core";
2
+ export interface BrowserInfo {
3
+ id: string;
4
+ headless: boolean;
5
+ pageIds: string[];
6
+ }
7
+ export interface PageInfo {
8
+ id: string;
9
+ browserId: string;
10
+ url: string;
11
+ title: string;
12
+ }
13
+ export interface BrowserEntry {
14
+ browser: Browser;
15
+ context: BrowserContext;
16
+ headless: boolean;
17
+ }
18
+ export interface PageEntry {
19
+ page: Page;
20
+ browserId: string;
21
+ }
22
+ /**
23
+ * Interface for browser session managers.
24
+ * Both BrowserSessionManager and TestBrowserSessionManager implement this.
25
+ */
26
+ export interface IBrowserSessionManager {
27
+ getPage(pageId: string): Page | undefined;
28
+ requirePage(pageId: string): Page;
29
+ getBrowserIdForPage(pageId: string): string | undefined;
30
+ listPages(browserId?: string): PageInfo[];
31
+ listBrowsers(): BrowserInfo[];
32
+ newPage(browserId: string, url?: string): Promise<{
33
+ pageId: string;
34
+ browserId: string;
35
+ url: string;
36
+ title: string;
37
+ }>;
38
+ closePage(pageId: string): Promise<{
39
+ success: true;
40
+ }>;
41
+ }
@@ -0,0 +1 @@
1
+ export { PageStateScanner, DEFAULT_CONFIG, type FormatConfig } from "./page-state";
@@ -0,0 +1,99 @@
1
+ import type { IBrowserSessionManager } from "../session";
2
+ export interface FormatConfig {
3
+ /** Max length for content summary (0 = no limit) */
4
+ maxContentLength: number;
5
+ /** Include DOM structure hints */
6
+ includeStructure: boolean;
7
+ /** Include content summary */
8
+ includeSummary: boolean;
9
+ /** Max number of links to show (0 = no limit). Default: 50 */
10
+ maxLinks: number;
11
+ }
12
+ export declare const DEFAULT_CONFIG: FormatConfig;
13
+ /**
14
+ * Scans pages and formats state for LLM context injection.
15
+ */
16
+ export declare class PageStateScanner {
17
+ private manager;
18
+ private config;
19
+ private cachedState;
20
+ private scanPromise;
21
+ constructor(manager: IBrowserSessionManager, config?: FormatConfig);
22
+ /**
23
+ * Get cached state synchronously (for trailing message).
24
+ * Call refreshState() to update the cache.
25
+ */
26
+ getCachedState(): string;
27
+ /**
28
+ * Refresh the cached state (call after state-changing operations).
29
+ * Uses proper locking to avoid concurrent scans and handles errors correctly.
30
+ */
31
+ refreshState(): Promise<void>;
32
+ private doRefresh;
33
+ /**
34
+ * Scan all open pages and format as compact string for trailing message.
35
+ * Output is wrapped in <CurrentBrowserState> tags for clear LLM context.
36
+ */
37
+ scanAllPages(): Promise<string>;
38
+ /**
39
+ * Scan a single page for state.
40
+ */
41
+ private scanPage;
42
+ /**
43
+ * Get all data-test attribute values from the page.
44
+ */
45
+ private getDataAttributes;
46
+ /**
47
+ * Get visible text content from page.
48
+ */
49
+ private getContentSummary;
50
+ /**
51
+ * Get simplified DOM structure (forms, main sections).
52
+ */
53
+ private getStructure;
54
+ /**
55
+ * Get all interactive elements.
56
+ * Processes all selector types in parallel for better performance.
57
+ */
58
+ private getInteractiveElements;
59
+ /**
60
+ * Extract info from a single element.
61
+ */
62
+ private extractElementInfo;
63
+ /**
64
+ * Format elements with unique indexed selectors when duplicates exist.
65
+ * Returns array of formatted lines.
66
+ */
67
+ private formatElements;
68
+ /**
69
+ * Format page state as compact string.
70
+ */
71
+ private formatPageState;
72
+ /**
73
+ * Check if an ID looks like garbage (dynamically generated).
74
+ */
75
+ private isGarbageId;
76
+ /**
77
+ * Check if a class name is meaningful (not framework garbage).
78
+ */
79
+ private isMeaningfulClass;
80
+ /**
81
+ * Escape special characters for CSS selector.
82
+ */
83
+ private escapeCSSSelector;
84
+ /**
85
+ * Scan for collapsed sections (accordions, panels) and extract their contents.
86
+ * This allows the agent to see what options are available BEFORE expanding.
87
+ */
88
+ private getCollapsedSections;
89
+ /**
90
+ * Get all <select> elements with their available options.
91
+ * This allows the agent to see dropdown options BEFORE opening them.
92
+ */
93
+ private getSelectOptions;
94
+ /**
95
+ * Get a valid CSS selector for element type when no better selector is available.
96
+ * Maps our internal type names to actual valid CSS selectors.
97
+ */
98
+ private getFallbackSelector;
99
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Human-like timing utilities for browser automation.
3
+ */
4
+ /**
5
+ * Generate a random delay within a range (for human-like timing).
6
+ * @param min Minimum delay in milliseconds
7
+ * @param max Maximum delay in milliseconds
8
+ */
9
+ export declare function randomDelay(min: number, max: number): number;
10
+ /**
11
+ * Sleep for a random duration (for human-like timing).
12
+ * @param min Minimum delay in milliseconds
13
+ * @param max Maximum delay in milliseconds
14
+ */
15
+ export declare function humanDelay(min?: number, max?: number): Promise<void>;
@@ -0,0 +1,112 @@
1
+ import { z } from "llmist";
2
+ import type { ExecutionContext, GadgetMediaOutput } from "llmist";
3
+ import type { IBrowserSessionManager, StartBrowserOptions, StartBrowserResult } from "../session";
4
+ /**
5
+ * Session manager type with the required methods for browser automation.
6
+ * Compatible with both BrowserSessionManager and TestBrowserSessionManager.
7
+ */
8
+ export type DhalsimSessionManager = IBrowserSessionManager & {
9
+ startBrowser(options: StartBrowserOptions): Promise<StartBrowserResult>;
10
+ closeAll(): Promise<void>;
11
+ };
12
+ /**
13
+ * Options for configuring the Dhalsim subagent.
14
+ */
15
+ export interface DhalsimOptions {
16
+ /** Custom session manager for Node.js compatibility or testing */
17
+ sessionManager?: DhalsimSessionManager;
18
+ /** Custom system prompt (defaults to DHALSIM_SYSTEM_PROMPT) */
19
+ systemPrompt?: string;
20
+ }
21
+ declare const Dhalsim_base: new () => {
22
+ description: string;
23
+ parameterSchema: z.ZodObject<{
24
+ task: z.ZodString;
25
+ url: z.ZodString;
26
+ maxIterations: z.ZodOptional<z.ZodNumber>;
27
+ model: z.ZodOptional<z.ZodString>;
28
+ headless: z.ZodOptional<z.ZodBoolean>;
29
+ }, z.core.$strip>;
30
+ name: string | undefined;
31
+ timeoutMs: number | undefined;
32
+ examples: import("llmist").GadgetExample<{
33
+ task: string;
34
+ url: string;
35
+ maxIterations?: number | undefined;
36
+ model?: string | undefined;
37
+ headless?: boolean | undefined;
38
+ }>[] | undefined;
39
+ readonly params: {
40
+ task: string;
41
+ url: string;
42
+ maxIterations?: number | undefined;
43
+ model?: string | undefined;
44
+ headless?: boolean | undefined;
45
+ };
46
+ execute(params: Record<string, unknown>, ctx?: ExecutionContext): import("llmist").GadgetExecuteReturn | Promise<import("llmist").GadgetExecuteReturn>;
47
+ throwIfAborted(ctx?: ExecutionContext): void;
48
+ onAbort(ctx: ExecutionContext | undefined, cleanup: () => void | Promise<void>): void;
49
+ createLinkedAbortController(ctx?: ExecutionContext): AbortController;
50
+ readonly instruction: string;
51
+ getInstruction(optionsOrArgPrefix?: string | {
52
+ argPrefix?: string;
53
+ startPrefix?: string;
54
+ endPrefix?: string;
55
+ }): string;
56
+ } & {
57
+ params: {
58
+ task: string;
59
+ url: string;
60
+ maxIterations?: number | undefined;
61
+ model?: string | undefined;
62
+ headless?: boolean | undefined;
63
+ };
64
+ };
65
+ /**
66
+ * Dhalsim subagent - a high-level gadget that runs its own agent loop
67
+ * to accomplish web browsing tasks autonomously.
68
+ *
69
+ * This is the recommended way for most users to interact with dhalsim.
70
+ * Instead of registering 26+ individual gadgets, just use Dhalsim
71
+ * and let it handle the complexity of web automation.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // In your agent
76
+ * const dhalsim = new Dhalsim();
77
+ * registry.register('Dhalsim', dhalsim);
78
+ *
79
+ * // The agent can now call:
80
+ * // Dhalsim(task="Find the price of iPhone 16 Pro", url="https://apple.com")
81
+ * ```
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // With custom session manager for Node.js compatibility
86
+ * import { TestBrowserSessionManager } from "dhalsim";
87
+ *
88
+ * const dhalsim = new Dhalsim({
89
+ * sessionManager: new TestBrowserSessionManager(),
90
+ * });
91
+ * ```
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * // With minimal prompt for simpler tasks
96
+ * import { DHALSIM_MINIMAL_PROMPT } from "dhalsim";
97
+ *
98
+ * const dhalsim = new Dhalsim({
99
+ * systemPrompt: DHALSIM_MINIMAL_PROMPT,
100
+ * });
101
+ * ```
102
+ */
103
+ export declare class Dhalsim extends Dhalsim_base {
104
+ private customSessionManager?;
105
+ private customSystemPrompt?;
106
+ constructor(options?: DhalsimOptions);
107
+ execute(params: this["params"], ctx?: ExecutionContext): Promise<{
108
+ result: string;
109
+ media?: GadgetMediaOutput[];
110
+ }>;
111
+ }
112
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { Dhalsim } from "./dhalsim";
2
+ export type { DhalsimOptions, DhalsimSessionManager } from "./dhalsim";
3
+ export { DHALSIM_SYSTEM_PROMPT, DHALSIM_MINIMAL_PROMPT } from "./prompts";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * System prompt for the Dhalsim subagent.
3
+ * This is a focused version of the CLI prompt, optimized for task completion.
4
+ */
5
+ export declare const DHALSIM_SYSTEM_PROMPT = "You are a browser automation agent focused on completing a specific web task.\n\n## Browser State (<CurrentBrowserState>)\nAfter each message, you receive a <CurrentBrowserState> block showing the LIVE browser state.\nThis is your source of truth for what's on screen. It contains:\n- OPEN PAGES: List of available pageIds (e.g., \"p1\")\n- URL and title of each page\n- INPUTS: Form fields with CSS selectors\n- BUTTONS: Clickable buttons with CSS selectors\n- LINKS: Navigation links with CSS selectors\n- CHECKBOXES: Checkbox/radio inputs\n- MENUITEMS: Dropdown options (only visible when dropdown is open)\n\n## CRITICAL Rules\n1. You have ONE page (p1) already open. Use Navigate to go to URLs.\n2. ONLY use selectors exactly as shown in <CurrentBrowserState>\n3. NEVER guess selectors - use GetFullPageContent if you need more info\n4. Focus on completing the task efficiently - avoid unnecessary actions\n5. 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.\n6. For batch extraction: GetFullPageContent returns ALL matches when a selector matches multiple elements (as \"texts\" array). Use this instead of querying each element separately.\n\n## Efficient Pattern\nOn first call: Navigate and DismissOverlays are ALREADY done. Take action immediately.\nAfter any Navigate call: DismissOverlays, then interact with elements.\n\nIf an action doesn't produce expected results, use GetFullPageContent to diagnose before retrying.\n\n## Dropdown/Toggle Behavior\nDropdowns are TOGGLES - clicking the same trigger twice will close it!\n- After Click on a dropdown trigger, check <CurrentBrowserState> for MENUITEMS\n- If menuitems appear, click the menuitem ONCE - do NOT click the trigger again\n- One click opens, second click closes\n\n## Avoid Infinite Loops\nIf an action doesn't produce the expected result after 2-3 attempts:\n1. Stop retrying the same action\n2. Use GetFullPageContent or Screenshot to diagnose\n3. Try a different approach or skip and continue\nNEVER click the same element more than 3 times in a row.\n\n## Available Gadgets\n- ReportResult: **REQUIRED** - Call this to return your findings when task is complete\n- Navigate: Go to a URL\n- Click: Click an element (auto-waits for element to be actionable)\n- Fill: Fill a form input\n- FillForm: Fill multiple fields and submit\n- Select: Select dropdown option\n- Check: Toggle checkboxes\n- GetFullPageContent: Read page text content\n- Screenshot: Capture the page (use when you need to show visual results)\n- DismissOverlays: Auto-dismiss cookie banners\n- Scroll: Scroll the page\n- WaitForElement: Wait for an element to appear\n- Wait: General wait\n\n## Task Completion\nWhen you have accomplished the task, you MUST call ReportResult with your findings:\n1. Call ReportResult(result=\"...\") with all extracted data and findings\n2. Include any relevant URLs, text content, or structured data\n3. If you took screenshots, describe what they show in the result\n\nRemember: You are a focused automation agent. Complete the task, call ReportResult, then stop.";
6
+ /**
7
+ * Truncated prompt for simpler tasks (fewer gadgets, less context).
8
+ */
9
+ export declare const DHALSIM_MINIMAL_PROMPT = "You are a browser agent. Complete the given task efficiently.\n\n## Browser State\n<CurrentBrowserState> shows what's on screen:\n- OPEN PAGES: Your page is \"p1\"\n- Selectors for INPUTS, BUTTONS, LINKS\n\n## Rules\n1. Use Navigate(pageId=\"p1\", url=\"...\") to visit URLs\n2. Use selectors exactly as shown in <CurrentBrowserState>\n3. Use DismissOverlays for cookie banners\n4. Complete the task and report findings";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Centralized constants for the dhalsim browser automation CLI.
3
+ */
4
+ export declare const ELEMENT_TEXT_MAX_LENGTH = 100;
5
+ export declare const ERROR_PREVIEW_LENGTH = 57;
6
+ export declare const RESULT_PREVIEW_LENGTH = 97;
7
+ export declare const TOOL_NAME_MAX_LENGTH = 27;
8
+ export declare const DEFAULT_CLICK_TIMEOUT = 5000;
9
+ export declare const DEFAULT_NAVIGATION_TIMEOUT = 30000;
10
+ export declare const OVERLAY_DISMISS_DELAY = 300;
11
+ export declare const UI_SETTLE_DELAY = 150;
12
+ export declare const BUTTON_SCORING: {
13
+ readonly saturationWeight: 5;
14
+ readonly brightnessThreshold: 100;
15
+ readonly positionWeight: 2;
16
+ readonly indexDecay: 0.5;
17
+ readonly areaDivisor: 5000;
18
+ };
19
+ export declare const MAX_SELECTORS_PER_QUERY = 50;
20
+ export declare const MAX_INPUTS_TO_SCAN = 100;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Utility functions for element existence checking.
3
+ */
4
+ import type { Locator } from "playwright-core";
5
+ /**
6
+ * Checks if an element exists and returns an error JSON string if not found or ambiguous.
7
+ * Returns null if exactly one element matches.
8
+ *
9
+ * When multiple elements match, provides disambiguation hints to help select a specific element.
10
+ */
11
+ export declare function checkElementExists(locator: Locator, selector: string): Promise<string | null>;
12
+ /**
13
+ * Checks if an element exists and is visible.
14
+ * Returns an error JSON string if not found, ambiguous, or not visible.
15
+ * Returns null if exactly one element matches and is visible.
16
+ */
17
+ export declare function checkElementVisible(locator: Locator, selector: string): Promise<string | null>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Utility functions for error handling and text processing.
3
+ */
4
+ /**
5
+ * Extracts a string message from an unknown error type.
6
+ * Safely handles both Error objects and other thrown values.
7
+ */
8
+ export declare function getErrorMessage(error: unknown): string;
9
+ /**
10
+ * Truncates text to a maximum length, adding ellipsis if truncated.
11
+ */
12
+ export declare function truncate(text: string, maxLength: number): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility exports for dhalsim browser automation CLI.
3
+ */
4
+ export { getErrorMessage, truncate, humanDelay, randomDelay } from "llmist";
5
+ export { ELEMENT_TEXT_MAX_LENGTH, ERROR_PREVIEW_LENGTH, RESULT_PREVIEW_LENGTH, TOOL_NAME_MAX_LENGTH, DEFAULT_CLICK_TIMEOUT, DEFAULT_NAVIGATION_TIMEOUT, OVERLAY_DISMISS_DELAY, BUTTON_SCORING, MAX_SELECTORS_PER_QUERY, MAX_INPUTS_TO_SCAN, } from "./constants.js";
6
+ export { checkElementExists, checkElementVisible } from "./element-checks.js";
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "dhalsim",
3
+ "version": "0.1.0",
4
+ "description": "Browser automation for llmist agents using Camoufox anti-detect browser",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "llmist": {
9
+ "gadgets": "./dist/index.js",
10
+ "factory": "./dist/index.js",
11
+ "subagents": {
12
+ "BrowseWeb": {
13
+ "entryPoint": "./dist/index.js",
14
+ "export": "Dhalsim",
15
+ "description": "Browse websites and accomplish tasks autonomously",
16
+ "uses": ["Navigate", "Click", "Screenshot", "GetFullPageContent", "Fill"],
17
+ "defaultModel": "sonnet",
18
+ "maxIterations": 15
19
+ }
20
+ },
21
+ "presets": {
22
+ "all": "*",
23
+ "subagent": ["BrowseWeb"],
24
+ "readonly": ["Navigate", "Screenshot", "GetFullPageContent", "ListPages"],
25
+ "minimal": ["Navigate", "Screenshot", "GetFullPageContent"]
26
+ },
27
+ "session": {
28
+ "factory": "getSessionManager",
29
+ "type": "browser"
30
+ }
31
+ },
32
+ "scripts": {
33
+ "build": "bun build src/index.ts --outdir dist --target node --external playwright-core --external camoufox-js --external chromium-bidi --external electron --external llmist && bun run build:types",
34
+ "build:types": "tsc --emitDeclarationOnly",
35
+ "typecheck": "tsc --noEmit",
36
+ "lint": "biome lint .",
37
+ "format": "biome format --write .",
38
+ "check": "biome check --write .",
39
+ "test": "vitest run --no-file-parallelism",
40
+ "precheck": "bun run lint && bun run typecheck && bun run test",
41
+ "prepare": "lefthook install"
42
+ },
43
+ "keywords": [
44
+ "browser",
45
+ "automation",
46
+ "playwright",
47
+ "llm",
48
+ "agent",
49
+ "web",
50
+ "scraping"
51
+ ],
52
+ "author": "Zbigniew Sobiecki",
53
+ "license": "MIT",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/zbigniewsobiecki/dhalsim.git"
57
+ },
58
+ "homepage": "https://github.com/zbigniewsobiecki/dhalsim#readme",
59
+ "bugs": {
60
+ "url": "https://github.com/zbigniewsobiecki/dhalsim/issues"
61
+ },
62
+ "files": [
63
+ "dist",
64
+ "dhalsim-icon.png",
65
+ "LICENSE",
66
+ "README.md"
67
+ ],
68
+ "dependencies": {
69
+ "camoufox-js": "github:zbigniewsobiecki/camoufox-js#impit-fallback",
70
+ "sharp": "^0.34.5"
71
+ },
72
+ "optionalDependencies": {
73
+ "better-sqlite3": "^11.0.0"
74
+ },
75
+ "devDependencies": {
76
+ "@biomejs/biome": "^2.3.2",
77
+ "@llmist/testing": ">=9.2.0",
78
+ "@types/node": "^20.12.7",
79
+ "bun-types": "^1.3.2",
80
+ "lefthook": "^1.6.0",
81
+ "llmist": ">=9.2.0",
82
+ "typescript": "^5.4.5",
83
+ "vitest": "^4.0.15"
84
+ },
85
+ "peerDependencies": {
86
+ "llmist": ">=9.2.0"
87
+ }
88
+ }