(tmpDir: string)
| 81 | } |
| 82 | |
| 83 | const startHarness = async (tmpDir: string): Promise<Harness> => { |
| 84 | const plugins = [ |
| 85 | mcpPlugin({ dangerouslyAllowStdioMCP: false }), |
| 86 | fileSecretsPlugin({ directory: tmpDir }), |
| 87 | ] as const; |
| 88 | const sqlite = await createSqliteFumaDb({ |
| 89 | tables: collectTables(), |
| 90 | namespace: "executor_local_test", |
| 91 | path: join(tmpDir, "data.db"), |
| 92 | }); |
| 93 | |
| 94 | const executor = await Effect.runPromise( |
| 95 | createExecutor({ |
| 96 | tenant: Tenant.make(`test-${randomBytes(4).toString("hex")}`), |
| 97 | subject: Subject.make("local"), |
| 98 | db: sqlite.db, |
| 99 | plugins, |
| 100 | onElicitation: "accept-all", |
| 101 | oauthEndpointUrlPolicy: { allowHttp: true }, |
| 102 | // EXPLICIT OAuth callback — required now that the localhost default is |
| 103 | // gone; the local daemon serves `/api/oauth/callback` on the web origin. |
| 104 | redirectUri: "http://localhost:4788/api/oauth/callback", |
| 105 | }), |
| 106 | ); |
| 107 | |
| 108 | const engine = createExecutionEngine({ |
| 109 | executor, |
| 110 | codeExecutor: makeQuickJsExecutor(), |
| 111 | }); |
| 112 | |
| 113 | const TestObservability = observabilityMiddleware(TestApi); |
| 114 | |
| 115 | const TestApiBase = HttpApiBuilder.layer(TestApi).pipe( |
| 116 | Layer.provide(CoreHandlers), |
| 117 | Layer.provide(McpHandlers), |
| 118 | Layer.provide(TestObservability), |
| 119 | Layer.provide(ErrorCaptureLive), |
| 120 | ); |
| 121 | |
| 122 | const pluginExtensions = Layer.succeed(McpExtensionService)(executor.mcp); |
| 123 | |
| 124 | const { handler: webHandler, dispose: disposeHandler } = HttpRouter.toWebHandler( |
| 125 | TestApiBase.pipe( |
| 126 | Layer.provideMerge(pluginExtensions), |
| 127 | Layer.provideMerge(Layer.succeed(ExecutorService)(executor)), |
| 128 | Layer.provideMerge(Layer.succeed(ExecutionEngineService)(engine)), |
| 129 | Layer.provideMerge(HttpServer.layerServices), |
| 130 | Layer.provideMerge(Layer.succeed(HttpRouter.RouterConfig)({ maxParamLength: 1000 })), |
| 131 | ), |
| 132 | ); |
| 133 | |
| 134 | return { |
| 135 | fetch: ((input: RequestInfo | URL, init?: RequestInit) => |
| 136 | webHandler( |
| 137 | input instanceof Request ? input : new Request(input, init), |
| 138 | )) as typeof globalThis.fetch, |
| 139 | // `oauth.start` refuses an integration that is not in the catalog, so the |
| 140 | // flow under test needs a registered MCP server to mint against. |
no test coverage detected