Skip to content

refactor(ts-migration): move onboard and cli to typescript#1673

Merged
ericksoa merged 13 commits into
mainfrom
ts-migration/09-onboard-cli
Apr 9, 2026
Merged

refactor(ts-migration): move onboard and cli to typescript#1673
ericksoa merged 13 commits into
mainfrom
ts-migration/09-onboard-cli

Conversation

@cv

@cv cv commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add the final mechanical migration phase manifest
  • mechanically move bin/lib/onboard.js to src/lib/onboard.ts
  • mechanically move bin/nemoclaw.js to src/nemoclaw.ts
  • leave compatibility wrappers in bin/
  • rename the remaining root CLI tests from .js to .ts
  • retarget source-inspection assertions to the new TS source where appropriate

Testing

  • npm run build:cli
  • npm run typecheck:cli
  • npm run lint
  • npx vitest run test/cli.test.ts test/install-preflight.test.ts test/onboard-readiness.test.ts test/onboard-selection.test.ts test/onboard.test.ts test/runner.test.ts test/credential-exposure.test.ts test/gateway-cleanup.test.ts test/shellquote-sandbox.test.ts
  • npm test

Summary by CodeRabbit

  • New Features

    • Implemented CLI command dispatcher with support for sandbox management (connect, status, destroy).
    • Added gateway health checks and automatic recovery mechanisms.
    • Enhanced sandbox validation and reconciliation against live gateway state.
    • Added credentials and policy management commands.
  • Chores

    • Migrated CLI implementation to TypeScript.

@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request migrates CLI implementation from JavaScript to TypeScript. The entry point bin/nemoclaw.js is simplified to delegate to a compiled module, while a new src/nemoclaw.ts provides the full CLI dispatcher with command routing, sandbox lifecycle management, gateway health checks, and recovery logic. Multiple test files are updated to reference TypeScript source locations instead of compiled JavaScript artifacts.

Changes

Cohort / File(s) Summary
CLI Entry Point
bin/nemoclaw.js, src/nemoclaw.ts
Refactored from 1444-line inline implementation to a delegating shim. New TypeScript entrypoint consolidates command dispatch, OpenShell binary resolution, sandbox validation/reconciliation, gateway health checks with SSH-based probing, recovery mechanisms (lock cleanup, gateway restart, port forward re-establishment), policy management, credentials handling, and colored terminal output with NO_COLOR support.
Migration Configuration
scripts/ts-migration/phases/09-onboard-cli.json
New phase configuration file directing test file renames, relocation of bin/lib/onboard.jssrc/lib/onboard.ts and bin/nemoclaw.jssrc/nemoclaw.ts, and shim strategy assignment (simple for onboard, cli-launcher for nemoclaw).
Test Updates
test/cli.test.ts, test/credential-exposure.test.ts, test/gateway-cleanup.test.ts, test/install-preflight.test.ts, test/onboard-readiness.test.ts, test/onboard-selection.test.ts, test/onboard.test.ts, test/runner.test.ts, test/shellquote-sandbox.test.ts
Updated source file references from bin/lib/onboard.js and bin/nemoclaw.js to src/lib/onboard.ts and src/nemoclaw.ts. Added // @ts-nocheck`` directives to disable TypeScript checks. Updated assertion messages and path strings to reflect new locations.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Dispatcher
    participant OpenShell as OpenShell Binary
    participant Gateway as Gateway (SSH)
    participant Registry as Sandbox Registry
    participant Reconcile as Reconciliation

    CLI->>OpenShell: Resolve & invoke binary
    OpenShell-->>CLI: Running
    CLI->>Registry: Validate sandbox names
    Registry-->>CLI: Sandbox list
    CLI->>Gateway: Check each sandbox status via SSH
    
    alt Gateway Responsive
        Gateway-->>CLI: Sandbox present/missing
        CLI->>Reconcile: Classify state (present/missing/error)
    else Gateway Unresponsive
        Gateway-->>CLI: Connection error
        CLI->>CLI: Re-establish nemoclaw gateway
        CLI->>Gateway: Retry sandbox reconciliation
    end
    
    alt Recovery Needed
        CLI->>Gateway: Run recovery script (cleanup locks)
        Gateway->>Gateway: Clean temp files, restart
        CLI->>Gateway: Re-establish port forward
    end
    
    Reconcile-->>CLI: Reconciliation outcome
    CLI-->>CLI: Execute command (connect/status/deploy)
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

