21 lines
1.2 KiB
TypeScript
21 lines
1.2 KiB
TypeScript
import path from "node:path";
|
|
|
|
import { PostgresHarnessRLRegistry } from "./registry.ts";
|
|
import { createHarnessRLService } from "./service.ts";
|
|
import { createHarnessRLTemporalGateway } from "./temporal.ts";
|
|
|
|
export function harnessRLRuntime(env: Record<string, string | undefined> = process.env) {
|
|
const cwd = path.resolve(String(env.HWLAB_CASERUN_REPO_ROOT ?? process.cwd()));
|
|
const caseRepo = path.resolve(cwd, String(env.HWLAB_CASERUN_CASE_REPO ?? env.HWLAB_CASE_REPO ?? "."));
|
|
const stateRoot = path.resolve(cwd, String(env.HARNESSRL_STATE_DIR ?? ".state/harnessrl"));
|
|
const registry = new PostgresHarnessRLRegistry(String(env.HARNESSRL_DATABASE_URL ?? ""));
|
|
const temporalAddress = String(env.HARNESSRL_TEMPORAL_ADDRESS ?? env.TEMPORAL_ADDRESS ?? "");
|
|
const temporalNamespace = String(env.HARNESSRL_TEMPORAL_NAMESPACE ?? "unidesk");
|
|
const taskQueue = String(env.HARNESSRL_TEMPORAL_TASK_QUEUE ?? "hwlab-v03-harnessrl");
|
|
const temporal = createHarnessRLTemporalGateway({ address: temporalAddress, namespace: temporalNamespace, taskQueue });
|
|
return {
|
|
cwd, caseRepo, stateRoot, registry, temporalAddress, temporalNamespace, taskQueue,
|
|
service: createHarnessRLService({ registry, temporal, cwd, caseRepo, stateRoot })
|
|
};
|
|
}
|