MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / executeCode

Function executeCode

apps/cli/src/main.ts:951–991  ·  view source on GitHub ↗
(input: {
  target: ServerTarget;
  code: string;
})

Source from the content-addressed store, hash-verified

949};
950
951const 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
993const serverTargetResumeFlag = (
994 target: ServerTarget,

Callers 1

main.tsFile · 0.70

Calls 7

extractExecutionIdFunction · 0.90
extractPausedInteractionFunction · 0.90
extractExecutionResultFunction · 0.90
makeApiClientFunction · 0.85
buildResumeApprovalUrlFunction · 0.70
executeMethod · 0.65

Tested by

no test coverage detected