🐰 Hop, skip, and a TypeScript bound!
Our CLI found a TypeScript ground,
Sandbox and gateway dance in sync,
No more compiled artifacts on the brink,
Tests now follow the new .ts link!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(ts-migration): move onboard and cli to typescript' clearly summarizes the main change: migrating onboard and CLI components from JavaScript to TypeScript as part of a larger ts-migration effort.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ts-migration/09-onboard-cli

Comment @coderabbitai help to get the list of available commands and usage tips.

@wscurran wscurran added CI/CD refactor PR restructures code without intended behavior change labels Apr 9, 2026
@cv cv added the v0.0.11 label Apr 9, 2026
@ericksoa ericksoa changed the base branch from ts-migration/08-tests-e to main April 9, 2026 18:04
…rd-cli

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>

# Conflicts:
#	scripts/migrate-js-to-ts.ts
#	test/skills-frontmatter.test.ts
@ericksoa ericksoa merged commit 1e59846 into main Apr 9, 2026
8 of 9 checks passed
prekshivyas pushed a commit to prekshivyas/NemoClaw that referenced this pull request Apr 9, 2026
- add the final mechanical migration phase manifest
- mechanically move `bin/lib/onboard.js` to `src/lib/onboard.ts`
- mechanically move `bin/nemoclaw.js` to `src/nemoclaw.ts`
- leave compatibility wrappers in `bin/`
- rename the remaining root CLI tests from `.js` to `.ts`
- retarget source-inspection assertions to the new TS source where
appropriate

- npm run build:cli
- npm run typecheck:cli
- npm run lint
- npx vitest run test/cli.test.ts test/install-preflight.test.ts
test/onboard-readiness.test.ts test/onboard-selection.test.ts
test/onboard.test.ts test/runner.test.ts
test/credential-exposure.test.ts test/gateway-cleanup.test.ts
test/shellquote-sandbox.test.ts
- npm test

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **New Features**
* Implemented CLI command dispatcher with support for sandbox management
(connect, status, destroy).
  * Added gateway health checks and automatic recovery mechanisms.
* Enhanced sandbox validation and reconciliation against live gateway
state.
  * Added credentials and policy management commands.

* **Chores**
  * Migrated CLI implementation to TypeScript.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Aaron Erickson <aerickson@nvidia.com>
