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

Function makeSelfHostTestApp

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

Source from the content-addressed store, hash-verified

178}
179
180export const makeSelfHostTestApp = async (
181 options: MakeSelfHostTestAppOptions,
182): Promise<SelfHostTestHandler> => {
183 const config = loadConfig();
184
185 const dbHandle = await createSelfHostDb({
186 path: options.dbPath ?? config.dbPath,
187 namespace: SELF_HOST_NAMESPACE,
188 version: SELF_HOST_SCHEMA_VERSION,
189 });
190
191 const sessionStore = makeSelfHostMcpSessionStore(dbHandle);
192 const pluginsProvider = options.pluginDeps
193 ? Layer.succeed(PluginsProvider)({
194 plugins: (context) =>
195 executorConfig.plugins({
196 ...options.pluginDeps,
197 activeToolkitSlug:
198 context?.mcpResource?.kind === "toolkit"
199 ? context.mcpResource.slug
200 : options.pluginDeps?.activeToolkitSlug,
201 allowLocalNetwork:
202 options.pluginDeps?.allowLocalNetwork ??
203 process.env.EXECUTOR_ALLOW_LOCAL_NETWORK === "true",
204 }),
205 })
206 : SelfHostPluginsProvider;
207
208 const { toWebHandler } = ExecutorApp.make({
209 plugins: selfHostPlugins,
210 providers: {
211 identity: options.identity,
212 db: SelfHostDbProvider,
213 engine: { codeExecutor: SelfHostCodeExecutorProvider },
214 mcp: {
215 auth: stubMcpAuth,
216 sessions: selfHostMcpSessions(sessionStore),
217 reporter: selfHostMcpReporter,
218 },
219 plugins: { provider: pluginsProvider, config: SelfHostHostConfig },
220 errorCapture: ErrorCaptureLive,
221 },
222 extensions: {
223 routes: [
224 HttpApiSwagger.layer(composePluginApi(selfHostPlugins).prefix("/api"), { path: "/docs" }),
225 ],
226 },
227 config: { mountPrefix: "/api", failure: textFailureStrategy },
228 // The test identity is boot-scoped exactly as production's is: no
229 // requestScoped layer, so the execution middleware leaves IdentityProvider
230 // residual and `provideMerge(boot)` supplies it.
231 boot: Layer.merge(Layer.succeed(SelfHostDb)(dbHandle), options.identity),
232 });
233
234 const web = toWebHandler();
235 return {
236 handler: web.handler,
237 dispose: async () => {

Callers 2

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