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

Function makeSelfHostTestApp

apps/host-selfhost/src/testing/test-app.ts:203–267  ·  view source on GitHub ↗
(
  options: MakeSelfHostTestAppOptions,
)

Source from the content-addressed store, hash-verified

201}
202
203export const makeSelfHostTestApp = async (
204 options: MakeSelfHostTestAppOptions,
205): Promise<SelfHostTestHandler> => {
206 const config = loadConfig();
207
208 const dbHandle = await createSelfHostDb({
209 path: options.dbPath ?? config.dbPath,
210 namespace: SELF_HOST_NAMESPACE,
211 version: SELF_HOST_SCHEMA_VERSION,
212 });
213
214 const sessionStore = makeSelfHostMcpSessionStore(dbHandle);
215 const pluginsProvider = options.pluginDeps
216 ? Layer.succeed(PluginsProvider)({
217 plugins: (context) =>
218 executorConfig.plugins({
219 ...options.pluginDeps,
220 activeToolkitSlug:
221 context?.mcpResource?.kind === "toolkit"
222 ? context.mcpResource.slug
223 : options.pluginDeps?.activeToolkitSlug,
224 allowLocalNetwork:
225 options.pluginDeps?.allowLocalNetwork ??
226 process.env.EXECUTOR_ALLOW_LOCAL_NETWORK === "true",
227 }),
228 })
229 : SelfHostPluginsProvider;
230
231 const { toWebHandler } = ExecutorApp.make({
232 plugins: selfHostPlugins,
233 providers: {
234 identity: options.identity,
235 db: SelfHostDbProvider,
236 engine: { codeExecutor: SelfHostCodeExecutorProvider },
237 mcp: {
238 auth: stubMcpAuth,
239 sessions: selfHostMcpSessions(sessionStore),
240 modern: makeSelfHostMcpModernServerBuilder(dbHandle),
241 reporter: selfHostMcpReporter,
242 },
243 plugins: { provider: pluginsProvider, config: SelfHostHostConfig },
244 errorCapture: ErrorCaptureLive,
245 },
246 extensions: {
247 routes: [
248 HttpApiSwagger.layer(composePluginApi(selfHostPlugins).prefix("/api"), { path: "/docs" }),
249 ],
250 },
251 config: { mountPrefix: "/api", failure: textFailureStrategy },
252 // The test identity is boot-scoped exactly as production's is: no
253 // requestScoped layer, so the execution middleware leaves IdentityProvider
254 // residual and `provideMerge(boot)` supplies it.
255 boot: Layer.merge(Layer.succeed(SelfHostDb)(dbHandle), options.identity),
256 });
257
258 const web = toWebHandler();
259 return {
260 handler: web.handler,

Callers 3

boot.test.tsFile · 0.85

Calls 7

loadConfigFunction · 0.90
createSelfHostDbFunction · 0.90
composePluginApiFunction · 0.85
disposeMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected