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

main
ts 53 lines 1.67 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 { Runtime } from "./Runtime.ts";
5
6 export 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 */
40 export 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<agentcore.InvokeAgentRuntimeResponse, agentcore.InvokeAgentRuntimeError>
49 >
50 > {}
51 export const InvokeAgentRuntime = Binding.Service<InvokeAgentRuntime>(
52 "AWS.BedrockAgentCore.InvokeAgentRuntime",
53 );