realkim93 added a commit to realkim93/NemoClaw that referenced this pull request Apr 12, 2026
Main underwent a large-scale refactoring while this PR was open:
- JS→TS migration: bin/lib/onboard.js → src/lib/onboard.ts,
  bin/nemoclaw.js → src/nemoclaw.ts (NVIDIA#1673)
- Legacy shim removal: 18 bin/lib/*.js files deleted (NVIDIA#1713)
- Command handler extraction: src/lib/onboard-command.ts (NVIDIA#1710)
- Test renames: .js → .ts across all test files

Conflict resolution:
- bin/nemoclaw.js: accept main's 6-line launcher (logic in src/nemoclaw.ts)
- src/lib/onboard.ts: take main's build context staging (fromDockerfile
  + agent + stageOptimized), keep Jetson gateway patch functions
- docs/get-started/quickstart.md: use main's table format, add Jetson row
- test/onboard.test.js: accept deletion (migrated to .ts)

Re-ported Jetson features onto new TS structure:
- Add setup-jetson to GLOBAL_COMMANDS, help text, and switch dispatch
  in src/nemoclaw.ts (not a deprecated alias — runs setup-jetson.sh)
- Add Jetson to ci/platform-matrix.json (source of truth for docs table)
- Add getGatewayImageTag and patchGatewayImageForJetson to exports in
  src/lib/onboard.ts
- Port 4 Jetson tests to test/onboard.test.ts (dist/lib/onboard paths)

Verified on Jetson Orin Nano Super (8GB, JetPack 6.x, Node 22.22.0):
- Build: tsc passes
- 4 Jetson tests: all pass
- GPU: jetson=true, 7619 MB unified memory
- Gateway: iptables v1.8.10 (legacy), io.nemoclaw.jetson-patched=true
- Sandbox: Phase Ready
- Inference: openclaw agent → "2 + 2 = 4."
- Path: sandbox → host.openshell.internal:11434 → Ollama → nemotron-3-nano:4b

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realkim93 added a commit to realkim93/NemoClaw that referenced this pull request Apr 12, 2026
Main underwent a large-scale refactoring while this PR was open:
- JS→TS migration: bin/lib/onboard.js → src/lib/onboard.ts,
  bin/nemoclaw.js → src/nemoclaw.ts (NVIDIA#1673)
- Legacy shim removal: 18 bin/lib/*.js files deleted (NVIDIA#1713)
- Command handler extraction: src/lib/onboard-command.ts (NVIDIA#1710)
- Test renames: .js → .ts across all test files

Conflict resolution:
- bin/nemoclaw.js: accept main's 6-line launcher (logic in src/nemoclaw.ts)
- src/lib/onboard.ts: take main's build context staging (fromDockerfile
  + agent + stageOptimized), keep Jetson gateway patch functions
- docs/get-started/quickstart.md: use main's table format, add Jetson row
- test/onboard.test.js: accept deletion (migrated to .ts)

Re-ported Jetson features onto new TS structure:
- Add setup-jetson to GLOBAL_COMMANDS, help text, and switch dispatch
  in src/nemoclaw.ts (not a deprecated alias — runs setup-jetson.sh)
- Add Jetson to ci/platform-matrix.json (source of truth for docs table)
- Add getGatewayImageTag and patchGatewayImageForJetson to exports in
  src/lib/onboard.ts
- Port 4 Jetson tests to test/onboard.test.ts (dist/lib/onboard paths)

Verified on Jetson Orin Nano Super (8GB, JetPack 6.x, Node 22.22.0):
- Build: tsc passes
- 4 Jetson tests: all pass
- GPU: jetson=true, 7619 MB unified memory
- Gateway: iptables v1.8.10 (legacy), io.nemoclaw.jetson-patched=true
- Sandbox: Phase Ready
- Inference: openclaw agent → "2 + 2 = 4."
- Path: sandbox → host.openshell.internal:11434 → Ollama → nemotron-3-nano:4b

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
## Summary
- add the final mechanical migration phase manifest
- mechanically move `bin/lib/onboard.js` to `src/lib/onboard.ts`
- mechanically move `bin/nemoclaw.js` to `src/nemoclaw.ts`
- leave compatibility wrappers in `bin/`
- rename the remaining root CLI tests from `.js` to `.ts`
- retarget source-inspection assertions to the new TS source where
appropriate

## Testing
- npm run build:cli
- npm run typecheck:cli
- npm run lint
- npx vitest run test/cli.test.ts test/install-preflight.test.ts
test/onboard-readiness.test.ts test/onboard-selection.test.ts
test/onboard.test.ts test/runner.test.ts
test/credential-exposure.test.ts test/gateway-cleanup.test.ts
test/shellquote-sandbox.test.ts
- npm test


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Implemented CLI command dispatcher with support for sandbox management
(connect, status, destroy).
  * Added gateway health checks and automatic recovery mechanisms.
* Enhanced sandbox validation and reconciliation against live gateway
state.
  * Added credentials and policy management commands.

* **Chores**
  * Migrated CLI implementation to TypeScript.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Aaron Erickson <aerickson@nvidia.com>
brandonpelfrey pushed a commit that referenced this pull request Apr 16, 2026
…detection (#1978)

## Summary

Supersedes #1716.

Using `localhost` can resolve to IPv6 (`::1`) on some systems, causing
local inference health checks, probe commands, and model queries to fail
silently. This replaces all host-side `localhost` references with
explicit `127.0.0.1` for deterministic IPv4 behavior.

Based on the original work in #1716 by @chandler-barlow — the JS→TS
migration (#1673) made the original PR unrebaseable, so the change has
been re-applied on the current codebase with attribution.

## Changes

- `src/lib/local-inference.ts`: validation URLs, health endpoints, error
messages, model queries, warmup/probe commands
- `src/lib/nim.ts`: NIM health check curls
- `src/lib/onboard.ts`: Ollama and vLLM detection curls
- `src/lib/local-inference.test.ts`: updated expectations
- `src/lib/nim.test.ts`: updated mock matchers
- `test/cli.test.ts`: updated status output assertion
- `test/onboard-selection.test.ts`: updated mock matchers
- `test/e2e/test-gpu-e2e.sh`: host-side Ollama curls

## Test plan

- [x] 50 unit tests passing (local-inference + nim)
- [x] Zero `http://localhost:11434` or `http://localhost:8000`
references remain in src/ test/ scripts/
- [x] Dashboard URLs intentionally unchanged (different scope)

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved reliability of local inference and onboarding checks by
standardizing local service addresses to the loopback IP.

* **Tests**
* Updated unit, integration, and end-to-end test expectations and
scripts to match the adjusted loopback addressing and health-check
behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Co-authored-by: Chandler Barlow <cbarlow@nvidia.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cv cv deleted the ts-migration/09-onboard-cli branch May 27, 2026 21:19
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions chore Build, CI, dependency, or tooling maintenance and removed CI/CD chore Build, CI, dependency, or tooling maintenance labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants