@@ -19,12 +19,12 @@ import * as Effect from "effect/Effect";
1919import * as FileSystem from "effect/FileSystem" ;
2020import * as Path from "effect/Path" ;
2121import * as Schema from "effect/Schema" ;
22- import * as Stream from "effect/Stream" ;
2322import { HttpClient } from "effect/unstable/http" ;
2423import { ChildProcessSpawner } from "effect/unstable/process" ;
2524
2625import { makeOpenCodeTextGeneration } from "../../textGeneration/OpenCodeTextGeneration.ts" ;
2726import { ServerConfig } from "../../config.ts" ;
27+ import { ServerSettingsService } from "../../serverSettings.ts" ;
2828import { ProviderDriverError } from "../Errors.ts" ;
2929import { makeOpenCodeAdapter } from "../Layers/OpenCodeAdapter.ts" ;
3030import {
@@ -47,6 +47,11 @@ import {
4747 normalizeCommandPath ,
4848 resolveProviderMaintenanceCapabilitiesEffect ,
4949} from "../providerMaintenance.ts" ;
50+ import {
51+ haveProviderSnapshotSettingsChanged ,
52+ makeProviderSnapshotSettingsSource ,
53+ type ProviderSnapshotSettings ,
54+ } from "../providerUpdateSettings.ts" ;
5055const decodeOpenCodeSettings = Schema . decodeSync ( OpenCodeSettings ) ;
5156
5257const DRIVER_KIND = ProviderDriverKind . make ( "opencode" ) ;
@@ -80,7 +85,8 @@ export type OpenCodeDriverEnv =
8085 | OpenCodeRuntime
8186 | Path . Path
8287 | ProviderEventLoggers
83- | ServerConfig ;
88+ | ServerConfig
89+ | ServerSettingsService ;
8490
8591const withInstanceIdentity =
8692 ( input : {
@@ -111,6 +117,7 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
111117 const openCodeRuntime = yield * OpenCodeRuntime ;
112118 const serverConfig = yield * ServerConfig ;
113119 const httpClient = yield * HttpClient . HttpClient ;
120+ const serverSettings = yield * ServerSettingsService ;
114121 const eventLoggers = yield * ProviderEventLoggers ;
115122 const processEnv = mergeProviderInstanceEnvironment ( environment ) ;
116123 const continuationIdentity = defaultProviderContinuationIdentity ( {
@@ -142,21 +149,26 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
142149 processEnv ,
143150 ) . pipe ( Effect . map ( stampIdentity ) , Effect . provideService ( OpenCodeRuntime , openCodeRuntime ) ) ;
144151
145- const snapshot = yield * makeManagedServerProvider < OpenCodeSettings > ( {
146- maintenanceCapabilities,
147- getSettings : Effect . succeed ( effectiveConfig ) ,
148- streamSettings : Stream . never ,
149- haveSettingsChanged : ( ) => false ,
150- initialSnapshot : ( settings ) =>
151- makePendingOpenCodeProvider ( settings ) . pipe ( Effect . map ( stampIdentity ) ) ,
152- checkProvider,
153- enrichSnapshot : ( { snapshot, publishSnapshot } ) =>
154- enrichProviderSnapshotWithVersionAdvisory ( snapshot , maintenanceCapabilities ) . pipe (
155- Effect . provideService ( HttpClient . HttpClient , httpClient ) ,
156- Effect . flatMap ( ( enrichedSnapshot ) => publishSnapshot ( enrichedSnapshot ) ) ,
157- ) ,
158- refreshInterval : SNAPSHOT_REFRESH_INTERVAL ,
159- } ) . pipe (
152+ const snapshotSettings = makeProviderSnapshotSettingsSource ( effectiveConfig , serverSettings ) ;
153+ const snapshot = yield * makeManagedServerProvider < ProviderSnapshotSettings < OpenCodeSettings > > (
154+ {
155+ maintenanceCapabilities,
156+ getSettings : snapshotSettings . getSettings ,
157+ streamSettings : snapshotSettings . streamSettings ,
158+ haveSettingsChanged : haveProviderSnapshotSettingsChanged ,
159+ initialSnapshot : ( settings ) =>
160+ makePendingOpenCodeProvider ( settings . provider ) . pipe ( Effect . map ( stampIdentity ) ) ,
161+ checkProvider,
162+ enrichSnapshot : ( { settings, snapshot, publishSnapshot } ) =>
163+ enrichProviderSnapshotWithVersionAdvisory ( snapshot , maintenanceCapabilities , {
164+ enableProviderUpdateChecks : settings . enableProviderUpdateChecks ,
165+ } ) . pipe (
166+ Effect . provideService ( HttpClient . HttpClient , httpClient ) ,
167+ Effect . flatMap ( ( enrichedSnapshot ) => publishSnapshot ( enrichedSnapshot ) ) ,
168+ ) ,
169+ refreshInterval : SNAPSHOT_REFRESH_INTERVAL ,
170+ } ,
171+ ) . pipe (
160172 Effect . mapError (
161173 ( cause ) =>
162174 new ProviderDriverError ( {
0 commit comments