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

Function resolveRequestedExecutorServerConnection

apps/cli/src/main.ts:710–749  ·  view source on GitHub ↗
(
  target: ServerTarget,
)

Source from the content-addressed store, hash-verified

708 }).pipe(Effect.mapError(toError));
709
710const resolveRequestedExecutorServerConnection = (
711 target: ServerTarget,
712): Effect.Effect<
713 RequestedExecutorServerConnection,
714 Error,
715 FileSystem.FileSystem | PlatformPath.Path
716> =>
717 Effect.gen(function* () {
718 if (target.baseUrl && target.serverName) {
719 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
720 }
721
722 if (target.serverName) {
723 const store = yield* readCliServerConnectionStore();
724 const profile = findCliServerConnectionProfile(store, target.serverName);
725 if (!profile) {
726 return yield* Effect.fail(new Error(`No server profile named "${target.serverName}".`));
727 }
728 return { connection: withCliServerAuthFallback(profile.connection), source: "explicit" };
729 }
730
731 if (!target.baseUrl) {
732 const store = yield* readCliServerConnectionStore();
733 const profile = defaultCliServerConnectionProfile(store);
734 if (profile) {
735 return {
736 connection: withCliServerAuthFallback(profile.connection),
737 source: "default-profile",
738 };
739 }
740
741 const active = yield* readActiveLocalServerManifest();
742 if (active) return { connection: active.connection, source: "active-local" };
743 }
744
745 return {
746 connection: yield* parseExecutorServerConnection(target.baseUrl ?? DEFAULT_BASE_URL),
747 source: target.baseUrl ? "explicit" : "implicit-default",
748 };
749 });
750
751// Refresh an `oauth` (device-login) credential a minute before it expires, so
752// `executor call` against a hosted server keeps working long after the browser

Callers 2

main.tsFile · 0.85

Tested by

no test coverage detected