agentcore

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AWS 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:
  1. Environment variables (
    AWS_ACCESS_KEY_ID
    ,
    AWS_SECRET_ACCESS_KEY
    , optionally
    AWS_SESSION_TOKEN
    )
  2. AWS CLI fallback (
    aws configure export-credentials
    ), which supports SSO, IAM roles, and named profiles
No additional setup is needed if the user already has working AWS credentials.
凭证会自动解析:
  1. 环境变量(
    AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY
    ,可选配置
    AWS_SESSION_TOKEN
  2. AWS CLI fallback(
    aws configure export-credentials
    ),支持SSO、IAM角色和命名配置文件
如果用户已经有可用的AWS凭证,无需进行额外配置。

Core Workflow

核心工作流

bash
undefined
bash
undefined

Open 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
undefined
agent-browser snapshot -i agent-browser click @e1 agent-browser screenshot page.png agent-browser close
undefined

Environment Variables

环境变量

VariableDescriptionDefault
AGENTCORE_REGION
AWS region
us-east-1
AGENTCORE_BROWSER_ID
Browser identifier
aws.browser.v1
AGENTCORE_PROFILE_ID
Persistent browser profile (cookies, localStorage)(none)
AGENTCORE_SESSION_TIMEOUT
Session timeout in seconds
3600
AWS_PROFILE
AWS CLI profile for credential resolution
default
变量名说明默认值
AGENTCORE_REGION
AWS区域
us-east-1
AGENTCORE_BROWSER_ID
浏览器标识符
aws.browser.v1
AGENTCORE_PROFILE_ID
持久化浏览器配置文件(存储cookies、localStorage)
AGENTCORE_SESSION_TIMEOUT
会话超时时间,单位为秒
3600
AWS_PROFILE
用于凭证解析的AWS CLI配置文件
default

Persistent Profiles

持久化配置文件

Use
AGENTCORE_PROFILE_ID
to persist browser state across sessions. This is useful for maintaining login sessions:
bash
undefined
使用
AGENTCORE_PROFILE_ID
可以跨会话持久化浏览器状态,适合保留登录会话:
bash
undefined

First 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
undefined
AGENTCORE_PROFILE_ID=my-app agent-browser -p agentcore open https://app.example.com/dashboard
undefined

Live 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
undefined
bash
undefined

Default: 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
undefined
AGENTCORE_REGION=eu-west-1 agent-browser -p agentcore open https://example.com
undefined

Credential Patterns

凭证使用方式

bash
undefined
bash
undefined

Explicit 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
undefined
agent-browser -p agentcore open https://example.com
undefined

Using with AGENT_BROWSER_PROVIDER

搭配AGENT_BROWSER_PROVIDER使用

Set the provider via environment variable to avoid passing
-p agentcore
on every command:
bash
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 agentcore
参数:
bash
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

Common Issues

常见问题

"Failed to run aws CLI" means AWS CLI is not installed or not in PATH. Either install it or set
AWS_ACCESS_KEY_ID
and
AWS_SECRET_ACCESS_KEY
directly.
"AWS CLI failed: ... Run 'aws sso login'" means SSO credentials have expired. Run
aws sso login
to refresh them.
Session 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_ID
AWS_SECRET_ACCESS_KEY
环境变量。
"AWS CLI failed: ... Run 'aws sso login'" 表示SSO凭证已过期,运行
aws sso login
刷新凭证即可。
会话超时: 默认超时时间为3600秒(1小时)。如果需要运行更长时间的任务,可以通过
AGENTCORE_SESSION_TIMEOUT=7200
调大超时时间。