mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-20 23:45:22 +08:00
fix(tools): resolve the sandbox interpreter for workspace file scripts
The workspace file tools (read/write/edit/glob/grep) ran a script through `python`, which a sandbox built from a host rootfs may not provide: those hosts ship `python3` only, and a read-only /usr prevents creating a `python` shim inside the jail. Every file tool then failed with `/bin/sh: 1: python: not found`. Resolve the interpreter with `command -v python3 || command -v python`, matching the interpreter the Box service already uses for its own scripts.
This commit is contained in:
@@ -754,9 +754,16 @@ class NativeToolLoader(loader.ToolLoader):
|
||||
return f'{str(base).rstrip("/")}/{relative}'
|
||||
|
||||
async def _run_workspace_file_script(self, script: str, query: pipeline_query.Query) -> dict:
|
||||
# Sandbox images built from a host rootfs may only ship `python3`, and a
|
||||
# read-only /usr prevents creating a `python` shim inside the jail, so
|
||||
# resolve the interpreter instead of assuming its name.
|
||||
command = (
|
||||
'PYTHON_BIN=$(command -v python3 || command -v python); '
|
||||
f"\"$PYTHON_BIN\" - <<'PY'\n{script}\nPY"
|
||||
)
|
||||
result = await self.ap.box_service.execute_tool(
|
||||
{
|
||||
'command': f"python - <<'PY'\n{script}\nPY",
|
||||
'command': command,
|
||||
'timeout_sec': 30,
|
||||
},
|
||||
query,
|
||||
|
||||
Reference in New Issue
Block a user