Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@browseros/server",
"version": "0.0.73",
"version": "0.0.74",
"description": "BrowserOS server",
"type": "module",
"main": "./src/index.ts",
Expand Down
4 changes: 1 addition & 3 deletions apps/server/src/agent/ai-sdk-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ export class AiSdkAgent {
}

// Build system prompt with optional section exclusions
// Tool definitions are already injected by the AI SDK via tool schemas,
// so skip the redundant tool-reference section.
const excludeSections: string[] = ['tool-reference']
const excludeSections: string[] = []
if (config.resolvedConfig.isScheduledTask) {
excludeSections.push('tab-grouping')
}
Expand Down
83 changes: 0 additions & 83 deletions apps/server/src/agent/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,82 +128,6 @@ function getErrorRecovery(): string {
---`
}

// -----------------------------------------------------------------------------
// section: cdp-tool-reference
// Skipped by ToolLoopAgent — the AI SDK already injects tool schemas into the
// LLM call. Kept for MCP prompt serving where clients lack tool definitions.
// -----------------------------------------------------------------------------

function getCdpToolReference(): string {
return `# Tool Reference

## Page Management
- \`get_active_page\` - Get the currently active (focused) page
- \`list_pages\` - Get all open pages with IDs, titles, tab IDs, and URLs
- \`new_page(url, hidden?, background?, windowId?)\` - Open a new page. Use hidden for background processing, background to avoid activating.
- \`close_page(page)\` - Close a page by its page ID
- \`navigate_page(page, action, url?)\` - Navigate: action is "url", "back", "forward", or "reload"
- \`wait_for(page, text?, selector?, timeout?)\` - Wait for text or CSS selector to appear

## Content Capture
- \`take_snapshot(page)\` - Get interactive elements with IDs (e.g. [47]). **Always take before interacting.**
- \`take_enhanced_snapshot(page)\` - Detailed accessibility tree with structural context
- \`get_page_content(page, selector?, viewportOnly?, includeLinks?, includeImages?)\` - Extract page as clean markdown with headers, links, lists, tables. **Prefer for data extraction.**
- \`take_screenshot(page, format?, quality?, fullPage?)\` - Capture page image
- \`evaluate_script(page, expression)\` - Run JavaScript in page context

## Input & Interaction
- \`click(page, element)\` - Click element by ID from snapshot
- \`click_at(page, x, y)\` - Click at specific coordinates
- \`hover(page, element)\` - Hover over element
- \`focus(page, element)\` - Focus an element (scrolls into view first)
- \`clear(page, element)\` - Clear text from input or textarea
- \`fill(page, element, text, clear?)\` - Type into input/textarea (clears first by default)
- \`check(page, element)\` - Check a checkbox or radio button (no-op if already checked)
- \`uncheck(page, element)\` - Uncheck a checkbox (no-op if already unchecked)
- \`upload_file(page, element, files)\` - Set file(s) on a file input (absolute paths)
- \`select_option(page, element, value)\` - Select dropdown option by value or text
- \`press_key(page, key)\` - Press key or combo (e.g., "Enter", "Control+A", "ArrowDown")
- \`drag(page, sourceElement, targetElement?, targetX?, targetY?)\` - Drag element to another element or coordinates
- \`scroll(page, direction?, amount?, element?)\` - Scroll page or element (up/down/left/right)
- \`handle_dialog(page, accept, promptText?)\` - Handle browser dialogs (alert, confirm, prompt)

## Page Actions
- \`save_pdf(page, path, cwd?)\` - Save page as PDF to disk
- \`download_file(page, element, path, cwd?)\` - Click element to trigger download, save to directory

## Window Management
- \`list_windows\` - Get all browser windows
- \`create_window(hidden?)\` - Create a new browser window
- \`close_window(windowId)\` - Close a browser window
- \`activate_window(windowId)\` - Activate (focus) a browser window

## Tab Groups
- \`list_tab_groups\` - Get all tab groups with IDs, titles, colors, and page IDs
- \`group_tabs(pageIds, title?, groupId?)\` - Create group or add pages to existing group (groupId is a string)
- \`update_tab_group(groupId, title?, color?, collapsed?)\` - Update group properties
- \`ungroup_tabs(pageIds)\` - Remove pages from their groups
- \`close_tab_group(groupId)\` - Close a tab group and all its tabs

**Colors**: grey, blue, red, yellow, green, pink, purple, cyan, orange

## Bookmarks
- \`get_bookmarks\` - Get all bookmarks
- \`create_bookmark(title, url?, parentId?)\` - Create bookmark or folder (omit url for folder)
- \`update_bookmark(id, title?, url?)\` - Edit bookmark
- \`remove_bookmark(id)\` - Delete bookmark or folder (recursive)
- \`move_bookmark(id, parentId?, index?)\` - Move bookmark or folder
- \`search_bookmarks(query)\` - Search bookmarks by title or URL

## History
- \`search_history(query, maxResults?)\` - Search browser history
- \`get_recent_history(maxResults?)\` - Get recent history items
- \`delete_history_url(url)\` - Delete a specific URL from history
- \`delete_history_range(startTime, endTime)\` - Delete history within a time range (epoch ms)

---`
}

// -----------------------------------------------------------------------------
// section: external-integrations
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -481,7 +405,6 @@ const promptSections: Record<string, PromptSectionFn> = {
'observe-act-verify': getObserveActVerify,
'handle-obstacles': getHandleObstacles,
'error-recovery': getErrorRecovery,
'tool-reference': getCdpToolReference,
'external-integrations': getExternalIntegrations,
style: getStyle,
nudges: getNudges,
Expand All @@ -495,8 +418,6 @@ const promptSections: Record<string, PromptSectionFn> = {
'security-reminder': getSecurityReminder,
}

export const PROMPT_SECTION_KEYS = Object.keys(promptSections)

interface BuildSystemPromptOptions {
userSystemPrompt?: string
exclude?: string[]
Expand All @@ -523,7 +444,3 @@ export function buildSystemPrompt(options?: BuildSystemPromptOptions): string {

return `<AGENT_PROMPT>\n${sections.join('\n\n')}\n</AGENT_PROMPT>`
}

export function getSystemPrompt(): string {
return buildSystemPrompt()
}
2 changes: 1 addition & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading