Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ reviews:
- path: "src/lib/onboard/preflight.ts"
instructions: *e2e-overlayfs

- path: "src/lib/deploy.ts"
- path: "src/lib/deploy/**"
instructions: |
This file contains deployment lifecycle logic (start/stop,
cloudflared tunnel, uninstall).
Expand Down
6 changes: 3 additions & 3 deletions bin/lib/tiers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Thin re-export shim — the implementation lives in src/lib/tiers.ts,
// compiled to dist/lib/tiers.js.
// Thin re-export shim — the implementation lives in src/lib/policy/tiers.ts,
// compiled to dist/lib/policy/tiers.js.

const mod = require("../../dist/lib/tiers");
const mod = require("../../dist/lib/policy/tiers");
module.exports = {
TIERS_FILE: mod.TIERS_FILE,
listTiers: mod.listTiers,
Expand Down
2 changes: 1 addition & 1 deletion nemoclaw-blueprint/private-networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
#
# IPv4 and IPv6 networks that SSRF validation must reject. Consumed by:
# - src/lib/sandbox-config.ts (CLI `config set` literal-IP gate)
# - src/lib/sandbox/config.ts (CLI `config set` literal-IP gate)
# - nemoclaw/src/blueprint/ssrf.ts (plugin endpoint URL validator)
# Both consumers build a node:net BlockList from this data at module load.
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/benchmark-sandbox-image-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
collectBuildContextStats,
stageLegacySandboxBuildContext,
stageOptimizedSandboxBuildContext,
} = require("../dist/lib/sandbox-build-context");
} = require("../dist/lib/sandbox/build-context");

