@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, 04:45 UTC

main
ts 67 lines 2.16 KB
Raw
1 import type * as agentcore from "@distilled.cloud/aws/bedrock-agentcore";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Memory } from "./Memory.ts";
5
6 export interface CreateEventRequest extends Omit<agentcore.CreateEventInput, "memoryId"> {}
7
8 /**
9 * Records an interaction event into a memory's short-term store.
10 *
11 * Bind a {@link Memory} inside a function runtime to get a callable that
12 * appends conversational turns (or binary blobs) to an actor's session.
13 * Provide `AgentCore.CreateEventHttp` on the Function effect to implement
14 * the binding over the AgentCore data-plane API.
15 *
16 * ### Recording Events
17 * **Example:** Record a Conversational Turn from a Lambda Function
18 * ```typescript
19 * import * as AgentCore from "@alchemy.run/aws/BedrockAgentCore";
20 *
21 * export default MyFunction.make(
22 * { main: import.meta.url, functionUrl: true },
23 * Effect.gen(function* () {
24 * const memory = yield* AgentCore.Memory("AgentMemory", {
25 * eventExpiryDuration: "30 days",
26 * });
27 *
28 * // init
29 * const createEvent = yield* AgentCore.CreateEvent(memory);
30 *
31 * return {
32 * fetch: Effect.gen(function* () {
33 * // runtime
34 * const result = yield* createEvent({
35 * actorId: "user-1",
36 * sessionId: "session-1",
37 * eventTimestamp: new Date(),
38 * payload: [
39 * {
40 * conversational: {
41 * role: "USER",
42 * content: { text: "My favorite color is teal." },
43 * },
44 * },
45 * ],
46 * });
47 * return HttpServerResponse.json({ eventId: result.event.eventId });
48 * }),
49 * };
50 * }).pipe(Effect.provide(AgentCore.CreateEventHttp)),
51 * );
52 * ```
53 *
54 * @binding
55 */
56 export interface CreateEvent extends Binding.Service<
57 CreateEvent,
58 "AWS.BedrockAgentCore.CreateEvent",
59 <R extends Memory>(
60 memory: R,
61 ) => Effect.Effect<
62 (
63 request: CreateEventRequest,
64 ) => Effect.Effect<agentcore.CreateEventOutput, agentcore.CreateEventError>
65 >
66 > {}
67 export const CreateEvent = Binding.Service<CreateEvent>("AWS.BedrockAgentCore.CreateEvent");