Skip to content
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
4b7a4a2
refactor(cli): extract sandbox live state helpers
cv May 2, 2026
2ce87dd
refactor(cli): extract sandbox skill install action
cv May 2, 2026
4cd3cf3
refactor(cli): extract sandbox connect action
cv May 3, 2026
e9dd46e
refactor(cli): extract sandbox status action
cv May 3, 2026
aab6c86
refactor(cli): extract sandbox doctor action
cv May 3, 2026
8908521
refactor(cli): extract sandbox destroy action
cv May 3, 2026
56e4f05
refactor(cli): extract sandbox rebuild action
cv May 3, 2026
8bf1958
refactor(cli): extract upgrade sandboxes action
cv May 3, 2026
38eb84d
refactor(cli): remove runtime bridge
cv May 3, 2026
b2ad5da
refactor(cli): remove legacy dispatch fallbacks
cv May 3, 2026
edd2650
refactor(cli): expose explicit main entrypoint
cv May 3, 2026
a15da95
refactor(cli): add oclif examples for utility commands
cv May 3, 2026
4f57ebb
refactor(cli): validate logs flags with oclif
cv May 3, 2026
8b2d077
refactor(cli): improve sandbox diagnostic command metadata
cv May 3, 2026
a09cc51
refactor(cli): tighten policy and channel parser validation
cv May 3, 2026
75857dc
refactor(cli): improve snapshot command metadata
cv May 3, 2026
11c0676
refactor(cli): require skill install path in oclif
cv May 3, 2026
05f9eca
refactor(cli): add lifecycle confirmation flag aliases
cv May 3, 2026
4ebeae4
refactor(cli): split share into oclif subcommands
cv May 3, 2026
7d72437
Revert "refactor(cli): split share into oclif subcommands"
cv May 3, 2026
0ee5ca5
refactor(cli): split share into oclif subcommands
cv May 3, 2026
928219c
refactor(cli): model debug flags with oclif
cv May 3, 2026
36cce5e
refactor(cli): model onboard flags with oclif
cv May 3, 2026
702afb1
docs: sync oclif UX command reference
cv May 3, 2026
3224350
refactor(cli): extract public argv normalizer
cv May 3, 2026
cd4cdb8
refactor(cli): rename oclif dispatch module
cv May 3, 2026
9499ca6
refactor(cli): normalize policy command ids
cv May 3, 2026
42028ef
test(cli): require oclif command metadata
cv May 3, 2026
a05c6b3
refactor(cli): return typed debug parse results
cv May 3, 2026
1875fe9
refactor(cli): add public command display ids
cv May 3, 2026
36f1dbe
refactor(cli): use oclif summaries in root help
cv May 3, 2026
78bfd5a
refactor(cli): table-drive sandbox dispatch
cv May 3, 2026
96ce61f
refactor(cli): normalize gateway token command id
cv May 3, 2026
266ebc9
refactor(cli): render public oclif help
cv May 3, 2026
dc98994
refactor(cli): add shared oclif command base
cv May 3, 2026
d0d2a70
refactor(cli): use oclif flag relationships
cv May 3, 2026
8396c06
refactor(cli): pass lifecycle typed options
cv May 3, 2026
1532b19
refactor(cli): parse durations with oclif flags
cv May 3, 2026
7c0445a
refactor(cli): project public help through oclif
cv May 3, 2026
3978c32
test(cli): cover oclif metadata routing helpers
cv May 3, 2026
591eabb
test(cli): cover global oclif command adapters
cv May 3, 2026
8a6ecbc
test(cli): cover sandbox oclif command adapters
cv May 3, 2026
e5aa22f
refactor(cli): split share oclif commands
cv May 3, 2026
e179336
test(cli): narrow sandbox logs coverage ignores
cv May 3, 2026
a629813
test(cli): cover remaining global oclif adapters
cv May 3, 2026
c5954e7
test(cli): cover credentials oclif adapter
cv May 3, 2026
3380de9
test(cli): cover runtime utility helpers
cv May 3, 2026
f60a190
test(cli): improve global adapter coverage
cv May 3, 2026
78a16d1
merge: sync simple global adapter coverage
cv May 3, 2026
a58dc90
merge: sync credentials adapter coverage
cv May 3, 2026
034454f
merge: include credentials adapter coverage
cv May 3, 2026
28bc497
merge: sync combined global adapter coverage
cv May 3, 2026
e9ed6ba
test(cli): cover global action facade
cv May 3, 2026
00b288c
merge: sync global action facade coverage
cv May 3, 2026
7bd5f32
test(cli): stabilize coverage dist sourcemaps
cv May 4, 2026
d4b55d9
test(cli): rebaseline clean-dist function coverage
cv May 4, 2026
b872474
refactor(cli): extract maintenance image helpers
cv May 4, 2026
4965762
refactor(cli): extract upgrade sandbox helpers
cv May 4, 2026
9acd660
refactor(cli): extract sandbox destroy helpers
cv May 4, 2026
cc0eaa1
refactor(cli): extract sandbox logs helpers
cv May 4, 2026
847e115
refactor(cli): extract policy channel helpers
cv May 4, 2026
b6c0f5a
test(cli): allow clean coverage variance
cv May 4, 2026
5c98bd1
merge: sync coverage stabilization
cv May 4, 2026
4754f3e
merge: sync maintenance helper extraction
cv May 4, 2026
96f0758
merge: sync upgrade helper extraction
cv May 4, 2026
b6bd105
merge: sync destroy helper extraction
cv May 4, 2026
98fb75d
merge: sync logs helper extraction
cv May 4, 2026
5920d5b
test(cli): keep destroy helpers outside coverage ratchet
cv May 4, 2026
64d1646
merge: sync destroy helper coverage boundary
cv May 4, 2026
717c482
test(cli): keep logs helpers outside coverage ratchet
cv May 4, 2026
688074f
merge: sync logs helper coverage boundary
cv May 4, 2026
1314270
test(cli): keep policy channel helpers outside coverage ratchet
cv May 4, 2026
79d81c2
refactor(cli): group oclif core modules
cv May 4, 2026
5453a89
refactor(cli): split oclif commands by command tree
cv May 4, 2026
bbc297f
test(cli): reset credential command helper cache
cv May 4, 2026
25224c1
test(cli): avoid generic warning assertion in debug output
cv May 4, 2026
1ed9256
refactor(cli): group pure domain helpers
cv May 4, 2026
51799e4
refactor(cli): group openshell adapters
cv May 4, 2026
0b1e877
test(cli): enforce initial layer import boundaries
cv May 4, 2026
91d750b
refactor(cli): group sandbox actions
cv May 4, 2026
4321d63
refactor(cli): group global actions
cv May 4, 2026
5bc2242
test(cli): format layer boundary checker
cv May 4, 2026
073225e
ci(prek): tolerate unmatched biome format chunks
cv May 4, 2026
29a26ae
refactor(cli): group state modules
cv May 4, 2026
523e2d9
refactor(cli): group docker adapters
cv May 4, 2026
f25fcce
Merge branch 'test/layer-import-boundaries' into refactor/layer-sandb…
cv May 4, 2026
301b0a7
Merge branch 'refactor/layer-sandbox-actions' into refactor/layer-glo…
cv May 4, 2026
668235a
Merge branch 'refactor/layer-global-actions' into refactor/layer-stat…
cv May 4, 2026
392bebb
Merge branch 'refactor/layer-state-modules' into refactor/layer-docke…
cv May 4, 2026
e25e0a3
refactor(cli): discover oclif commands by pattern
cv May 6, 2026
bb7ebc3
refactor(cli): move coredns patcher behind internal command
cv May 6, 2026
489198d
refactor(cli): move dns proxy setup behind internal command
cv May 6, 2026
b5cdf50
refactor(uninstall): extract plan domain helpers
cv May 6, 2026
cc93aae
fix(uninstall): allow optional host env fields in plan tests
cv May 6, 2026
aa0f853
refactor(uninstall): run uninstall through internal command
cv May 6, 2026
cf416a4
fix(cli): locate node for uninstall wrapper
cv May 6, 2026
359fefd
test(cli): exclude source-tested uninstall helpers from coverage ratchet
cv May 6, 2026
f729544
refactor(cli): wrap debug script with TypeScript command
cv May 6, 2026
ab60b4c
refactor(cli): move dev shim install behind internal command
cv May 6, 2026
7f39bd5
ci(cli): typecheck cli sources during pre-push
cv May 6, 2026
9f8c6a3
refactor(cli): read metadata from oclif discovery
cv May 6, 2026
7e9d3c0
refactor(cli): colocate display metadata with commands
cv May 6, 2026
ca4388c
refactor(cli): derive legacy sandbox dispatch from metadata
cv May 6, 2026
70c78ec
refactor(cli): remove compatibility command index
cv May 6, 2026
9af5206
test(cli): cover oclif-native sandbox commands
cv May 6, 2026
28daa3e
refactor(installer): extract pure domain helpers
cv May 6, 2026
3489904
refactor(installer): add internal plan commands
cv May 6, 2026
46d30f5
refactor(runtime): extract entrypoint preload modules
cv May 6, 2026
bf278fa
merge(main): reconcile runtime preload extraction
cv May 6, 2026
292218f
fix(runtime): tolerate missing preload fixtures in chmod
cv May 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ reviews:
gh workflow run nightly-e2e.yaml --ref <branch> -f jobs=deployment-services-e2e
```

- path: "src/lib/sandbox-state.ts"
- path: "src/lib/state/sandbox.ts"
instructions: |
This file manages sandbox state (backup, restore, rebuild,
snapshot). Changes affect data persistence across sandbox
Expand Down
6 changes: 2 additions & 4 deletions .github/actions/basic-checks/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ runs:
run: npm run build:cli

- name: Typecheck CLI + tests (strict)
# Explicit gate independent of the prek tsc-cli hook's file-pattern filter.
# The hook's `files:` scope excludes test/ and src/, which let #2130 +
# #2422 interact to ship a strict-mode regression onto main silently.
# Running this unconditionally here catches that class of drift.
# Explicit CI gate that complements the pre-push tsc-cli hook. CI runs it
# unconditionally so type drift is caught even when a local hook is skipped.
shell: bash
run: npm run typecheck:cli

Expand Down
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ repos:
hooks:
- id: biome-format
name: Biome format
entry: npx biome format --write
entry: npx biome format --write --no-errors-on-unmatched
language: system
files: ^(biome\.json|package(-lock)?\.json|nemoclaw/package(-lock)?\.json|commitlint\.config\.js|bin/.*\.js|src/.*\.ts|scripts/.*\.(js|ts)|test/.*\.js|nemoclaw/src/.*\.ts)$
pass_filenames: true
Expand Down Expand Up @@ -231,8 +231,7 @@ repos:
entry: npx tsc -p tsconfig.cli.json
language: system
pass_filenames: false
files: ^(bin|scripts)/
types_or: [ts, tsx]
files: ^(bin|scripts|src|test|nemoclaw-blueprint/scripts)/.*\.(ts|tsx)$|^tsconfig\.cli\.json$
stages: [pre-push]
priority: 10

Expand Down Expand Up @@ -266,7 +265,7 @@ repos:
hooks:
- id: test-cli
name: Test (CLI)
entry: bash -c 'npm run build:cli && npx vitest run --project cli --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary --coverage.reportsDirectory=coverage/cli --coverage.include="bin/**/*.js" --coverage.include="dist/lib/**/*.js" --coverage.exclude="test/**/*.js" --coverage.exclude="test/**/*.ts" && npx tsx scripts/check-coverage-ratchet.ts coverage/cli/coverage-summary.json ci/coverage-threshold-cli.json "CLI coverage"'
entry: bash -c 'npm run clean:cli && npm run build:cli && npm run dist:sourcemaps:check && npx vitest run --project cli --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary --coverage.reportsDirectory=coverage/cli --coverage.include="bin/**/*.js" --coverage.include="dist/lib/**/*.js" --coverage.exclude="test/**/*.js" --coverage.exclude="test/**/*.ts" && npx tsx scripts/check-coverage-ratchet.ts coverage/cli/coverage-summary.json ci/coverage-threshold-cli.json "CLI coverage"'
language: system
pass_filenames: false
files: ^(bin/|src/|test/)
Expand Down
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ These are the primary `make` and `npm` targets for day-to-day development:
| `make check` | Run all linters (TypeScript + Python) |
| `make lint` | Same as `make check` |
| `make format` | Auto-format TypeScript and Python source |
| `npm run typecheck:cli` | Type-check CLI TypeScript (`bin/`, `scripts/`) |
| `npm run typecheck:cli` | Type-check CLI TypeScript (`bin/`, `scripts/`, `src/`, `test/`) |
| `npm test` | Run root-level tests (`test/*.test.js`) |
| `cd nemoclaw && npm test` | Run plugin unit tests (Vitest) |
| `make docs` | Build documentation (Sphinx/MyST) |
Expand All @@ -92,6 +92,10 @@ All git hooks are managed by [prek](https://prek.j178.dev/), a fast, single-bina

For a full manual check: `npx prek run --all-files`. For scoped runs: `npx prek run --from-ref <base> --to-ref HEAD`.

For TypeScript changes under `src/`, `test/`, `scripts/`, or `bin/`, also run
`npm run typecheck:cli` before opening a PR. CI runs this unconditionally, and the
pre-push hook is configured to run it when CLI TypeScript files change.

If you still have `core.hooksPath` set from an old Husky setup, Git will ignore `.git/hooks`. Run `git config --unset core.hooksPath` in this repo, then `npm install` so `prek install` (via `prepare`) can register the hooks.

`make check` remains the primary documented linter entry point.
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ RUN mkdir -p /sandbox/.nemoclaw/blueprints/0.1.0 \
# Copy startup script and shared sandbox initialisation library
COPY scripts/lib/sandbox-init.sh /usr/local/lib/nemoclaw/sandbox-init.sh
COPY scripts/nemoclaw-start.sh /usr/local/bin/nemoclaw-start
# Copy ws-proxy-fix.js to a Landlock-accessible path. OpenShell ≥0.0.36
# Copy NODE_OPTIONS preload modules to a Landlock-accessible path. OpenShell ≥0.0.36
# blocks /opt/nemoclaw-blueprint/ from non-root users, but the entrypoint
# needs to read this file to install the NODE_OPTIONS --require preload.
COPY nemoclaw-blueprint/scripts/ws-proxy-fix.js /usr/local/lib/nemoclaw/ws-proxy-fix.js
# needs to read these files to install runtime preloads under /tmp.
COPY nemoclaw-blueprint/scripts/*.js /usr/local/lib/nemoclaw/preloads/
COPY scripts/codex-acp-wrapper.sh /usr/local/bin/nemoclaw-codex-acp
COPY scripts/generate-openclaw-config.py /usr/local/lib/nemoclaw/generate-openclaw-config.py
RUN chmod 755 /usr/local/bin/nemoclaw-start /usr/local/bin/nemoclaw-codex-acp /usr/local/lib/nemoclaw/sandbox-init.sh \
&& chmod 644 /usr/local/lib/nemoclaw/ws-proxy-fix.js
&& chmod 644 /usr/local/lib/nemoclaw/preloads/*.js

# Build args for config that varies per deployment.
# nemoclaw onboard passes these at image build time.
Expand Down
2 changes: 1 addition & 1 deletion ci/coverage-threshold-cli.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lines": 22,
"functions": 32,
"functions": 31.8,
"branches": 22,
"statements": 22
}
30 changes: 15 additions & 15 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The wizard creates an OpenShell gateway, registers inference providers, builds t
Use this command for new installs and for recreating a sandbox after changes to policy or configuration.

```console
$ nemoclaw onboard [--non-interactive] [--resume] [--recreate-sandbox] [--from <Dockerfile>] [--name <sandbox>] [--agent <name>] [--control-ui-port <N>] [--yes-i-accept-third-party-software]
$ nemoclaw onboard [--non-interactive] [--resume | --fresh] [--recreate-sandbox] [--from <Dockerfile>] [--name <sandbox>] [--agent <name>] [--control-ui-port <N>] [--yes-i-accept-third-party-software]
```

:::{warning}
Expand Down Expand Up @@ -315,12 +315,12 @@ $ nemoclaw my-assistant doctor [--json]
### `nemoclaw <name> logs`

View sandbox logs.
Use `--follow` to stream output in real time.
Use `--follow` to stream output in real time, `--tail <lines>` (or `-n <lines>`) to choose how many lines to show, and `--since <duration>` for recent OpenShell logs such as `5m`, `1h`, or `30s`.
The command reads both OpenClaw gateway output and OpenShell audit events, so policy denials appear alongside the gateway log stream.
If one log source is unavailable, NemoClaw prints a warning and keeps reading the remaining source.

```console
$ nemoclaw my-assistant logs [--follow]
$ nemoclaw my-assistant logs [--follow] [--tail <lines>|-n <lines>] [--since <duration>]
```

### `nemoclaw <name> gateway-token`
Expand Down Expand Up @@ -357,7 +357,7 @@ If you want to upgrade the sandbox while preserving state, use `nemoclaw <name>
:::

If another terminal has an active SSH session to the sandbox, `destroy` prints an active-session warning and requires a second confirmation before it proceeds.
Pass `--yes` or `--force` to skip the prompt in scripted workflows.
Pass `--yes`, `-y`, or `--force` to skip the prompt in scripted workflows.

```console
$ nemoclaw my-assistant destroy
Expand Down Expand Up @@ -546,16 +546,16 @@ Credentials are stripped from backups before storage.
Policy presets applied to the old sandbox are reapplied to the new one so your egress rules survive the rebuild.

```console
$ nemoclaw my-assistant rebuild [--yes] [--verbose]
$ nemoclaw my-assistant rebuild [--yes|-y|--force] [--verbose|-v]
```

| Flag | Description |
|------|-------------|
| `--yes`, `--force` | Skip the confirmation prompt |
| `--verbose` | Log SSH commands, exit codes, and session state (also enabled by `NEMOCLAW_REBUILD_VERBOSE=1`) |
| `--yes`, `-y`, `--force` | Skip the confirmation prompt |
| `--verbose`, `-v` | Log SSH commands, exit codes, and session state (also enabled by `NEMOCLAW_REBUILD_VERBOSE=1`) |

If another terminal has an active SSH session to the sandbox, `rebuild` prints an active-session warning and requires confirmation before destroying the sandbox.
Pass `--yes` or `--force` to skip the prompt in scripted workflows.
Pass `--yes`, `-y`, or `--force` to skip the prompt in scripted workflows.

The sandbox must be running for the backup step to succeed.
After restore, the command runs `openclaw doctor --fix` for cross-version structure repair.
Expand All @@ -567,14 +567,14 @@ NemoClaw resolves the digest of `ghcr.io/nvidia/nemoclaw/sandbox-base:latest` fr
Sandboxes that match the current digest are left alone.

```console
$ nemoclaw upgrade-sandboxes [--check] [--auto] [--yes]
$ nemoclaw upgrade-sandboxes [--check] [--auto] [--yes|-y]
```

| Flag | Description |
|------|-------------|
| `--check` | List stale sandboxes without rebuilding any of them. Exits non-zero if any are stale. |
| `--auto` | Rebuild every stale sandbox without prompting. Used by the installer to upgrade in place. |
| `--yes` | Skip the confirmation prompt for the rebuild plan. |
| `--yes`, `-y` | Skip the confirmation prompt for the rebuild plan. |

Each rebuild reuses the same workspace backup-and-restore flow as `nemoclaw <name> rebuild`, so workspace files survive the upgrade.
If the registry is unreachable (offline or firewalled hosts), NemoClaw falls back to the unpinned `:latest` tag and reports that the digest could not be resolved instead of failing.
Expand Down Expand Up @@ -791,14 +791,14 @@ Gathers system info, Docker state, gateway logs, and sandbox status into a summa
Use `--sandbox <name>` to target a specific sandbox, `--quick` for a smaller snapshot, or `--output <path>` to save a tarball that you can attach to an issue.

```console
$ nemoclaw debug [--quick] [--sandbox NAME] [--output PATH]
$ nemoclaw debug [--quick|-q] [--sandbox NAME] [--output PATH|-o PATH]
```

| Flag | Description |
|------|-------------|
| `--quick` | Collect minimal diagnostics only |
| `--quick`, `-q` | Collect minimal diagnostics only |
| `--sandbox NAME` | Target a specific sandbox (default: auto-detect) |
| `--output PATH` | Write diagnostics tarball to the given path |
| `--output PATH`, `-o PATH` | Write diagnostics tarball to the given path |

If `--output` is set and the tarball cannot be written (for example, the destination directory is missing or read-only), the command exits non-zero so scripts can detect the failure.

Expand Down Expand Up @@ -833,13 +833,13 @@ The `destroy` and `rebuild` commands clean up the image automatically, but image
This command lists all `openshell/sandbox-from:*` images, cross-references the sandbox registry, and removes any that are no longer associated with a registered sandbox.

```console
$ nemoclaw gc [--dry-run] [--yes|--force]
$ nemoclaw gc [--dry-run] [--yes|-y|--force]
```

| Flag | Description |
|------|-------------|
| `--dry-run` | List orphaned images without removing them |
| `--yes`, `--force` | Skip the confirmation prompt |
| `--yes`, `-y`, `--force` | Skip the confirmation prompt |

### `nemoclaw uninstall`

Expand Down
100 changes: 100 additions & 0 deletions nemoclaw-blueprint/scripts/ciao-network-guard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// ciao-network-guard.js — prevents @homebridge/ciao mDNS library from
// crashing the gateway when os.networkInterfaces() fails in restricted
// sandbox network namespaces.

(function () {
'use strict';

function basename(value) {
return String(value || '').split(/[\\/]/).pop();
}

function gatewayProcessFlavor() {
if (basename(process.argv0) === 'openclaw-gateway') return 'openclaw-gateway';
if (basename(process.title) === 'openclaw-gateway') return 'openclaw-gateway';
if (process.argv[2] === 'gateway') return 'launcher';
if (basename(process.argv[1]) === 'openclaw-gateway') return 'openclaw-gateway';
if (basename(process.argv[0]) === 'openclaw-gateway') return 'openclaw-gateway';
return '';
}

var _gatewayProcess = gatewayProcessFlavor();
if (_gatewayProcess) {
try {
process.stderr.write('[guard] ciao-network-guard loaded (' + _gatewayProcess + ')\n');
} catch (_) {}
}

// Monkey-patch os.networkInterfaces to return empty on failure.
var os = require('os');
var _origNetworkInterfaces = os.networkInterfaces;
// Rate-limit the failure log. The bonjour watchdog inside ciao retries
// advertising every few seconds, so a naive "log on every failure" fills
// sandbox logs with hundreds of identical lines per hour. Log the first
// failure (operator gets the actionable message) and at most one summary
// every 5 minutes thereafter, with a suppression count so volume is
// still observable. See GitHub issue #2611.
var _failureCount = 0;
var _lastLogMs = 0;
var _suppressedSinceLog = 0;
var _LOG_INTERVAL_MS = 5 * 60 * 1000;
os.networkInterfaces = function () {
try {
return _origNetworkInterfaces.call(os);
} catch (err) {
_failureCount++;
var nowMs = Date.now();
var shouldLog = _failureCount === 1 || (nowMs - _lastLogMs) >= _LOG_INTERVAL_MS;
if (shouldLog) {
var suffix = _suppressedSinceLog > 0
? ' [' + _suppressedSinceLog + ' suppressed in last ~5min, ' + _failureCount + ' total]'
: '';
process.stderr.write(
'[guard] os.networkInterfaces() failed: ' + (err.message || err) +
' — returning empty (mDNS disabled)' + suffix + '\n'
);
_lastLogMs = nowMs;
_suppressedSinceLog = 0;
} else {
_suppressedSinceLog++;
}
return {};
}
};

// Fallback: catch uncaughtException from ciao if the monkey-patch
// doesn't cover all call sites. Gateway-only — registering ANY
// uncaughtException listener tells Node "don't crash by default", and
// we want CLI processes (agent, doctor, plugins, tui) to keep default
// Node crash behavior so errors surface promptly.
//
// For gateway processes, non-ciao errors fall through (return) to the
// sandbox safety net registered later in the preload chain. The safety
// net is the single point of "keep gateway alive on unknown errors".
if (_gatewayProcess) {
process.on('uncaughtException', function (err, origin) {
if (
err && err.code === 'ERR_SYSTEM_ERROR' &&
String(err.message || '').indexOf('uv_interface_addresses') !== -1
) {
process.stderr.write(
'[guard] ciao/networkInterfaces crash caught: ' + (err.message || err) +
' \u2014 gateway continues\n'
);
return;
}
if (err && err.stack && err.stack.indexOf('ciao') !== -1 &&
String(err.message || '').indexOf('networkInterfaces') !== -1) {
process.stderr.write(
'[guard] ciao network error caught: ' + (err.message || err) +
' \u2014 gateway continues\n'
);
return;
}
// Not ciao — let the sandbox safety net handle it.
});
}
})();
9 changes: 3 additions & 6 deletions nemoclaw-blueprint/scripts/http-proxy-fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@
// OpenClaw's dist/ — there are no require() calls to intercept. The
// http.request wrapper sits below all libraries and catches every path.
//
// This file is the canonical source for review and tests. At sandbox boot
// This file is the canonical source for review and tests. The Dockerfile
// copies it into /usr/local/lib/nemoclaw/preloads/, then at sandbox boot
// nemoclaw-start.sh writes an identical copy to /tmp/nemoclaw-http-proxy-fix.js
// and loads it via NODE_OPTIONS=--require. A sync test enforces byte-for-byte
// equality. The content cannot be baked into /opt/nemoclaw-blueprint/scripts/
// because adding files to the optimized sandbox build context cache-busts the
// `COPY nemoclaw-blueprint/` Dockerfile layer and hangs npm ci in k3s
// Docker-in-Docker — see src/lib/sandbox-build-context.ts.
// and loads it via NODE_OPTIONS=--require.

(function () {
'use strict';
Expand Down
Loading
Loading