MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / addJob

Method addJob

src/runtime/adapters/scheduler.ts:364–389  ·  view source on GitHub ↗

* Add a new job, persist to job.json.

(jobConfig: ScheduledJobConfig)

Source from the content-addressed store, hash-verified

362 // Dynamic management API
363 // -------------------------------------------------------------------------
364
365 /**
366 * Add a new job, persist to job.json.
367 */
368 addJob(jobConfig: ScheduledJobConfig): { success: boolean; message: string } {
369 if (this.jobs.has(jobConfig.id)) {
370 return {
371 success: false,
372 message: `Job "${jobConfig.name}" already exists. Remove it first.`,
373 };
374 }
375
376 const result = this.registerJob(jobConfig);
377 if (!result.registered) {
378 return { success: false, message: result.message };
379 }
380
381 this.persistJobs();
382
383 const recurring = isRecurringJob(jobConfig);
384 const enabled = recurring ? jobConfig.enabled !== false : true;
385 return {
386 success: true,
387 message: recurring
388 ? enabled
389 ? `Job "${jobConfig.name}" created and scheduled.`
390 : `Job "${jobConfig.name}" created (disabled).`
391 : `Job "${jobConfig.name}" created as a one-time task.`,
392 };

Callers 4

executeFunction · 0.80
handleRequestMethod · 0.80
startMethod · 0.80
scheduler.test.tsFile · 0.80

Calls 3

registerJobMethod · 0.95
persistJobsMethod · 0.95
isRecurringJobFunction · 0.85

Tested by

no test coverage detected