MCPcopy Index your code
hub / github.com/simstudioai/sim / getMothershipBaseURL

Function getMothershipBaseURL

apps/sim/lib/copilot/server/agent-url.ts:43–70  ·  view source on GitHub ↗
(
  options: GetMothershipBaseURLOptions = {}
)

Source from the content-addressed store, hash-verified

41}
42
43export async function getMothershipBaseURL(
44 options: GetMothershipBaseURLOptions = {}
45): Promise<string> {
46 const defaultUrl = getDefaultMothershipBaseURL(options.fallbackUrl)
47
48 const { userId } = options
49 if (!userId) return defaultUrl
50
51 const [row] = await db
52 .select({
53 role: user.role,
54 superUserModeEnabled: settings.superUserModeEnabled,
55 mothershipEnvironment: settings.mothershipEnvironment,
56 })
57 .from(user)
58 .leftJoin(settings, eq(settings.userId, user.id))
59 .where(eq(user.id, userId))
60 .limit(1)
61
62 const effectiveSuperUser = row?.role === 'admin' && (row.superUserModeEnabled ?? false)
63 if (!effectiveSuperUser) return defaultUrl
64
65 const selectedEnvironment = options.environment ?? row.mothershipEnvironment
66 const parsedEnvironment = mothershipEnvironmentSchema.safeParse(selectedEnvironment)
67 const environment = parsedEnvironment.success ? parsedEnvironment.data : 'default'
68
69 return getConfiguredEnvironmentUrl(environment) ?? defaultUrl
70}
71
72export function getMothershipSourceEnvHeaders(): Record<string, string> {
73 const sourceEnv = env.COPILOT_SOURCE_ENV?.trim().toLowerCase()

Callers 10

requestChatTitleFunction · 0.90
runCheckpointLoopFunction · 0.90
agent-url.test.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
getMothershipUrlFunction · 0.90

Calls 3

eqFunction · 0.50

Tested by

no test coverage detected