epic-12: after epic audit and init commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.correx.infrastructure
|
||||
|
||||
import com.correx.core.approvals.domain.ApprovalEngine
|
||||
import com.correx.core.events.EventDispatcher
|
||||
import com.correx.core.events.stores.EventStore
|
||||
import com.correx.core.inference.DefaultInferenceRouter
|
||||
import com.correx.core.inference.InferenceProvider
|
||||
import com.correx.core.inference.InferenceRouter
|
||||
import com.correx.core.inference.ProviderRegistry
|
||||
import com.correx.core.inference.RoutingStrategy
|
||||
import com.correx.infrastructure.inference.DefaultProviderRegistry
|
||||
import com.correx.infrastructure.inference.FirstAvailableRoutingStrategy
|
||||
import com.correx.core.tools.contract.ToolExecutor
|
||||
import com.correx.core.tools.registry.ToolRegistry
|
||||
import com.correx.infrastructure.inference.commons.ModelManager
|
||||
import com.correx.infrastructure.inference.llama.cpp.DefaultModelManager
|
||||
import com.correx.infrastructure.persistence.SqliteEventStore
|
||||
import com.correx.infrastructure.tools.DefaultToolRegistry
|
||||
import com.correx.infrastructure.tools.DispatchingToolExecutor
|
||||
import com.correx.infrastructure.tools.SandboxedToolExecutor
|
||||
import com.correx.infrastructure.tools.ToolConfig
|
||||
import com.correx.infrastructure.tools.buildTools
|
||||
import com.correx.infrastructure.tools.filesystem.FileEditTool
|
||||
import com.correx.infrastructure.tools.filesystem.FileReadTool
|
||||
import com.correx.infrastructure.tools.filesystem.FileWriteTool
|
||||
import com.correx.infrastructure.tools.shell.ShellTool
|
||||
import io.ktor.client.HttpClient
|
||||
import java.nio.file.Path
|
||||
import java.sql.DriverManager
|
||||
|
||||
object InfrastructureModule {
|
||||
fun createEventStore(dbPath: String): EventStore =
|
||||
SqliteEventStore(DriverManager.getConnection("jdbc:sqlite:$dbPath"))
|
||||
|
||||
fun createModelManager(
|
||||
eventStore: EventStore,
|
||||
httpClient: HttpClient,
|
||||
eventDispatcher: EventDispatcher,
|
||||
): ModelManager = DefaultModelManager(
|
||||
eventStore = eventStore,
|
||||
httpClient = httpClient,
|
||||
eventDispatcher = eventDispatcher,
|
||||
)
|
||||
|
||||
fun createToolRegistry(config: ToolConfig): ToolRegistry =
|
||||
DefaultToolRegistry.build(config.buildTools())
|
||||
|
||||
fun createInferenceRouter(
|
||||
providers: List<InferenceProvider> = emptyList(),
|
||||
registry: ProviderRegistry = DefaultProviderRegistry(providers),
|
||||
strategy: RoutingStrategy = FirstAvailableRoutingStrategy(),
|
||||
): InferenceRouter = DefaultInferenceRouter(registry, strategy)
|
||||
|
||||
fun createToolExecutor(
|
||||
registry: ToolRegistry,
|
||||
approvalEngine: ApprovalEngine,
|
||||
eventStore: EventStore,
|
||||
eventDispatcher: EventDispatcher,
|
||||
workDir: Path,
|
||||
): ToolExecutor = SandboxedToolExecutor(
|
||||
delegate = DispatchingToolExecutor(registry),
|
||||
registry = registry,
|
||||
approvalEngine = approvalEngine,
|
||||
eventStore = eventStore,
|
||||
eventDispatcher = eventDispatcher,
|
||||
workDir = workDir,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user