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

Function makeSelfHostTestApp

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

Source from the content-addressed store, hash-verified

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

Callers 3

boot.test.tsFile · 0.85

Calls 6

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

Tested by

no test coverage detected