veil-browser 0.1.7 → 0.1.8

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 (2) hide show
  1. package/dist/ai.js +37 -16
  2. package/package.json +1 -1
package/dist/ai.js CHANGED
@@ -81,30 +81,51 @@ async function getPageSnapshot(page) {
81
81
  }
82
82
  // Call LLM to get action steps
83
83
  async function getActionsFromLLM(instruction, snapshot, pageUrl, llm) {
84
- const systemPrompt = `You are a browser automation assistant. Given a page snapshot (ARIA/DOM tree) and a user instruction, return a JSON array of action steps to complete the task.
84
+ // Load platform-specific guide
85
+ let platformGuide = '';
86
+ if (pageUrl.includes('x.com') || pageUrl.includes('twitter.com')) {
87
+ try {
88
+ const { readFileSync } = await import('fs');
89
+ platformGuide = readFileSync(new URL('../prompts/x-guide.md', import.meta.url), 'utf-8');
90
+ }
91
+ catch { }
92
+ }
93
+ else if (pageUrl.includes('linkedin.com')) {
94
+ try {
95
+ const { readFileSync } = await import('fs');
96
+ platformGuide = readFileSync(new URL('../prompts/linkedin-guide.md', import.meta.url), 'utf-8');
97
+ }
98
+ catch { }
99
+ }
100
+ const systemPrompt = `You are an expert browser automation assistant. Given a page snapshot and a user instruction, return ONLY a valid JSON array of action steps.
101
+
102
+ ${platformGuide ? `\n## Platform-Specific Guide\n${platformGuide}\n` : ''}
85
103
 
86
- Available actions:
87
- - click: { action: "click", selector: "CSS or data-testid selector", description: "..." }
88
- - type: { action: "type", selector: "...", text: "the text to type", description: "..." }
89
- - press: { action: "press", key: "Enter|Tab|Escape|...", description: "..." }
90
- - navigate: { action: "navigate", url: "https://...", description: "..." }
91
- - wait: { action: "wait", ms: 1000, description: "..." }
92
- - scroll: { action: "scroll", direction: "down", description: "..." }
104
+ ## Available Actions
105
+ - click: { action: "click", selector: "CSS or data-testid selector" }
106
+ - type: { action: "type", selector: "...", text: "text to type" }
107
+ - press: { action: "press", key: "Enter|Tab|Escape|..." }
108
+ - navigate: { action: "navigate", url: "https://..." }
109
+ - wait: { action: "wait", ms: 1000 }
110
+ - scroll: { action: "scroll", direction: "down" }
93
111
 
94
- Rules:
95
- - Prefer data-testid selectors when available (most stable)
96
- - For Twitter/X: use [data-testid="tweetTextarea_0"] for tweet box, [data-testid="tweetButtonInline"] for post button
97
- - Return ONLY valid JSON array, no explanation
98
- - Add a wait step after clicks on buttons that trigger UI changes
99
- - For typing in contenteditable areas, click first then type`;
112
+ ## Rules
113
+ 1. Return ONLY valid JSON array, nothing else
114
+ 2. Each action MUST have all required fields
115
+ 3. Never generate navigate actions unless instruction explicitly says to go to a URL
116
+ 4. Add description field to every action
117
+ 5. After clicks that open modals/menus, always add 500ms wait
118
+ 6. Use data-testid selectors when available (most stable)
119
+ 7. For contenteditable areas, click first then type
120
+ 8. Always filter posts by visible content before interacting`;
100
121
  const userPrompt = `Current URL: ${pageUrl}
101
122
 
102
123
  Page snapshot:
103
- ${snapshot.slice(0, 4000)}
124
+ ${snapshot.slice(0, 3500)}
104
125
 
105
126
  Instruction: ${instruction}
106
127
 
107
- Return JSON array of action steps:`;
128
+ Return ONLY a valid JSON array of action steps with no other text:`;
108
129
  let response;
109
130
  if (llm.provider === 'ollama') {
110
131
  const baseUrl = llm.baseUrl ?? 'http://localhost:11434';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veil-browser",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Stealth browser CLI for AI agents — bypass bot detection, persist sessions, local CAPTCHA solving, MCP server",
5
5
  "keywords": [
6
6
  "browser",