feat(cron): add --session-key option to cron add/edit CLI commands
Expose the existing CronJob.sessionKey field through the CLI so users can target cron jobs at specific named sessions without needing an external shell script + system crontab workaround. The backend already fully supports sessionKey on cron jobs - this change wires it to the CLI surface with --session-key on cron add, and --session-key / --clear-session-key on cron edit. Closes #27158 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
452a8c9db9
commit
f692288301
@@ -37,6 +37,8 @@ export function registerCronEditCommand(cron: Command) {
|
||||
.option("--session <target>", "Session target (main|isolated)")
|
||||
.option("--agent <id>", "Set agent id")
|
||||
.option("--clear-agent", "Unset agent and use default", false)
|
||||
.option("--session-key <key>", "Set session key for job routing")
|
||||
.option("--clear-session-key", "Unset session key", false)
|
||||
.option("--wake <mode>", "Wake mode (now|next-heartbeat)")
|
||||
.option("--at <when>", "Set one-shot time (ISO) or duration like 20m")
|
||||
.option("--every <duration>", "Set interval duration like 10m")
|
||||
@@ -133,6 +135,15 @@ export function registerCronEditCommand(cron: Command) {
|
||||
if (opts.clearAgent) {
|
||||
patch.agentId = null;
|
||||
}
|
||||
if (opts.sessionKey && opts.clearSessionKey) {
|
||||
throw new Error("Use --session-key or --clear-session-key, not both");
|
||||
}
|
||||
if (typeof opts.sessionKey === "string" && opts.sessionKey.trim()) {
|
||||
patch.sessionKey = opts.sessionKey.trim();
|
||||
}
|
||||
if (opts.clearSessionKey) {
|
||||
patch.sessionKey = null;
|
||||
}
|
||||
|
||||
const scheduleChosen = [opts.at, opts.every, opts.cron].filter(Boolean).length;
|
||||
if (scheduleChosen > 1) {
|
||||
|
||||
Reference in New Issue
Block a user