mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-12 06:06:05 +00:00
* fix(nodes): explain unknown approval request ids * fix(nodes): keep stale request handling CI-clean * fix(nodes): point stale approve hint at pending command * fix(nodes): explain stale approval request ids * fix(nodes): make stale approval guidance reliable * fix(nodes): preserve stale approval error context --------- Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
// Node CLI runtime helpers: terminal theme adaptation and standard error handling.
|
||||
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
|
||||
import { isRich, theme } from "../../../packages/terminal-core/src/theme.js";
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import { runCommandWithRuntime } from "../cli-utils.js";
|
||||
import { unauthorizedHintForMessage } from "./rpc.js";
|
||||
import type { NodesRpcOpts } from "./types.js";
|
||||
|
||||
/** Return color helpers that degrade to plain text in non-rich terminals. */
|
||||
export function getNodesTheme() {
|
||||
@@ -18,10 +21,20 @@ export function getNodesTheme() {
|
||||
};
|
||||
}
|
||||
|
||||
export function formatConnectionFlagReminder(opts: NodesRpcOpts): string | null {
|
||||
const flags = [
|
||||
normalizeOptionalString(opts.url) ? "--url" : null,
|
||||
normalizeOptionalString(opts.token) ? "--token" : null,
|
||||
].filter((flag) => flag !== null);
|
||||
return flags.length > 0
|
||||
? `Reuse the same connection option${flags.length === 1 ? "" : "s"} when rerunning: ${flags.join(", ")}.`
|
||||
: null;
|
||||
}
|
||||
|
||||
/** Run a node CLI action with standard failure text and authorization hints. */
|
||||
export function runNodesCommand(label: string, action: () => Promise<void>) {
|
||||
return runCommandWithRuntime(defaultRuntime, action, (err) => {
|
||||
const message = String(err);
|
||||
const message = formatErrorMessage(err);
|
||||
const { error, warn } = getNodesTheme();
|
||||
defaultRuntime.error(error(`nodes ${label} failed: ${message}`));
|
||||
const hint = unauthorizedHintForMessage(message);
|
||||
|
||||
Reference in New Issue
Block a user