refactor(server): use nodes for global services
This commit is contained in:
parent
0fb44051ee
commit
26ad7d7561
8 changed files with 32 additions and 9 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import { SessionV2 } from "@opencode-ai/core/session"
|
||||
import { Credential } from "@opencode-ai/core/credential"
|
||||
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||
import { LocationServiceMap } from "@opencode-ai/core/location-layer"
|
||||
import { PermissionSaved } from "@opencode-ai/core/permission/saved"
|
||||
import { SessionV2 } from "@opencode-ai/core/session"
|
||||
import { SessionExecutionLocal } from "@opencode-ai/core/session/execution/local"
|
||||
import { Layer } from "effect"
|
||||
import { layer as locationLayer } from "./groups/location"
|
||||
import { sessionLocationLayer } from "./middleware/session-location"
|
||||
|
|
@ -17,11 +20,9 @@ import { AgentHandler } from "./handlers/agent"
|
|||
import { HealthHandler } from "./handlers/health"
|
||||
import { QuestionHandler } from "./handlers/question"
|
||||
import { ReferenceHandler } from "./handlers/reference"
|
||||
import * as SessionExecutionLocal from "@opencode-ai/core/session/execution/local"
|
||||
import { LocationHandler } from "./handlers/location"
|
||||
import { IntegrationHandler } from "./handlers/integration"
|
||||
import { CredentialHandler } from "./handlers/credential"
|
||||
import { Credential } from "@opencode-ai/core/credential"
|
||||
|
||||
export const handlers = Layer.mergeAll(
|
||||
HealthHandler,
|
||||
|
|
@ -43,9 +44,9 @@ export const handlers = Layer.mergeAll(
|
|||
).pipe(
|
||||
Layer.provide(sessionLocationLayer),
|
||||
Layer.provide(locationLayer),
|
||||
Layer.provide(SessionV2.defaultLayer),
|
||||
Layer.provide(SessionExecutionLocal.defaultLayer),
|
||||
Layer.provide(PermissionSaved.defaultLayer),
|
||||
Layer.provide(LayerNode.buildLayer(SessionV2.node)),
|
||||
Layer.provide(LayerNode.buildLayer(SessionExecutionLocal.node)),
|
||||
Layer.provide(LayerNode.buildLayer(PermissionSaved.node)),
|
||||
Layer.provide(LocationServiceMap.layer),
|
||||
Layer.provide(Credential.defaultLayer),
|
||||
Layer.provide(LayerNode.buildLayer(Credential.node)),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Database } from "@opencode-ai/core/database/database"
|
||||
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||
import { EventV2 } from "@opencode-ai/core/event"
|
||||
import { LocationServiceMap } from "@opencode-ai/core/location-layer"
|
||||
import { FetchHttpClient, HttpRouter, HttpServer } from "effect/unstable/http"
|
||||
|
|
@ -21,8 +22,8 @@ export function createRoutes(password?: string) {
|
|||
: ServerAuth.Config.defaultLayer,
|
||||
),
|
||||
Layer.provide(LocationServiceMap.layer),
|
||||
Layer.provide(Database.defaultLayer),
|
||||
Layer.provide(EventV2.defaultLayer),
|
||||
Layer.provide(LayerNode.buildLayer(Database.node)),
|
||||
Layer.provide(LayerNode.buildLayer(EventV2.node)),
|
||||
Layer.provide(FetchHttpClient.layer),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue