# Class SchedulerInstance

SDK wrapper for Scheduler operations. Provides a simplified interface for scheduling and managing jobs.

#### Example

    const scheduler = new SchedulerInstance('LocalScheduler', {}, AccessCandidate.agent('my-agent'));

    await scheduler.add('cleanup', Schedule.every('1h'), new Job(
      async () => console.log('Cleanup'),
      { name: 'Cleanup Job' }
    ));

#### Hierarchy (View Summary)

- SDKObject
  - SchedulerInstance

- Defined in src/Scheduler/SchedulerInstance.class.ts:178

##### Index

### Constructors

constructor

### Properties

_readyPromise

### Accessors

ready

### Methods

add
call
delete
emit
get
init
initSignal
list
off
on
once
pause
prompt
removeListener
resume
trigger

## Constructors

### constructor

- new SchedulerInstance(
  providerId?: TSchedulerProvider,
  schedulerSettings?: any,
  candidate?: Agent | AccessCandidate,
  ): SchedulerInstance

  #### Parameters

  - `Optional` providerId: TSchedulerProvider
  - schedulerSettings: any = {}
  - `Optional` candidate: Agent | AccessCandidate

  #### Returns SchedulerInstance

  Overrides SDKObject.constructor

  - Defined in src/Scheduler/SchedulerInstance.class.ts:184

## Properties

### `Protected`_readyPromise

_readyPromise: ControlledPromise<any>

Inherited from SDKObject._readyPromise

- Defined in src/Core/SDKObject.class.ts:17

## Accessors

### ready

- get ready(): ControlledPromise<any>

  #### Returns ControlledPromise<any>

  Inherited from SDKObject.ready

  - Defined in src/Core/SDKObject.class.ts:19

## Methods

### add

- add(jobId: string, job: Job, schedule: Schedule): Promise<boolean>

  Add or update a scheduled job. If a job with the same ID exists, it will be updated.

  #### Parameters

  - jobId: string

    Unique identifier for the job

  - job: Job

    Job instance with execution function and metadata

  - schedule: Schedule

    Schedule definition (interval or cron)

  #### Returns Promise<boolean>

  Promise that resolves when the job is scheduled

  #### Example

      await scheduler.add('backup',
        Schedule.every('6h'),
        new Job(async () => {
          console.log('Running backup...');
        }, {
          name: 'Backup Job',
          retryOnFailure: true
        })
      );

  - Defined in src/Scheduler/SchedulerInstance.class.ts:238

### call

- call(
  skillName: string,
  args?: any[] | Record<string, any>,
  metadata?: IJobMetadata,
  ): SchedulerJobCommand

  Schedule an agent skill execution with chainable syntax. Requires an agent to be associated with this scheduler instance.

  #### Parameters

  - skillName: string

    Name of the skill to execute

  - `Optional` args: any[] | Record<string, any>

    Arguments to pass to the skill

  - `Optional` metadata: IJobMetadata

    Optional job metadata (name, description, retryOnFailure, etc.)

  #### Returns SchedulerJobCommand

  SchedulerJobBuilder that can be chained with .every() or .cron()

  #### Throws

  Error if no agent is associated with this scheduler

  #### Example

      // Schedule a skill to run every 5 seconds
      await scheduler.call('processData', { input: 'test' }, { name: 'Data Processor' }).every('5s');

      // Schedule with cron expression
      await scheduler.call('backup', {}, { retryOnFailure: true }).cron('0 0 * * *');

  - Defined in src/Scheduler/SchedulerInstance.class.ts:380

### delete

- delete(jobId: string): Promise<void>

  Delete a scheduled job. This removes the job permanently and stops all scheduled executions.

  #### Parameters

  - jobId: string

    Unique identifier of the job to delete

  #### Returns Promise<void>

  Promise that resolves when the job is deleted

  #### Example

      await scheduler.delete('backup');
      console.log('Backup job deleted');

  - Defined in src/Scheduler/SchedulerInstance.class.ts:351

### emit

- emit(event: string, ...args: any[]): void

  #### Parameters

  - event: string
  - ...args: any[]

  #### Returns void

  Inherited from SDKObject.emit

  - Defined in src/Core/SDKObject.class.ts:45

### get

