diff --git a/src/lib/channels-mutate-cli-commands.ts b/src/lib/channels-mutate-cli-commands.ts index 52d956045a9..e123596a9de 100644 --- a/src/lib/channels-mutate-cli-commands.ts +++ b/src/lib/channels-mutate-cli-commands.ts @@ -5,20 +5,23 @@ import { Args, Command, Flags } from "@oclif/core"; -type RuntimeBridge = { - sandboxChannelsAdd: (sandboxName: string, args?: string[]) => Promise; - sandboxChannelsRemove: (sandboxName: string, args?: string[]) => Promise; - sandboxChannelsStart: (sandboxName: string, args?: string[]) => Promise; - sandboxChannelsStop: (sandboxName: string, args?: string[]) => Promise; -}; +import type { NemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; + +type ChannelsRuntimeBridge = Pick< + NemoClawRuntimeBridge, + "sandboxChannelsAdd" | "sandboxChannelsRemove" | "sandboxChannelsStart" | "sandboxChannelsStop" +>; -let runtimeBridgeFactory = (): RuntimeBridge => require("../nemoclaw") as RuntimeBridge; +let runtimeBridgeFactory = (): ChannelsRuntimeBridge => getNemoClawRuntimeBridge(); -export function setChannelsRuntimeBridgeFactoryForTest(factory: () => RuntimeBridge): void { +export function setChannelsRuntimeBridgeFactoryForTest( + factory: () => ChannelsRuntimeBridge, +): void { runtimeBridgeFactory = factory; } -function getRuntimeBridge(): RuntimeBridge { +function getRuntimeBridge(): ChannelsRuntimeBridge { return runtimeBridgeFactory(); } diff --git a/src/lib/policy-mutate-cli-commands.ts b/src/lib/policy-mutate-cli-commands.ts index 59287f7c7d2..969d48957e9 100644 --- a/src/lib/policy-mutate-cli-commands.ts +++ b/src/lib/policy-mutate-cli-commands.ts @@ -5,18 +5,18 @@ import { Args, Command, Flags } from "@oclif/core"; -type RuntimeBridge = { - sandboxPolicyAdd: (sandboxName: string, args?: string[]) => Promise; - sandboxPolicyRemove: (sandboxName: string, args?: string[]) => Promise; -}; +import type { NemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; -let runtimeBridgeFactory = (): RuntimeBridge => require("../nemoclaw") as RuntimeBridge; +type PolicyRuntimeBridge = Pick; -export function setPolicyRuntimeBridgeFactoryForTest(factory: () => RuntimeBridge): void { +let runtimeBridgeFactory = (): PolicyRuntimeBridge => getNemoClawRuntimeBridge(); + +export function setPolicyRuntimeBridgeFactoryForTest(factory: () => PolicyRuntimeBridge): void { runtimeBridgeFactory = factory; } -function getRuntimeBridge(): RuntimeBridge { +function getRuntimeBridge(): PolicyRuntimeBridge { return runtimeBridgeFactory(); }