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

Function executeCode

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

Source from the content-addressed store, hash-verified

974};
975
976const 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
1018const serverTargetResumeFlag = (
1019 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