(input: {
target: ServerTarget;
code: string;
})
| 949 | }; |
| 950 | |
| 951 | const executeCode = (input: { |
| 952 | target: ServerTarget; |
| 953 | code: string; |
| 954 | }): Effect.Effect<ExecuteCodeResult, Error, FileSystem.FileSystem | PlatformPath.Path> => |
| 955 | Effect.gen(function* () { |
| 956 | const connection = yield* resolveExecutorServerConnection(input.target); |
| 957 | const client = yield* makeApiClient(connection); |
| 958 | const response = yield* client.executions.execute({ |
| 959 | payload: { |
| 960 | code: input.code, |
| 961 | }, |
| 962 | }); |
| 963 | |
| 964 | if (response.status === "paused") { |
| 965 | const executionId = extractExecutionId(response.structured); |
| 966 | return { |
| 967 | connection, |
| 968 | outcome: { |
| 969 | status: "paused" as const, |
| 970 | text: response.text, |
| 971 | executionId, |
| 972 | approvalUrl: executionId |
| 973 | ? buildResumeApprovalUrl(connection.origin, executionId) |
| 974 | : undefined, |
| 975 | interaction: extractPausedInteraction(response.structured), |
| 976 | }, |
| 977 | }; |
| 978 | } |
| 979 | |
| 980 | if (response.isError) { |
| 981 | return yield* Effect.fail(new Error(response.text)); |
| 982 | } |
| 983 | |
| 984 | return { |
| 985 | connection, |
| 986 | outcome: { |
| 987 | status: "completed" as const, |
| 988 | result: extractExecutionResult(response.structured), |
| 989 | }, |
| 990 | }; |
| 991 | }).pipe(Effect.mapError(toError)); |
| 992 | |
| 993 | const serverTargetResumeFlag = ( |
| 994 | target: ServerTarget, |
no test coverage detected