@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 61 lines 2.03 KB
Raw
1 import type * as agentcore from "@distilled.cloud/aws/bedrock-agentcore";
2 import * as Binding from "alchemy/Binding";
3 import type * as Duration from "effect/Duration";
4 import type * as Effect from "effect/Effect";
5 import type { BrowserCustom } from "./BrowserCustom.ts";
6
7 export interface StartBrowserSessionRequest extends Omit<
8 agentcore.StartBrowserSessionRequest,
9 "browserIdentifier" | "sessionTimeoutSeconds"
10 > {
11 /**
12 * How long the session may sit idle before AgentCore terminates it, e.g.
13 * `"5 minutes"` or `Duration.minutes(5)` (a bare number is milliseconds).
14 */
15 sessionTimeout?: Duration.Input;
16 }
17
18 /**
19 * Starts a managed, sandboxed browser session on a custom browser.
20 *
21 * Bind a {@link BrowserCustom} inside a function runtime to open cloud
22 * browser sessions for web automation; pair with `GetBrowserSession`,
23 * `InvokeBrowser`, and `StopBrowserSession`. Provide
24 * `AgentCore.StartBrowserSessionHttp` on the Function effect to implement
25 * the binding.
26 *
27 * ### Browser Sessions
28 * **Example:** Start and Stop a Browser Session
29 * ```typescript
30 * // init
31 * const startBrowserSession = yield* AgentCore.StartBrowserSession(browser);
32 * const stopBrowserSession = yield* AgentCore.StopBrowserSession(browser);
33 *
34 * return {
35 * fetch: Effect.gen(function* () {
36 * // runtime
37 * const session = yield* startBrowserSession({
38 * sessionTimeout: "5 minutes",
39 * });
40 * yield* stopBrowserSession({ sessionId: session.sessionId });
41 * return HttpServerResponse.json({ sessionId: session.sessionId });
42 * }),
43 * };
44 * ```
45 *
46 * @binding
47 */
48 export interface StartBrowserSession extends Binding.Service<
49 StartBrowserSession,
50 "AWS.BedrockAgentCore.StartBrowserSession",
51 <R extends BrowserCustom>(
52 browser: R,
53 ) => Effect.Effect<
54 (
55 request: StartBrowserSessionRequest,
56 ) => Effect.Effect<agentcore.StartBrowserSessionResponse, agentcore.StartBrowserSessionError>
57 >
58 > {}
59 export const StartBrowserSession = Binding.Service<StartBrowserSession>(
60 "AWS.BedrockAgentCore.StartBrowserSession",
61 );