mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 23:43:54 +00:00
* fix(cli): retry logs.tail after journal fallback in logs follow Rebase #88159 onto current main and keep systemd journal fallback temporary in follow mode. Preserve the journal cursor across repeated fallback outages, but retry logs.tail on the next loop so recovered Gateway RPC returns to normal log output. This refresh also replaces the stale red checks-node-core-fast result from the old head with a current-head CI run. * Keep log source metadata explicit * ci: retrigger checks for PR #88159 * docs: clarify logs follow JSON source transitions * fix(cli): keep journal logs responsive during recovery --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
// Runtime gateway RPC helper shared by CLI commands that call the Gateway.
|
|
import {
|
|
GATEWAY_CLIENT_MODES,
|
|
GATEWAY_CLIENT_NAMES,
|
|
} from "../../packages/gateway-protocol/src/client-info.js";
|
|
import { callGateway } from "../gateway/call.js";
|
|
import type { GatewayRpcOpts } from "./gateway-rpc.types.js";
|
|
import { parseTimeoutMsWithFallback } from "./parse-timeout.js";
|
|
import { withProgress } from "./progress.js";
|
|
|
|
type CallGatewayFromCliRuntimeExtra = {
|
|
clientName?: Parameters<typeof callGateway>[0]["clientName"];
|
|
mode?: Parameters<typeof callGateway>[0]["mode"];
|
|
deviceIdentity?: Parameters<typeof callGateway>[0]["deviceIdentity"];
|
|
signal?: Parameters<typeof callGateway>[0]["signal"];
|
|
expectFinal?: boolean;
|
|
progress?: boolean;
|
|
scopes?: Parameters<typeof callGateway>[0]["scopes"];
|
|
};
|
|
|
|
const DEFAULT_GATEWAY_RPC_TIMEOUT_MS = 30_000;
|
|
|
|
export async function callGatewayFromCliRuntime(
|
|
method: string,
|
|
opts: GatewayRpcOpts,
|
|
params?: unknown,
|
|
extra?: CallGatewayFromCliRuntimeExtra,
|
|
) {
|
|
// Progress is disabled for JSON output so stdout stays parseable.
|
|
const showProgress = extra?.progress ?? opts.json !== true;
|
|
const timeoutMs = parseTimeoutMsWithFallback(opts.timeout, DEFAULT_GATEWAY_RPC_TIMEOUT_MS, {
|
|
invalidType: "error",
|
|
});
|
|
return await withProgress(
|
|
{
|
|
label: `Gateway ${method}`,
|
|
indeterminate: true,
|
|
enabled: showProgress,
|
|
},
|
|
async () =>
|
|
await callGateway({
|
|
url: opts.url,
|
|
token: opts.token,
|
|
method,
|
|
params,
|
|
deviceIdentity: extra?.deviceIdentity,
|
|
expectFinal: extra?.expectFinal ?? Boolean(opts.expectFinal),
|
|
scopes: extra?.scopes,
|
|
signal: extra?.signal,
|
|
timeoutMs,
|
|
clientName: extra?.clientName ?? GATEWAY_CLIENT_NAMES.CLI,
|
|
mode: extra?.mode ?? GATEWAY_CLIENT_MODES.CLI,
|
|
}),
|
|
);
|
|
}
|