fix(core): isolate location layer instances

This commit is contained in:
Dax Raad
2026-05-30 19:59:56 -04:00
parent aa86a20b1d
commit 0269d6f5de
4 changed files with 65 additions and 9 deletions

View File

@@ -317,4 +317,8 @@ export const layer = Layer.effect(
const SMALL_MODEL_RE = /\b(nano|flash|lite|mini|haiku|small|fast)\b/
export const defaultLayer = layer.pipe(Layer.provide(EventV2.defaultLayer), Layer.provide(PluginV2.defaultLayer))
export const defaultLayer = layer.pipe(
Layer.provide(EventV2.defaultLayer),
Layer.provide(PluginV2.defaultLayer),
Layer.provide(Policy.defaultLayer),
)

View File

@@ -200,4 +200,8 @@ export const layer = Layer.effect(
}),
)
export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer), Layer.provide(Global.defaultLayer))
export const defaultLayer = layer.pipe(
Layer.provide(AppFileSystem.defaultLayer),
Layer.provide(Global.defaultLayer),
Layer.provide(Policy.defaultLayer),
)

View File

@@ -2,18 +2,16 @@ import { Layer, LayerMap } from "effect"
import { Location } from "./location"
import { Catalog } from "./catalog"
import { PluginBoot } from "./plugin/boot"
import { Policy } from "./policy"
import { Config } from "./config"
import { AgentV2 } from "./agent"
export class LocationServiceMap extends LayerMap.Service<LocationServiceMap>()("@opencode/example/LocationServiceMap", {
lookup: (ref: Location.Ref) => {
const result = Layer.mergeAll(
Catalog.defaultLayer,
PluginBoot.defaultLayer,
Config.defaultLayer,
AgentV2.defaultLayer,
).pipe(Layer.provideMerge(Policy.defaultLayer), Layer.provideMerge(Location.defaultLayer(ref)))
const result = Layer.fresh(
Layer.mergeAll(Catalog.defaultLayer, PluginBoot.defaultLayer, Config.defaultLayer, AgentV2.defaultLayer).pipe(
Layer.provideMerge(Location.defaultLayer(ref)),
),
)
return result
},
idleTimeToLive: "60 minutes",