| 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 { CodeInterpreter } from "./CodeInterpreter.ts"; |
| 5 | |
| 6 | export interface StopCodeInterpreterSessionRequest extends Omit< |
| 7 | agentcore.StopCodeInterpreterSessionRequest, |
| 8 | "codeInterpreterIdentifier" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Stops a running code interpreter session. |
| 13 | * |
| 14 | * Bind a {@link CodeInterpreter} inside a function runtime to end sessions |
| 15 | * opened with `StartCodeInterpreterSession` and release the sandbox. |
| 16 | * Provide `AgentCore.StopCodeInterpreterSessionHttp` on the Function effect |
| 17 | * to implement the binding. |
| 18 | * |
| 19 | * ### Stopping Sessions |
| 20 | * **Example:** Stop a Session After Use |
| 21 | * ```typescript |
| 22 | * // init |
| 23 | * const stopSession = yield* AgentCore.StopCodeInterpreterSession(interpreter); |
| 24 | * |
| 25 | * // runtime (inside the handler) |
| 26 | * yield* stopSession({ sessionId: session.sessionId }); |
| 27 | * ``` |
| 28 | * |
| 29 | * @binding |
| 30 | */ |
| 31 | export interface StopCodeInterpreterSession extends Binding.Service< |
| 32 | StopCodeInterpreterSession, |
| 33 | "AWS.BedrockAgentCore.StopCodeInterpreterSession", |
| 34 | <R extends CodeInterpreter>( |
| 35 | codeInterpreter: R, |
| 36 | ) => Effect.Effect< |
| 37 | ( |
| 38 | request: StopCodeInterpreterSessionRequest, |
| 39 | ) => Effect.Effect< |
| 40 | agentcore.StopCodeInterpreterSessionResponse, |
| 41 | agentcore.StopCodeInterpreterSessionError |
| 42 | > |
| 43 | > |
| 44 | > {} |
| 45 | export const StopCodeInterpreterSession = |
| 46 | Binding.Service<StopCodeInterpreterSession>( |
| 47 | "AWS.BedrockAgentCore.StopCodeInterpreterSession", |
| 48 | ); |