mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import type { Command } from "commander";
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import {
|
||||
formatAge,
|
||||
formatPermissions,
|
||||
parseNodeList,
|
||||
parsePairingList,
|
||||
} from "./format.js";
|
||||
import { formatAge, formatPermissions, parseNodeList, parsePairingList } from "./format.js";
|
||||
import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js";
|
||||
import type { NodesRpcOpts } from "./types.js";
|
||||
|
||||
@@ -16,20 +11,14 @@ export function registerNodesStatusCommands(nodes: Command) {
|
||||
.description("List known nodes with connection status and capabilities")
|
||||
.action(async (opts: NodesRpcOpts) => {
|
||||
try {
|
||||
const result = (await callGatewayCli(
|
||||
"node.list",
|
||||
opts,
|
||||
{},
|
||||
)) as unknown;
|
||||
const result = (await callGatewayCli("node.list", opts, {})) as unknown;
|
||||
if (opts.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
}
|
||||
const nodes = parseNodeList(result);
|
||||
const pairedCount = nodes.filter((n) => Boolean(n.paired)).length;
|
||||
const connectedCount = nodes.filter((n) =>
|
||||
Boolean(n.connected),
|
||||
).length;
|
||||
const connectedCount = nodes.filter((n) => Boolean(n.connected)).length;
|
||||
defaultRuntime.log(
|
||||
`Known: ${nodes.length} · Paired: ${pairedCount} · Connected: ${connectedCount}`,
|
||||
);
|
||||
@@ -78,22 +67,15 @@ export function registerNodesStatusCommands(nodes: Command) {
|
||||
typeof result === "object" && result !== null
|
||||
? (result as Record<string, unknown>)
|
||||
: {};
|
||||
const displayName =
|
||||
typeof obj.displayName === "string" ? obj.displayName : nodeId;
|
||||
const displayName = typeof obj.displayName === "string" ? obj.displayName : nodeId;
|
||||
const connected = Boolean(obj.connected);
|
||||
const caps = Array.isArray(obj.caps)
|
||||
? obj.caps.map(String).filter(Boolean).sort()
|
||||
: null;
|
||||
const caps = Array.isArray(obj.caps) ? obj.caps.map(String).filter(Boolean).sort() : null;
|
||||
const commands = Array.isArray(obj.commands)
|
||||
? obj.commands.map(String).filter(Boolean).sort()
|
||||
: [];
|
||||
const perms = formatPermissions(obj.permissions);
|
||||
const family =
|
||||
typeof obj.deviceFamily === "string" ? obj.deviceFamily : null;
|
||||
const model =
|
||||
typeof obj.modelIdentifier === "string"
|
||||
? obj.modelIdentifier
|
||||
: null;
|
||||
const family = typeof obj.deviceFamily === "string" ? obj.deviceFamily : null;
|
||||
const model = typeof obj.modelIdentifier === "string" ? obj.modelIdentifier : null;
|
||||
const ip = typeof obj.remoteIp === "string" ? obj.remoteIp : null;
|
||||
|
||||
const parts: string[] = ["Node:", displayName, nodeId];
|
||||
@@ -123,32 +105,21 @@ export function registerNodesStatusCommands(nodes: Command) {
|
||||
.description("List pending and paired nodes")
|
||||
.action(async (opts: NodesRpcOpts) => {
|
||||
try {
|
||||
const result = (await callGatewayCli(
|
||||
"node.pair.list",
|
||||
opts,
|
||||
{},
|
||||
)) as unknown;
|
||||
const result = (await callGatewayCli("node.pair.list", opts, {})) as unknown;
|
||||
if (opts.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
return;
|
||||
}
|
||||
const { pending, paired } = parsePairingList(result);
|
||||
defaultRuntime.log(
|
||||
`Pending: ${pending.length} · Paired: ${paired.length}`,
|
||||
);
|
||||
defaultRuntime.log(`Pending: ${pending.length} · Paired: ${paired.length}`);
|
||||
if (pending.length > 0) {
|
||||
defaultRuntime.log("\nPending:");
|
||||
for (const r of pending) {
|
||||
const name = r.displayName || r.nodeId;
|
||||
const repair = r.isRepair ? " (repair)" : "";
|
||||
const ip = r.remoteIp ? ` · ${r.remoteIp}` : "";
|
||||
const age =
|
||||
typeof r.ts === "number"
|
||||
? ` · ${formatAge(Date.now() - r.ts)} ago`
|
||||
: "";
|
||||
defaultRuntime.log(
|
||||
`- ${r.requestId}: ${name}${repair}${ip}${age}`,
|
||||
);
|
||||
const age = typeof r.ts === "number" ? ` · ${formatAge(Date.now() - r.ts)} ago` : "";
|
||||
defaultRuntime.log(`- ${r.requestId}: ${name}${repair}${ip}${age}`);
|
||||
}
|
||||
}
|
||||
if (paired.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user