function parseArgs(argv) {
const args = {
Expand Down
6 changes: 3 additions & 3 deletions scripts/check-legacy-migrated-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const REMOVED_SHIM_MOVES: Record<string, string> = {
"bin/lib/registry.js": "src/lib/state/registry.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",
"bin/lib/sandbox-build-context.js": "src/lib/sandbox/build-context.ts",
"bin/lib/services.js": "src/lib/tunnel/services.ts",
"bin/lib/version.js": "src/lib/core/version.ts",
"bin/lib/onboard.js": "src/lib/onboard.ts",
"bin/lib/policies.js": "src/lib/policies.ts",
"bin/lib/policies.js": "src/lib/policy/index.ts",
"bin/lib/runner.js": "src/lib/runner.ts",
};

Expand Down
2 changes: 1 addition & 1 deletion scripts/dev-tier-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const onboard = /** @type {{
* selectTierPresetsAndAccess: (tierName: string, allPresets: unknown[]) => Promise<unknown>;
* }} */ (require("../dist/lib/onboard.js"));
const { selectPolicyTier, selectTierPresetsAndAccess } = onboard;
const policies = require("../dist/lib/policies.js");
const policies = require("../dist/lib/policy/index.js");

(async () => {
const tier = await selectPolicyTier();
Expand Down
8 changes: 4 additions & 4 deletions scripts/ts-migration-assist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ const SPECIAL_REWRITES: Record<string, Array<[string, string]>> = {
['require("./lib/credentials")', 'require("../bin/lib/credentials")'],
['require("./lib/registry")', 'require("../bin/lib/registry")'],
['require("./lib/nim")', 'require("../bin/lib/nim")'],
['require("./lib/policies")', 'require("../bin/lib/policies")'],
['require("./lib/policy")', 'require("../bin/lib/policies")'],
['require("./lib/inference/config")', 'require("../bin/lib/inference-config")'],
['require("./lib/version")', 'require("../bin/lib/version")'],
['require("./lib/state/onboard-session")', 'require("../bin/lib/onboard-session")'],
['require("./lib/runtime-recovery")', 'require("../bin/lib/runtime-recovery")'],
['require("./lib/onboard/usage-notice")', 'require("../bin/lib/usage-notice")'],
['require("./lib/services")', 'require("../bin/lib/services")'],
['require("./lib/tunnel/services")', 'require("../bin/lib/services")'],
['require("./lib/debug")', 'require("./lib/diagnostics/debug")'],
['require("./lib/debug-command")', 'require("./lib/diagnostics/debug-command")'],
['require("../dist/lib/debug-command")', 'require("./lib/diagnostics/debug-command")'],
['require("../dist/lib/openshell")', 'require("./lib/openshell")'],
['require("../dist/lib/inventory-commands")', 'require("./lib/inventory-commands")'],
['require("./lib/inventory")', 'require("./lib/inventory-commands")'],
['require("../dist/lib/deploy")', 'require("./lib/deploy")'],
['require("../dist/lib/services-command")', 'require("./lib/services-command")'],
['require("./lib/tunnel/service-command")', 'require("./lib/services-command")'],
['require("../dist/lib/uninstall-command")', 'require("./lib/uninstall-command")'],
],
};
Expand Down
4 changes: 2 additions & 2 deletions scripts/ts-migration/move-map.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"runtimeMoves": {
"bin/lib/platform.js": "src/lib/platform.ts",
"bin/lib/sandbox-build-context.js": "src/lib/sandbox-build-context.ts",
"bin/lib/sandbox-build-context.js": "src/lib/sandbox/build-context.ts",
"bin/lib/runner.js": "src/lib/runner.ts",
"bin/lib/policies.js": "src/lib/policies.ts",
"bin/lib/policies.js": "src/lib/policy/index.ts",
"bin/lib/onboard.js": "src/lib/onboard.ts",
"bin/nemoclaw.js": "src/nemoclaw.ts"
}
Expand Down
21 changes: 21 additions & 0 deletions src/commands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->

# `src/commands`

This tree is the oclif discovery surface for the packaged `nemoclaw` CLI.
Each file is intentionally thin: it exports a command class from `src/lib/commands/**`
and attaches NemoClaw's public display metadata.

```text
src/commands/<public command path>.ts
-> import command implementation from src/lib/commands/**
-> wrap with src/lib/cli/command-display.ts metadata
```

Keep behavior out of this tree. Product behavior belongs in `src/lib/actions/**`, pure
planning and classification belongs in `src/lib/domain/**`, and host/runtime boundaries
belong in `src/lib/adapters/**`.

Hidden `nemoclaw internal ...` entrypoints live under `src/commands/internal/**`; see
`src/commands/internal/README.md` for their narrower compatibility contract.
2 changes: 1 addition & 1 deletion src/commands/sandbox/config/set.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import Command from "../../../lib/sandbox-config-set-cli-command";
import Command from "../../../lib/commands/sandbox/config/set";
import { withCommandDisplay } from "../../../lib/cli/command-display";

export default withCommandDisplay(Command, [
Expand Down
7 changes: 4 additions & 3 deletions src/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ src/lib/dashboard/** dashboard contract, health, and recovery helpers
src/lib/deploy/** deploy/build-image support that is not yet action-shaped
src/lib/diagnostics/** debug collection and diagnostic report helpers
src/lib/inference/** inference config, health probes, local runtime helpers
src/lib/inventory/** list/status inventory shaping and presentation models
src/lib/messaging/** channel/messaging policy and message filtering helpers
src/lib/onboard/** onboarding support modules around the large legacy flow
src/lib/policy/** policy preset loading and application support
src/lib/policy/** policy preset loading, tier selection, and application support
src/lib/runtime/** sandbox/runtime recovery helpers
src/lib/sandbox/** sandbox config, build, stream, and version support
src/lib/sandbox/** sandbox config, build, stream, channel, and version support
src/lib/security/** redaction, secret patterns, and credential filtering
src/lib/shields/** shields orchestration, timers, and audit helpers
src/lib/tunnel/** local service/tunnel command support
```

Prefer small mechanical PRs that move one cluster at a time. High-import legacy files such as `onboard.ts`, `runner.ts`, `policies.ts`, `nim.ts`, and `services.ts` should either move late or keep temporary compatibility re-export files at their old paths.
Prefer small mechanical PRs that move one cluster at a time. High-import legacy files such as `onboard.ts`, `runner.ts`, and any remaining large top-level modules should either move late or keep temporary compatibility re-export files at their old paths.

## Suggested migration sequence

Expand Down
4 changes: 2 additions & 2 deletions src/lib/actions/inference-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { describe, expect, it, vi } from "vitest";

import type { ConfigObject } from "../security/credential-filter";
import type { AgentConfigTarget } from "../sandbox-config";
import type { AgentConfigTarget } from "../sandbox/config";
import type { Session } from "../state/onboard-session";
import type { SandboxEntry } from "../state/registry";

Expand All @@ -16,7 +16,7 @@ vi.mock("../inference/local", () => ({
DEFAULT_OLLAMA_MODEL: "llama3.1",
}));

vi.mock("../sandbox-config", () => ({
vi.mock("../sandbox/config", () => ({
readSandboxConfig: vi.fn(),
recomputeSandboxConfigHash: vi.fn(),
resolveAgentConfig: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions/inference-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
resolveAgentConfig,
type AgentConfigTarget,
writeSandboxConfig,
} from "../sandbox-config";
} from "../sandbox/config";
import { appendAuditEntry } from "../shields/audit";
import * as onboardSession from "../state/onboard-session";
import * as registry from "../state/registry";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions/sandbox/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
getActiveSandboxSessions,
} from "../../state/sandbox-session";
import { checkAndRecoverSandboxProcesses } from "./process-recovery";
import * as sandboxVersion from "../../sandbox-version";
import * as sandboxVersion from "../../sandbox/version";
import { D, G, R, YW } from "../../cli/terminal-style";
import { resolveOpenshell } from "../../adapters/openshell/resolve";

Expand Down
4 changes: 2 additions & 2 deletions src/lib/actions/sandbox/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function cleanupSandboxServices(
const stopAll =
deps.stopAll ??
((opts: { sandboxName: string }) => {
const services = require("../../services") as {
const services = require("../../tunnel/services") as {
stopAll: (opts: { sandboxName: string }) => void;
};
services.stopAll(opts);
Expand All @@ -221,7 +221,7 @@ export function cleanupSandboxServices(

if (stopHostServices) {
// `stopAll()` already runs `unloadOllamaModels()` unconditionally —
// see src/lib/services.ts. Don't double-call here.
// see src/lib/tunnel/services.ts. Don't double-call here.
stopAll({ sandboxName });
} else {
// No global stop, so `stopAll()` did not run; explicitly free Ollama
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions/sandbox/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { SandboxEntry } from "../../state/registry";
import { resolveOpenshell } from "../../adapters/openshell/resolve";
import { ROOT } from "../../runner";
import { parseLiveSandboxNames } from "../../runtime-recovery";
import * as sandboxVersion from "../../sandbox-version";
import * as sandboxVersion from "../../sandbox/version";
import * as shields from "../../shields";
import { buildStatusCommandDeps } from "../../status-command-deps";
import { B, D, G, R, RD, YW } from "../../cli/terminal-style";
Expand Down
6 changes: 3 additions & 3 deletions src/lib/actions/sandbox/policy-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import { getCredential, prompt as askPrompt } from "../../credentials/store";
import { recoverNamedGatewayRuntime } from "../../gateway-runtime-action";
const { isNonInteractive } = require("../../onboard") as { isNonInteractive: () => boolean };
const onboardProviders = require("../../onboard/providers");
import * as policies from "../../policies";
import * as policies from "../../policy";
import { parsePolicyAddArgs } from "../../domain/policy-channel";
import * as registry from "../../state/registry";
import { runOpenshell } from "../../adapters/openshell/runtime";
import { rebuildSandbox } from "./runtime";
import { rebuildSandbox } from "./rebuild";
import {
KNOWN_CHANNELS,
clearChannelTokens,
getChannelDef,
getChannelTokenKeys,
knownChannelNames,
persistChannelTokens,
} from "../../sandbox-channels";
} from "../../sandbox/channels";

const useColor = !process.env.NO_COLOR && !!process.stdout.isTTY;
const trueColor =
Expand Down
4 changes: 2 additions & 2 deletions src/lib/actions/sandbox/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import * as nim from "../../inference/nim";
import type { Session } from "../../state/onboard-session";
import * as onboardSession from "../../state/onboard-session";
import { captureOpenshell, runOpenshell } from "../../adapters/openshell/runtime";
import * as policies from "../../policies";
import * as policies from "../../policy";
import * as registry from "../../state/registry";
import { resolveOpenshell } from "../../adapters/openshell/resolve";
import { parseLiveSandboxNames } from "../../runtime-recovery";
Expand All @@ -46,7 +46,7 @@ import {
getActiveSandboxSessions,
} from "../../state/sandbox-session";
import * as sandboxState from "../../state/sandbox";
import * as sandboxVersion from "../../sandbox-version";
import * as sandboxVersion from "../../sandbox/version";
import { B, D, G, R, RD as _RD, YW } from "../../cli/terminal-style";

const agentRuntime = require("../../../../bin/lib/agent-runtime");
Expand Down
74 changes: 0 additions & 74 deletions src/lib/actions/sandbox/runtime.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/actions/sandbox/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { stripAnsi } from "../../adapters/openshell/client";
import { parseLiveSandboxNames } from "../../runtime-recovery";
import { ROOT, run, shellQuote, validateName } from "../../runner";
import { captureOpenshell, getOpenshellBinary } from "../../adapters/openshell/runtime";
import * as policies from "../../policies";
import * as policies from "../../policy";
import * as registry from "../../state/registry";
import type { SandboxEntry } from "../../state/registry";
import * as sandboxState from "../../state/sandbox";
Expand Down Expand Up @@ -125,7 +125,7 @@ async function autoCreateSandboxFromSource(
dstName: string,
srcEntry: SandboxEntry | { name: string },
): Promise<void> {
const sandboxCreateStream = require("../../sandbox-create-stream");
const sandboxCreateStream = require("../../sandbox/create-stream");
const { isSandboxReady } = require("../../state/gateway");
const basePolicy = path.join(ROOT, "nemoclaw-blueprint", "policies", "openclaw-sandbox.yaml");
const openshellBin = getOpenshellBinary();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions/sandbox/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
createSystemDeps as createSessionDeps,
getActiveSandboxSessions,
} from "../../state/sandbox-session";
import * as sandboxVersion from "../../sandbox-version";
import * as sandboxVersion from "../../sandbox/version";
import * as shields from "../../shields";
import { D, G, R, RD, YW } from "../../cli/terminal-style";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions/upgrade-sandboxes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { captureOpenshell } from "../adapters/openshell/runtime";
import * as registry from "../state/registry";
import { parseLiveSandboxNames } from "../runtime-recovery";
import { rebuildSandbox } from "./sandbox/rebuild";
import * as sandboxVersion from "../sandbox-version";
import * as sandboxVersion from "../sandbox/version";
import { B, D, G, R, YW } from "../cli/terminal-style";
import {
classifyUpgradeableSandboxes,
Expand Down
8 changes: 8 additions & 0 deletions src/lib/adapters/http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->

# HTTP adapters

HTTP adapter modules isolate host-side network probes and subprocess-backed HTTP
checks from action/domain logic. Keep pure response classification in domain or
feature modules; keep `curl`, temporary files, and network-boundary behavior here.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
summarizeCurlFailure,
summarizeProbeError,
summarizeProbeFailure,
} from "./http-probe";
} from "./probe";

describe("http-probe helpers", () => {
it("returns explicit curl timeouts", () => {
Expand Down
Loading
Loading