1import type * as agentcore from "@distilled.cloud/aws/bedrock-agentcore";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Runtime } from "./Runtime.ts";
5
6export interface InvokeAgentRuntimeRequest extends Omit<
7 agentcore.InvokeAgentRuntimeRequest,
8 "agentRuntimeArn"
9> {}
10
11/**
12 * Sends a request to an agent hosted in an AgentCore Runtime and receives
13 * the (optionally streaming) response.
14 *
15 * Bind a {@link Runtime} inside a function runtime to invoke the hosted
16 * agent with session isolation (requests with the same `runtimeSessionId`
17 * land on the same sandbox). Provide `AgentCore.InvokeAgentRuntimeHttp` on
18 * the Function effect to implement the binding.
19 *
20 * ### Invoking an Agent
21 * **Example:** Invoke a Hosted Agent
22 * ```typescript
23 * // init
24 * const invoke = yield* AgentCore.InvokeAgentRuntime(runtime);
25 *
26 * return {
27 * fetch: Effect.gen(function* () {
28 * // runtime
29 * const response = yield* invoke({
30 * runtimeSessionId: "session-0000000000000000000000000000000001",
31 * payload: JSON.stringify({ prompt: "hello" }),
32 * });
33 * return HttpServerResponse.json({ contentType: response.contentType });
34 * }),
35 * };
36 * ```
37 *
38 * @binding
39 */
40export interface InvokeAgentRuntime extends Binding.Service<
41 InvokeAgentRuntime,
42 "AWS.BedrockAgentCore.InvokeAgentRuntime",
43 <R extends Runtime>(
44 runtime: R,
45 ) => Effect.Effect<
46 (
47 request: InvokeAgentRuntimeRequest,
48 ) => Effect.Effect<
49 agentcore.InvokeAgentRuntimeResponse,
50 agentcore.InvokeAgentRuntimeError
51 >
52 >
53> {}
54export const InvokeAgentRuntime = Binding.Service<InvokeAgentRuntime>(
55 "AWS.BedrockAgentCore.InvokeAgentRuntime",
56);