refactor(cli): extract sandbox live state helpers - #2886
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
📝 WalkthroughWalkthroughMoves sandbox gateway reconciliation and lifecycle handling into a new module, adds terminal color utilities, removes an unused runtime-bridge method, updates wiring to use the new helpers, and adjusts a test Dockerfile extraction marker. ChangesSandbox Gateway State & CLI Wiring
Sequence Diagram(s)sequenceDiagram
participant CLI as NemoClaw CLI
participant Module as sandbox-gateway-state-action
participant Gateway as OpenShell Gateway
participant SSH as SSH / known_hosts & Registry
CLI->>Module: getReconciledSandboxGatewayState(sandbox)
Module->>Gateway: sandbox get / status probe (sync or async)
alt present
Module-->>CLI: present (with merged live policy if available)
else missing
Module->>Gateway: openshell gateway select nemoclaw (attempt recovery)
Gateway-->>Module: new state
alt recovered
Module-->>CLI: recoveredGateway (present)
else still missing
Module->>SSH: remove stale registry / prune known_hosts
Module-->>CLI: exit with remediation instructions
end
else gateway_error
Module->>Gateway: recoverNamedGatewayRuntime (restart/recover)
Module-->>CLI: gateway_unreachable_after_restart or gateway_missing_after_restart
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
prekshivyas
left a comment
There was a problem hiding this comment.
LGTM as a lift-and-shift. Verified mechanically against main: no behavior change, no exit-code/error-message drift, no zombies in nemoclaw.ts, all 15 PR checks green, no tests deleted. The share-command-deps.ts cleanup (drops require("../nemoclaw")) and the getSshConfig status: number | null typing fix are both nice incidental wins.
Two non-blocking asks for the description so future bisects don't get confused:
- Mention the
test/sandbox-provisioning.test.tsmarker change. It came in via themerge(main): resolve sandbox live state conflictscommit, butDockerfile.baseis byte-identical onmainand the PR branch — there was no actual conflict, so the change reads as out-of-scope without an explanation. - Note that
src/lib/terminal-style.tsis currently a duplicate of the inline color block atsrc/nemoclaw.ts:14-22and link the follow-up PR that migrates the inline copy.
## Summary Extract the sandbox skill install command implementation from `src/nemoclaw.ts` into a dedicated action module. This removes `sandboxSkillInstall` from the transitional runtime bridge while preserving the existing oclif wrapper and legacy fallback behavior. ## Stack Navigation - Position: 2 of 60 - Previous PR: [#2886 — refactor(cli): extract sandbox live state helpers](#2886) - Next PR: [#2891 — refactor(cli): extract sandbox connect action](#2891) ## Changes - Added `src/lib/sandbox-skill-install-action.ts` for skill install usage, plugin-shape detection, validation, upload, post-install, and verification flow. - Updated `src/lib/sandbox-runtime-actions.ts` and the legacy skill fallback to call the extracted action. - Removed `sandboxSkillInstall` from `src/nemoclaw.ts` and `NemoClawRuntimeBridge`. ## 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 - [ ] 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) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> --------- Co-authored-by: Prekshi Vyas <34834085+prekshivyas@users.noreply.github.com>
Summary
Extract shared sandbox gateway-state and liveness helpers from
src/nemoclaw.tsinto reusable CLI library modules. This reduces the legacy entrypoint surface before moving connect, status, skill install, and lifecycle actions out of the runtime bridge.Stack Navigation
mainChanges
src/lib/sandbox-gateway-state-action.tsfor sandbox liveness, gateway reconciliation, live-policy merging, and lifecycle guidance helpers.src/lib/terminal-style.tsfor shared CLI color constants.src/nemoclaw.tsto import the extracted sandbox gateway-state helpers instead of defining them inline.src/lib/share-command-deps.tsto depend on extracted helpers instead of requiring../nemoclaw.sandboxLogsfromNemoClawRuntimeBridge.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
New Features
Bug Fixes
Chores