mirror of
https://github.com/arjunkomath/openclaw-railway-template.git
synced 2026-08-14 00:48:11 +00:00
Fix device approval
This commit is contained in:
@@ -278,9 +278,6 @@
|
||||
this.devicesPending = [];
|
||||
this.devicesPaired = [];
|
||||
}
|
||||
if (j.raw) {
|
||||
this.log += '[devices] ' + j.raw.trim() + '\n';
|
||||
}
|
||||
} catch (e) {
|
||||
this.log += '✗ Failed to load devices: ' + String(e) + '\n';
|
||||
} finally {
|
||||
|
||||
+10
-2
@@ -842,10 +842,18 @@ app.post("/setup/api/doctor", requireSetupAuth, async (_req, res) => {
|
||||
app.get("/setup/api/devices", requireSetupAuth, async (_req, res) => {
|
||||
const args = ["devices", "list", "--json", "--token", OPENCLAW_GATEWAY_TOKEN];
|
||||
const result = await runCmd(OPENCLAW_NODE, clawArgs(args));
|
||||
log.info("devices", `list exit=${result.code} output=${result.output}`);
|
||||
try {
|
||||
const data = JSON.parse(result.output);
|
||||
const jsonMatch = result.output.match(/(\{[\s\S]*\}|\[[\s\S]*\])\s*$/);
|
||||
if (!jsonMatch) {
|
||||
log.warn("devices", "no JSON found in output");
|
||||
return res.json({ ok: result.code === 0, raw: result.output });
|
||||
}
|
||||
const data = JSON.parse(jsonMatch[1]);
|
||||
log.info("devices", `parsed keys=${Object.keys(data)} pending=${JSON.stringify(data.pending)} paired=${JSON.stringify(data.paired)}`);
|
||||
return res.json({ ok: true, data, raw: result.output });
|
||||
} catch {
|
||||
} catch (parseErr) {
|
||||
log.warn("devices", `JSON parse failed: ${parseErr.message}`);
|
||||
return res.json({ ok: result.code === 0, raw: result.output });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user