| 1 | import type * as agentcore from "@distilled.cloud/aws/bedrock-agentcore"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { BrowserCustom } from "./BrowserCustom.ts"; |
| 5 | |
| 6 | export interface InvokeBrowserRequest extends Omit< |
| 7 | agentcore.InvokeBrowserRequest, |
| 8 | "browserIdentifier" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Performs an OS-level browser action (mouse, keyboard, screenshot) in a session. |
| 13 | * |
| 14 | * OS-level actions cover interactions the Chrome DevTools Protocol cannot reach — print dialogs, context menus, and JavaScript alerts. |
| 15 | * |
| 16 | * Bind a {@link BrowserCustom} inside a function runtime to call the |
| 17 | * AgentCore data-plane API against it. Provide `AgentCore.InvokeBrowserHttp` |
| 18 | * on the Function effect to implement the binding. |
| 19 | * |
| 20 | * ### Browser Automation |
| 21 | * **Example:** Take a Screenshot |
| 22 | * ```typescript |
| 23 | * // init |
| 24 | * const invokeBrowser = yield* AgentCore.InvokeBrowser(browser); |
| 25 | * |
| 26 | * return { |
| 27 | * fetch: Effect.gen(function* () { |
| 28 | * // runtime |
| 29 | * const result = yield* invokeBrowser({ |
| 30 | * sessionId, |
| 31 | * action: { screenshot: {} }, |
| 32 | * }); |
| 33 | * return HttpServerResponse.json({ result: result.result }); |
| 34 | * }), |
| 35 | * }; |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface InvokeBrowser extends Binding.Service< |
| 41 | InvokeBrowser, |
| 42 | "AWS.BedrockAgentCore.InvokeBrowser", |
| 43 | <R extends BrowserCustom>( |
| 44 | browser: R, |
| 45 | ) => Effect.Effect< |
| 46 | ( |
| 47 | request: InvokeBrowserRequest, |
| 48 | ) => Effect.Effect< |
| 49 | agentcore.InvokeBrowserResponse, |
| 50 | agentcore.InvokeBrowserError |
| 51 | > |
| 52 | > |
| 53 | > {} |
| 54 | export const InvokeBrowser = Binding.Service<InvokeBrowser>( |
| 55 | "AWS.BedrockAgentCore.InvokeBrowser", |
| 56 | ); |