diff --git a/scripts/check-legacy-migrated-paths.ts b/scripts/check-legacy-migrated-paths.ts index b51032ed2f..edc7300528 100644 --- a/scripts/check-legacy-migrated-paths.ts +++ b/scripts/check-legacy-migrated-paths.ts @@ -34,7 +34,7 @@ const REMOVED_SHIM_MOVES: Record = { "bin/lib/platform.js": "src/lib/platform.ts", "bin/lib/preflight.js": "src/lib/preflight.ts", "bin/lib/registry.js": "src/lib/registry.ts", - "bin/lib/resolve-openshell.js": "src/lib/resolve-openshell.ts", + "bin/lib/resolve-openshell.js": "src/lib/adapters/openshell/resolve.ts", "bin/lib/runtime-recovery.js": "src/lib/runtime-recovery.ts", "bin/lib/sandbox-build-context.js": "src/lib/sandbox-build-context.ts", "bin/lib/services.js": "src/lib/services.ts", diff --git a/src/lib/openshell.test.ts b/src/lib/adapters/openshell/client.test.ts similarity index 99% rename from src/lib/openshell.test.ts rename to src/lib/adapters/openshell/client.test.ts index c46c40cc5e..bd3101e616 100644 --- a/src/lib/openshell.test.ts +++ b/src/lib/adapters/openshell/client.test.ts @@ -14,7 +14,7 @@ import { runOpenshellCommand, stripAnsi, versionGte, -} from "./openshell"; +} from "./client"; interface SpawnResultSpec { status: number | null; diff --git a/src/lib/openshell.ts b/src/lib/adapters/openshell/client.ts similarity index 100% rename from src/lib/openshell.ts rename to src/lib/adapters/openshell/client.ts diff --git a/src/lib/resolve-openshell.test.ts b/src/lib/adapters/openshell/resolve.test.ts similarity index 97% rename from src/lib/resolve-openshell.test.ts rename to src/lib/adapters/openshell/resolve.test.ts index 7d1d05a6dd..a62e4c72ca 100644 --- a/src/lib/resolve-openshell.test.ts +++ b/src/lib/adapters/openshell/resolve.test.ts @@ -5,7 +5,7 @@ import { describe, it, expect } from "vitest"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { resolveOpenshell } from "../../dist/lib/resolve-openshell"; +import { resolveOpenshell } from "../../../../dist/lib/adapters/openshell/resolve"; describe("lib/resolve-openshell", () => { it("returns command -v result when absolute path", () => { diff --git a/src/lib/resolve-openshell.ts b/src/lib/adapters/openshell/resolve.ts similarity index 100% rename from src/lib/resolve-openshell.ts rename to src/lib/adapters/openshell/resolve.ts diff --git a/src/lib/openshell-runtime.ts b/src/lib/adapters/openshell/runtime.ts similarity index 93% rename from src/lib/openshell-runtime.ts rename to src/lib/adapters/openshell/runtime.ts index 24a8abd48c..17abdf2deb 100644 --- a/src/lib/openshell-runtime.ts +++ b/src/lib/adapters/openshell/runtime.ts @@ -5,15 +5,15 @@ import type { StdioOptions } from "node:child_process"; -import { ROOT } from "./runner"; +import { ROOT } from "../../runner"; import { captureOpenshellCommand, captureOpenshellCommandAsync, getInstalledOpenshellVersion, runOpenshellCommand, -} from "./openshell"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; -import { resolveOpenshell } from "./resolve-openshell"; +} from "./client"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./timeouts"; +import { resolveOpenshell } from "./resolve"; type CommandArgs = string[]; diff --git a/src/lib/openshell-timeouts.test.ts b/src/lib/adapters/openshell/timeouts.test.ts similarity index 97% rename from src/lib/openshell-timeouts.test.ts rename to src/lib/adapters/openshell/timeouts.test.ts index 6202cfcc0b..65ea905188 100644 --- a/src/lib/openshell-timeouts.test.ts +++ b/src/lib/adapters/openshell/timeouts.test.ts @@ -8,7 +8,7 @@ import { OPENSHELL_HEAVY_TIMEOUT_MS, OPENSHELL_OPERATION_TIMEOUT_MS, OPENSHELL_PROBE_TIMEOUT_MS, -} from "./openshell-timeouts"; +} from "./timeouts"; describe("openshell-timeouts", () => { it("exports positive integer constants", () => { diff --git a/src/lib/openshell-timeouts.ts b/src/lib/adapters/openshell/timeouts.ts similarity index 100% rename from src/lib/openshell-timeouts.ts rename to src/lib/adapters/openshell/timeouts.ts diff --git a/src/lib/commands/credentials/list.ts b/src/lib/commands/credentials/list.ts index 73d9b27287..7c47c731b0 100644 --- a/src/lib/commands/credentials/list.ts +++ b/src/lib/commands/credentials/list.ts @@ -5,7 +5,7 @@ import { Command, Flags } from "@oclif/core"; import { CLI_NAME } from "../../branding"; import { runOpenshellProviderCommand } from "../../global-cli-actions"; -import { OPENSHELL_OPERATION_TIMEOUT_MS } from "../../openshell-timeouts"; +import { OPENSHELL_OPERATION_TIMEOUT_MS } from "../../adapters/openshell/timeouts"; import { isBridgeProviderName, recoverGatewayOrExit } from "./common"; export default class CredentialsListCommand extends Command { diff --git a/src/lib/commands/credentials/reset.ts b/src/lib/commands/credentials/reset.ts index d02418afc5..afe1e42cbb 100644 --- a/src/lib/commands/credentials/reset.ts +++ b/src/lib/commands/credentials/reset.ts @@ -6,7 +6,7 @@ import { Args, Command, Flags } from "@oclif/core"; import { CLI_NAME } from "../../branding"; import { prompt as askPrompt } from "../../credentials"; import { runOpenshellProviderCommand } from "../../global-cli-actions"; -import { OPENSHELL_OPERATION_TIMEOUT_MS } from "../../openshell-timeouts"; +import { OPENSHELL_OPERATION_TIMEOUT_MS } from "../../adapters/openshell/timeouts"; import { isBridgeProviderName, recoverGatewayOrExit } from "./common"; export default class CredentialsResetCommand extends Command { diff --git a/src/lib/commands/debug.ts b/src/lib/commands/debug.ts index 6a1a7f6771..db9aead37b 100644 --- a/src/lib/commands/debug.ts +++ b/src/lib/commands/debug.ts @@ -8,11 +8,11 @@ import { runDebug } from "../debug"; import type { DebugOptions } from "../debug"; import type { RunDebugCommandDeps } from "../debug-command"; import { runDebugCommandWithOptions } from "../debug-command"; -import type { CaptureOpenshellResult } from "../openshell"; -import { captureOpenshellCommand } from "../openshell"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "../openshell-timeouts"; +import type { CaptureOpenshellResult } from "../adapters/openshell/client"; +import { captureOpenshellCommand } from "../adapters/openshell/client"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "../adapters/openshell/timeouts"; import * as registry from "../registry"; -import { resolveOpenshell } from "../resolve-openshell"; +import { resolveOpenshell } from "../adapters/openshell/resolve"; import { parseLiveSandboxNames } from "../runtime-recovery"; const useColor = !process.env.NO_COLOR && !!process.stderr.isTTY; diff --git a/src/lib/commands/simple-global-oclif-adapters.test.ts b/src/lib/commands/simple-global-oclif-adapters.test.ts index 855fbdf67a..f0b6c01c0b 100644 --- a/src/lib/commands/simple-global-oclif-adapters.test.ts +++ b/src/lib/commands/simple-global-oclif-adapters.test.ts @@ -36,9 +36,9 @@ vi.mock("../global-cli-actions", () => ({ showRootHelp: mocks.showRootHelp, showVersion: mocks.showVersion, })); -vi.mock("../openshell", () => ({ captureOpenshellCommand: mocks.captureOpenshellCommand })); +vi.mock("../adapters/openshell/client", () => ({ captureOpenshellCommand: mocks.captureOpenshellCommand })); vi.mock("../registry", () => ({ listSandboxes: mocks.listSandboxes })); -vi.mock("../resolve-openshell", () => ({ resolveOpenshell: mocks.resolveOpenshell })); +vi.mock("../adapters/openshell/resolve", () => ({ resolveOpenshell: mocks.resolveOpenshell })); vi.mock("../services", () => ({ startAll: mocks.startAll, stopAll: mocks.stopAll })); vi.mock("../services-command", () => ({ runStartCommand: mocks.runStartCommand, diff --git a/src/lib/gateway-runtime-action.ts b/src/lib/gateway-runtime-action.ts index ded22eb9bd..e3a48a9f85 100644 --- a/src/lib/gateway-runtime-action.ts +++ b/src/lib/gateway-runtime-action.ts @@ -4,9 +4,9 @@ const { startGatewayForRecovery } = require("./onboard") as { startGatewayForRecovery: () => Promise; }; -import { OPENSHELL_OPERATION_TIMEOUT_MS, OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; -import { stripAnsi } from "./openshell"; -import { captureOpenshell, runOpenshell } from "./openshell-runtime"; +import { OPENSHELL_OPERATION_TIMEOUT_MS, OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; +import { stripAnsi } from "./adapters/openshell/client"; +import { captureOpenshell, runOpenshell } from "./adapters/openshell/runtime"; function hasNamedGateway(output = ""): boolean { return stripAnsi(output).includes("Gateway: nemoclaw"); diff --git a/src/lib/global-cli-actions.test.ts b/src/lib/global-cli-actions.test.ts index 7a004ceeaa..cb395e7877 100644 --- a/src/lib/global-cli-actions.test.ts +++ b/src/lib/global-cli-actions.test.ts @@ -29,7 +29,7 @@ vi.mock("./onboard-action", () => ({ runSetupAction: mocks.runSetupAction, runSetupSparkAction: mocks.runSetupSparkAction, })); -vi.mock("./openshell-runtime", () => ({ runOpenshell: mocks.runOpenshell })); +vi.mock("./adapters/openshell/runtime", () => ({ runOpenshell: mocks.runOpenshell })); vi.mock("./root-help-action", () => ({ help: mocks.help, version: mocks.version })); import { diff --git a/src/lib/global-cli-actions.ts b/src/lib/global-cli-actions.ts index 9d5692327d..a13bbf7ee0 100644 --- a/src/lib/global-cli-actions.ts +++ b/src/lib/global-cli-actions.ts @@ -16,7 +16,7 @@ import { runSetupSparkAction as executeSetupSparkAction, } from "./onboard-action"; import { recoverNamedGatewayRuntime as recoverNamedGatewayRuntimeAction } from "./gateway-runtime-action"; -import { runOpenshell } from "./openshell-runtime"; +import { runOpenshell } from "./adapters/openshell/runtime"; import { help, version } from "./root-help-action"; type GatewayRecovery = { recovered: boolean }; diff --git a/src/lib/list-command-deps.ts b/src/lib/list-command-deps.ts index 093cabd813..7bc2792b03 100644 --- a/src/lib/list-command-deps.ts +++ b/src/lib/list-command-deps.ts @@ -6,10 +6,10 @@ import * as onboardSession from "./onboard-session"; import type { ListSandboxesCommandDeps } from "./inventory-commands"; import { parseGatewayInference } from "./inference-config"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import { parseSshProcesses, createSystemDeps } from "./sandbox-session-state"; -import { resolveOpenshell } from "./resolve-openshell"; -import { captureOpenshell } from "./openshell-runtime"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; +import { captureOpenshell } from "./adapters/openshell/runtime"; import { recoverRegistryEntries } from "./registry-recovery-action"; export function buildListCommandDeps(): ListSandboxesCommandDeps { diff --git a/src/lib/maintenance-actions.ts b/src/lib/maintenance-actions.ts index dd4bcdb760..5be7f5a126 100644 --- a/src/lib/maintenance-actions.ts +++ b/src/lib/maintenance-actions.ts @@ -10,7 +10,7 @@ import { } from "./domain/lifecycle/options"; import { dockerListImagesFormat, dockerRmi } from "./docker"; import { findOrphanedSandboxImages, parseSandboxImageRows } from "./domain/maintenance/images"; -import { captureOpenshell } from "./openshell-runtime"; +import { captureOpenshell } from "./adapters/openshell/runtime"; import * as registry from "./registry"; import { parseLiveSandboxNames } from "./runtime-recovery"; import * as sandboxState from "./sandbox-state"; diff --git a/src/lib/onboard.ts b/src/lib/onboard.ts index 663f1bc0a1..79a4452d94 100644 --- a/src/lib/onboard.ts +++ b/src/lib/onboard.ts @@ -259,7 +259,7 @@ const { const { sleepSeconds } = require("./wait"); const platformUtils: typeof import("./platform") = require("./platform"); const { inferContainerRuntime, isWsl, shouldPatchCoredns } = platformUtils; -const { resolveOpenshell } = require("./resolve-openshell"); +const { resolveOpenshell } = require("./adapters/openshell/resolve"); const credentials: typeof import("./credentials") = require("./credentials"); const { prompt, diff --git a/src/lib/policy-channel-actions.ts b/src/lib/policy-channel-actions.ts index 4b85e8bab3..9c512a7f10 100644 --- a/src/lib/policy-channel-actions.ts +++ b/src/lib/policy-channel-actions.ts @@ -15,7 +15,7 @@ const onboardProviders = require("./onboard-providers"); import * as policies from "./policies"; import { parsePolicyAddArgs } from "./domain/policy-channel"; import * as registry from "./registry"; -import { runOpenshell } from "./openshell-runtime"; +import { runOpenshell } from "./adapters/openshell/runtime"; import { rebuildSandbox } from "./sandbox-runtime-actions"; import { KNOWN_CHANNELS, diff --git a/src/lib/registry-recovery-action.test.ts b/src/lib/registry-recovery-action.test.ts index 8ce30606c4..604677954b 100644 --- a/src/lib/registry-recovery-action.test.ts +++ b/src/lib/registry-recovery-action.test.ts @@ -33,7 +33,7 @@ vi.mock("./registry.js", () => ({ }, })); -vi.mock("./resolve-openshell.js", () => ({ +vi.mock("./adapters/openshell/resolve.js", () => ({ resolveOpenshell: vi.fn(() => null), })); @@ -41,7 +41,7 @@ vi.mock("./gateway-runtime-action.js", () => ({ recoverNamedGatewayRuntime: vi.fn(), })); -vi.mock("./openshell-runtime.js", () => ({ +vi.mock("./adapters/openshell/runtime.js", () => ({ captureOpenshell: vi.fn(), })); diff --git a/src/lib/registry-recovery-action.ts b/src/lib/registry-recovery-action.ts index 41a0c69a80..cc02dfbd16 100644 --- a/src/lib/registry-recovery-action.ts +++ b/src/lib/registry-recovery-action.ts @@ -4,11 +4,11 @@ import { recoverNamedGatewayRuntime } from "./gateway-runtime-action"; import type { RecoveryResult } from "./inventory-commands"; import * as onboardSession from "./onboard-session"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; -import { captureOpenshell } from "./openshell-runtime"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; +import { captureOpenshell } from "./adapters/openshell/runtime"; import * as registry from "./registry"; import type { SandboxEntry } from "./registry"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { parseLiveSandboxNames } from "./runtime-recovery"; import { validateName } from "./runner"; diff --git a/src/lib/sandbox-config.ts b/src/lib/sandbox-config.ts index b56c8c0117..0c1340273a 100644 --- a/src/lib/sandbox-config.ts +++ b/src/lib/sandbox-config.ts @@ -27,7 +27,7 @@ const { isPrivateHostname, isPrivateIp } = require("./private-networks"); type ConfigObject = import("./credential-filter").ConfigObject; type ConfigValue = import("./credential-filter").ConfigValue; -const { runOpenshellCommand, captureOpenshellCommand } = require("./openshell"); +const { runOpenshellCommand, captureOpenshellCommand } = require("./adapters/openshell/client"); function parseJson(text: string): T { return JSON.parse(text); diff --git a/src/lib/sandbox-connect-action.ts b/src/lib/sandbox-connect-action.ts index 308b005cd1..f0083ccfd2 100644 --- a/src/lib/sandbox-connect-action.ts +++ b/src/lib/sandbox-connect-action.ts @@ -13,8 +13,8 @@ import { captureOpenshell, getOpenshellBinary, runOpenshell, -} from "./openshell-runtime"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +} from "./adapters/openshell/runtime"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import * as registry from "./registry"; import { ROOT } from "./runner"; import { ensureLiveSandboxOrExit } from "./sandbox-gateway-state-action"; @@ -25,7 +25,7 @@ import { import { checkAndRecoverSandboxProcesses } from "./sandbox-process-recovery-action"; import * as sandboxVersion from "./sandbox-version"; import { D, G, R, YW } from "./terminal-style"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; const agentRuntime = require("../../bin/lib/agent-runtime"); diff --git a/src/lib/sandbox-destroy-action.ts b/src/lib/sandbox-destroy-action.ts index 32f7eab212..db8dfb5005 100644 --- a/src/lib/sandbox-destroy-action.ts +++ b/src/lib/sandbox-destroy-action.ts @@ -13,10 +13,10 @@ import { } from "./domain/lifecycle/options"; import * as onboardSession from "./onboard-session"; import type { Session } from "./onboard-session"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import { DASHBOARD_PORT } from "./ports"; import * as registry from "./registry"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { parseLiveSandboxNames } from "./runtime-recovery"; import { createSystemDeps as createSessionDeps, @@ -45,7 +45,7 @@ const NEMOCLAW_GATEWAY_NAME = "nemoclaw"; const DASHBOARD_FORWARD_PORT = String(DASHBOARD_PORT); function cleanupGatewayAfterLastSandbox(): void { - const { runOpenshell } = require("./openshell-runtime") as { + const { runOpenshell } = require("./adapters/openshell/runtime") as { runOpenshell: (args: string[], opts?: Record) => { status: number | null }; }; const { dockerRemoveVolumesByPrefix } = require("./docker") as { @@ -63,7 +63,7 @@ function cleanupGatewayAfterLastSandbox(): void { } function hasNoLiveSandboxes(): boolean { - const { captureOpenshell } = require("./openshell-runtime") as { + const { captureOpenshell } = require("./adapters/openshell/runtime") as { captureOpenshell: ( args: string[], opts?: { ignoreError?: boolean; timeout?: number }, @@ -102,7 +102,7 @@ function cleanupSandboxServices( // Delete messaging providers created during onboard. Suppress stderr so // "! Provider not found" noise doesn't appear when messaging was never configured. - const { runOpenshell } = require("./openshell-runtime") as { + const { runOpenshell } = require("./adapters/openshell/runtime") as { runOpenshell: (args: string[], opts?: Record) => { status: number | null }; }; for (const suffix of ["telegram-bridge", "discord-bridge", "slack-bridge"]) { @@ -209,7 +209,7 @@ export async function destroySandbox( } console.log(` Deleting sandbox '${sandboxName}'...`); - const { runOpenshell } = require("./openshell-runtime") as { + const { runOpenshell } = require("./adapters/openshell/runtime") as { runOpenshell: ( args: string[], opts?: Record, diff --git a/src/lib/sandbox-doctor-action.ts b/src/lib/sandbox-doctor-action.ts index 50559b21b9..4f103a64a7 100644 --- a/src/lib/sandbox-doctor-action.ts +++ b/src/lib/sandbox-doctor-action.ts @@ -12,13 +12,13 @@ import { isErrnoException } from "./errno"; import { recoverNamedGatewayRuntime } from "./gateway-runtime-action"; import { probeProviderHealth } from "./inference-health"; import { parseGatewayInference } from "./inference-config"; -import { stripAnsi } from "./openshell"; -import { captureOpenshell } from "./openshell-runtime"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +import { stripAnsi } from "./adapters/openshell/client"; +import { captureOpenshell } from "./adapters/openshell/runtime"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import { GATEWAY_PORT, OLLAMA_PORT } from "./ports"; import * as registry from "./registry"; import type { SandboxEntry } from "./registry"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { ROOT } from "./runner"; import { parseLiveSandboxNames } from "./runtime-recovery"; import * as sandboxVersion from "./sandbox-version"; diff --git a/src/lib/sandbox-gateway-state-action.ts b/src/lib/sandbox-gateway-state-action.ts index 00a7a88677..32f24c3f79 100644 --- a/src/lib/sandbox-gateway-state-action.ts +++ b/src/lib/sandbox-gateway-state-action.ts @@ -18,18 +18,18 @@ const { pruneKnownHostsEntries } = require("./onboard") as { }; import * as onboardSession from "./onboard-session"; import type { Session } from "./onboard-session"; -import { stripAnsi } from "./openshell"; +import { stripAnsi } from "./adapters/openshell/client"; import { captureOpenshell, captureOpenshellForStatus, getStatusProbeTimeoutMs, isCommandTimeout, runOpenshell, -} from "./openshell-runtime"; +} from "./adapters/openshell/runtime"; import { OPENSHELL_OPERATION_TIMEOUT_MS, OPENSHELL_PROBE_TIMEOUT_MS, -} from "./openshell-timeouts"; +} from "./adapters/openshell/timeouts"; import * as registry from "./registry"; type SandboxGatewayState = { diff --git a/src/lib/sandbox-logs-action.ts b/src/lib/sandbox-logs-action.ts index 0c81c4a728..b5b1b5dd19 100644 --- a/src/lib/sandbox-logs-action.ts +++ b/src/lib/sandbox-logs-action.ts @@ -4,7 +4,7 @@ import { spawn } from "node:child_process"; import { ROOT } from "./runner"; -import { getOpenshellBinary, runOpenshell } from "./openshell-runtime"; +import { getOpenshellBinary, runOpenshell } from "./adapters/openshell/runtime"; import { buildEnableSandboxAuditLogsArgs, buildSandboxLogsArgs, diff --git a/src/lib/sandbox-process-recovery-action.ts b/src/lib/sandbox-process-recovery-action.ts index 4a5eb4e836..3000802c66 100644 --- a/src/lib/sandbox-process-recovery-action.ts +++ b/src/lib/sandbox-process-recovery-action.ts @@ -15,8 +15,8 @@ import { getOpenshellBinary, isCommandTimeout, runOpenshell, -} from "./openshell-runtime"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +} from "./adapters/openshell/runtime"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import { ROOT, shellQuote } from "./runner"; import { parseForwardList } from "./sandbox-session-state"; import { G, R } from "./terminal-style"; diff --git a/src/lib/sandbox-rebuild-action.ts b/src/lib/sandbox-rebuild-action.ts index 59a1ae199b..58b7e1b474 100644 --- a/src/lib/sandbox-rebuild-action.ts +++ b/src/lib/sandbox-rebuild-action.ts @@ -24,10 +24,10 @@ import { getSandboxDeleteOutcome } from "./domain/sandbox/destroy"; import * as nim from "./nim"; import type { Session } from "./onboard-session"; import * as onboardSession from "./onboard-session"; -import { captureOpenshell, runOpenshell } from "./openshell-runtime"; +import { captureOpenshell, runOpenshell } from "./adapters/openshell/runtime"; import * as policies from "./policies"; import * as registry from "./registry"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { parseLiveSandboxNames } from "./runtime-recovery"; import { removeSandboxRegistryEntry } from "./sandbox-destroy-action"; import { executeSandboxCommand } from "./sandbox-process-recovery-action"; diff --git a/src/lib/sandbox-skill-install-action.ts b/src/lib/sandbox-skill-install-action.ts index 0704881fa4..9a2742934a 100644 --- a/src/lib/sandbox-skill-install-action.ts +++ b/src/lib/sandbox-skill-install-action.ts @@ -8,7 +8,7 @@ import os from "node:os"; import path from "node:path"; import { CLI_NAME } from "./branding"; -import { captureOpenshell } from "./openshell-runtime"; +import { captureOpenshell } from "./adapters/openshell/runtime"; import { ensureLiveSandboxOrExit } from "./sandbox-gateway-state-action"; import * as skillInstall from "./skill-install"; import { D, G, R, YW } from "./terminal-style"; diff --git a/src/lib/sandbox-state.ts b/src/lib/sandbox-state.ts index 6f8aa103f6..9159e7d6c0 100644 --- a/src/lib/sandbox-state.ts +++ b/src/lib/sandbox-state.ts @@ -28,8 +28,8 @@ import path from "node:path"; import * as registry from "./registry.js"; import { loadAgent } from "./agent-defs.js"; import type { AgentStateFile } from "./agent-defs.js"; -import { resolveOpenshell } from "./resolve-openshell.js"; -import { captureOpenshellCommand } from "./openshell.js"; +import { resolveOpenshell } from "./adapters/openshell/resolve.js"; +import { captureOpenshellCommand } from "./adapters/openshell/client.js"; import { sanitizeConfigFile, isSensitiveFile } from "./credential-filter.js"; import { shellQuote } from "./runner.js"; diff --git a/src/lib/sandbox-status-action.ts b/src/lib/sandbox-status-action.ts index 8a32aeda29..50cf2855c0 100644 --- a/src/lib/sandbox-status-action.ts +++ b/src/lib/sandbox-status-action.ts @@ -11,9 +11,12 @@ import { probeProviderHealth } from "./inference-health"; import * as nim from "./nim"; import * as onboardSession from "./onboard-session"; import type { Session } from "./onboard-session"; -import { captureOpenshellForStatus, isCommandTimeout } from "./openshell-runtime"; +import { + captureOpenshellForStatus, + isCommandTimeout, +} from "./adapters/openshell/runtime"; import * as registry from "./registry"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { getReconciledSandboxGatewayState, getSandboxGatewayStateForStatus, diff --git a/src/lib/sandbox-version.test.ts b/src/lib/sandbox-version.test.ts index 5e8f35c4c2..90a844493e 100644 --- a/src/lib/sandbox-version.test.ts +++ b/src/lib/sandbox-version.test.ts @@ -7,11 +7,11 @@ import { join } from "node:path"; import { tmpdir } from "node:os"; // Mock heavy dependencies that pull in the full module graph -vi.mock("./resolve-openshell.js", () => ({ +vi.mock("./adapters/openshell/resolve.js", () => ({ resolveOpenshell: vi.fn(() => "/usr/local/bin/openshell"), })); -vi.mock("./openshell.js", () => ({ +vi.mock("./adapters/openshell/client.js", () => ({ parseVersionFromText: (value = "") => { const match = String(value).match(/([0-9]+\.[0-9]+\.[0-9]+)/); return match ? match[1] : null; @@ -49,8 +49,8 @@ vi.mock("child_process", async (importOriginal) => { import { checkAgentVersion, formatStalenessWarning } from "./sandbox-version.js"; import * as registry from "./registry.js"; -import { captureOpenshellCommand } from "./openshell.js"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts.js"; +import { captureOpenshellCommand } from "./adapters/openshell/client.js"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts.js"; import { spawnSync } from "child_process"; describe("checkAgentVersion", () => { diff --git a/src/lib/sandbox-version.ts b/src/lib/sandbox-version.ts index 29481422b1..0c76ab5f93 100644 --- a/src/lib/sandbox-version.ts +++ b/src/lib/sandbox-version.ts @@ -13,12 +13,12 @@ import fs from "fs"; import os from "os"; import path from "path"; -import { parseVersionFromText, versionGte } from "./openshell.js"; +import { parseVersionFromText, versionGte } from "./adapters/openshell/client.js"; import * as registry from "./registry.js"; import { loadAgent } from "./agent-defs.js"; -import { resolveOpenshell } from "./resolve-openshell.js"; -import { captureOpenshellCommand } from "./openshell.js"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts.js"; +import { resolveOpenshell } from "./adapters/openshell/resolve.js"; +import { captureOpenshellCommand } from "./adapters/openshell/client.js"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts.js"; export interface VersionCheckResult { sandboxVersion: string | null; diff --git a/src/lib/services-sandbox.test.ts b/src/lib/services-sandbox.test.ts index 0ce457d704..202025012c 100644 --- a/src/lib/services-sandbox.test.ts +++ b/src/lib/services-sandbox.test.ts @@ -14,7 +14,7 @@ import { spawnSync as realSpawnSync } from "node:child_process"; // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-require-imports -const resolveOpenshellModule = require("../../dist/lib/resolve-openshell"); +const resolveOpenshellModule = require("../../dist/lib/adapters/openshell/resolve"); import { stopSandboxChannels, diff --git a/src/lib/services.ts b/src/lib/services.ts index 3656d89e13..d32df737bb 100644 --- a/src/lib/services.ts +++ b/src/lib/services.ts @@ -18,7 +18,7 @@ import { join } from "node:path"; import { AGENT_PRODUCT_NAME, CLI_DISPLAY_NAME } from "./branding"; import { dockerSpawnSync } from "./docker"; import { DASHBOARD_PORT } from "./ports"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { buildSubprocessEnv } from "./subprocess-env"; // --------------------------------------------------------------------------- diff --git a/src/lib/share-command-deps.ts b/src/lib/share-command-deps.ts index b29c6a761d..2ec86f7f42 100644 --- a/src/lib/share-command-deps.ts +++ b/src/lib/share-command-deps.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { CLI_NAME } from "./branding"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import { G, R } from "./terminal-style"; export interface ShareCommandDeps { @@ -19,7 +19,7 @@ export interface ShareCommandDeps { } export function buildShareCommandDeps(): ShareCommandDeps { - const { captureOpenshell } = require("./openshell-runtime") as { + const { captureOpenshell } = require("./adapters/openshell/runtime") as { captureOpenshell: ( args: string[], opts?: { ignoreError?: boolean; timeout?: number }, diff --git a/src/lib/snapshot-action.ts b/src/lib/snapshot-action.ts index d7ba7c369d..27b14a88fb 100644 --- a/src/lib/snapshot-action.ts +++ b/src/lib/snapshot-action.ts @@ -10,7 +10,7 @@ import { CLI_NAME } from "./branding"; import { dockerCapture, dockerInspect } from "./docker"; import { parseLiveSandboxNames } from "./runtime-recovery"; import { ROOT, run, shellQuote, validateName } from "./runner"; -import { captureOpenshell, getOpenshellBinary } from "./openshell-runtime"; +import { captureOpenshell, getOpenshellBinary } from "./adapters/openshell/runtime"; import * as policies from "./policies"; import * as registry from "./registry"; import type { SandboxEntry } from "./registry"; diff --git a/src/lib/status-command-deps.ts b/src/lib/status-command-deps.ts index 9fc245e800..3512039b2a 100644 --- a/src/lib/status-command-deps.ts +++ b/src/lib/status-command-deps.ts @@ -8,11 +8,11 @@ import { spawnSync } from "node:child_process"; import { parseGatewayInference } from "./inference-config"; import type { MessagingBridgeHealth, ShowStatusCommandDeps } from "./inventory-commands"; import { backfillMessagingChannels, findAllOverlaps } from "./messaging-conflict"; -import type { CaptureOpenshellResult } from "./openshell"; -import { captureOpenshellCommand, stripAnsi } from "./openshell"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./openshell-timeouts"; +import type { CaptureOpenshellResult } from "./adapters/openshell/client"; +import { captureOpenshellCommand, stripAnsi } from "./adapters/openshell/client"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./adapters/openshell/timeouts"; import * as registry from "./registry"; -import { resolveOpenshell } from "./resolve-openshell"; +import { resolveOpenshell } from "./adapters/openshell/resolve"; import { getServiceStatuses, showStatus as showServiceStatus } from "./services"; function captureOpenshell( diff --git a/src/lib/upgrade-sandboxes-action.ts b/src/lib/upgrade-sandboxes-action.ts index e347cc9e80..47afa87028 100644 --- a/src/lib/upgrade-sandboxes-action.ts +++ b/src/lib/upgrade-sandboxes-action.ts @@ -9,7 +9,7 @@ import { normalizeUpgradeSandboxesOptions, type UpgradeSandboxesOptions, } from "./domain/lifecycle/options"; -import { captureOpenshell } from "./openshell-runtime"; +import { captureOpenshell } from "./adapters/openshell/runtime"; import * as registry from "./registry"; import { parseLiveSandboxNames } from "./runtime-recovery"; import { rebuildSandbox } from "./sandbox-rebuild-action"; diff --git a/src/nemoclaw.ts b/src/nemoclaw.ts index 001d0a4068..507d2ce93c 100644 --- a/src/nemoclaw.ts +++ b/src/nemoclaw.ts @@ -34,7 +34,7 @@ const { dockerRemoveVolumesByPrefix, dockerRmi, } = require("./lib/docker"); -const { resolveOpenshell } = require("./lib/resolve-openshell"); +const { resolveOpenshell } = require("./lib/adapters/openshell/resolve"); const { hydrateCredentialEnv, isNonInteractive } = require("./lib/onboard"); const registry = require("./lib/registry"); import type { SandboxEntry } from "./lib/registry"; @@ -47,11 +47,11 @@ const { buildStatusCommandDeps } = require("./lib/status-command-deps"); const { help, version } = require("./lib/root-help-action"); const onboardSession = require("./lib/onboard-session"); import type { Session } from "./lib/onboard-session"; -const { stripAnsi } = require("./lib/openshell"); +const { stripAnsi } = require("./lib/adapters/openshell/client"); const { getInstalledOpenshellVersionOrNull, runOpenshell, -} = require("./lib/openshell-runtime"); +} = require("./lib/adapters/openshell/runtime"); const { recoverNamedGatewayRuntime, } = require("./lib/gateway-runtime-action"); @@ -84,7 +84,7 @@ const { sandboxActionTokens, } = require("./lib/command-registry"); import { normalizeArgv, suggestCommand } from "./lib/cli/argv-normalizer"; -import { OPENSHELL_PROBE_TIMEOUT_MS } from "./lib/openshell-timeouts"; +import { OPENSHELL_PROBE_TIMEOUT_MS } from "./lib/adapters/openshell/timeouts"; import { renderPublicOclifHelp } from "./lib/cli/public-oclif-help"; import { resolveGlobalOclifDispatch, diff --git a/test/config-set-nested-ssrf.test.ts b/test/config-set-nested-ssrf.test.ts index 22118b2054..4bdc7f4833 100644 --- a/test/config-set-nested-ssrf.test.ts +++ b/test/config-set-nested-ssrf.test.ts @@ -10,7 +10,7 @@ const requireCache: Record = require.cache as any; describe("config set nested URL SSRF enforcement", () => { it("rejects nested object/array URL values that target private hosts", async () => { const sandboxConfigPath = require.resolve("../dist/lib/sandbox-config"); - const openshellPath = require.resolve("../dist/lib/openshell"); + const openshellPath = require.resolve("../dist/lib/adapters/openshell/client"); const shieldsAuditPath = require.resolve("../dist/lib/shields-audit"); const priorSandboxConfig = require.cache[sandboxConfigPath]; @@ -85,7 +85,7 @@ describe("config set nested URL SSRF enforcement", () => { it("validates the key before doing URL or DNS validation", async () => { const sandboxConfigPath = require.resolve("../dist/lib/sandbox-config"); - const openshellPath = require.resolve("../dist/lib/openshell"); + const openshellPath = require.resolve("../dist/lib/adapters/openshell/client"); const shieldsAuditPath = require.resolve("../dist/lib/shields-audit"); const priorSandboxConfig = require.cache[sandboxConfigPath]; @@ -164,7 +164,7 @@ describe("config set nested URL SSRF enforcement", () => { it("accepts nested object/array URL values when all are public", async () => { const sandboxConfigPath = require.resolve("../dist/lib/sandbox-config"); - const openshellPath = require.resolve("../dist/lib/openshell"); + const openshellPath = require.resolve("../dist/lib/adapters/openshell/client"); const shieldsAuditPath = require.resolve("../dist/lib/shields-audit"); const priorSandboxConfig = require.cache[sandboxConfigPath]; @@ -239,7 +239,7 @@ describe("config set nested URL SSRF enforcement", () => { it("ignores nested non-http URL-like strings and does not crash", async () => { const sandboxConfigPath = require.resolve("../dist/lib/sandbox-config"); - const openshellPath = require.resolve("../dist/lib/openshell"); + const openshellPath = require.resolve("../dist/lib/adapters/openshell/client"); const shieldsAuditPath = require.resolve("../dist/lib/shields-audit"); const priorSandboxConfig = require.cache[sandboxConfigPath]; @@ -315,7 +315,7 @@ describe("config set nested URL SSRF enforcement", () => { it("recognizes mixed-case http and https schemes in nested values", async () => { const sandboxConfigPath = require.resolve("../dist/lib/sandbox-config"); - const openshellPath = require.resolve("../dist/lib/openshell"); + const openshellPath = require.resolve("../dist/lib/adapters/openshell/client"); const shieldsAuditPath = require.resolve("../dist/lib/shields-audit"); const priorSandboxConfig = require.cache[sandboxConfigPath]; @@ -390,7 +390,7 @@ describe("config set nested URL SSRF enforcement", () => { it("redacts credentials, query strings, and fragments in validation errors", async () => { const sandboxConfigPath = require.resolve("../dist/lib/sandbox-config"); - const openshellPath = require.resolve("../dist/lib/openshell"); + const openshellPath = require.resolve("../dist/lib/adapters/openshell/client"); const shieldsAuditPath = require.resolve("../dist/lib/shields-audit"); const priorSandboxConfig = require.cache[sandboxConfigPath]; diff --git a/test/onboard-preset-diff.test.ts b/test/onboard-preset-diff.test.ts index 658c4c465c..ac168870b1 100644 --- a/test/onboard-preset-diff.test.ts +++ b/test/onboard-preset-diff.test.ts @@ -52,7 +52,7 @@ function buildPreamble({ const registryPath = JSON.stringify(path.join(repoRoot, "dist", "lib", "registry.js")); const policiesPath = JSON.stringify(path.join(repoRoot, "dist", "lib", "policies.js")); const resolveOpenshellPath = JSON.stringify( - path.join(repoRoot, "dist", "lib", "resolve-openshell.js"), + path.join(repoRoot, "dist", "lib", "adapters", "openshell", "resolve.js"), ); const onboardPath = JSON.stringify(path.join(repoRoot, "dist", "lib", "onboard.js")); diff --git a/test/policy-tiers-onboard.test.ts b/test/policy-tiers-onboard.test.ts index 83d06de6ca..445db85c15 100644 --- a/test/policy-tiers-onboard.test.ts +++ b/test/policy-tiers-onboard.test.ts @@ -54,7 +54,7 @@ function buildPreamble({ const registryPath = JSON.stringify(path.join(repoRoot, "dist", "lib", "registry.js")); const onboardPath = JSON.stringify(path.join(repoRoot, "dist", "lib", "onboard.js")); const resolveOpenshellPath = JSON.stringify( - path.join(repoRoot, "dist", "lib", "resolve-openshell.js"), + path.join(repoRoot, "dist", "lib", "adapters", "openshell", "resolve.js"), ); // Both stubs must run before onboard.js is required — onboard destructures diff --git a/test/resolve-openshell.test.ts b/test/resolve-openshell.test.ts index 74588b12f9..8cdfa0fa93 100644 --- a/test/resolve-openshell.test.ts +++ b/test/resolve-openshell.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; -import { resolveOpenshell } from "../dist/lib/resolve-openshell"; +import { resolveOpenshell } from "../dist/lib/adapters/openshell/resolve"; describe("resolveOpenshell", () => { it("returns an absolute command -v result immediately", () => { diff --git a/test/service-env.test.ts b/test/service-env.test.ts index d0b043ba48..e241325505 100644 --- a/test/service-env.test.ts +++ b/test/service-env.test.ts @@ -10,7 +10,7 @@ import { import { mkdtempSync, writeFileSync, unlinkSync, readFileSync, lstatSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { resolveOpenshell } from "../dist/lib/resolve-openshell"; +import { resolveOpenshell } from "../dist/lib/adapters/openshell/resolve"; import { parseAllowedChatIds, isChatAllowed } from "../dist/lib/chat-filter.js"; const NEMOCLAW_START_SCRIPT = join(import.meta.dirname, "../scripts/nemoclaw-start.sh");