(input: {
target: ServerTarget;
code: string;
})
| 974 | }; |
| 975 | |
| 976 | const executeCode = (input: { |
| 977 | target: ServerTarget; |
| 978 | code: string; |
| 979 | }): Effect.Effect<ExecuteCodeResult, Error, FileSystem.FileSystem | PlatformPath.Path> => |
| 980 | Effect.gen(function* () { |
| 981 | const connection = yield* resolveExecutorServerConnection(input.target); |
| 982 | const client = yield* makeApiClient(connection, input.target); |
| 983 | const response = yield* client.executions.execute({ |
| 984 | payload: { |
| 985 | code: input.code, |
| 986 | }, |
| 987 | }); |
| 988 | |
| 989 | if (response.status === "paused") { |
| 990 | const executionId = extractExecutionId(response.structured); |
| 991 | return { |
| 992 | connection, |
| 993 | outcome: { |
| 994 | status: "paused" as const, |
| 995 | text: response.text, |
| 996 | executionId, |
| 997 | approvalUrl: executionId |
| 998 | ? buildResumeApprovalUrl(connection.origin, executionId) |
| 999 | : undefined, |
| 1000 | interaction: extractPausedInteraction(response.structured), |
| 1001 | }, |
| 1002 | }; |
| 1003 | } |
| 1004 | |
| 1005 | if (response.isError) { |
| 1006 | return yield* Effect.fail(new Error(response.text)); |
| 1007 | } |
| 1008 | |
| 1009 | return { |
| 1010 | connection, |
| 1011 | outcome: { |
| 1012 | status: "completed" as const, |
| 1013 | result: extractExecutionResult(response.structured), |
| 1014 | }, |
| 1015 | }; |
| 1016 | }).pipe(Effect.mapError(toError)); |
| 1017 | |
| 1018 | const serverTargetResumeFlag = ( |
| 1019 | target: ServerTarget, |
no test coverage detected