|
|
@@ -22,7 +22,6 @@ import { McpAuth } from "@/mcp/auth"
|
|
|
import { Permission } from "@/permission"
|
|
|
import { Plugin } from "@/plugin"
|
|
|
import { PluginPtyEnvironment } from "@/plugin/pty-environment"
|
|
|
-import { InstanceBootstrap } from "@/project/bootstrap"
|
|
|
import { InstanceStore } from "@/project/instance-store"
|
|
|
import { Project } from "@/project/project"
|
|
|
import { Vcs } from "@/project/vcs"
|
|
|
@@ -52,7 +51,7 @@ import { Worktree } from "@/worktree"
|
|
|
import { RuntimeFlags } from "@/effect/runtime-flags"
|
|
|
import { MoveSession } from "@opencode-ai/core/control-plane/move-session"
|
|
|
import { Database } from "@opencode-ai/core/database/database"
|
|
|
-import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
|
|
|
+import { AppNodeBuilderV1 } from "@/effect/app-node-builder-v1"
|
|
|
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
|
|
import { httpClient } from "@opencode-ai/core/effect/app-node-platform"
|
|
|
import { EventV2 } from "@opencode-ai/core/event"
|
|
|
@@ -101,7 +100,7 @@ import { sessionHandlers } from "./handlers/session"
|
|
|
import { syncHandlers } from "./handlers/sync"
|
|
|
import { tuiHandlers } from "./handlers/tui"
|
|
|
import { handlers } from "@opencode-ai/server/handlers"
|
|
|
-import { locationServiceMapLayer } from "@opencode-ai/core/location-services"
|
|
|
+import { buildLocationServiceMap, LocationServiceMap } from "@opencode-ai/core/location-services"
|
|
|
import { layer as locationLayer } from "@opencode-ai/server/location"
|
|
|
import { sessionLocationLayer } from "@opencode-ai/server/middleware/session-location"
|
|
|
import { PtyEnvironment } from "@opencode-ai/server/pty-environment"
|
|
|
@@ -134,10 +133,10 @@ const cors = (corsOptions?: CorsOptions) =>
|
|
|
// - ptyConnectApiRoutes: typed WebSocket upgrade route with ticket-aware auth.
|
|
|
// - instanceApiRoutes: remaining typed instance routes.
|
|
|
// - uiRoute: raw catch-all fallback; auth is router middleware so public static assets can bypass it.
|
|
|
-const authOnlyRouterLayer = authorizationRouterMiddleware.layer.pipe(Layer.provide(ServerAuth.Config.defaultLayer))
|
|
|
-const httpApiAuthLayer = authorizationLayer.pipe(Layer.provide(ServerAuth.Config.defaultLayer))
|
|
|
-const ptyConnectHttpApiAuthLayer = ptyConnectAuthorizationLayer.pipe(Layer.provide(ServerAuth.Config.defaultLayer))
|
|
|
-const serverHttpApiAuthLayer = serverAuthorizationLayer.pipe(Layer.provide(ServerAuth.Config.defaultLayer))
|
|
|
+const authOnlyRouterLayer = authorizationRouterMiddleware.layer.pipe(Layer.provide(ServerAuth.Config.layer))
|
|
|
+const httpApiAuthLayer = authorizationLayer.pipe(Layer.provide(ServerAuth.Config.layer))
|
|
|
+const ptyConnectHttpApiAuthLayer = ptyConnectAuthorizationLayer.pipe(Layer.provide(ServerAuth.Config.layer))
|
|
|
+const serverHttpApiAuthLayer = serverAuthorizationLayer.pipe(Layer.provide(ServerAuth.Config.layer))
|
|
|
const workspaceRoutingLive = workspaceRoutingLayer.pipe(Layer.provide(Socket.layerWebSocketConstructorGlobal))
|
|
|
const rootApiRoutes = HttpApiBuilder.layer(RootHttpApi).pipe(
|
|
|
Layer.provide([controlHandlers, controlPlaneHandlers, globalHandlers]),
|
|
|
@@ -272,6 +271,8 @@ const app = LayerNode.group([
|
|
|
export function createRoutes(
|
|
|
corsOptions?: CorsOptions,
|
|
|
): Layer.Layer<never, EffectConfig.ConfigError, RouteRequirements> {
|
|
|
+ const locationServiceMapV2 = buildLocationServiceMap()
|
|
|
+
|
|
|
return Layer.mergeAll(
|
|
|
rootApiRoutes,
|
|
|
eventApiRoutes,
|
|
|
@@ -287,7 +288,7 @@ export function createRoutes(
|
|
|
corsVaryFix,
|
|
|
fenceLayer,
|
|
|
cors(corsOptions),
|
|
|
- AppNodeBuilder.build(MoveSession.node),
|
|
|
+ AppNodeBuilderV1.build(MoveSession.node, [[LocationServiceMap.node, locationServiceMapV2]]),
|
|
|
HttpServer.layerServices,
|
|
|
]),
|
|
|
Layer.provide(Layer.succeed(CorsConfig)(corsOptions)),
|
|
|
@@ -297,13 +298,14 @@ export function createRoutes(
|
|
|
Layer.provide(locationLayer),
|
|
|
Layer.provide(PtyEnvironment.layer),
|
|
|
Layer.provide(
|
|
|
- AppNodeBuilder.build(SessionV2.node, [[SessionExecution.node, SessionExecutionLocal.node]]).pipe(
|
|
|
- Layer.provide(locationServiceMapLayer),
|
|
|
- ),
|
|
|
+ AppNodeBuilderV1.build(SessionV2.node, [
|
|
|
+ [LocationServiceMap.node, locationServiceMapV2],
|
|
|
+ [SessionExecution.node, SessionExecutionLocal.node],
|
|
|
+ ]),
|
|
|
),
|
|
|
- Layer.provide(locationServiceMapLayer),
|
|
|
+ Layer.provide(locationServiceMapV2),
|
|
|
|
|
|
- Layer.provide(LayerNode.compile(app, [[InstanceStore.bootstrapNode, InstanceBootstrap.node]])),
|
|
|
+ Layer.provide(AppNodeBuilderV1.build(app)),
|
|
|
)
|
|
|
}
|
|
|
|