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