@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 48 lines 1.51 KB
Raw
1 import type * as Lambda from "@distilled.cloud/aws/lambda";
2 import * as Binding from "alchemy/Binding";
3 import * as Effect from "effect/Effect";
4 import type { Function } from "./Function.ts";
5
6 export interface InvokeWithResponseStreamRequest extends Omit<
7 Lambda.InvokeWithResponseStreamRequest,
8 "FunctionName"
9 > {}
10
11 /**
12 * Runtime binding for `lambda:InvokeFunction` over the response-streaming
13 * API. Invokes the bound {@link Function} and returns the streaming
14 * response — `EventStream` yields `PayloadChunk` events followed by a final
15 * `InvokeComplete` event.
16 *
17 * Provide the `InvokeWithResponseStreamHttp` layer on the Function to
18 * satisfy the binding.
19 * ### Invoking Functions
20 * **Example:** Stream a function's response
21 * ```typescript
22 * const invokeStream = yield* AWS.Lambda.InvokeWithResponseStream(target);
23 *
24 * const response = yield* invokeStream({
25 * Payload: new TextEncoder().encode(JSON.stringify({ prompt: "hi" })),
26 * });
27 * const chunks = yield* Stream.runCollect(response.EventStream!);
28 * ```
29 *
30 * @binding
31 */
32 export interface InvokeWithResponseStream extends Binding.Service<
33 InvokeWithResponseStream,
34 "AWS.Lambda.InvokeWithResponseStream",
35 (
36 func: Function,
37 ) => Effect.Effect<
38 (
39 request?: InvokeWithResponseStreamRequest,
40 ) => Effect.Effect<
41 Lambda.InvokeWithResponseStreamResponse,
42 Lambda.InvokeWithResponseStreamError
43 >
44 >
45 > {}
46 export const InvokeWithResponseStream = Binding.Service<InvokeWithResponseStream>(
47 "AWS.Lambda.InvokeWithResponseStream",
48 );