@dcrays/scheduled-task 0.3.6-beta.1 → 0.3.6-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcrays/scheduled-task",
3
- "version": "0.3.6-beta.1",
3
+ "version": "0.3.6-beta.2",
4
4
  "description": "Persistent client-facing cron automation service for DeepSeek Harness",
5
5
  "type": "module",
6
6
  "main": "plugin/index.js",
package/plugin/index.js CHANGED
@@ -1100,6 +1100,9 @@ var CronAutomationManager = class {
1100
1100
  if (patch.at !== void 0 && Date.parse(patch.at) <= now) {
1101
1101
  throw new CronAutomationInputError("invalid_envelope", "at must be in the future");
1102
1102
  }
1103
+ if (patch.enabled === true && next.schedule.kind === "at" && atTimestamp(next.schedule) <= now) {
1104
+ throw new CronAutomationInputError("invalid_envelope", "at must be in the future");
1105
+ }
1103
1106
  if (patch.enabled !== void 0) {
1104
1107
  next.enabled = patch.enabled;
1105
1108
  delete next.state.runningAtMs;
@@ -1328,7 +1331,11 @@ var CronAutomationManager = class {
1328
1331
  }
1329
1332
  this.blockedAgents.delete(dshAgentIdFor(job));
1330
1333
  this.blockedUntil.delete(dshAgentIdFor(job));
1331
- if (job.deleteAfterRun === true || job.schedule.kind === "at") {
1334
+ if (job.schedule.kind === "at") {
1335
+ job.enabled = false;
1336
+ setNextOccurrence(job, void 0);
1337
+ await this.repository.upsert([job]);
1338
+ } else if (job.deleteAfterRun === true) {
1332
1339
  this.jobs.delete(jobId);
1333
1340
  await this.repository.delete(jobId);
1334
1341
  } else {
package/src/manager.js CHANGED
@@ -382,6 +382,9 @@ export class CronAutomationManager {
382
382
  if (patch.at !== undefined && Date.parse(patch.at) <= now) {
383
383
  throw new CronAutomationInputError('invalid_envelope', 'at must be in the future');
384
384
  }
385
+ if (patch.enabled === true && next.schedule.kind === 'at' && atTimestamp(next.schedule) <= now) {
386
+ throw new CronAutomationInputError('invalid_envelope', 'at must be in the future');
387
+ }
385
388
  if (patch.enabled !== undefined) {
386
389
  next.enabled = patch.enabled;
387
390
  delete next.state.runningAtMs;
@@ -630,7 +633,12 @@ export class CronAutomationManager {
630
633
  }
631
634
  this.blockedAgents.delete(dshAgentIdFor(job));
632
635
  this.blockedUntil.delete(dshAgentIdFor(job));
633
- if (job.deleteAfterRun === true || job.schedule.kind === 'at') {
636
+ if (job.schedule.kind === 'at') {
637
+ job.enabled = false;
638
+ setNextOccurrence(job, undefined);
639
+ await this.repository.upsert([job]);
640
+ }
641
+ else if (job.deleteAfterRun === true) {
634
642
  this.jobs.delete(jobId);
635
643
  await this.repository.delete(jobId);
636
644
  }