indieclaw-agent 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +34 -45
- package/install.sh +14 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -144,63 +144,52 @@ try {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// --- OpenClaw Detection ---
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
function tryOpenClawPort(port) {
|
|
147
|
+
function detectOpenClaw() {
|
|
150
148
|
return new Promise((resolve) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
resolve({ available: false, models: [], port });
|
|
149
|
+
// Method 1: Use `openclaw gateway status` CLI (most reliable)
|
|
150
|
+
exec('openclaw gateway status 2>&1', { timeout: 5000 }, (err, stdout) => {
|
|
151
|
+
const output = (stdout || '').toLowerCase();
|
|
152
|
+
// "running" in output means gateway is active
|
|
153
|
+
if (!err && (output.includes('running') || output.includes('active'))) {
|
|
154
|
+
// Try to get the gateway port from config
|
|
155
|
+
const portMatch = (stdout || '').match(/:(\d+)/);
|
|
156
|
+
const port = portMatch ? parseInt(portMatch[1], 10) : 18789;
|
|
157
|
+
return resolve({ available: true, models: ['openclaw'], port });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Method 2: Check if openclaw binary exists at all
|
|
161
|
+
exec('command -v openclaw 2>/dev/null', { timeout: 2000 }, (err2, binPath) => {
|
|
162
|
+
if (err2 || !binPath?.trim()) {
|
|
163
|
+
// Method 3: Check if openclaw-gateway process is running
|
|
164
|
+
exec('pgrep -f "openclaw.gateway\\|openclaw-gateway" 2>/dev/null', { timeout: 2000 }, (err3, pid) => {
|
|
165
|
+
if (!err3 && pid?.trim()) {
|
|
166
|
+
return resolve({ available: true, models: ['openclaw'], port: 18789 });
|
|
170
167
|
}
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
return resolve({ available: false, models: [], port: null });
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Binary exists but gateway might not be running — try health check
|
|
174
|
+
exec('openclaw gateway health --url ws://127.0.0.1:18789 2>&1', { timeout: 5000 }, (err4, healthOut) => {
|
|
175
|
+
const hOutput = (healthOut || '').toLowerCase();
|
|
176
|
+
if (!err4 && (hOutput.includes('ok') || hOutput.includes('healthy') || hOutput.includes('reachable'))) {
|
|
177
|
+
return resolve({ available: true, models: ['openclaw'], port: 18789 });
|
|
173
178
|
}
|
|
179
|
+
// Binary installed but gateway not running
|
|
180
|
+
return resolve({ available: false, models: [], port: null });
|
|
174
181
|
});
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
req.on('timeout', () => {
|
|
178
|
-
req.destroy();
|
|
179
|
-
resolve({ available: false, models: [], port });
|
|
180
|
-
});
|
|
181
|
-
req.on('error', () => {
|
|
182
|
-
resolve({ available: false, models: [], port });
|
|
182
|
+
});
|
|
183
183
|
});
|
|
184
|
-
req.end();
|
|
185
184
|
});
|
|
186
185
|
}
|
|
187
186
|
|
|
188
|
-
async function detectOpenClaw() {
|
|
189
|
-
// Try all common ports in parallel
|
|
190
|
-
const results = await Promise.all(OPENCLAW_PORTS.map(tryOpenClawPort));
|
|
191
|
-
const found = results.find((r) => r.available);
|
|
192
|
-
if (found) {
|
|
193
|
-
return { available: true, models: found.models, port: found.port };
|
|
194
|
-
}
|
|
195
|
-
return { available: false, models: [], port: null };
|
|
196
|
-
}
|
|
197
|
-
|
|
198
187
|
// Run detection on startup
|
|
199
188
|
detectOpenClaw().then((oc) => {
|
|
200
189
|
if (oc.available) {
|
|
201
|
-
console.log(` [OpenClaw] Detected on port ${oc.port}
|
|
190
|
+
console.log(` [OpenClaw] Detected (gateway running on port ${oc.port})`);
|
|
202
191
|
} else {
|
|
203
|
-
console.log(
|
|
192
|
+
console.log(' [OpenClaw] Not detected');
|
|
204
193
|
}
|
|
205
194
|
});
|
|
206
195
|
|
package/install.sh
CHANGED
|
@@ -110,11 +110,21 @@ echo -e " ${GREEN}✓${NC} IP: ${MACHINE_IP}"
|
|
|
110
110
|
# Step 5: Check OpenClaw
|
|
111
111
|
echo -e "${YELLOW}[5/5]${NC} Checking OpenClaw..."
|
|
112
112
|
OPENCLAW_STATUS="not detected"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
# Check via CLI (gateway status), then via process, then via binary existence
|
|
114
|
+
if command -v openclaw &> /dev/null; then
|
|
115
|
+
OC_STATUS=$(openclaw gateway status 2>&1 || true)
|
|
116
|
+
if echo "$OC_STATUS" | grep -qi "running\|active"; then
|
|
117
|
+
OPENCLAW_STATUS="running"
|
|
118
|
+
echo -e " ${GREEN}✓${NC} OpenClaw gateway is running"
|
|
119
|
+
elif pgrep -f "openclaw.gateway\|openclaw-gateway" > /dev/null 2>&1; then
|
|
120
|
+
OPENCLAW_STATUS="running"
|
|
121
|
+
echo -e " ${GREEN}✓${NC} OpenClaw gateway process detected"
|
|
122
|
+
else
|
|
123
|
+
OPENCLAW_STATUS="installed (gateway not running)"
|
|
124
|
+
echo -e " ${YELLOW}—${NC} OpenClaw installed but gateway not running. Start with: openclaw gateway run"
|
|
125
|
+
fi
|
|
116
126
|
else
|
|
117
|
-
echo -e " ${YELLOW}—${NC} OpenClaw not
|
|
127
|
+
echo -e " ${YELLOW}—${NC} OpenClaw not installed (optional, for AI features)"
|
|
118
128
|
fi
|
|
119
129
|
|
|
120
130
|
# Build deep link
|