Files
openclaw/src/cli/gateway-rpc.runtime.ts
2026-04-04 01:07:28 +09:00

32 lines
957 B
TypeScript

import { callGateway } from "../gateway/call.js";
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
import type { GatewayRpcOpts } from "./gateway-rpc.js";
import { withProgress } from "./progress.js";
export async function callGatewayFromCliRuntime(
method: string,
opts: GatewayRpcOpts,
params?: unknown,
extra?: { expectFinal?: boolean; progress?: boolean },
) {
const showProgress = extra?.progress ?? opts.json !== true;
return await withProgress(
{
label: `Gateway ${method}`,
indeterminate: true,
enabled: showProgress,
},
async () =>
await callGateway({
url: opts.url,
token: opts.token,
method,
params,
expectFinal: extra?.expectFinal ?? Boolean(opts.expectFinal),
timeoutMs: Number(opts.timeout ?? 10_000),
clientName: GATEWAY_CLIENT_NAMES.CLI,
mode: GATEWAY_CLIENT_MODES.CLI,
}),
);
}