agentcore
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAWS Bedrock AgentCore
AWS Bedrock AgentCore
Run agent-browser on cloud browser sessions hosted by AWS Bedrock AgentCore. All standard agent-browser commands work identically; the only difference is where the browser runs.
在AWS Bedrock AgentCore托管的云浏览器会话上运行agent-browser。所有标准的agent-browser命令工作逻辑完全一致,唯一的区别是浏览器的运行位置不同。
Setup
配置
Credentials are resolved automatically:
- Environment variables (,
AWS_ACCESS_KEY_ID, optionallyAWS_SECRET_ACCESS_KEY)AWS_SESSION_TOKEN - AWS CLI fallback (), which supports SSO, IAM roles, and named profiles
aws configure export-credentials
No additional setup is needed if the user already has working AWS credentials.
凭证会自动解析:
- 环境变量(、
AWS_ACCESS_KEY_ID,可选配置AWS_SECRET_ACCESS_KEY)AWS_SESSION_TOKEN - AWS CLI fallback(),支持SSO、IAM角色和命名配置文件
aws configure export-credentials
如果用户已经有可用的AWS凭证,无需进行额外配置。
Core Workflow
核心工作流
bash
undefinedbash
undefinedOpen a page on an AgentCore cloud browser
在AgentCore云浏览器上打开页面
agent-browser -p agentcore open https://example.com
agent-browser -p agentcore open https://example.com
Everything else is the same as local Chrome
其余操作和本地Chrome完全一致
agent-browser snapshot -i
agent-browser click @e1
agent-browser screenshot page.png
agent-browser close
undefinedagent-browser snapshot -i
agent-browser click @e1
agent-browser screenshot page.png
agent-browser close
undefinedEnvironment Variables
环境变量
| Variable | Description | Default |
|---|---|---|
| AWS region | |
| Browser identifier | |
| Persistent browser profile (cookies, localStorage) | (none) |
| Session timeout in seconds | |
| AWS CLI profile for credential resolution | |
| 变量名 | 说明 | 默认值 |
|---|---|---|
| AWS区域 | |
| 浏览器标识符 | |
| 持久化浏览器配置文件(存储cookies、localStorage) | 无 |
| 会话超时时间,单位为秒 | |
| 用于凭证解析的AWS CLI配置文件 | |
Persistent Profiles
持久化配置文件
Use to persist browser state across sessions. This is useful for maintaining login sessions:
AGENTCORE_PROFILE_IDbash
undefined使用可以跨会话持久化浏览器状态,适合保留登录会话:
AGENTCORE_PROFILE_IDbash
undefinedFirst run: log in
首次运行:登录
AGENTCORE_PROFILE_ID=my-app agent-browser -p agentcore open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser close
AGENTCORE_PROFILE_ID=my-app agent-browser -p agentcore open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser close
Future runs: already authenticated
后续运行:已自动认证
AGENTCORE_PROFILE_ID=my-app agent-browser -p agentcore open https://app.example.com/dashboard
undefinedAGENTCORE_PROFILE_ID=my-app agent-browser -p agentcore open https://app.example.com/dashboard
undefinedLive View
实时预览
When a session starts, AgentCore prints a Live View URL to stderr. Open it in a browser to watch the session in real time from the AWS Console:
Session: abc123-def456
Live View: https://us-east-1.console.aws.amazon.com/bedrock-agentcore/browser/aws.browser.v1/session/abc123-def456#会话启动时,AgentCore会将实时预览URL打印到标准错误流。在浏览器中打开该URL即可从AWS控制台实时查看会话运行状态:
Session: abc123-def456
Live View: https://us-east-1.console.aws.amazon.com/bedrock-agentcore/browser/aws.browser.v1/session/abc123-def456#Region Selection
区域选择
bash
undefinedbash
undefinedDefault: us-east-1
默认区域:us-east-1
agent-browser -p agentcore open https://example.com
agent-browser -p agentcore open https://example.com
Explicit region
指定区域
AGENTCORE_REGION=eu-west-1 agent-browser -p agentcore open https://example.com
undefinedAGENTCORE_REGION=eu-west-1 agent-browser -p agentcore open https://example.com
undefinedCredential Patterns
凭证使用方式
bash
undefinedbash
undefinedExplicit credentials (CI/CD, scripts)
显式传入凭证(适用于CI/CD、脚本场景)
export AWS_ACCESS_KEY_ID=AKIA...
export AWS_SECRET_ACCESS_KEY=...
agent-browser -p agentcore open https://example.com
export AWS_ACCESS_KEY_ID=AKIA...
export AWS_SECRET_ACCESS_KEY=...
agent-browser -p agentcore open https://example.com
SSO (interactive)
SSO(交互式场景)
aws sso login --profile my-profile
AWS_PROFILE=my-profile agent-browser -p agentcore open https://example.com
aws sso login --profile my-profile
AWS_PROFILE=my-profile agent-browser -p agentcore open https://example.com
IAM role / default credential chain
IAM角色/默认凭证链
agent-browser -p agentcore open https://example.com
undefinedagent-browser -p agentcore open https://example.com
undefinedUsing with AGENT_BROWSER_PROVIDER
搭配AGENT_BROWSER_PROVIDER使用
Set the provider via environment variable to avoid passing on every command:
-p agentcorebash
export AGENT_BROWSER_PROVIDER=agentcore
export AGENTCORE_REGION=us-east-2
agent-browser open https://example.com
agent-browser snapshot -i
agent-browser click @e1
agent-browser close通过环境变量设置提供商,避免每次命令都传入参数:
-p agentcorebash
export AGENT_BROWSER_PROVIDER=agentcore
export AGENTCORE_REGION=us-east-2
agent-browser open https://example.com
agent-browser snapshot -i
agent-browser click @e1
agent-browser closeCommon Issues
常见问题
"Failed to run aws CLI" means AWS CLI is not installed or not in PATH. Either install it or set and directly.
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY"AWS CLI failed: ... Run 'aws sso login'" means SSO credentials have expired. Run to refresh them.
aws sso loginSession timeout: The default is 3600 seconds (1 hour). For longer tasks, increase with .
AGENTCORE_SESSION_TIMEOUT=7200"Failed to run aws CLI" 表示AWS CLI未安装或不在PATH路径中。可以安装AWS CLI,或者直接设置和环境变量。
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY"AWS CLI failed: ... Run 'aws sso login'" 表示SSO凭证已过期,运行刷新凭证即可。
aws sso login会话超时: 默认超时时间为3600秒(1小时)。如果需要运行更长时间的任务,可以通过调大超时时间。
AGENTCORE_SESSION_TIMEOUT=7200