Skip to content

Commit 209baf8

Browse files
author
awstools
committed
feat(client-bedrock-agentcore): This release includes support for 1) InvokeBrowser API, enabling OS-level control of AgentCore Browser Tool sessions through mouse actions, keyboard input, and screenshots. 2) Added documentation noting that empty sessions are automatically deleted after one day in the ListSessions API.
1 parent 2498b34 commit 209baf8

13 files changed

Lines changed: 1887 additions & 10 deletions

File tree

clients/client-bedrock-agentcore/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ InvokeAgentRuntimeCommand
321321
</details>
322322
<details>
323323
<summary>
324+
InvokeBrowser
325+
</summary>
326+
327+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agentcore/command/InvokeBrowserCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agentcore/Interface/InvokeBrowserCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agentcore/Interface/InvokeBrowserCommandOutput/)
328+
</details>
329+
<details>
330+
<summary>
324331
InvokeCodeInterpreter
325332
</summary>
326333

clients/client-bedrock-agentcore/src/BedrockAgentCore.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ import {
9595
type InvokeAgentRuntimeCommandCommandOutput,
9696
InvokeAgentRuntimeCommandCommand,
9797
} from "./commands/InvokeAgentRuntimeCommandCommand";
98+
import {
99+
type InvokeBrowserCommandInput,
100+
type InvokeBrowserCommandOutput,
101+
InvokeBrowserCommand,
102+
} from "./commands/InvokeBrowserCommand";
98103
import {
99104
type InvokeCodeInterpreterCommandInput,
100105
type InvokeCodeInterpreterCommandOutput,
@@ -208,6 +213,7 @@ const commands = {
208213
GetWorkloadAccessTokenForUserIdCommand,
209214
InvokeAgentRuntimeCommand,
210215
InvokeAgentRuntimeCommandCommand,
216+
InvokeBrowserCommand,
211217
InvokeCodeInterpreterCommand,
212218
ListActorsCommand,
213219
ListBrowserSessionsCommand,
@@ -576,6 +582,23 @@ export interface BedrockAgentCore {
576582
cb: (err: any, data?: InvokeAgentRuntimeCommandCommandOutput) => void
577583
): void;
578584

585+
/**
586+
* @see {@link InvokeBrowserCommand}
587+
*/
588+
invokeBrowser(
589+
args: InvokeBrowserCommandInput,
590+
options?: __HttpHandlerOptions
591+
): Promise<InvokeBrowserCommandOutput>;
592+
invokeBrowser(
593+
args: InvokeBrowserCommandInput,
594+
cb: (err: any, data?: InvokeBrowserCommandOutput) => void
595+
): void;
596+
invokeBrowser(
597+
args: InvokeBrowserCommandInput,
598+
options: __HttpHandlerOptions,
599+
cb: (err: any, data?: InvokeBrowserCommandOutput) => void
600+
): void;
601+
579602
/**
580603
* @see {@link InvokeCodeInterpreterCommand}
581604
*/

clients/client-bedrock-agentcore/src/BedrockAgentCoreClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ import type {
130130
InvokeAgentRuntimeCommandCommandInput,
131131
InvokeAgentRuntimeCommandCommandOutput,
132132
} from "./commands/InvokeAgentRuntimeCommandCommand";
133+
import type { InvokeBrowserCommandInput, InvokeBrowserCommandOutput } from "./commands/InvokeBrowserCommand";
133134
import type {
134135
InvokeCodeInterpreterCommandInput,
135136
InvokeCodeInterpreterCommandOutput,
@@ -224,6 +225,7 @@ export type ServiceInputTypes =
224225
| GetWorkloadAccessTokenForUserIdCommandInput
225226
| InvokeAgentRuntimeCommandCommandInput
226227
| InvokeAgentRuntimeCommandInput
228+
| InvokeBrowserCommandInput
227229
| InvokeCodeInterpreterCommandInput
228230
| ListActorsCommandInput
229231
| ListBrowserSessionsCommandInput
@@ -266,6 +268,7 @@ export type ServiceOutputTypes =
266268
| GetWorkloadAccessTokenForUserIdCommandOutput
267269
| InvokeAgentRuntimeCommandCommandOutput
268270
| InvokeAgentRuntimeCommandOutput
271+
| InvokeBrowserCommandOutput
269272
| InvokeCodeInterpreterCommandOutput
270273
| ListActorsCommandOutput
271274
| ListBrowserSessionsCommandOutput
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { Command as $Command } from "@smithy/smithy-client";
4+
import type { MetadataBearer as __MetadataBearer } from "@smithy/types";
5+
6+
import type {
7+
BedrockAgentCoreClientResolvedConfig,
8+
ServiceInputTypes,
9+
ServiceOutputTypes,
10+
} from "../BedrockAgentCoreClient";
11+
import { commonParams } from "../endpoint/EndpointParameters";
12+
import type { InvokeBrowserRequest, InvokeBrowserResponse } from "../models/models_0";
13+
import { InvokeBrowser$ } from "../schemas/schemas_0";
14+
15+
/**
16+
* @public
17+
*/
18+
export type { __MetadataBearer };
19+
export { $Command };
20+
/**
21+
* @public
22+
*
23+
* The input for {@link InvokeBrowserCommand}.
24+
*/
25+
export interface InvokeBrowserCommandInput extends InvokeBrowserRequest {}
26+
/**
27+
* @public
28+
*
29+
* The output of {@link InvokeBrowserCommand}.
30+
*/
31+
export interface InvokeBrowserCommandOutput extends InvokeBrowserResponse, __MetadataBearer {}
32+
33+
/**
34+
* <p>Invokes an operating system-level action on a browser session in Amazon Bedrock AgentCore. This operation provides direct OS-level control over browser sessions, enabling mouse actions, keyboard input, and screenshots that the WebSocket-based Chrome DevTools Protocol (CDP) cannot handle — such as interacting with print dialogs, context menus, and JavaScript alerts.</p> <p>You send a request with exactly one action in the <code>BrowserAction</code> union, and receive a corresponding result in the <code>BrowserActionResult</code> union.</p> <p>The following operations are related to <code>InvokeBrowser</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_StartBrowserSession.html">StartBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_GetBrowserSession.html">GetBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_StopBrowserSession.html">StopBrowserSession</a> </p> </li> </ul>
35+
* @example
36+
* Use a bare-bones client and the command you need to make an API call.
37+
* ```javascript
38+
* import { BedrockAgentCoreClient, InvokeBrowserCommand } from "@aws-sdk/client-bedrock-agentcore"; // ES Modules import
39+
* // const { BedrockAgentCoreClient, InvokeBrowserCommand } = require("@aws-sdk/client-bedrock-agentcore"); // CommonJS import
40+
* // import type { BedrockAgentCoreClientConfig } from "@aws-sdk/client-bedrock-agentcore";
41+
* const config = {}; // type is BedrockAgentCoreClientConfig
42+
* const client = new BedrockAgentCoreClient(config);
43+
* const input = { // InvokeBrowserRequest
44+
* browserIdentifier: "STRING_VALUE", // required
45+
* sessionId: "STRING_VALUE", // required
46+
* action: { // BrowserAction Union: only one key present
47+
* mouseClick: { // MouseClickArguments
48+
* x: Number("int"), // required
49+
* y: Number("int"), // required
50+
* button: "LEFT" || "RIGHT" || "MIDDLE",
51+
* clickCount: Number("int"),
52+
* },
53+
* mouseMove: { // MouseMoveArguments
54+
* x: Number("int"), // required
55+
* y: Number("int"), // required
56+
* },
57+
* mouseDrag: { // MouseDragArguments
58+
* endX: Number("int"), // required
59+
* endY: Number("int"), // required
60+
* startX: Number("int"), // required
61+
* startY: Number("int"), // required
62+
* button: "LEFT" || "RIGHT" || "MIDDLE",
63+
* },
64+
* mouseScroll: { // MouseScrollArguments
65+
* x: Number("int"), // required
66+
* y: Number("int"), // required
67+
* deltaX: Number("int"),
68+
* deltaY: Number("int"),
69+
* },
70+
* keyType: { // KeyTypeArguments
71+
* text: "STRING_VALUE", // required
72+
* },
73+
* keyPress: { // KeyPressArguments
74+
* key: "STRING_VALUE", // required
75+
* presses: Number("int"),
76+
* },
77+
* keyShortcut: { // KeyShortcutArguments
78+
* keys: [ // KeyList // required
79+
* "STRING_VALUE",
80+
* ],
81+
* },
82+
* screenshot: { // ScreenshotArguments
83+
* format: "PNG",
84+
* },
85+
* },
86+
* };
87+
* const command = new InvokeBrowserCommand(input);
88+
* const response = await client.send(command);
89+
* // { // InvokeBrowserResponse
90+
* // result: { // BrowserActionResult Union: only one key present
91+
* // mouseClick: { // MouseClickResult
92+
* // status: "SUCCESS" || "FAILED", // required
93+
* // error: "STRING_VALUE",
94+
* // },
95+
* // mouseMove: { // MouseMoveResult
96+
* // status: "SUCCESS" || "FAILED", // required
97+
* // error: "STRING_VALUE",
98+
* // },
99+
* // mouseDrag: { // MouseDragResult
100+
* // status: "SUCCESS" || "FAILED", // required
101+
* // error: "STRING_VALUE",
102+
* // },
103+
* // mouseScroll: { // MouseScrollResult
104+
* // status: "SUCCESS" || "FAILED", // required
105+
* // error: "STRING_VALUE",
106+
* // },
107+
* // keyType: { // KeyTypeResult
108+
* // status: "SUCCESS" || "FAILED", // required
109+
* // error: "STRING_VALUE",
110+
* // },
111+
* // keyPress: { // KeyPressResult
112+
* // status: "SUCCESS" || "FAILED", // required
113+
* // error: "STRING_VALUE",
114+
* // },
115+
* // keyShortcut: { // KeyShortcutResult
116+
* // status: "SUCCESS" || "FAILED", // required
117+
* // error: "STRING_VALUE",
118+
* // },
119+
* // screenshot: { // ScreenshotResult
120+
* // status: "SUCCESS" || "FAILED", // required
121+
* // error: "STRING_VALUE",
122+
* // data: new Uint8Array(),
123+
* // },
124+
* // },
125+
* // sessionId: "STRING_VALUE", // required
126+
* // };
127+
*
128+
* ```
129+
*
130+
* @param InvokeBrowserCommandInput - {@link InvokeBrowserCommandInput}
131+
* @returns {@link InvokeBrowserCommandOutput}
132+
* @see {@link InvokeBrowserCommandInput} for command's `input` shape.
133+
* @see {@link InvokeBrowserCommandOutput} for command's `response` shape.
134+
* @see {@link BedrockAgentCoreClientResolvedConfig | config} for BedrockAgentCoreClient's `config` shape.
135+
*
136+
* @throws {@link AccessDeniedException} (client fault)
137+
* <p>The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.</p>
138+
*
139+
* @throws {@link InternalServerException} (server fault)
140+
* <p>The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.</p>
141+
*
142+
* @throws {@link ResourceNotFoundException} (client fault)
143+
* <p>The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.</p>
144+
*
145+
* @throws {@link ServiceQuotaExceededException} (client fault)
146+
* <p>The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.</p>
147+
*
148+
* @throws {@link ThrottlingException} (client fault)
149+
* <p>The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.</p>
150+
*
151+
* @throws {@link ValidationException} (client fault)
152+
* <p>The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.</p>
153+
*
154+
* @throws {@link BedrockAgentCoreServiceException}
155+
* <p>Base exception class for all service exceptions from BedrockAgentCore service.</p>
156+
*
157+
*
158+
* @public
159+
*/
160+
export class InvokeBrowserCommand extends $Command
161+
.classBuilder<
162+
InvokeBrowserCommandInput,
163+
InvokeBrowserCommandOutput,
164+
BedrockAgentCoreClientResolvedConfig,
165+
ServiceInputTypes,
166+
ServiceOutputTypes
167+
>()
168+
.ep(commonParams)
169+
.m(function (this: any, Command: any, cs: any, config: BedrockAgentCoreClientResolvedConfig, o: any) {
170+
return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
171+
})
172+
.s("AmazonBedrockAgentCore", "InvokeBrowser", {})
173+
.n("BedrockAgentCoreClient", "InvokeBrowserCommand")
174+
.sc(InvokeBrowser$)
175+
.build() {
176+
/** @internal type navigation helper, not in runtime. */
177+
protected declare static __types: {
178+
api: {
179+
input: InvokeBrowserRequest;
180+
output: InvokeBrowserResponse;
181+
};
182+
sdk: {
183+
input: InvokeBrowserCommandInput;
184+
output: InvokeBrowserCommandOutput;
185+
};
186+
};
187+
}

clients/client-bedrock-agentcore/src/commands/ListSessionsCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ListSessionsCommandInput extends ListSessionsInput {}
3131
export interface ListSessionsCommandOutput extends ListSessionsOutput, __MetadataBearer {}
3232

3333
/**
34-
* <p>Lists sessions in an AgentCore Memory resource based on specified criteria. We recommend using pagination to ensure that the operation returns quickly and successfully.</p> <p>To use this operation, you must have the <code>bedrock-agentcore:ListSessions</code> permission.</p>
34+
* <p>Lists sessions in an AgentCore Memory resource based on specified criteria. We recommend using pagination to ensure that the operation returns quickly and successfully.</p> <p>Empty sessions are automatically deleted after one day.</p> <p>To use this operation, you must have the <code>bedrock-agentcore:ListSessions</code> permission.</p>
3535
* @example
3636
* Use a bare-bones client and the command you need to make an API call.
3737
* ```javascript

clients/client-bedrock-agentcore/src/commands/StartBrowserSessionCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface StartBrowserSessionCommandInput extends StartBrowserSessionRequ
3131
export interface StartBrowserSessionCommandOutput extends StartBrowserSessionResponse, __MetadataBearer {}
3232

3333
/**
34-
* <p>Creates and initializes a browser session in Amazon Bedrock AgentCore. The session enables agents to navigate and interact with web content, extract information from websites, and perform web-based tasks as part of their response generation.</p> <p>To create a session, you must specify a browser identifier and a name. You can also configure the viewport dimensions to control the visible area of web content. The session remains active until it times out or you explicitly stop it using the <code>StopBrowserSession</code> operation.</p> <p>The following operations are related to <code>StartBrowserSession</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_GetBrowserSession.html">GetBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_UpdateBrowserStream.html">UpdateBrowserStream</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_SaveBrowserSessionProfile.html">SaveBrowserSessionProfile</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_StopBrowserSession.html">StopBrowserSession</a> </p> </li> </ul>
34+
* <p>Creates and initializes a browser session in Amazon Bedrock AgentCore. The session enables agents to navigate and interact with web content, extract information from websites, and perform web-based tasks as part of their response generation.</p> <p>To create a session, you must specify a browser identifier and a name. You can also configure the viewport dimensions to control the visible area of web content. The session remains active until it times out or you explicitly stop it using the <code>StopBrowserSession</code> operation.</p> <p>The following operations are related to <code>StartBrowserSession</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_GetBrowserSession.html">GetBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_UpdateBrowserStream.html">UpdateBrowserStream</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_SaveBrowserSessionProfile.html">SaveBrowserSessionProfile</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_StopBrowserSession.html">StopBrowserSession</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_InvokeBrowser.html">InvokeBrowser</a> </p> </li> </ul>
3535
* @example
3636
* Use a bare-bones client and the command you need to make an API call.
3737
* ```javascript

clients/client-bedrock-agentcore/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export * from "./GetWorkloadAccessTokenForJWTCommand";
1919
export * from "./GetWorkloadAccessTokenForUserIdCommand";
2020
export * from "./InvokeAgentRuntimeCommand";
2121
export * from "./InvokeAgentRuntimeCommandCommand";
22+
export * from "./InvokeBrowserCommand";
2223
export * from "./InvokeCodeInterpreterCommand";
2324
export * from "./ListActorsCommand";
2425
export * from "./ListBrowserSessionsCommand";

clients/client-bedrock-agentcore/src/models/enums.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,45 @@ export const AutomationStreamStatus = {
6868
*/
6969
export type AutomationStreamStatus = (typeof AutomationStreamStatus)[keyof typeof AutomationStreamStatus];
7070

71+
/**
72+
* @public
73+
* @enum
74+
*/
75+
export const MouseButton = {
76+
LEFT: "LEFT",
77+
MIDDLE: "MIDDLE",
78+
RIGHT: "RIGHT",
79+
} as const;
80+
/**
81+
* @public
82+
*/
83+
export type MouseButton = (typeof MouseButton)[keyof typeof MouseButton];
84+
85+
/**
86+
* @public
87+
* @enum
88+
*/
89+
export const ScreenshotFormat = {
90+
PNG: "PNG",
91+
} as const;
92+
/**
93+
* @public
94+
*/
95+
export type ScreenshotFormat = (typeof ScreenshotFormat)[keyof typeof ScreenshotFormat];
96+
97+
/**
98+
* @public
99+
* @enum
100+
*/
101+
export const BrowserActionStatus = {
102+
FAILED: "FAILED",
103+
SUCCESS: "SUCCESS",
104+
} as const;
105+
/**
106+
* @public
107+
*/
108+
export type BrowserActionStatus = (typeof BrowserActionStatus)[keyof typeof BrowserActionStatus];
109+
71110
/**
72111
* @public
73112
* @enum

0 commit comments

Comments
 (0)