Overall Goal: Add support for Stagehand AI browser automation with configuration for both OpenAI and Anthropic providers.
Add new configuration sections for Stagehand and its providers:
{
"stagehand": {
"provider": "anthropic", // or "openai"
"timeout": 30000,
"headless": true,
"verbose": false,
"debugDom": false,
"enableCaching": true,
"model": {
"anthropic": "claude-3-5-sonnet-latest",
"openai": "o3-mini"
}
}
}
Add support for provider API keys:
ANTHROPIC_API_KEY="your-anthropic-api-key"
OPENAI_API_KEY="your-openai-api-key"
-
Update Configuration System
- Modify
src/config.ts
to include new Stagehand configuration types and defaults - Add validation for Stagehand-specific configuration
- Update environment variable loading to handle new API keys
- Modify
-
Update Installation Process
- Modify
src/commands/install.ts
to:- Prompt for Stagehand provider selection (OpenAI or Anthropic)
- Collect appropriate API key based on provider
- Set up default configuration in
cursor-tools.config.json
- Modify
-
Stagehand Command Implementation
- Create
src/commands/browser/stagehand/config.ts
for Stagehand-specific configuration - Update
src/commands/browser/stagehand/act.ts
to:- Use configuration from
cursor-tools.config.json
- Handle provider-specific setup (API keys, models)
- Implement proper error handling and timeout management
- Use configuration from
- Create
-
Documentation Updates
- Update README.md with Stagehand configuration instructions
- Add examples for both OpenAI and Anthropic usage
- Document configuration options and their effects
interface StagehandConfig {
provider: 'anthropic' | 'openai';
timeout: number;
headless: boolean;
verbose: boolean;
debugDom: boolean;
enableCaching: boolean;
model: {
anthropic: string;
openai: string;
};
}
const defaultStagehandConfig: StagehandConfig = {
provider: 'anthropic',
timeout: 30000,
headless: true,
verbose: false,
debugDom: false,
enableCaching: true,
model: {
anthropic: 'claude-3-5-sonnet-latest',
openai: 'o3-mini'
}
};
- Follow existing pattern of checking both project-level and user-level .env files
- Add validation to ensure required API key is present based on selected provider
- Provide clear error messages if required keys are missing
-
Configuration Tests
- Test loading and validation of Stagehand configuration
- Verify provider selection affects which API key is required
- Test fallback to default values
-
Integration Tests
- Test Stagehand initialization with both providers
- Verify timeout handling
- Test error scenarios (missing API keys, invalid configuration)
-
Manual Testing
- Test browser automation with both providers
- Verify configuration changes affect behavior
- Test error handling and user feedback
- Add configuration system updates
- Implement API key management
- Update installation process
- Implement Stagehand command updates
- Add documentation
- Add tests
- Manual testing and refinement
- Add support for provider-specific configuration options
- Consider adding provider-specific timeout settings
- Add support for custom model configurations
- Consider adding caching configuration options
- Add support for session management with Browserbase