From 3f37cb6434766d7017c55afaadd9e909a2c35934 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Wed, 27 May 2026 19:12:59 -0400 Subject: [PATCH 1/2] fix: use mounted workspace backend in sandbox --- packages/cli/src/agent-code.ts | 4 ++++ scripts/agent-sandbox-code-smoke.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/cli/src/agent-code.ts b/packages/cli/src/agent-code.ts index 9bc24bac..45bbf504 100644 --- a/packages/cli/src/agent-code.ts +++ b/packages/cli/src/agent-code.ts @@ -64,6 +64,8 @@ if (!defined('DATAMACHINE_WORKSPACE_PATH')) { define('DATAMACHINE_WORKSPACE_PATH', ${JSON.stringify(SANDBOX_WORKSPACE_ROOT)}); } +add_filter('datamachine_code_remote_workspace_backend_should_handle', '__return_false', 100); + $sandbox_workspace_adoptions = array(); if (function_exists('wp_get_ability')) { $sandbox_adopt_callback = static function () use (&$sandbox_workspace_adoptions): void { @@ -257,6 +259,8 @@ if (!defined('DATAMACHINE_WORKSPACE_PATH')) { define('DATAMACHINE_WORKSPACE_PATH', ${JSON.stringify(SANDBOX_WORKSPACE_ROOT)}); } +add_filter('datamachine_code_remote_workspace_backend_should_handle', '__return_false', 100); + add_filter('datamachine_should_load_full_runtime', '__return_true', 1); $plugins = array_merge(array( diff --git a/scripts/agent-sandbox-code-smoke.ts b/scripts/agent-sandbox-code-smoke.ts index 7efd8e26..adc1407f 100644 --- a/scripts/agent-sandbox-code-smoke.ts +++ b/scripts/agent-sandbox-code-smoke.ts @@ -14,6 +14,7 @@ async function main() { assert.match(code, /\\"agent_modes\\":\[\\"sandbox\\",\\"pipeline\\"\]/, "client context should report additive sandbox modes") assert.match(code, /\\"tool_policy\\":\{\\"mode\\":\\"allow\\",\\"tools\\":\[.*\\"workspace_read\\"/, "sandbox agent should allow workspace tools") assert.match(code, /datamachine_agent_mode_sandbox/, "sandbox mode should inject tool guidance") + assert.match(code, /datamachine_code_remote_workspace_backend_should_handle/, "sandbox mode should use the mounted workspace backend") assert.match(code, /Do not invent alternate tool names such as read_file/, "sandbox guidance should prevent pseudo-tool aliases") assert.match(code, /workspace_apply_patch/, "sandbox tool policy should include patch application") } From dbe15040eb9dca3d2825b05edfc0a48d8fb3edf6 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Wed, 27 May 2026 19:26:27 -0400 Subject: [PATCH 2/2] fix: preserve recipe run diagnostics --- packages/runtime-playground/src/index.ts | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/runtime-playground/src/index.ts b/packages/runtime-playground/src/index.ts index 6eb8b289..397452ee 100644 --- a/packages/runtime-playground/src/index.ts +++ b/packages/runtime-playground/src/index.ts @@ -80,6 +80,15 @@ class PlaygroundCommandCrashError extends Error { } } +class PlaygroundCliExitError extends Error { + readonly code = "wp-codebox-playground-cli-exited" + + constructor(readonly exitCode: number) { + super(`WordPress Playground CLI exited while booting the runtime with exit code ${exitCode}.`) + this.name = "PlaygroundCliExitError" + } +} + class PlaygroundPreviewPortUnavailableError extends Error { readonly code = "wp-codebox-preview-port-in-use" @@ -115,6 +124,20 @@ function errorMessage(error: unknown): string { return error instanceof Error ? error.message : String(error) } +async function runPlaygroundCliWithoutProcessExit(callback: () => Promise): Promise { + const exit = process.exit + process.exit = ((code?: string | number | null | undefined): never => { + const exitCode = typeof code === "number" ? code : 1 + throw new PlaygroundCliExitError(exitCode) + }) as typeof process.exit + + try { + return await callback() + } finally { + process.exit = exit + } +} + interface PlaygroundCliServer { playground: { run(options: { code: string } | { scriptPath: string }): Promise @@ -1290,7 +1313,7 @@ echo json_encode(array('command' => 'inspect-mounted-inputs', 'mounts' => $inspe } try { - const server = await runCLI({ + const server = await runPlaygroundCliWithoutProcessExit(() => runCLI({ command: "server", port: 0, quiet: true, @@ -1302,7 +1325,7 @@ echo json_encode(array('command' => 'inspect-mounted-inputs', 'mounts' => $inspe wp: this.spec.environment.version, "site-url": this.spec.preview?.siteUrl, blueprint: playgroundBlueprint(this.spec.environment.blueprint, this.spec.policy, this.spec.preview?.siteUrl), - }) + })) if (!this.spec.preview?.port) { return server