* schedule: add `paseo schedule update` to edit schedules in place Editing a schedule today requires delete+recreate, losing run history and the schedule id. This adds an additive RPC and CLI command that patches name, prompt, cadence, new-agent target fields, max-runs, and expires-in without touching runs or in-flight executions. nextRunAt is recomputed only when the cadence actually changes. * schedule(cli): share cadence flag parser between create and update Both paths were turning --every/--cron into a ScheduleCadence with near-identical code. Extract `parseCadenceFromFlags` so the literals and the exclusivity check live in one place; create wraps it to require a value, update lets it stay optional.
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import type { Command } from "commander";
|
|
import type { ListResult } from "../../output/index.js";
|
|
import {
|
|
createScheduleInspectRows,
|
|
createScheduleInspectSchema,
|
|
type ScheduleInspectRow,
|
|
} from "./schema.js";
|
|
import {
|
|
connectScheduleClient,
|
|
parseScheduleUpdateInput,
|
|
toScheduleCommandError,
|
|
type ScheduleCommandOptions,
|
|
} from "./shared.js";
|
|
|
|
export interface ScheduleUpdateOptions extends ScheduleCommandOptions {
|
|
every?: string;
|
|
cron?: string;
|
|
name?: string;
|
|
prompt?: string;
|
|
provider?: string;
|
|
model?: string;
|
|
mode?: string;
|
|
cwd?: string;
|
|
maxRuns?: string;
|
|
noMaxRuns?: boolean;
|
|
expiresIn?: string;
|
|
noExpiresIn?: boolean;
|
|
}
|
|
|
|
export async function runUpdateCommand(
|
|
id: string,
|
|
options: ScheduleUpdateOptions,
|
|
_command: Command,
|
|
): Promise<ListResult<ScheduleInspectRow>> {
|
|
const input = parseScheduleUpdateInput({
|
|
id,
|
|
every: options.every,
|
|
cron: options.cron,
|
|
name: options.name,
|
|
prompt: options.prompt,
|
|
provider: options.provider,
|
|
model: options.model,
|
|
mode: options.mode,
|
|
cwd: options.cwd,
|
|
maxRuns: options.maxRuns,
|
|
expiresIn: options.expiresIn,
|
|
clearMaxRuns: options.noMaxRuns,
|
|
clearExpires: options.noExpiresIn,
|
|
});
|
|
const { client } = await connectScheduleClient(options.host);
|
|
try {
|
|
const payload = await client.scheduleUpdate(input);
|
|
if (payload.error || !payload.schedule) {
|
|
throw new Error(payload.error ?? `Failed to update schedule: ${id}`);
|
|
}
|
|
return {
|
|
type: "list",
|
|
data: createScheduleInspectRows(payload.schedule),
|
|
schema: createScheduleInspectSchema(payload.schedule),
|
|
};
|
|
} catch (error) {
|
|
throw toScheduleCommandError("SCHEDULE_UPDATE_FAILED", "update schedule", error);
|
|
} finally {
|
|
await client.close().catch(() => {});
|
|
}
|
|
}
|