Skip to content

Commit 0dbb995

Browse files
authored
refactor(cli): group inference and onboard support modules (NVIDIA#3195)
## Summary Groups the remaining inference and onboarding support modules into the feature folders from the placement map. This retargets the combined R4/R5 reorg onto `main` now that the lower stack has landed, while keeping the large legacy `onboard.ts` flow in place. ## Changes - Move inference config, health, provider model, prompt, NIM, local inference, web-search, and onboard probe helpers under `src/lib/inference/**`. - Move Ollama-specific helpers under `src/lib/inference/ollama/**` and vLLM helpers under `src/lib/inference/vllm.ts`. - Move onboard support modules under `src/lib/onboard/**`. - Move persisted onboard session state under `src/lib/state/onboard-session.ts`. - Update imports, tests, bin shims, installer references, E2E path probes, scripts, and source-shape checks for the new paths. - Keep `src/lib/onboard.ts` as the legacy flow entrypoint for future focused splitting. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off required by CI. Run: git config user.name && git config user.email --> Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Project modules reorganized into a new internal folder structure; import wiring updated across the codebase. * **Install / Onboarding** * Installer preflight now uses the relocated onboarding preflight implementation, affecting which host checks run during install. * **Tests** * Test suites and fixtures updated to reference the restructured modules so tests continue to run against the new layout. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent d413b6b commit 0dbb995

75 files changed

Lines changed: 220 additions & 215 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coderabbit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ reviews:
221221
gh workflow run nightly-e2e.yaml --ref <branch> -f jobs=overlayfs-autofix-e2e
222222
```
223223

224-
- path: "src/lib/preflight.ts"
224+
- path: "src/lib/onboard/preflight.ts"
225225
instructions: *e2e-overlayfs
226226

227227
- path: "src/lib/deploy.ts"

bin/lib/usage-notice.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
// Thin re-export shim — the implementation lives in src/lib/usage-notice.ts,
5-
// compiled to dist/lib/usage-notice.js.
6-
const usageNotice = require("../../dist/lib/usage-notice");
4+
// Thin re-export shim — the implementation lives in src/lib/onboard/usage-notice.ts,
5+
// compiled to dist/lib/onboard/usage-notice.js.
6+
const usageNotice = require("../../dist/lib/onboard/usage-notice");
77

88
if (require.main === module) {
99
usageNotice.cli().catch((error) => {

scripts/check-legacy-migrated-paths.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ const REMOVED_SHIM_MOVES: Record<string, string> = {
2727
"bin/lib/chat-filter.js": "src/lib/chat-filter.ts",
2828
"bin/lib/config-io.js": "src/lib/state/config-io.ts",
2929
"bin/lib/debug.js": "src/lib/diagnostics/debug.ts",
30-
"bin/lib/inference-config.js": "src/lib/inference-config.ts",
31-
"bin/lib/local-inference.js": "src/lib/local-inference.ts",
32-
"bin/lib/nim.js": "src/lib/nim.ts",
33-
"bin/lib/onboard-session.js": "src/lib/onboard-session.ts",
30+
"bin/lib/inference-config.js": "src/lib/inference/config.ts",
31+
"bin/lib/local-inference.js": "src/lib/inference/local.ts",
32+
"bin/lib/nim.js": "src/lib/inference/nim.ts",
33+
"bin/lib/onboard-session.js": "src/lib/state/onboard-session.ts",
3434
"bin/lib/platform.js": "src/lib/platform.ts",
35-
"bin/lib/preflight.js": "src/lib/preflight.ts",
35+
"bin/lib/preflight.js": "src/lib/onboard/preflight.ts",
3636
"bin/lib/registry.js": "src/lib/state/registry.ts",
3737
"bin/lib/resolve-openshell.js": "src/lib/adapters/openshell/resolve.ts",
3838
"bin/lib/runtime-recovery.js": "src/lib/runtime-recovery.ts",

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ verify_nemoclaw() {
14641464
# 5. Onboard
14651465
# ---------------------------------------------------------------------------
14661466
run_installer_host_preflight() {
1467-
local preflight_module="${NEMOCLAW_SOURCE_ROOT}/dist/lib/preflight.js"
1467+
local preflight_module="${NEMOCLAW_SOURCE_ROOT}/dist/lib/onboard/preflight.js"
14681468
if ! command_exists node || [[ ! -f "$preflight_module" ]]; then
14691469
return 0
14701470
fi

scripts/ts-migration-assist.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ const SPECIAL_REWRITES: Record<string, Array<[string, string]>> = {
2222
"bin/lib/onboard.js": [
2323
['require("./runner")', 'require("../../bin/lib/runner")'],
2424
['require("./sandbox-build-context")', 'require("../../bin/lib/sandbox-build-context")'],
25-
['require("./local-inference")', 'require("../../bin/lib/local-inference")'],
26-
['require("./inference-config")', 'require("../../bin/lib/inference-config")'],
25+
['require("./inference/local")', 'require("../../bin/lib/local-inference")'],
26+
['require("./inference/config")', 'require("../../bin/lib/inference-config")'],
2727
['require("./platform")', 'require("../../bin/lib/platform")'],
2828
['require("./resolve-openshell")', 'require("../../bin/lib/resolve-openshell")'],
2929
['require("./credentials/store")', 'require("../../bin/lib/credentials")'],
3030
['require("./state/registry")', 'require("../../bin/lib/registry")'],
31-
['require("./nim")', 'require("../../bin/lib/nim")'],
32-
['require("./onboard-session")', 'require("../../bin/lib/onboard-session")'],
31+
['require("./inference/nim")', 'require("../../bin/lib/nim")'],
32+
['require("./state/onboard-session")', 'require("../../bin/lib/onboard-session")'],
3333
['require("./policies")', 'require("../../bin/lib/policies")'],
34-
['require("./usage-notice")', 'require("../../bin/lib/usage-notice")'],
35-
['require("./preflight")', 'require("../../bin/lib/preflight")'],
34+
['require("./onboard/usage-notice")', 'require("../../bin/lib/usage-notice")'],
35+
['require("./onboard/preflight")', 'require("../../bin/lib/preflight")'],
3636
],
3737
"bin/nemoclaw.js": [
3838
['require("./lib/runner")', 'require("../bin/lib/runner")'],
@@ -42,11 +42,11 @@ const SPECIAL_REWRITES: Record<string, Array<[string, string]>> = {
4242
['require("./lib/registry")', 'require("../bin/lib/registry")'],
4343
['require("./lib/nim")', 'require("../bin/lib/nim")'],
4444
['require("./lib/policies")', 'require("../bin/lib/policies")'],
45-
['require("./lib/inference-config")', 'require("../bin/lib/inference-config")'],
45+
['require("./lib/inference/config")', 'require("../bin/lib/inference-config")'],
4646
['require("./lib/version")', 'require("../bin/lib/version")'],
47-
['require("./lib/onboard-session")', 'require("../bin/lib/onboard-session")'],
47+
['require("./lib/state/onboard-session")', 'require("../bin/lib/onboard-session")'],
4848
['require("./lib/runtime-recovery")', 'require("../bin/lib/runtime-recovery")'],
49-
['require("./lib/usage-notice")', 'require("../bin/lib/usage-notice")'],
49+
['require("./lib/onboard/usage-notice")', 'require("../bin/lib/usage-notice")'],
5050
['require("./lib/services")', 'require("../bin/lib/services")'],
5151
['require("./lib/debug")', 'require("./lib/diagnostics/debug")'],
5252
['require("./lib/debug-command")', 'require("./lib/diagnostics/debug-command")'],

src/lib/actions/onboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { listAgents } from "../agent/defs";
5-
import { runDeprecatedOnboardAliasCommand, runOnboardCommand } from "../onboard-command";
6-
import { NOTICE_ACCEPT_ENV, NOTICE_ACCEPT_FLAG } from "../usage-notice";
5+
import { runDeprecatedOnboardAliasCommand, runOnboardCommand } from "../onboard/legacy-command";
6+
import { NOTICE_ACCEPT_ENV, NOTICE_ACCEPT_FLAG } from "../onboard/usage-notice";
77

88
const { onboard: runOnboard } = require("../onboard") as {
99
onboard: (options?: unknown) => Promise<void>;

src/lib/actions/sandbox/connect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { spawnSync } from "node:child_process";
77
import os from "node:os";
88

99
import { CLI_NAME } from "../../cli/branding";
10-
import { parseGatewayInference } from "../../inference-config";
11-
import { ensureOllamaAuthProxy } from "../../onboard-ollama-proxy";
10+
import { parseGatewayInference } from "../../inference/config";
11+
import { ensureOllamaAuthProxy } from "../../inference/ollama/proxy";
1212
import {
1313
captureOpenshell,
1414
getOpenshellBinary,

src/lib/actions/sandbox/destroy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
type DestroySandboxOptions,
1313
normalizeDestroySandboxOptions,
1414
} from "../../domain/lifecycle/options";
15-
import * as onboardSession from "../../onboard-session";
16-
import type { Session } from "../../onboard-session";
15+
import * as onboardSession from "../../state/onboard-session";
16+
import type { Session } from "../../state/onboard-session";
1717
import { OPENSHELL_PROBE_TIMEOUT_MS } from "../../adapters/openshell/timeouts";
1818
import { DASHBOARD_PORT } from "../../core/ports";
1919
import * as registry from "../../state/registry";
@@ -95,7 +95,7 @@ function cleanupSandboxServices(
9595
// branch a single-sandbox destroy would leave models loaded on the GPU.
9696
const sb = registry.getSandbox(sandboxName);
9797
if (sb?.provider?.includes("ollama")) {
98-
const { unloadOllamaModels } = require("../../onboard-ollama-proxy");
98+
const { unloadOllamaModels } = require("../../inference/ollama/proxy");
9999
unloadOllamaModels();
100100
}
101101
}
@@ -225,7 +225,7 @@ export async function destroySandbox(
225225
}
226226
}
227227

228-
const nim = require("../../nim") as {
228+
const nim = require("../../inference/nim") as {
229229
stopNimContainer: (sandboxName: string, opts?: { silent?: boolean }) => void;
230230
stopNimContainerByName: (name: string) => void;
231231
};
@@ -246,7 +246,7 @@ export async function destroySandbox(
246246
// through `stopAll()` or directly into `unloadOllamaModels()` based on
247247
// whether host services are being torn down).
248248
if (sb?.provider?.includes("ollama")) {
249-
const { killStaleProxy } = require("../../onboard-ollama-proxy");
249+
const { killStaleProxy } = require("../../inference/ollama/proxy");
250250
killStaleProxy();
251251
}
252252

src/lib/actions/sandbox/doctor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import path from "node:path";
1010
import { CLI_DISPLAY_NAME, CLI_NAME } from "../../cli/branding";
1111
import { isErrnoException } from "../../core/errno";
1212
import { recoverNamedGatewayRuntime } from "../../gateway-runtime-action";
13-
import { probeProviderHealth } from "../../inference-health";
14-
import { parseGatewayInference } from "../../inference-config";
13+
import { probeProviderHealth } from "../../inference/health";
14+
import { parseGatewayInference } from "../../inference/config";
1515
import { stripAnsi } from "../../adapters/openshell/client";
1616
import { captureOpenshell } from "../../adapters/openshell/runtime";
1717
import { OPENSHELL_PROBE_TIMEOUT_MS } from "../../adapters/openshell/timeouts";

src/lib/actions/sandbox/gateway-state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import {
1616
const { pruneKnownHostsEntries } = require("../../onboard") as {
1717
pruneKnownHostsEntries: (contents: string) => string;
1818
};
19-
import * as onboardSession from "../../onboard-session";
20-
import type { Session } from "../../onboard-session";
19+
import * as onboardSession from "../../state/onboard-session";
20+
import type { Session } from "../../state/onboard-session";
2121
import { stripAnsi } from "../../adapters/openshell/client";
2222
import {
2323
captureOpenshell,

0 commit comments

Comments
 (0)