| 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 { Memory } from "./Memory.ts"; |
| 5 | |
| 6 | export interface GetEventRequest extends Omit< |
| 7 | agentcore.GetEventInput, |
| 8 | "memoryId" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Fetches a single short-term event from an actor's session. |
| 13 | * |
| 14 | * Bind a {@link Memory} inside a function runtime to call the |
| 15 | * AgentCore data-plane API against it. Provide `AgentCore.GetEventHttp` |
| 16 | * on the Function effect to implement the binding. |
| 17 | * |
| 18 | * ### Reading Events |
| 19 | * **Example:** Fetch an Event by Id |
| 20 | * ```typescript |
| 21 | * // init |
| 22 | * const getEvent = yield* AgentCore.GetEvent(memory); |
| 23 | * |
| 24 | * return { |
| 25 | * fetch: Effect.gen(function* () { |
| 26 | * // runtime |
| 27 | * const result = yield* getEvent({ |
| 28 | * actorId: "user-1", |
| 29 | * sessionId: "session-1", |
| 30 | * eventId, |
| 31 | * }); |
| 32 | * return HttpServerResponse.json({ event: result.event }); |
| 33 | * }), |
| 34 | * }; |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface GetEvent extends Binding.Service< |
| 40 | GetEvent, |
| 41 | "AWS.BedrockAgentCore.GetEvent", |
| 42 | <R extends Memory>( |
| 43 | memory: R, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request: GetEventRequest, |
| 47 | ) => Effect.Effect<agentcore.GetEventOutput, agentcore.GetEventError> |
| 48 | > |
| 49 | > {} |
| 50 | export const GetEvent = Binding.Service<GetEvent>( |
| 51 | "AWS.BedrockAgentCore.GetEvent", |
| 52 | ); |