Skip to content

Commit 4b6ee77

Browse files
paulcam206Copilotsteipete
authored
docs(mxc): isolate test setup and cleanup (#118945)
* docs(mxc): correct timeout default Co-authored-by: Copilot <[email protected]> Copilot-Session: d7253887-71c9-4083-a591-91979c981e39 * docs(mxc): preserve existing agents in setup Co-authored-by: Copilot <[email protected]> Copilot-Session: d7253887-71c9-4083-a591-91979c981e39 * docs(mxc): make cleanup non-destructive The Cleanup section replaced the entire agents.list with a single default main entry, which would silently drop any other agents a user had configured. Mirror the non-destructive approach now used in Test setup: 'openclaw agents delete mxc-test --force' plus a plugin-only config patch. Co-authored-by: Copilot <[email protected]> Copilot-Session: d7253887-71c9-4083-a591-91979c981e39 * docs(mxc): restore effective timeoutSeconds default An unset timeoutSeconds resolves to the 300s sandbox baseline, not the internal 120 value, since timeoutSecondsConfigured stays unset. Co-authored-by: Copilot <[email protected]> * docs(mxc): keep test setup and cleanup isolated Use a uniquely owned test agent and freshly reserved workspace, stop after failed native commands, and leave installation-wide MXC configuration and policy untouched. Preserve the effective unset timeout and existing SDK transport wording. Co-authored-by: Paul Campbell <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Copilot-Session: d7253887-71c9-4083-a591-91979c981e39
1 parent 7e7c5d4 commit 4b6ee77

1 file changed

Lines changed: 37 additions & 103 deletions

File tree

‎extensions/mxc/README.md‎

Lines changed: 37 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -101,107 +101,52 @@ help stay in sync with plugin runtime validation.
101101
- Windows filesystem-deny and host-list network policy knobs are not exposed by
102102
this plugin until MXC can enforce them on ProcessContainer.
103103

104-
## Test setup with `openclaw config`
104+
## Test setup
105105

106-
This patch creates a default `main` agent, then adds a dedicated `mxc-test`
107-
agent so MXC testing does not change the default agent. It uses
106+
Use an already configured OpenClaw installation with MXC installed and enabled
107+
on a supported Windows host. These commands create a uniquely named test agent
108+
and a new temporary workspace, leaving existing agents and workspaces alone.
108109
[`openclaw config patch --stdin`](https://docs.openclaw.ai/cli/config#config-patch)
109-
so setup is one validated config write instead of several path-based
110-
`config set` commands.
110+
applies sandbox settings only to that agent. Installation-wide MXC settings
111+
and policy files remain unchanged; review them before testing because they
112+
apply to the test agent too.
111113

112-
If you already have `agents.list` entries, copy them into the patch before
113-
`mxc-test` instead of replacing the list.
114+
Run setup, testing, and cleanup in the same PowerShell session. Finish cleanup
115+
before running setup again. Stop if any command fails.
114116

115117
```powershell
116-
$mxcPolicyPath = Join-Path $env:TEMP "openclaw-mxc-policy.json"
117-
@'
118-
{
119-
"filesystem": {
120-
"restrictToProjectDir": true,
121-
"additionalReadonlyPaths": [],
122-
"additionalReadwritePaths": []
123-
},
124-
"process": {
125-
"timeoutSeconds": 120
126-
}
127-
}
128-
'@ | Set-Content -Path $mxcPolicyPath -Encoding utf8
118+
$mxcAgentCreated = $false
119+
$mxcAgent = "mxc-test-" + [guid]::NewGuid().ToString("N")
120+
$mxcWorkspace = Join-Path ([System.IO.Path]::GetTempPath()) $mxcAgent
121+
New-Item -ItemType Directory -Path $mxcWorkspace -ErrorAction Stop | Out-Null
122+
123+
openclaw agents add $mxcAgent `
124+
--workspace $mxcWorkspace `
125+
--non-interactive
126+
if ($LASTEXITCODE -ne 0) { throw "Agent creation failed; stop without patching or deleting an existing agent." }
127+
$mxcAgentCreated = $true
129128
130-
$mxcPolicyPathLiteral = ConvertTo-Json $mxcPolicyPath -Compress
131129
$mxcConfigPatch = @"
132130
{
133131
agents: {
134-
list: [
135-
{
136-
id: "main",
137-
workspace: "~/.openclaw/workspace",
138-
},
139-
{
140-
id: "mxc-test",
141-
workspace: "~/.openclaw/workspace-mxc-test",
132+
entries: {
133+
"$mxcAgent": {
142134
sandbox: {
143135
mode: "all",
144136
backend: "mxc",
145137
scope: "agent",
146138
workspaceAccess: "none",
147139
},
148140
},
149-
],
150-
},
151-
plugins: {
152-
entries: {
153-
mxc: {
154-
enabled: true,
155-
config: {
156-
containment: "process",
157-
network: "none",
158-
mxcPolicyPaths: [$mxcPolicyPathLiteral],
159-
},
160-
},
161141
},
162142
},
163143
}
164144
"@
165145
166146
$mxcConfigPatch | openclaw config patch --stdin --dry-run
147+
if ($LASTEXITCODE -ne 0) { throw "Sandbox validation failed; use Cleanup to remove the new test agent." }
167148
$mxcConfigPatch | openclaw config patch --stdin
168-
```
169-
170-
Resulting config shape:
171-
172-
```jsonc
173-
{
174-
"agents": {
175-
"list": [
176-
{
177-
"id": "main",
178-
"workspace": "~/.openclaw/workspace",
179-
},
180-
{
181-
"id": "mxc-test",
182-
"workspace": "~/.openclaw/workspace-mxc-test",
183-
"sandbox": {
184-
"mode": "all",
185-
"backend": "mxc",
186-
"scope": "agent",
187-
"workspaceAccess": "none",
188-
},
189-
},
190-
],
191-
},
192-
"plugins": {
193-
"entries": {
194-
"mxc": {
195-
"enabled": true,
196-
"config": {
197-
"containment": "process",
198-
"network": "none",
199-
"mxcPolicyPaths": ["C:\\Users\\you\\AppData\\Local\\Temp\\openclaw-mxc-policy.json"],
200-
},
201-
},
202-
},
203-
},
204-
}
149+
if ($LASTEXITCODE -ne 0) { throw "Sandbox setup failed; use Cleanup to remove the new test agent." }
205150
```
206151

207152
## Sandbox policy files
@@ -283,44 +228,33 @@ ProcessContainer cannot safely enforce the nested read-only grant.
283228
Run the TUI as that agent:
284229

285230
```powershell
286-
openclaw tui --session agent:mxc-test:main
231+
openclaw tui --session "agent:${mxcAgent}:main"
287232
```
288233

289234
For local embedded testing without a Gateway:
290235

291236
```powershell
292-
openclaw tui --local --session agent:mxc-test:main
237+
openclaw tui --local --session "agent:${mxcAgent}:main"
293238
```
294239

295240
## Cleanup
296241

297-
If you used the exact sample above, remove the test agent and MXC plugin
298-
configuration by patching the config back to the default-only shape:
242+
In the same PowerShell session, remove only the agent created by setup:
299243

300244
```powershell
301-
$mxcCleanupPatch = @'
302-
{
303-
agents: {
304-
list: [
305-
{
306-
id: "main",
307-
workspace: "~/.openclaw/workspace",
308-
},
309-
],
310-
},
311-
plugins: {
312-
entries: {
313-
mxc: null,
314-
},
315-
},
245+
if (-not $mxcAgentCreated) {
246+
throw "No successfully created test agent in this session; do not delete an existing agent."
316247
}
317-
'@
318-
319-
$mxcCleanupPatch | openclaw config patch --stdin --dry-run
320-
$mxcCleanupPatch | openclaw config patch --stdin
321-
Remove-Item -Path $mxcPolicyPath -ErrorAction SilentlyContinue
248+
openclaw agents delete $mxcAgent --force
249+
if ($LASTEXITCODE -ne 0) { throw "Agent cleanup failed; inspect the error before retrying." }
250+
$mxcAgentCreated = $false
322251
```
323252

253+
The delete command removes the test agent's configuration and attempts to move
254+
its workspace and state to Trash. Check its output for any manual-cleanup
255+
warning. Do not remove the MXC plugin entry or shared policy files: other
256+
agents may still use them.
257+
324258
## Host readiness
325259

326260
IsoEnvBroker must be available on the host OS. The plugin checks this before
@@ -342,7 +276,7 @@ wxc-host-prep prepare-system-drive
342276
pnpm test:extension mxc
343277
```
344278

345-
`pnpm test extensions/mxc` is equivalent and also works.
279+
`pnpm test extensions/mxc` is also supported for the bundled extension test lane.
346280

347281
For policy-only edits, the focused coverage is in:
348282

0 commit comments

Comments
 (0)