diff --git a/src/lib/credentials-cli-command.ts b/src/lib/credentials-cli-command.ts index 1f62b61ca3a..887ec5f5de1 100644 --- a/src/lib/credentials-cli-command.ts +++ b/src/lib/credentials-cli-command.ts @@ -7,7 +7,7 @@ import { Args, Command, Flags } from "@oclif/core"; import { CLI_DISPLAY_NAME, CLI_NAME } from "./branding"; import { prompt as askPrompt } from "./credentials"; -import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { recoverNamedGatewayRuntime, runOpenshellProviderCommand } from "./global-cli-actions"; import { OPENSHELL_OPERATION_TIMEOUT_MS } from "./openshell-timeouts"; // Suffixes that mark per-sandbox messaging integrations in the gateway's @@ -37,8 +37,7 @@ function printCredentialsUsage(log: (message?: string) => void = console.log): v } async function recoverGatewayOrExit(kind: "query" | "reach"): Promise { - const runtime = getNemoClawRuntimeBridge(); - const recovery = await runtime.recoverNamedGatewayRuntime(); + const recovery = await recoverNamedGatewayRuntime(); if (recovery.recovered) return; if (kind === "query") { @@ -81,8 +80,7 @@ export class CredentialsListCommand extends Command { await this.parse(CredentialsListCommand); await recoverGatewayOrExit("query"); - const runtime = getNemoClawRuntimeBridge(); - const result = runtime.runOpenshell(["provider", "list", "--names"], { + const result = runOpenshellProviderCommand(["provider", "list", "--names"], { ignoreError: true, stdio: ["ignore", "pipe", "pipe"], timeout: OPENSHELL_OPERATION_TIMEOUT_MS, @@ -166,8 +164,7 @@ export class CredentialsResetCommand extends Command { await recoverGatewayOrExit("reach"); - const runtime = getNemoClawRuntimeBridge(); - const result = runtime.runOpenshell(["provider", "delete", key], { + const result = runOpenshellProviderCommand(["provider", "delete", key], { ignoreError: true, stdio: ["ignore", "pipe", "pipe"], timeout: OPENSHELL_OPERATION_TIMEOUT_MS, diff --git a/src/lib/deploy-cli-command.ts b/src/lib/deploy-cli-command.ts index 6bbb148e714..c4cfa76f177 100644 --- a/src/lib/deploy-cli-command.ts +++ b/src/lib/deploy-cli-command.ts @@ -5,7 +5,7 @@ import { Args, Command, Flags } from "@oclif/core"; -import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { runDeployAction } from "./global-cli-actions"; export default class DeployCliCommand extends Command { static id = "deploy"; @@ -26,6 +26,6 @@ export default class DeployCliCommand extends Command { public async run(): Promise { const { args } = await this.parse(DeployCliCommand); - await getNemoClawRuntimeBridge().deploy(args.instanceName); + await runDeployAction(args.instanceName); } } diff --git a/src/lib/global-cli-actions.ts b/src/lib/global-cli-actions.ts new file mode 100644 index 00000000000..68fb95f8c5a --- /dev/null +++ b/src/lib/global-cli-actions.ts @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +/* v8 ignore start -- transitional action facade until implementations leave src/nemoclaw.ts. */ + +import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; + +export async function runOnboardAction(args: string[] = []): Promise { + await getNemoClawRuntimeBridge().onboard(args); +} + +export async function runSetupAction(args: string[] = []): Promise { + await getNemoClawRuntimeBridge().setup(args); +} + +export async function runSetupSparkAction(args: string[] = []): Promise { + await getNemoClawRuntimeBridge().setupSpark(args); +} + +export async function runDeployAction(instanceName?: string): Promise { + await getNemoClawRuntimeBridge().deploy(instanceName); +} + +export function runBackupAllAction(): void { + getNemoClawRuntimeBridge().backupAll(); +} + +export async function runUpgradeSandboxesAction(args: string[] = []): Promise { + await getNemoClawRuntimeBridge().upgradeSandboxes(args); +} + +export async function runGarbageCollectImagesAction(args: string[] = []): Promise { + await getNemoClawRuntimeBridge().garbageCollectImages(args); +} + +export function showRootHelp(): void { + getNemoClawRuntimeBridge().help(); +} + +export function showVersion(): void { + getNemoClawRuntimeBridge().version(); +} + +export async function recoverNamedGatewayRuntime(): Promise<{ recovered: boolean }> { + return getNemoClawRuntimeBridge().recoverNamedGatewayRuntime(); +} + +export function runOpenshellProviderCommand( + args: string[], + opts?: { + env?: Record; + ignoreError?: boolean; + stdio?: import("node:child_process").StdioOptions; + timeout?: number; + }, +) { + return getNemoClawRuntimeBridge().runOpenshell(args, opts); +} diff --git a/src/lib/help-version-cli-commands.ts b/src/lib/help-version-cli-commands.ts index 8e6ce36eabd..3727cd8c323 100644 --- a/src/lib/help-version-cli-commands.ts +++ b/src/lib/help-version-cli-commands.ts @@ -5,7 +5,7 @@ import { Command } from "@oclif/core"; -import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { showRootHelp, showVersion } from "./global-cli-actions"; export class RootHelpCommand extends Command { static id = "root:help"; @@ -15,7 +15,7 @@ export class RootHelpCommand extends Command { public async run(): Promise { this.parsed = true; - getNemoClawRuntimeBridge().help(); + showRootHelp(); } } @@ -27,6 +27,6 @@ export class VersionCommand extends Command { public async run(): Promise { this.parsed = true; - getNemoClawRuntimeBridge().version(); + showVersion(); } } diff --git a/src/lib/maintenance-cli-commands.ts b/src/lib/maintenance-cli-commands.ts index 60af17694a6..eb03289e090 100644 --- a/src/lib/maintenance-cli-commands.ts +++ b/src/lib/maintenance-cli-commands.ts @@ -5,7 +5,11 @@ import { Command, Flags } from "@oclif/core"; -import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { + runBackupAllAction, + runGarbageCollectImagesAction, + runUpgradeSandboxesAction, +} from "./global-cli-actions"; export class BackupAllCommand extends Command { static id = "backup-all"; @@ -19,7 +23,7 @@ export class BackupAllCommand extends Command { public async run(): Promise { await this.parse(BackupAllCommand); - getNemoClawRuntimeBridge().backupAll(); + runBackupAllAction(); } } @@ -42,7 +46,7 @@ export class UpgradeSandboxesCommand extends Command { if (flags.check) args.push("--check"); if (flags.auto) args.push("--auto"); if (flags.yes) args.push("--yes"); - await getNemoClawRuntimeBridge().upgradeSandboxes(args); + await runUpgradeSandboxesAction(args); } } @@ -65,6 +69,6 @@ export class GarbageCollectImagesCommand extends Command { if (flags["dry-run"]) args.push("--dry-run"); if (flags.yes) args.push("--yes"); if (flags.force) args.push("--force"); - await getNemoClawRuntimeBridge().garbageCollectImages(args); + await runGarbageCollectImagesAction(args); } } diff --git a/src/lib/onboard-cli-commands.ts b/src/lib/onboard-cli-commands.ts index 70337fdb9d8..f57e36b7122 100644 --- a/src/lib/onboard-cli-commands.ts +++ b/src/lib/onboard-cli-commands.ts @@ -5,7 +5,7 @@ import { Command } from "@oclif/core"; -import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge"; +import { runOnboardAction, runSetupAction, runSetupSparkAction } from "./global-cli-actions"; export class OnboardCliCommand extends Command { static id = "onboard"; @@ -16,7 +16,7 @@ export class OnboardCliCommand extends Command { public async run(): Promise { this.parsed = true; - await getNemoClawRuntimeBridge().onboard(this.argv); + await runOnboardAction(this.argv); } } @@ -29,7 +29,7 @@ export class SetupCliCommand extends Command { public async run(): Promise { this.parsed = true; - await getNemoClawRuntimeBridge().setup(this.argv); + await runSetupAction(this.argv); } } @@ -42,6 +42,6 @@ export class SetupSparkCliCommand extends Command { public async run(): Promise { this.parsed = true; - await getNemoClawRuntimeBridge().setupSpark(this.argv); + await runSetupSparkAction(this.argv); } }