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

Class SchedulerAdapter

src/runtime/adapters/scheduler.ts:91–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91// ---------------------------------------------------------------------------
92// SchedulerAdapter
93// ---------------------------------------------------------------------------
94
95export class SchedulerAdapter implements PlatformAdapter {
96 readonly name = "scheduler";
97
98 private agent!: IPackAgent;
99 private rootDir = "";
100 private ipcBroadcaster: IpcBroadcaster | null = null;
101 private notifyFn: (
102 adapter: string,
103 channelId: string,
104 text: string,
105 ) => Promise<void> = async () => {};
106 private jobs = new Map<string, ManagedJob>();
107
108 async start(ctx: AdapterContext): Promise<void> {
109 this.agent = ctx.agent;
110 this.rootDir = ctx.rootDir;
111 this.ipcBroadcaster = ctx.ipcBroadcaster ?? null;
112 this.notifyFn = ctx.notify || (async () => {});
113 console.log(
114 `[Scheduler] IPC broadcaster ${this.ipcBroadcaster ? "attached" : "not available"} for agent events`,
115 );
116
117 const jobConfigs = loadJobFile(this.rootDir).jobs;
118
119 let scheduledCount = 0;
120 let disabledCount = 0;
121 let oneTimeCount = 0;
122 for (const jc of jobConfigs) {
123 const result = this.registerJob(jc);
124 if (result.registered) {
125 if (!isRecurringJob(jc)) {
126 oneTimeCount++;
127 } else if (jc.enabled === false) {
128 disabledCount++;
129 } else {
130 scheduledCount++;
131 }
132 }
133 }
134
135 const parts: string[] = [];
136 if (scheduledCount > 0) parts.push(`${scheduledCount} active`);
137 if (disabledCount > 0) parts.push(`${disabledCount} disabled`);
138 if (oneTimeCount > 0) parts.push(`${oneTimeCount} one-time`);
139 if (parts.length > 0) {
140 console.log(`[SchedulerAdapter] Started with ${parts.join(", ")} job(s)`);
141 } else {
142 console.log("[SchedulerAdapter] Started (no jobs configured)");
143 }
144 }
145
146 // -------------------------------------------------------------------------
147 // Core: register a job into the managed map
148 // -------------------------------------------------------------------------

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected