mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 19:10:39 +00:00
Fixes #7667 Task 1: Fix cron operation timeouts - Increase default gateway tool timeout from 10s to 30s - Increase cron-specific tool timeout to 60s - Increase CLI default timeout from 10s to 30s - Prevents timeouts when gateway is busy with long-running jobs Task 2: Add timestamp validation - New validateScheduleTimestamp() function in validate-timestamp.ts - Rejects atMs timestamps more than 1 minute in the past - Rejects atMs timestamps more than 10 years in the future - Applied to both cron.add and cron.update operations - Provides helpful error messages with current time and offset Task 3: Enable file sync for manual edits - Track file modification time (storeFileMtimeMs) in CronServiceState - Check file mtime in ensureLoaded() and reload if changed - Recompute next runs after reload to maintain accuracy - Update mtime after persist() to prevent reload loop - Dashboard now picks up manual edits to ~/.openclaw/cron/jobs.json
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import type { Command } from "commander";
|
|
import { callGateway } from "../gateway/call.js";
|
|
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
|
import { withProgress } from "./progress.js";
|
|
|
|
export type GatewayRpcOpts = {
|
|
url?: string;
|
|
token?: string;
|
|
timeout?: string;
|
|
expectFinal?: boolean;
|
|
json?: boolean;
|
|
};
|
|
|
|
export function addGatewayClientOptions(cmd: Command) {
|
|
return cmd
|
|
.option("--url <url>", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)")
|
|
.option("--token <token>", "Gateway token (if required)")
|
|
.option("--timeout <ms>", "Timeout in ms", "30000")
|
|
.option("--expect-final", "Wait for final response (agent)", false);
|
|
}
|
|
|
|
export async function callGatewayFromCli(
|
|
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,
|
|
}),
|
|
);
|
|
}
|