import os
from polos import (
Agent, max_steps, MaxStepsConfig,
sandbox_tools, SandboxToolsConfig, DockerEnvironmentConfig, ExecToolConfig,
create_ask_user_tool,
)
workspace_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "workspace")
# Sandbox tools with exec security -- only allowlisted commands run
# without approval. Everything else suspends for the user to decide.
tools = sandbox_tools(
SandboxToolsConfig(
env="docker",
docker=DockerEnvironmentConfig(
image="node:20-slim",
workspace_dir=workspace_dir,
network="bridge",
),
exec=ExecToolConfig(
security="allowlist",
allowlist=[
"node *", # allow running node scripts
"cat *", # allow reading files
"echo *", # allow echo
"ls *", # allow listing
"ls", # allow bare ls
],
),
)
)
# Ask-user tool -- lets the agent ask the user questions during execution
ask_user = create_ask_user_tool()