Commit f6120bb
fix(cli): add --json flag to per-sandbox status command (#4323)
## Summary
`nemoclaw <name> status` now accepts `--json` and emits a structured
per-sandbox report, mirroring what the global `nemoclaw status --json`
(added in #2790 / #2822) already exposes. Automation can read
`hostGpuDetected`, `sandboxGpuEnabled`, `sandboxGpuMode`,
`sandboxGpuDevice`, `openshellDriver`, and `openshellVersion` for a
specific sandbox without scraping the text renderer.
## Related Issue
Fixes #4310. Enhances #2790 (resolved by #2822) by extending the JSON
renderer to the per-sandbox status variant.
## Changes
- `src/commands/sandbox/status.ts` opts into `static enableJsonFlag =
true`, updates the usage/examples to advertise `--json`, and branches on
`this.jsonEnabled()` so the existing text path is unchanged.
- New `getSandboxStatusReport(sandboxName)` in
`src/lib/actions/sandbox/status.ts` returns a `SandboxStatusReport`:
`schemaVersion`, `name`, `found`, `model`, `provider`, `phase`,
`gatewayState`, `inferenceHealth`, `hostGpuDetected`,
`sandboxGpuEnabled`, `sandboxGpuMode`, `sandboxGpuDevice`,
`openshellDriver`, `openshellVersion`, `policies`. `openshellDriver` and
`openshellVersion` are normalised to the string `"unknown"` when missing
so consumers can rely on `typeof` checks.
- The JSON path sets `process.exitCode = 1` when the sandbox is missing
locally or the gateway state is not `present`, so scripts can
distinguish "ready" from "drift/unreachable" without parsing the body.
- `test/cli.test.ts` covers the populated JSON shape, the `"unknown"`
string fallback for `openshellDriver` / `openshellVersion`, the
protobuf-mismatch path (asserts exit code `1`, `rpcIssue = { kind:
"protobuf_mismatch" }`, `inferenceHealth = null`, and `model` /
`provider` = `"unknown"`), and the `--help` advertising `--json`.
- `collectSandboxStatusSnapshot` is shared by `showSandboxStatus` and
`getSandboxStatusReport`; it fail-closes on
`detectOpenShellStateRpcResultIssue` so the JSON path no longer emits
inferred `model` / `provider` / `inferenceHealth` alongside an
`rpcIssue`. The host-side gateway-chain subprobe is appended in the
collector so both text and JSON paths surface it.
- `docs/reference/commands.mdx` documents the `--json` flag in the
per-sandbox status section (fields, fallback, exit-code contract) so the
CLI/docs parity check stays green.
## Type of Change
- [ ] Code change (feature, bug fix, or refactor)
- [X] 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
- [X] Docs updated for user-facing behavior changes
- [ ] `npm run 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: Tinson Lai <tinsonl@nvidia.com>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* `sandbox status` gains a `--json` mode that emits a structured
per-sandbox JSON report (gateway state, inference health, GPU details,
policies, model/provider, OpenShell driver/version).
* **Behavior**
* `openshellDriver`/`openshellVersion` default to `"unknown"` when
unset.
* `--json` returns structured data and sets non‑zero exit codes for
missing sandbox, non‑present gateway, or RPC/schema issues; text output
unchanged without `--json`.
* **Tests**
* Added coverage for JSON output, defaults, RPC issue handling, exit
codes, and help text.
* **Documentation**
* Command docs updated with `--json` behavior, fields, exit conditions,
and examples.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/4323?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Co-authored-by: Julie Yaunches <jyaunches@nvidia.com>1 parent eae6f8a commit f6120bb
4 files changed
Lines changed: 431 additions & 65 deletions
File tree
- docs/reference
- src
- commands/sandbox
- lib/actions/sandbox
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
394 | 406 | | |
395 | 407 | | |
396 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | | - | |
15 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
22 | | - | |
| 27 | + | |
23 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
24 | 40 | | |
25 | 41 | | |
26 | 42 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
66 | 194 | | |
67 | 195 | | |
68 | 196 | | |
| |||
113 | 241 | | |
114 | 242 | | |
115 | 243 | | |
116 | | - | |
117 | | - | |
118 | 244 | | |
119 | 245 | | |
120 | 246 | | |
121 | 247 | | |
122 | 248 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
127 | 256 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 257 | + | |
183 | 258 | | |
184 | 259 | | |
185 | 260 | | |
| |||
0 commit comments