feat(skills): add agent-browser option for browser automation (#1090)
Add configurable browser automation allowing users to choose between Playwright MCP (default) and Vercel's agent-browser CLI. Changes: - Add browser_automation_engine.provider config option - Dynamic skill loading based on provider selection - Comprehensive agent-browser CLI reference (inline in skills.ts) - Propagate browserProvider to delegate_task and buildAgent - Update documentation with provider comparison Co-authored-by: Suyeol Jeon <devxoul@gmail.com> Co-authored-by: YeonGyu Kim <code.yeongyu@gmail.com>
This commit is contained in:
@@ -3,14 +3,15 @@ import { DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS, CATEGORY_DESCRIPTIONS } fr
|
||||
import { resolveCategoryConfig } from "./tools"
|
||||
import type { CategoryConfig } from "../../config/schema"
|
||||
import { __resetModelCache } from "../../shared/model-availability"
|
||||
import { clearSkillCache } from "../../features/opencode-skill-loader/skill-content"
|
||||
|
||||
// Test constants - systemDefaultModel is required by resolveCategoryConfig
|
||||
const SYSTEM_DEFAULT_MODEL = "anthropic/claude-sonnet-4-5"
|
||||
|
||||
describe("sisyphus-task", () => {
|
||||
// Reset model cache before each test to prevent cross-test pollution
|
||||
beforeEach(() => {
|
||||
__resetModelCache()
|
||||
clearSkillCache()
|
||||
})
|
||||
|
||||
describe("DEFAULT_CATEGORIES", () => {
|
||||
@@ -1324,6 +1325,112 @@ describe("sisyphus-task", () => {
|
||||
}, { timeout: 20000 })
|
||||
})
|
||||
|
||||
describe("browserProvider propagation", () => {
|
||||
test("should resolve agent-browser skill when browserProvider is passed", async () => {
|
||||
// #given - delegate_task configured with browserProvider: "agent-browser"
|
||||
const { createDelegateTask } = require("./tools")
|
||||
let promptBody: any
|
||||
|
||||
const mockManager = { launch: async () => ({}) }
|
||||
const mockClient = {
|
||||
app: { agents: async () => ({ data: [] }) },
|
||||
config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) },
|
||||
session: {
|
||||
get: async () => ({ data: { directory: "/project" } }),
|
||||
create: async () => ({ data: { id: "ses_browser_provider" } }),
|
||||
prompt: async (input: any) => {
|
||||
promptBody = input.body
|
||||
return { data: {} }
|
||||
},
|
||||
messages: async () => ({
|
||||
data: [{ info: { role: "assistant" }, parts: [{ type: "text", text: "Done" }] }]
|
||||
}),
|
||||
status: async () => ({ data: {} }),
|
||||
},
|
||||
}
|
||||
|
||||
// Pass browserProvider to createDelegateTask
|
||||
const tool = createDelegateTask({
|
||||
manager: mockManager,
|
||||
client: mockClient,
|
||||
browserProvider: "agent-browser",
|
||||
})
|
||||
|
||||
const toolContext = {
|
||||
sessionID: "parent-session",
|
||||
messageID: "parent-message",
|
||||
agent: "Sisyphus",
|
||||
abort: new AbortController().signal,
|
||||
}
|
||||
|
||||
// #when - request agent-browser skill
|
||||
await tool.execute(
|
||||
{
|
||||
description: "Test browserProvider propagation",
|
||||
prompt: "Do something",
|
||||
category: "ultrabrain",
|
||||
run_in_background: false,
|
||||
load_skills: ["agent-browser"],
|
||||
},
|
||||
toolContext
|
||||
)
|
||||
|
||||
// #then - agent-browser skill should be resolved (not in notFound)
|
||||
expect(promptBody).toBeDefined()
|
||||
expect(promptBody.system).toBeDefined()
|
||||
expect(promptBody.system).toContain("agent-browser")
|
||||
}, { timeout: 20000 })
|
||||
|
||||
test("should NOT resolve agent-browser skill when browserProvider is not set", async () => {
|
||||
// #given - delegate_task without browserProvider (defaults to playwright)
|
||||
const { createDelegateTask } = require("./tools")
|
||||
|
||||
const mockManager = { launch: async () => ({}) }
|
||||
const mockClient = {
|
||||
app: { agents: async () => ({ data: [] }) },
|
||||
config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) },
|
||||
session: {
|
||||
get: async () => ({ data: { directory: "/project" } }),
|
||||
create: async () => ({ data: { id: "ses_no_browser_provider" } }),
|
||||
prompt: async () => ({ data: {} }),
|
||||
messages: async () => ({
|
||||
data: [{ info: { role: "assistant" }, parts: [{ type: "text", text: "Done" }] }]
|
||||
}),
|
||||
status: async () => ({ data: {} }),
|
||||
},
|
||||
}
|
||||
|
||||
// No browserProvider passed
|
||||
const tool = createDelegateTask({
|
||||
manager: mockManager,
|
||||
client: mockClient,
|
||||
})
|
||||
|
||||
const toolContext = {
|
||||
sessionID: "parent-session",
|
||||
messageID: "parent-message",
|
||||
agent: "Sisyphus",
|
||||
abort: new AbortController().signal,
|
||||
}
|
||||
|
||||
// #when - request agent-browser skill without browserProvider
|
||||
const result = await tool.execute(
|
||||
{
|
||||
description: "Test missing browserProvider",
|
||||
prompt: "Do something",
|
||||
category: "ultrabrain",
|
||||
run_in_background: false,
|
||||
load_skills: ["agent-browser"],
|
||||
},
|
||||
toolContext
|
||||
)
|
||||
|
||||
// #then - should return skill not found error
|
||||
expect(result).toContain("Skills not found")
|
||||
expect(result).toContain("agent-browser")
|
||||
})
|
||||
})
|
||||
|
||||
describe("buildSystemContent", () => {
|
||||
test("returns undefined when no skills and no category promptAppend", () => {
|
||||
// #given
|
||||
|
||||
@@ -3,7 +3,7 @@ import { existsSync, readdirSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
import type { DelegateTaskArgs } from "./types"
|
||||
import type { CategoryConfig, CategoriesConfig, GitMasterConfig } from "../../config/schema"
|
||||
import type { CategoryConfig, CategoriesConfig, GitMasterConfig, BrowserAutomationProvider } from "../../config/schema"
|
||||
import { DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS, CATEGORY_DESCRIPTIONS } from "./constants"
|
||||
import { findNearestMessageWithFields, findFirstMessageWithAgent, MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||
import { resolveMultipleSkillsAsync } from "../../features/opencode-skill-loader/skill-content"
|
||||
@@ -157,6 +157,7 @@ export interface DelegateTaskToolOptions {
|
||||
userCategories?: CategoriesConfig
|
||||
gitMasterConfig?: GitMasterConfig
|
||||
sisyphusJuniorModel?: string
|
||||
browserProvider?: BrowserAutomationProvider
|
||||
}
|
||||
|
||||
export interface BuildSystemContentInput {
|
||||
@@ -179,7 +180,7 @@ export function buildSystemContent(input: BuildSystemContentInput): string | und
|
||||
}
|
||||
|
||||
export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefinition {
|
||||
const { manager, client, directory, userCategories, gitMasterConfig, sisyphusJuniorModel } = options
|
||||
const { manager, client, directory, userCategories, gitMasterConfig, sisyphusJuniorModel, browserProvider } = options
|
||||
|
||||
const allCategories = { ...DEFAULT_CATEGORIES, ...userCategories }
|
||||
const categoryNames = Object.keys(allCategories)
|
||||
@@ -239,7 +240,7 @@ Prompts MUST be in English.`
|
||||
|
||||
let skillContent: string | undefined
|
||||
if (args.load_skills.length > 0) {
|
||||
const { resolved, notFound } = await resolveMultipleSkillsAsync(args.load_skills, { gitMasterConfig })
|
||||
const { resolved, notFound } = await resolveMultipleSkillsAsync(args.load_skills, { gitMasterConfig, browserProvider })
|
||||
if (notFound.length > 0) {
|
||||
const allSkills = await discoverSkills({ includeClaudeCodePaths: true })
|
||||
const available = allSkills.map(s => s.name).join(", ")
|
||||
|
||||
Reference in New Issue
Block a user