Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions scripts/start-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ do_start() {

command -v node > /dev/null || fail "node not found. Install Node.js first."

# Ensure ~/.local/bin is in PATH so child processes can find openshell
if [ -d "$HOME/.local/bin" ] && ! echo "$PATH" | tr ':' '\n' | grep -qx "$HOME/.local/bin"; then
export PATH="$HOME/.local/bin:$PATH"
fi

# Verify sandbox is running
if command -v openshell > /dev/null 2>&1; then
if ! openshell sandbox list 2>&1 | grep -q "Ready"; then
Expand All @@ -140,6 +145,11 @@ do_start() {

# Telegram bridge (only if token provided)
if [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; then
# Resolve openshell absolute path so child processes find it regardless of PATH
OPENSHELL_BIN="$(command -v openshell 2>/dev/null || true)"
if [ -n "$OPENSHELL_BIN" ]; then
export OPENSHELL_BIN
fi
Comment on lines +148 to +152

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fail fast when openshell is missing before launching Telegram bridge.

Right now the bridge still starts even when OPENSHELL_BIN cannot be resolved, which can lead to a “started but broken” service state. Consider failing early (or skipping bridge start with a warning) when TELEGRAM_BOT_TOKEN is set and openshell is absent.

Suggested fix
-    OPENSHELL_BIN="$(command -v openshell 2>/dev/null || true)"
-    if [ -n "$OPENSHELL_BIN" ]; then
-      export OPENSHELL_BIN
-    fi
+    OPENSHELL_BIN="$(command -v openshell 2>/dev/null || true)"
+    [ -n "$OPENSHELL_BIN" ] || fail "openshell not found. Install OpenShell or add it to PATH."
+    export OPENSHELL_BIN
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/start-services.sh` around lines 148 - 152, The script currently sets
OPENSHELL_BIN but continues to start the Telegram bridge even when openshell is
missing; update the block that defines OPENSHELL_BIN to check for
TELEGRAM_BOT_TOKEN and, if TELEGRAM_BOT_TOKEN is non-empty while OPENSHELL_BIN
is empty, immediately fail (echo a clear error and exit 1) or alternatively log
a warning and skip starting the bridge; refer to the OPENSHELL_BIN variable and
the TELEGRAM_BOT_TOKEN env var in your change so the script refuses to proceed
with launching the Telegram bridge when openshell cannot be resolved.

SANDBOX_NAME="$SANDBOX_NAME" start_service telegram-bridge \
node "$REPO_DIR/scripts/telegram-bridge.js"
fi
Expand Down
8 changes: 6 additions & 2 deletions scripts/telegram-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

const https = require("https");
const { execSync, spawn } = require("child_process");
const { execFileSync, spawn } = require("child_process");
const { resolveOpenshell } = require("../bin/lib/resolve-openshell");

const OPENSHELL = resolveOpenshell();
Expand Down Expand Up @@ -92,7 +92,11 @@ async function sendTyping(chatId) {

function runAgentInSandbox(message, sessionId) {
return new Promise((resolve) => {
const sshConfig = execSync(`"${OPENSHELL}" sandbox ssh-config "${SANDBOX}"`, { encoding: "utf-8" });
const sshConfig = execFileSync(
OPENSHELL,
["sandbox", "ssh-config", SANDBOX],
{ encoding: "utf-8" },
);

// Write temp ssh config
const confPath = `/tmp/nemoclaw-tg-ssh-${sessionId}.conf`;
Expand Down