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

Function executeCode

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

Source from the content-addressed store, hash-verified

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