- get(jobId: string): Promise<IScheduledJob>

  Get details of a specific scheduled job.

  #### Parameters

  - jobId: string

    Unique identifier of the job

  #### Returns Promise<IScheduledJob>

  Promise that resolves to the job details, or undefined if not found

  #### Example

      const job = await scheduler.get('backup');
      if (job) {
        console.log(`Status: ${job.status}`);
        console.log(`Next run: ${job.nextRun}`);
      }

  - Defined in src/Scheduler/SchedulerInstance.class.ts:285

### `Protected` init

- init(revolveReadyPromise?: boolean): Promise<void>

  #### Parameters

  - revolveReadyPromise: boolean = true

  #### Returns Promise<void>

  Inherited from SDKObject.init

  - Defined in src/Core/SDKObject.class.ts:30

### `Protected` initSignal

- initSignal(): Promise<void>

  #### Returns Promise<void>

  Inherited from SDKObject.initSignal

  - Defined in src/Core/SDKObject.class.ts:37

### list

- list(): Promise<IScheduledJob[]>

  List all scheduled jobs for this candidate.

  #### Returns Promise<IScheduledJob[]>

  Promise that resolves to an array of scheduled jobs

  #### Example

      const jobs = await scheduler.list();
      jobs.forEach(job => {
        console.log(`${job.metadata.name}: ${job.status}`);
      });

  - Defined in src/Scheduler/SchedulerInstance.class.ts:261

### off

- off(event: string, listener: (...args: any[]) => void): this

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns this

  Overrides SDKObject.off

  - Defined in src/Scheduler/SchedulerInstance.class.ts:212

### on

- on(event: string, listener: (...args: any[]) => void): this

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns this

  Overrides SDKObject.on

  - Defined in src/Scheduler/SchedulerInstance.class.ts:207

### once

- once(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.once

  - Defined in src/Core/SDKObject.class.ts:53

### pause

- pause(jobId: string): Promise<void>

  Pause a scheduled job. The job will not execute until resumed.

  #### Parameters

  - jobId: string

    Unique identifier of the job to pause

  #### Returns Promise<void>

  Promise that resolves when the job is paused

  #### Example

      await scheduler.pause('backup');
      console.log('Backup job paused');

  - Defined in src/Scheduler/SchedulerInstance.class.ts:307

### prompt

- prompt(prompt: string, metadata?: IJobMetadata): SchedulerJobCommand

  Schedule an agent prompt execution with chainable syntax. Requires an agent to be associated with this scheduler instance.

  #### Parameters

  - prompt: string

    The prompt text to send to the agent

  - `Optional` metadata: IJobMetadata

    Optional job metadata (name, description, retryOnFailure, etc.)

  #### Returns SchedulerJobCommand

  SchedulerJobBuilder that can be chained with .every() or .cron()

  #### Throws

  Error if no agent is associated with this scheduler

  #### Example

      // Schedule a prompt to run every hour
      await scheduler.prompt('Generate daily report', { name: 'Daily Report' }).every('1h');

      // Schedule with cron expression
      await scheduler.prompt('Summarize news', { name: 'News Summary' }).cron('0 9 * * *');

  - Defined in src/Scheduler/SchedulerInstance.class.ts:416

### removeListener

- removeListener(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.removeListener

  - Defined in src/Core/SDKObject.class.ts:56

### resume

- resume(jobId: string): Promise<void>

  Resume a paused job. The job will start executing according to its schedule.

  #### Parameters

  - jobId: string

    Unique identifier of the job to resume

  #### Returns Promise<void>

  Promise that resolves when the job is resumed

  #### Example

      await scheduler.resume('backup');
      console.log('Backup job resumed');

  - Defined in src/Scheduler/SchedulerInstance.class.ts:329

### trigger

- trigger(triggerName: string, metadata?: IJobMetadata): SchedulerJobCommand

  Schedule an agent trigger execution with chainable syntax. Requires an agent to be associated with this scheduler instance.

  #### Parameters

  - triggerName: string

    Name of the trigger to execute

  - `Optional` metadata: IJobMetadata

    Optional job metadata (name, description, retryOnFailure, etc.)

  #### Returns SchedulerJobCommand

  SchedulerJobBuilder that can be chained with .every() or .cron()

  #### Throws

  Error if no agent is associated with this scheduler

  #### Example

      // Schedule a trigger to run every day
      await scheduler.trigger('daily-sync', { name: 'Daily Sync' }).every('1d');

      // Schedule with cron expression
      await scheduler.trigger('weekly-report', { name: 'Weekly Report' }).cron('0 0 * * 0');

  - Defined in src/Scheduler/SchedulerInstance.class.ts:456