Fix sandbox launch with OpenCode v2 background service
OpenCode v2.2 starts a background service on 127.0.0.1:49374, which nono blocks unless a localhost port is granted. Give the sandbox its own service on 49376 with isolated config/state, and clean up its lifecycle. - Grant localhost ports 49376 (sandboxed service) and 3301 (Tinfoil proxy) - Add sandbox config/state dirs and XDG_STATE_HOME/OPENCODE_CONFIG_DIR - Wrapper mirrors real config, pins the sandbox service port, and stops stale/orphaned services so they never outlive the nono proxy - Remove deprecated commands.allow/deny and the redundant SSH key glob deny - Update installer, uninstall cleanup, and README
This commit is contained in:
+21
-3
@@ -7,6 +7,10 @@ PROFILE_DIR="${HOME}/.config/nono/profiles"
|
||||
BIN_DIR="${HOME}/.local/bin"
|
||||
WRAPPER_SRC="bin/opencode"
|
||||
|
||||
SANDBOX_CONFIG_DIR="${HOME}/.config/opencode-sandbox/opencode"
|
||||
SANDBOX_STATE_DIR="${HOME}/.local/state/opencode-sandbox/opencode"
|
||||
SANDBOX_SERVICE_PORT=49376
|
||||
|
||||
if ! command -v nono &>/dev/null; then
|
||||
echo "Error: nono is not installed. Install it first:"
|
||||
echo " brew install nono"
|
||||
@@ -27,17 +31,31 @@ chmod 644 "${PROFILE_DIR}/${PROFILE_NAME}.json"
|
||||
cp "${WRAPPER_SRC}" "${BIN_DIR}/opencode"
|
||||
chmod 755 "${BIN_DIR}/opencode"
|
||||
|
||||
# Create the sandbox-local OpenCode config/state directories. The wrapper also
|
||||
# does this at launch time, but doing it here makes the layout explicit and
|
||||
# lets the smoke test start from a clean setup.
|
||||
mkdir -p "${SANDBOX_CONFIG_DIR}" "${SANDBOX_STATE_DIR}"
|
||||
if [[ ! -f "${SANDBOX_CONFIG_DIR}/service.json" ]]; then
|
||||
printf '{\n "port": %s\n}\n' "${SANDBOX_SERVICE_PORT}" > "${SANDBOX_CONFIG_DIR}/service.json"
|
||||
chmod 600 "${SANDBOX_CONFIG_DIR}/service.json"
|
||||
fi
|
||||
|
||||
nono profile validate "${PROFILE_NAME}"
|
||||
|
||||
echo "Installed:"
|
||||
echo " Profile: ${PROFILE_DIR}/${PROFILE_NAME}.json"
|
||||
echo " Wrapper: ${BIN_DIR}/opencode"
|
||||
echo " Sandbox config: ${SANDBOX_CONFIG_DIR}"
|
||||
echo " Sandbox state: ${SANDBOX_STATE_DIR}"
|
||||
echo " Sandbox service port: ${SANDBOX_SERVICE_PORT}"
|
||||
|
||||
find_first_opencode() {
|
||||
local d c
|
||||
for d in $(printf '%s' "$PATH" | tr ':' ' '); do
|
||||
local IFS=:
|
||||
for d in $PATH; do
|
||||
[ -n "$d" ] || continue
|
||||
for c in "$d/opencode" "$d/opencode.exe"; do
|
||||
if [ -x "$c" ]; then
|
||||
if [ -f "$c" ] && [ -x "$c" ]; then
|
||||
printf '%s\n' "$c"
|
||||
return 0
|
||||
fi
|
||||
@@ -74,4 +92,4 @@ if "${BIN_DIR}/opencode" --version; then
|
||||
else
|
||||
echo "Error: sandboxed wrapper failed to launch." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user