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

Function executeCode

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

Source from the content-addressed store, hash-verified

960};
961
962const 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
1004const serverTargetResumeFlag = (
1005 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